Documentation
¶
Overview ¶
Package pkg provides gateway implementations for T-Mobile Home Internet devices.
Index ¶
Constants ¶
const InfoURL = "/TMI/v1/gateway/?get=all"
InfoURL is the endpoint for gateway information.
Variables ¶
var ( // ErrAuthentication indicates an authentication failure. ErrAuthentication = errors.New("could not authenticate") // ErrNotImplemented indicates an unsupported operation. ErrNotImplemented = errors.New("command not implemented") // ErrRebootFailed indicates a reboot operation failed. ErrRebootFailed = errors.New("reboot failed") // ErrSignalFailed indicates a signal operation failed. ErrSignalFailed = errors.New("signal failed") // ErrNoResponse indicates no response available from mock. ErrNoResponse = errors.New("no response available") )
Sentinel errors for gateway operations.
Functions ¶
func Base64urlEscape ¶ added in v0.2.0
Base64urlEscape converts base64 to URL-safe encoding.
func Random16bytes ¶ added in v0.2.0
func Random16bytes() string
Random16bytes generates 16 random bytes encoded as URL-safe base64.
func Sha256Hash ¶ added in v0.2.0
Sha256Hash computes SHA256 hash of val1:val2 and returns base64 encoding.
Types ¶
type ArcadyanGateway ¶ added in v0.3.1
type ArcadyanGateway struct {
*GatewayCommon
// contains filtered or unexported fields
}
ArcadyanGateway implements Gateway for Arcadyan-based T-Mobile gateways.
func NewArcadyanGateway ¶ added in v0.3.1
func NewArcadyanGateway() *ArcadyanGateway
NewArcadyanGateway creates a new Arcadyan gateway instance.
func (*ArcadyanGateway) Info ¶ added in v0.5.0
func (a *ArcadyanGateway) Info() error
Info retrieves and displays gateway information.
func (*ArcadyanGateway) Login ¶ added in v0.3.1
func (a *ArcadyanGateway) Login() error
Login authenticates with the Arcadyan gateway.
func (*ArcadyanGateway) Reboot ¶ added in v0.3.1
func (a *ArcadyanGateway) Reboot(dryRun bool) error
Reboot restarts the Arcadyan gateway. If dryRun is true, it logs without executing.
func (*ArcadyanGateway) Request ¶ added in v0.5.0
func (a *ArcadyanGateway) Request(method, path string) error
Request makes an HTTP request to the gateway and displays the response.
func (*ArcadyanGateway) Signal ¶ added in v0.7.0
func (a *ArcadyanGateway) Signal() error
Signal retrieves and displays signal strength information.
func (*ArcadyanGateway) Status ¶ added in v0.6.0
func (a *ArcadyanGateway) Status() error
Status checks and displays the gateway connection status.
type Gateway ¶ added in v0.7.0
type Gateway interface {
NewClient(version, gatewayIP string, timeout time.Duration, retries int, debug bool)
AddCredentials(username, password string)
Login() error
Reboot(dryRun bool) error
Request(method, path string) error
Info() error
Status() error
Signal() error
}
Gateway defines the interface for T-Mobile gateway implementations.
type GatewayCommon ¶ added in v0.6.0
type GatewayCommon struct {
Client *resty.Client
Username string
Password string
Authenticated bool
}
GatewayCommon provides shared functionality for gateway implementations.
func NewGatewayCommon ¶ added in v0.6.0
func NewGatewayCommon() *GatewayCommon
NewGatewayCommon creates a new GatewayCommon with default client.
func (*GatewayCommon) AddCredentials ¶ added in v0.6.0
func (gc *GatewayCommon) AddCredentials(username, password string)
AddCredentials sets the username and password for gateway authentication.
func (*GatewayCommon) NewClient ¶ added in v0.6.0
func (gc *GatewayCommon) NewClient( version, gatewayIP string, timeout time.Duration, retries int, debug bool, )
NewClient configures the HTTP client for the gateway.
func (*GatewayCommon) StatusCore ¶ added in v0.6.0
func (gc *GatewayCommon) StatusCore()
StatusCore checks if the gateway web interface is accessible.
type NokiaGateway ¶
type NokiaGateway struct {
*GatewayCommon
// contains filtered or unexported fields
}
NokiaGateway implements Gateway for Nokia-based T-Mobile gateways.
func NewNokiaGateway ¶ added in v0.2.0
func NewNokiaGateway() *NokiaGateway
NewNokiaGateway creates a new Nokia gateway instance.
func (*NokiaGateway) Info ¶ added in v0.5.0
func (n *NokiaGateway) Info() error
Info is not implemented for Nokia gateway.
func (*NokiaGateway) Login ¶
func (n *NokiaGateway) Login() error
Login authenticates with the Nokia gateway.
func (*NokiaGateway) Reboot ¶
func (n *NokiaGateway) Reboot(dryRun bool) error
Reboot restarts the Nokia gateway. If dryRun is true, it logs without executing.
func (*NokiaGateway) Request ¶ added in v0.5.0
func (n *NokiaGateway) Request(_, _ string) error
Request is not implemented for Nokia gateway.
func (*NokiaGateway) Signal ¶ added in v0.7.0
func (n *NokiaGateway) Signal() error
Signal is not implemented for Nokia gateway.
func (*NokiaGateway) Status ¶ added in v0.6.0
func (n *NokiaGateway) Status() error
Status checks and displays the gateway connection status.