Documentation
¶
Overview ¶
Package networking is the subsystem responsible for network/wifi management, and initial device setup via hotspot.
Index ¶
- Constants
- Variables
- func NetworkInfoToProto(net *NetworkInfo) *pb.NetworkInfo
- func NewConnectionState(logger logging.Logger) *connectionState
- func NewNetworkState(logger logging.Logger) *networkState
- func NewSubsystem(ctx context.Context, logger logging.Logger, cfg utils.AgentConfig) subsystems.Subsystem
- func WriteDeviceConfig(file string, input userInput) error
- type CloudConfig
- type MachineConfig
- type NetworkInfo
- type Networking
- func (n *Networking) ActivateConnection(ctx context.Context, ifName, ssid string) error
- func (n *Networking) AddOrUpdateConnection(cfg utils.NetworkDefinition) (bool, error)
- func (n *Networking) Config() utils.NetworkConfiguration
- func (n *Networking) DeactivateConnection(ifName, ssid string) error
- func (n *Networking) GetNetworkList(ctx context.Context, req *pb.GetNetworkListRequest) (*pb.GetNetworkListResponse, error)
- func (n *Networking) GetSmartMachineStatus(ctx context.Context, req *pb.GetSmartMachineStatusRequest) (*pb.GetSmartMachineStatusResponse, error)
- func (n *Networking) HealthCheck(ctx context.Context) error
- func (n *Networking) SetNetworkCredentials(ctx context.Context, req *pb.SetNetworkCredentialsRequest) (*pb.SetNetworkCredentialsResponse, error)
- func (n *Networking) SetSmartMachineCredentials(ctx context.Context, req *pb.SetSmartMachineCredentialsRequest) (*pb.SetSmartMachineCredentialsResponse, error)
- func (n *Networking) Start(ctx context.Context) error
- func (n *Networking) StartProvisioning(ctx context.Context, inputChan chan<- userInput) error
- func (n *Networking) Stop(ctx context.Context) error
- func (n *Networking) StopProvisioning() error
- func (n *Networking) Update(ctx context.Context, cfg utils.AgentConfig) (needRestart bool)
Constants ¶
View Source
const ( SubsysName = "networking" DNSMasqFilepath = "/etc/NetworkManager/dnsmasq-shared.d/80-viam.conf" DNSMasqContentsRedirect = "address=/#/10.42.0.1\n" DNSMasqContentsSetupOnly = "address=/.setup/10.42.0.1\n" PortalBindAddr = "10.42.0.1" ConnCheckFilepath = "/etc/NetworkManager/conf.d/80-viam.conf" ConnCheckContents = "[connectivity]\nuri=http://packages.viam.com/check_network_status.txt\ninterval=300\n" NetworkTypeWifi = "wifi" NetworkTypeWired = "wired" NetworkTypeHotspot = "hotspot" HealthCheckTimeout = time.Minute )
Variables ¶
View Source
var ( ErrBadPassword = errors.New("bad or missing password") ErrConnCheckDisabled = errors.New("NetworkManager connectivity checking disabled by user, network management will be unavailable") ErrNoActiveConnectionFound = errors.New("no active connection found") )
View Source
var ( ErrScanTimeout = errw.New("wifi scanning timed out") // how long is a scanned network "visible" for candidate selection? VisibleNetworkTimeout = time.Minute )
View Source
var ( ErrNM = errw.New("NetworkManager does not appear to be responding as expected. " + "Please ensure NetworkManger >= v1.30 is installed and enabled. Disabling networking until next restart.") ErrNoWifi = errw.New("No WiFi devices available. Disabling networking until next restart.") )
Functions ¶
func NetworkInfoToProto ¶
func NetworkInfoToProto(net *NetworkInfo) *pb.NetworkInfo
func NewConnectionState ¶
func NewNetworkState ¶
func NewSubsystem ¶
func NewSubsystem(ctx context.Context, logger logging.Logger, cfg utils.AgentConfig) subsystems.Subsystem
func WriteDeviceConfig ¶
Types ¶
type CloudConfig ¶
type MachineConfig ¶
type MachineConfig struct {
Cloud *CloudConfig `json:"cloud"`
}
MachineConfig represents the minimal needed for /etc/viam.json.
type NetworkInfo ¶
type NetworkInfo struct { Type string SSID string Security string Signal int32 Connected bool LastError string }
func NetworkInfoFromProto ¶
func NetworkInfoFromProto(buf *pb.NetworkInfo) *NetworkInfo
type Networking ¶
type Networking struct { pb.UnimplementedProvisioningServiceServer // contains filtered or unexported fields }
func (*Networking) ActivateConnection ¶
func (n *Networking) ActivateConnection(ctx context.Context, ifName, ssid string) error
func (*Networking) AddOrUpdateConnection ¶
func (n *Networking) AddOrUpdateConnection(cfg utils.NetworkDefinition) (bool, error)
func (*Networking) Config ¶
func (n *Networking) Config() utils.NetworkConfiguration
func (*Networking) DeactivateConnection ¶
func (n *Networking) DeactivateConnection(ifName, ssid string) error
func (*Networking) GetNetworkList ¶
func (n *Networking) GetNetworkList(ctx context.Context, req *pb.GetNetworkListRequest, ) (*pb.GetNetworkListResponse, error)
func (*Networking) GetSmartMachineStatus ¶
func (n *Networking) GetSmartMachineStatus(ctx context.Context, req *pb.GetSmartMachineStatusRequest, ) (*pb.GetSmartMachineStatusResponse, error)
func (*Networking) HealthCheck ¶
func (n *Networking) HealthCheck(ctx context.Context) error
HealthCheck reports if a subsystem is running correctly (it is restarted if not).
func (*Networking) SetNetworkCredentials ¶
func (n *Networking) SetNetworkCredentials(ctx context.Context, req *pb.SetNetworkCredentialsRequest, ) (*pb.SetNetworkCredentialsResponse, error)
func (*Networking) SetSmartMachineCredentials ¶
func (n *Networking) SetSmartMachineCredentials(ctx context.Context, req *pb.SetSmartMachineCredentialsRequest, ) (*pb.SetSmartMachineCredentialsResponse, error)
func (*Networking) StartProvisioning ¶
func (n *Networking) StartProvisioning(ctx context.Context, inputChan chan<- userInput) error
StartProvisioning puts the wifi in hotspot mode and starts a captive portal.
func (*Networking) StopProvisioning ¶
func (n *Networking) StopProvisioning() error
func (*Networking) Update ¶
func (n *Networking) Update(ctx context.Context, cfg utils.AgentConfig) (needRestart bool)
Update validates and/or updates a subsystem, returns true if subsystem should be restarted.
Click to show internal directories.
Click to hide internal directories.