Documentation
¶
Overview ¶
Package netconfig contains the mojo connection to cros_network_config.
Package netconfig contains functions to establish mojo connection to cros_network_config along with some helper functions.
Index ¶
- func NetworkStateIsConnectedOrOnline(networkState NetworkStateProperties) bool
- type ActivationStateType
- type AuthenticationType
- type CellularStateProperties
- type ConfigProperties
- type ConnectionStateType
- type CrosNetworkConfig
- func (c *CrosNetworkConfig) Close(ctx context.Context) error
- func (c *CrosNetworkConfig) ConfigureNetwork(ctx context.Context, properties ConfigProperties, shared bool) (string, error)
- func (c *CrosNetworkConfig) ForgetNetwork(ctx context.Context, guid string) (bool, error)
- func (c *CrosNetworkConfig) GetDeviceStateList(ctx context.Context) ([]DeviceStateProperties, error)
- func (c *CrosNetworkConfig) GetManagedProperties(ctx context.Context, guid string) (*ManagedProperties, error)
- func (c *CrosNetworkConfig) GetNetworkStateList(ctx context.Context, filter NetworkFilter) ([]NetworkStateProperties, error)
- func (c *CrosNetworkConfig) SetNetworkTypeEnabledState(ctx context.Context, networkType NetworkType, enable bool) error
- type DeviceStateProperties
- type DeviceStateType
- type EAPConfigProperties
- type EthernetStateProperties
- type FilterType
- type HiddenSsidMode
- type IPAddress
- type InhibitReason
- type ManagedBoolean
- type ManagedEAPProperties
- type ManagedProperties
- type ManagedString
- type ManagedStringList
- type ManagedSubjectAltNameMatchList
- type ManagedWiFiProperties
- type NetworkFilter
- type NetworkStateProperties
- type NetworkType
- type NetworkTypeConfigProperties
- type NetworkTypeManagedProperties
- type NetworkTypeStateProperties
- type OncSource
- type PortalState
- type ProxyMode
- type SIMInfo
- type SIMLockStatus
- type SecurityType
- type SubjectAltName
- type SubjectAltNameType
- type WiFiConfigProperties
- type WiFiStateProperties
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NetworkStateIsConnectedOrOnline ¶
func NetworkStateIsConnectedOrOnline(networkState NetworkStateProperties) bool
NetworkStateIsConnectedOrOnline checks whether network is connected or online.
Types ¶
type ActivationStateType ¶
type ActivationStateType int
ActivationStateType : Activation state for Cellular networks.
const ( UnknownAST ActivationStateType = iota NotActivatedAST ActivatingAST PartiallyActivatedAST ActivatedAST // NoServiceAST : A cellular modem exists, but no network service is available. NoServiceAST )
ActivationStateType values
type AuthenticationType ¶
type AuthenticationType int
AuthenticationType : The authentication type for Ethernet networks.
const ( NoneAT AuthenticationType = iota K8021x )
Ethernet Authenticationtype
type CellularStateProperties ¶
type CellularStateProperties struct { Iccid string `json:"iccid"` Eid string `json:"eid"` ActivationState ActivationStateType `json:"activationSstate"` NetworkTechnology string `json:"networkTechnology"` Roaming bool `json:"roaming"` SignalStrength int32 `json:"signalStrength"` SimLocked bool `json:"simLocked"` }
CellularStateProperties is member of NetworkTypeStateProperties
type ConfigProperties ¶
type ConfigProperties struct {
TypeConfig NetworkTypeConfigProperties `json:"typeConfig"`
}
ConfigProperties is passed to SetProperties or ConfigureNetwork to configure a new network or augment an existing one.
type ConnectionStateType ¶
type ConnectionStateType int
ConnectionStateType : Connection state of visible networks.
const ( // OnlineCST : The network is connected and internet connectivity is available. OnlineCST ConnectionStateType = iota // ConnectedCST : The network is connected and not in a detected portal state, but internet connectivity may not be available. ConnectedCST // PortalCST : The network is connected but a portal state was detected. Internet connectivity may be limited. Additional details are in PortalState. PortalCST // ConnectingCST : The network is in the process of connecting. ConnectingCST // NotConnectedCST : The network is not connected. NotConnectedCST )
type CrosNetworkConfig ¶
type CrosNetworkConfig struct {
// contains filtered or unexported fields
}
CrosNetworkConfig contains the mojo connection to cros_network_config.
func NewCrosNetworkConfig ¶
NewCrosNetworkConfig creates a connection to cros_network_config that allows to make mojo calls. Only works in a context where chrome://network may be opened.
func (*CrosNetworkConfig) Close ¶
func (c *CrosNetworkConfig) Close(ctx context.Context) error
Close cleans up the injected javascript and closes the chrome://network tab.
func (*CrosNetworkConfig) ConfigureNetwork ¶
func (c *CrosNetworkConfig) ConfigureNetwork(ctx context.Context, properties ConfigProperties, shared bool) (string, error)
ConfigureNetwork either configures a new network or updates an existing network configuration.
func (*CrosNetworkConfig) ForgetNetwork ¶
ForgetNetwork removes the network with guid from the device.
func (*CrosNetworkConfig) GetDeviceStateList ¶
func (c *CrosNetworkConfig) GetDeviceStateList(ctx context.Context) ([]DeviceStateProperties, error)
GetDeviceStateList returns a array of Device states.
func (*CrosNetworkConfig) GetManagedProperties ¶
func (c *CrosNetworkConfig) GetManagedProperties(ctx context.Context, guid string) (*ManagedProperties, error)
GetManagedProperties returns the managed properties of the given network, managed properties contain information on which values are set by policy or user. Look at cros_network_config.mojom or onc_spec.md for more information.
func (*CrosNetworkConfig) GetNetworkStateList ¶
func (c *CrosNetworkConfig) GetNetworkStateList(ctx context.Context, filter NetworkFilter) ([]NetworkStateProperties, error)
GetNetworkStateList returns a array of states of networks based on the filter.
func (*CrosNetworkConfig) SetNetworkTypeEnabledState ¶
func (c *CrosNetworkConfig) SetNetworkTypeEnabledState(ctx context.Context, networkType NetworkType, enable bool) error
SetNetworkTypeEnabledState enables/disable a given Network_Type.
type DeviceStateProperties ¶
type DeviceStateProperties struct { Ipv4Address IPAddress `json:"ipv4address,omitempty"` Ipv6Address IPAddress `json:"ipv6address,omitempty"` MacAddress string `json:"macaddress,omitempty"` Scanning bool `json:"scanning"` SimLockStatus SIMLockStatus `json:"simlockstatus"` SimInfos []SIMInfo `json:"siminfos,omitempty"` InhibitReason InhibitReason `json:"inhibitreason"` SimAbsent bool `json:"simabsent"` DeviceState DeviceStateType `json:"devicestate"` Type NetworkType `json:"type"` ManagedNetworkAvailable bool `json:"managednetworkavailable"` }
DeviceStateProperties is returned by GetDeviceStateList
type DeviceStateType ¶
type DeviceStateType int
DeviceStateType : Device / Technology state for devices.
const ( // UninitializedDST : The device is available but not yet initialized and can not be enabled. UninitializedDST DeviceStateType = iota // DisabledDST : The device is initialized but disabled. DisabledDST // DisablingDST : The device is in the process of disabling. Enable calls may fail until disabling has completed. DisablingDST // EnablingDST : The device is in the process of enabling. Disable calls may fail until enabling has completed. EnablingDST // EnabledDST : The device is enabled. Networks can be configured and connected. EnabledDST // ProhibitedDST : The device is disabled and enabling the device is prohibited by policy. ProhibitedDST UnavailableDST )
type EAPConfigProperties ¶
type EAPConfigProperties struct { AnonymousIdentity string `json:"anonymousIdentity,omitempty"` Identity string `json:"identity,omitempty"` Inner string `json:"inner,omitempty"` // "Automatic" Outer string `json:"outer"` // "PEAP" Password string `json:"password,omitempty"` SaveCredentials bool `json:"saveCredentials,omitempty"` // true. ClientCertType string `json:"clientCertType,omitempty"` // "None". DomainSuffixMatch []string `json:"domainSuffixMatch"` // Empty in manual example but not optional in mojo. SubjectAltNameMatch []SubjectAltName `json:"subjectAltNameMatch"` // Empty in manual example but not optional in mojo. UseSystemCAs bool `json:"useSystemCAs,omitempty"` // false. Defaults to true. }
EAPConfigProperties contains properties for EAP networks. Currently only PEAP networks without CA certificates are supported, so the fields related to certificates are not included: ServerCAPEMs, ServerCARefs, ServerCARef (deprecated), SubjectMatch, TLSVersionMax, UseProactiveKeyCaching.
type EthernetStateProperties ¶
type EthernetStateProperties struct {
Authentication AuthenticationType `json:"authentication"`
}
EthernetStateProperties is member of NetworkTypeStateProperties
type FilterType ¶
type FilterType int
FilterType is used for requesting lists of network states.
const ( // ActiveFT :Return active networks. A network is active when its ConnectionStateType != kNotConnected. ActiveFT FilterType = iota // VisibleFT :Return visible (active, physically connected or in-range) networks. Active networks will be listed first. VisibleFT // ConfiguredFT :Only include configured (saved) networks. ConfiguredFT // AllFT :Include all networks. AllFT )
type HiddenSsidMode ¶
type HiddenSsidMode int
HiddenSsidMode is the tri-state status of hidden SSID.
const ( Automatic HiddenSsidMode = iota Disabled Enabled )
Whether SSID is hidden.
type InhibitReason ¶
type InhibitReason int
InhibitReason : Reasons why the Cellular Device may have its scanning inhibited (i.e. temporarily stopped).
const ( // NotInhibited :Not inhibited NotInhibited InhibitReason = iota // InstallingProfile Inhibited because an eSIM profile is being installed. InstallingProfile // RenamingProfile :Inhibited because an eSIM profile is being renamed. RenamingProfile // RemovingProfile :Inhibited because an eSIM profile is being removed. RemovingProfile // ConnectingToProfile :Inhibited because a connection is in progress which requires that the device switch to a different eSIM profile ConnectingToProfile // RefreshingProfileList :Inhibited because the list of pending eSIM profiles is being refreshed by checking with an SMDS server. RefreshingProfileList // ResettingEuiccMemory :Inhibited because the EUICC memory is being reset. ResettingEuiccMemory // DisablingProfile :Inhibited because an eSIM profile is being disabled. DisablingProfile )
type ManagedBoolean ¶
type ManagedBoolean struct {
ActiveValue bool `json:"activeValue"`
}
ManagedBoolean contains active value, if required one may add policy value and source.
type ManagedEAPProperties ¶
type ManagedEAPProperties struct { AnonymousIdentity ManagedString `json:"anonymousIdentity,omitempty"` Identity ManagedString `json:"identity,omitempty"` Inner ManagedString `json:"inner,omitempty"` Outer ManagedString `json:"outer,omitempty"` Password ManagedString `json:"password,omitempty"` SaveCredentials ManagedBoolean `json:"saveCredentials,omitempty"` ClientCertType ManagedString `json:"clientCertType,omitempty"` DomainSuffixMatch ManagedStringList `json:"domainSuffixMatch,omitempty"` SubjectAltNameMatch ManagedSubjectAltNameMatchList `json:"subjectAltNameMatch,omitempty"` UseSystemCAs ManagedBoolean `json:"useSystemCas,omitempty"` }
ManagedEAPProperties contains properties for EAP networks. Currently only PEAP networks without CA certificates are supported. We include the same fields as EAPConfigProperties.
type ManagedProperties ¶
type ManagedProperties struct { Type NetworkType `json:"type"` TypeProperties NetworkTypeManagedProperties `json:"typeProperties"` }
ManagedProperties are provided by GetManagedProperties, see onc_spec.md for details.
type ManagedString ¶
type ManagedString struct {
ActiveValue string `json:"activeValue"`
}
ManagedString contains active value, if required one may add policy value and source.
type ManagedStringList ¶
type ManagedStringList struct {
ActiveValue []string `json:"activeValue"`
}
ManagedStringList contains active value, if required one may add policy value and source.
type ManagedSubjectAltNameMatchList ¶
type ManagedSubjectAltNameMatchList struct {
ActiveValue []SubjectAltName `json:"activeValue"`
}
ManagedSubjectAltNameMatchList contains active value, if required one may add policy value and source.
type ManagedWiFiProperties ¶
type ManagedWiFiProperties struct { // Passphrase is only used for PSK networks and Eap is only used for EAP. // These fields should not be included in the json object at all otherwise // (not even as an empty object). Setting the optional field as a pointer // allows it to be nullable and to not appear in the json object if not // provided. Eap *ManagedEAPProperties `json:"eap,omitempty"` Passphrase *ManagedString `json:"passphrase,omitempty"` Ssid ManagedString `json:"ssid"` Security SecurityType `json:"security"` }
ManagedWiFiProperties contain managed properties of a wifi connection.
type NetworkFilter ¶
type NetworkFilter struct { Filter FilterType `json:"filter"` NetworkType NetworkType `json:"networktype"` Limit int32 `json:"limit"` }
NetworkFilter is passed to GetNetworkStateList to filter the list of networks returned.
type NetworkStateProperties ¶
type NetworkStateProperties struct { Connectable bool `json:"connnectable"` ConnectRequested bool `json:"connectRequested"` ConnectionState ConnectionStateType `json:"connectionState"` ErrorState string `json:"errorState,omitempty"` GUID string `json:"guid"` Name string `json:"name"` PortalState PortalState `json:"portalState"` Priority int32 `json:"priority"` ProxyMode ProxyMode `json:"proxyMode"` ProhibitedByPolicy bool `json:"prohibitedByPolicy"` Source OncSource `json:"source"` Type NetworkType `json:"type"` TypeState NetworkTypeStateProperties `json:"typeState"` }
NetworkStateProperties is returned by GetNetworkStateList
type NetworkType ¶
type NetworkType int
NetworkType is the network technology type.
const ( All NetworkType = iota Cellular Ethernet Mobile Tether VPN Wireless WiFi )
Types of networks. Note that All and Wireless are only used for filtering.
type NetworkTypeConfigProperties ¶
type NetworkTypeConfigProperties struct {
Wifi WiFiConfigProperties `json:"wifi"`
}
NetworkTypeConfigProperties contains properties for one type of network. Currently only WiFi is supported.
type NetworkTypeManagedProperties ¶
type NetworkTypeManagedProperties struct {
Wifi ManagedWiFiProperties `json:"wifi"`
}
NetworkTypeManagedProperties contains managed properties for one of the network types. Only WiFi is implemented so far.
type NetworkTypeStateProperties ¶
type NetworkTypeStateProperties struct { Cellular CellularStateProperties `json:"cellular,omitempty"` Ethernet EthernetStateProperties `json:"ethernet,omitempty"` // Tether TetherStateProperties `json:"tether,omitempty"` // VPN VPNStateProperties `json:"vpn,omitempty"` WiFi WiFiStateProperties `json:"wifi,omitempty"` }
NetworkTypeStateProperties is union which is member of NetworkTypeStateProperties
type OncSource ¶
type OncSource int
OncSource : The ONC source for the network configuration, i.e. whether it is stored in the User or Device profile and whether it was configured by policy.
const ( // NoneOS : The network is not remembered, or the property is not configurable. NoneOS OncSource = iota // UserOS : The configuration is saved in the user profile. UserOS // DeviceOS : The configuration is saved in the device profile. DeviceOS // UserPolicyOS : The configuration came from a user policy and is saved in the user profile. UserPolicyOS // DevicePolicyOS : The configuration came from a device policy and is saved in the device profile. DevicePolicyOS )
type PortalState ¶
type PortalState int
PortalState : The captive portal state. Provides additional details when the connection state is kPortal.
const ( // UnknownPS : The network is not connected or the portal state is not available. UnknownPS PortalState = iota // OnlinePS : The network is connected and no portal is detected. OnlinePS // PortalSuspectedPS :A portal is suspected but no redirect was provided. PortalSuspectedPS // PortalPS : The network is in a portal state with a redirect URL. PortalPS // ProxyAuthRequiredPS :A proxy requiring authentication is detected. ProxyAuthRequiredPS // NoInternetPS : The network is connected but no internet is available and no proxy was detected. NoInternetPS )
type ProxyMode ¶
type ProxyMode int
ProxyMode is affecting this network. Includes any settings that affect a given network (i.e. global proxy settings are also considered)
const ( // DirectPM :Direct connection to the network. DirectPM ProxyMode = iota // AutoDetectPM :Try to retrieve a PAC script from http://wpad/wpad.dat. AutoDetectPM // PacScriptPM :Try to retrieve a PAC script from kProxyPacURL. PacScriptPM // FixedServersPM :Use a specified list of servers. FixedServersPM // SystemPM :Use the system's proxy settings. SystemPM )
type SIMInfo ¶
type SIMInfo struct { SlotID int32 `json:"slotID"` Eid string `json:"eid"` Iccid string `json:"iccid"` IsPrimary bool `json:"isPrimary"` }
SIMInfo is details about a sim slot available on the device.
type SIMLockStatus ¶
type SIMLockStatus struct { LockType string `json:"locktype"` LockEnabled bool `json:"lockenabled"` RetriesLeft int32 `json:"retriesleft"` }
SIMLockStatus is the SIM card lock status for Cellular networks.
type SecurityType ¶
type SecurityType int
SecurityType is the security for WiFi and Ethernet.
const ( None SecurityType = iota Wep8021x WepPsk WpaEap WpaPsk )
Security types.
type SubjectAltName ¶
type SubjectAltName struct { Type SubjectAltNameType `json:"type"` Value string `json:"value"` }
SubjectAltName contains the information of an alternative subject name.
type SubjectAltNameType ¶
type SubjectAltNameType int
SubjectAltNameType is the type for SubjectAltName.
const ( Email SubjectAltNameType = iota DNS URI )
Allowed types for the alternative subject name.
type WiFiConfigProperties ¶
type WiFiConfigProperties struct { // Eap configuration is only used if the wifi security is WpaEap and it should // not be included in the json object at all otherwise (not even as an empty // object). Setting the field Eap as a pointer allows it to be nullable and // to not appear in the json object if not provided. Eap *EAPConfigProperties `json:"eap,omitempty"` Passphrase string `json:"passphrase,omitempty"` Ssid string `json:"ssid,omitempty"` Security SecurityType `json:"security"` HiddenSsid HiddenSsidMode `json:"hiddenSsid"` }
WiFiConfigProperties is used to create new configurations or augment existing ones.
type WiFiStateProperties ¶
type WiFiStateProperties struct { Bssid string `json:"bssid"` Frequency int32 `json:"frequency"` HexSsid string `json:"hexSsid"` Security SecurityType `json:"security"` SignalStrength int32 `json:"signalStrength"` Ssid string `json:"ssid"` HiddenSsid bool `json:"hiddenSsid"` }
WiFiStateProperties is member of NetworkTypeStateProperties