pkg

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package pkg provides gateway implementations for T-Mobile Home Internet devices.

Index

Constants

View Source
const InfoURL = "/TMI/v1/gateway/?get=all"

InfoURL is the endpoint for gateway information.

Variables

View Source
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

func Base64urlEscape(b64 string) string

Base64urlEscape converts base64 to URL-safe encoding.

func NewAuthError added in v1.1.0

func NewAuthError(status int, message string) error

NewAuthError creates a new AuthenticationError.

func NewGatewayError added in v1.1.0

func NewGatewayError(op string, status int, message string, err error) error

NewGatewayError creates a new GatewayError.

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

func Sha256Hash(val1, val2 string) string

Sha256Hash computes SHA256 hash of val1:val2 and returns base64 encoding.

func Sha256Url added in v0.2.0

func Sha256Url(val1, val2 string) string

Sha256Url computes SHA256 hash and returns URL-safe 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 AuthenticationError added in v0.1.9

type AuthenticationError struct {
	Status  int
	Message string
}

AuthenticationError represents an authentication failure with the gateway.

func (*AuthenticationError) Error added in v1.1.0

func (e *AuthenticationError) Error() string

func (*AuthenticationError) Is added in v1.1.0

func (e *AuthenticationError) Is(target error) bool

Is checks if the target error matches ErrAuthentication.

func (*AuthenticationError) Unwrap added in v1.1.0

func (e *AuthenticationError) Unwrap() error

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 GatewayError added in v1.1.0

type GatewayError struct {
	Op         string
	Err        error
	HTTPStatus int
	Message    string
}

GatewayError represents a gateway operation failure.

func (*GatewayError) Error added in v1.1.0

func (e *GatewayError) Error() string

func (*GatewayError) Unwrap added in v1.1.0

func (e *GatewayError) Unwrap() error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL