Documentation
¶
Overview ¶
Package network reads NetworkManager state over the system D-Bus, the Go counterpart of crates/wayle-network's zbus proxy: overall state, wifi (enabled flag, active AP ssid and strength), wired (activated device), with StateChanged/PropertiesChanged ticks.
Index ¶
- Constants
- func IsSecret(service, key string) bool
- func KindOf(dict ConnectionDict) string
- func ParseWgQuick(text, fileName string) (values map[string]string, ok bool)
- func PublicKeyFor(private string) (public string, ok bool)
- func ReadProfileValues(dict ConnectionDict) map[string]string
- func SecretKeys(service string) []string
- func SignalIndex(strength uint8, numIcons int) int
- type AccessPoint
- type ActiveReason
- type ActiveState
- type Agent
- func (a *Agent) Cancel()
- func (a *Agent) Changes(ctx context.Context) <-chan struct{}
- func (a *Agent) DismissSave(uuid string)
- func (a *Agent) ExpectAttended(uuid string)
- func (a *Agent) ExpectUnattended(uuid string)
- func (a *Agent) Failure() (AuthFailure, bool)
- func (a *Agent) Failures(ctx context.Context) <-chan struct{}
- func (a *Agent) OfferSave(o SaveOffer)
- func (a *Agent) Prompt(ctx context.Context, req secrets.Request) (map[string]string, bool)
- func (a *Agent) Request() (secrets.Request, bool)
- func (a *Agent) SaveOffer() (SaveOffer, bool)
- func (a *Agent) Submit(values map[string]string)
- type AuthFailure
- type ConnectError
- type ConnectFailure
- type ConnectionDict
- type ConnectionType
- type DeviceReason
- type DeviceState
- type KeyPair
- type ListedNetwork
- type Profile
- type SaveOffer
- type SecretPrompt
- type SecurityType
- type Service
- type Settings
- func (s *Settings) Add(ctx context.Context, dict ConnectionDict) (dbus.ObjectPath, error)
- func (s *Settings) Changes(ctx context.Context) <-chan struct{}
- func (s *Settings) Delete(ctx context.Context, path dbus.ObjectPath) error
- func (s *Settings) DeleteForSSID(ctx context.Context, ssid []byte)
- func (s *Settings) ForSSID(ssid []byte) []Profile
- func (s *Settings) Get(ctx context.Context, path dbus.ObjectPath) (ConnectionDict, error)
- func (s *Settings) Profiles() []Profile
- func (s *Settings) Update(ctx context.Context, path dbus.ObjectPath, dict ConnectionDict) error
- type SignIn
- type Snapshot
- type Source
- type State
- type Status
- type System
- type VPN
- type VPNChoice
- type VPNField
- type VPNFormat
- type VPNKind
- type VPNService
- func (s *VPNService) Add(ctx context.Context, kind, name string, values map[string]string) error
- func (s *VPNService) Aggregate() VPNState
- func (s *VPNService) Changes(ctx context.Context) <-chan struct{}
- func (s *VPNService) Connect(ctx context.Context, uuid string) error
- func (s *VPNService) DeliverSSOCallback(uri string) bool
- func (s *VPNService) Disconnect(ctx context.Context, uuid string) error
- func (s *VPNService) Entries() []VPN
- func (s *VPNService) Get(uuid string) (VPN, bool)
- func (s *VPNService) IsEmpty() bool
- func (s *VPNService) Remove(ctx context.Context, uuid string) error
- func (s *VPNService) SettingsOf(ctx context.Context, uuid string) (ConnectionDict, error)
- func (s *VPNService) Toggle(ctx context.Context, uuid string) error
- func (s *VPNService) Update(ctx context.Context, uuid, kind, name string, values map[string]string) error
- type VPNState
- type Vault
- type VaultEntry
- type Wifi
- func (w *Wifi) AccessPoints(ctx context.Context) ([]AccessPoint, error)
- func (w *Wifi) ActiveSSID(ctx context.Context) string
- func (w *Wifi) Connect(ctx context.Context, apPath dbus.ObjectPath, password string) (dbus.ObjectPath, error)
- func (w *Wifi) ConnectAndWait(ctx context.Context, apPath dbus.ObjectPath, password string, ...) error
- func (w *Wifi) Disconnect(ctx context.Context) error
- func (w *Wifi) Enabled(ctx context.Context) (bool, error)
- func (w *Wifi) Forget(ctx context.Context, ssid string)
- func (w *Wifi) KnownSSIDs() map[string]bool
- func (w *Wifi) LastScan(ctx context.Context) int64
- func (w *Wifi) Scan(ctx context.Context) error
- func (w *Wifi) ScanAndWait(ctx context.Context, timeout time.Duration)
- func (w *Wifi) SetEnabled(ctx context.Context, on bool) error
Constants ¶
const ( // AgentPath is where NM expects the agent object: its agent manager // builds its proxy against this exact path. AgentPath = dbus.ObjectPath("/org/freedesktop/NetworkManager/SecretAgent") // AgentID is the identifier lys-shell registers under; NM requires it // be formatted like a bus name. AgentID = "dev.stubbe.lys.network" // RequestBudget is how long one request is worked on before it is // given up. NM waits 120 seconds for an agent's answer (a D-Bus // timeout fixed in nm_secret_agent_get_secrets) and then fails the // activation without telling the agent: no CancelGetSecrets follows // a timeout. Work that ran past it finished for nobody, and a // failure it wrote landed on the attempt that came since. This // stops short of NM's limit so the answer still reaches someone. RequestBudget = 110 * time.Second )
const (
// BusName is NetworkManager's well-known name on the system bus.
BusName = "org.freedesktop.NetworkManager"
)
const ConnectTimeout = 30 * time.Second
ConnectTimeout is how long a connect is watched (CONNECTION_TIMEOUT).
const WireGuard = "wireguard"
WireGuard is the id of the built-in WireGuard kind: a connection type, not a VPN plugin.
Variables ¶
This section is empty.
Functions ¶
func KindOf ¶
func KindOf(dict ConnectionDict) string
KindOf is the kind a saved profile belongs to, "" when it is no VPN.
func ParseWgQuick ¶
ParseWgQuick parses a wg-quick file into the WireGuard form's values. fileName names the interface the way `wg-quick up wg0` does (a wg0.conf is wg0); pass "" when there is no file. ok is false when the text is not a wg-quick config: an [Interface] with a private key is the least it can be. Only the keys the form asks for are read; MTU, Table, PreUp and friends have nowhere to go in the profile, and only the first [Peer] is taken, since the form models one.
func PublicKeyFor ¶
PublicKeyFor derives the public key for a base64 private key. ok is false when the text is not a 32-byte base64 key, so a half-typed or pasted-wrong key shows nothing rather than someone else's public key.
func ReadProfileValues ¶
func ReadProfileValues(dict ConnectionDict) map[string]string
ReadProfileValues reads a saved profile back into form values, for the edit form. The -flags keys are lys-shell's own bookkeeping and stay off the form.
func SecretKeys ¶
SecretKeys are the keys a plugin stores as secrets rather than plain data, taken from each plugin's own NM_*_KEY_* defines (checked against the nixpkgs sources: openvpn 1.12.5, strongswan 1.6.5, libreswan 1.2.31, l2tp, sstp 1.3.2, iodine, vpnc 1.4.0, fortisslvpn 1.4.0). Getting this wrong writes a password into vpn.data, in the clear. It is the single source of truth: the form marks a field secret by consulting it, and the profile builder decides which section a value lands in the same way.
func SignalIndex ¶
SignalIndex is helpers.rs's signal_to_index: the wifi strength bucketed over the icon list length. Exported for the module; pure.
Types ¶
type AccessPoint ¶
type AccessPoint struct {
// Path is the AccessPoint object, which a connect names.
Path dbus.ObjectPath
// SSID is the raw SSID; empty for a hidden network.
SSID []byte
// Strength is 0-100.
Strength uint8
// Security is the classification from the AP's flags.
Security SecurityType
// Frequency is in MHz.
Frequency uint32
// BSSID is the hardware address.
BSSID string
}
AccessPoint is one visible network.
func (AccessPoint) Name ¶
func (ap AccessPoint) Name() string
Name is the SSID as text, invalid UTF-8 replaced (to_string_lossy).
type ActiveReason ¶
type ActiveReason uint32
ActiveReason is NMActiveConnectionStateReason.
const ( ReasonUnknown ActiveReason = 0 ReasonNone ActiveReason = 1 ReasonUserDisconnected ActiveReason = 2 ReasonDeviceDisconnected ActiveReason = 3 ReasonServiceStopped ActiveReason = 4 ReasonIPConfigInvalid ActiveReason = 5 ReasonConnectTimeout ActiveReason = 6 ReasonServiceStartTimeout ActiveReason = 7 ReasonServiceStartFailed ActiveReason = 8 ReasonNoSecrets ActiveReason = 9 ReasonLoginFailed ActiveReason = 10 ReasonConnectionRemoved ActiveReason = 11 ReasonDependencyFailed ActiveReason = 12 ReasonDeviceRealizeFailed ActiveReason = 13 ReasonDeviceRemoved ActiveReason = 14 )
Active connection state reasons.
type ActiveState ¶
type ActiveState uint32
ActiveState is NMActiveConnectionState.
const ( ActiveUnknown ActiveState = 0 ActiveActivating ActiveState = 1 ActiveActivated ActiveState = 2 ActiveDeactivating ActiveState = 3 ActiveDeactivated ActiveState = 4 )
Active connection states.
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent is the pending-prompt state shared by the D-Bus object and the UI (SecretAgentState). It implements secrets.Prompter for the VPN sign-ins that run inside a request, and SecretPrompt for the UI.
func (*Agent) DismissSave ¶ added in v0.2.0
DismissSave takes the offer for profile uuid down, saved or declined.
func (*Agent) ExpectAttended ¶
ExpectAttended takes ExpectUnattended back: someone is here and asked.
func (*Agent) ExpectUnattended ¶
ExpectUnattended says the next activation of this profile is made with nobody watching: a tunnel brought back after a suspend, or after NM restarted. Its sign-in may reuse a session that is still alive and nothing else; asking for a password, or pushing a second factor to a phone nobody is looking at, is what made the first connect of the day hang.
func (*Agent) Failure ¶
func (a *Agent) Failure() (AuthFailure, bool)
Failure is the last sign-in failure, if one is standing.
func (*Agent) OfferSave ¶ added in v0.2.0
OfferSave puts up o, replacing any standing offer: a sign-in the user typed for a profile that then connected.
func (*Agent) Prompt ¶
Prompt implements secrets.Prompter: it publishes req and waits for the user, holding the prompt turn for the whole exchange so only one form is ever live. The wait also ends when ctx does (the request was withdrawn or ran out of time), and the form comes down with it: left up, it would take an answer nobody is waiting for and hold the turn every later prompt queues on.
type AuthFailure ¶
type AuthFailure struct {
// UUID of the profile that failed to authenticate.
UUID string
// Reason is shown on the VPN row verbatim.
Reason string
}
AuthFailure is a sign-in that did not produce secrets, and why: the gateway's own wording where it gave any.
type ConnectError ¶
type ConnectError struct {
Failure ConnectFailure
Reason DeviceReason
}
ConnectError is a wifi connect that ended without the device coming up.
func (*ConnectError) Error ¶
func (e *ConnectError) Error() string
type ConnectFailure ¶
type ConnectFailure int
ConnectFailure is why a wifi connect did not come up, in the dropdown's vocabulary.
const ( // FailureGeneric is "Connection failed". FailureGeneric ConnectFailure = iota // FailureAuth is a refused password. FailureAuth // FailureTimeout is the attempt timing out. FailureTimeout // FailureNotFound is the network gone. FailureNotFound // FailureIPConfig is no IP address. FailureIPConfig // FailureSuperseded is the attempt replaced by another (a user // request or a new activation): not an error to show. FailureSuperseded )
Connect failures.
type ConnectionDict ¶
ConnectionDict is a connection profile in NM's a{sa{sv}} shape (profile.rs's ConnectionDict).
func BuildProfile ¶
func BuildProfile(kind, name, uuid string, values map[string]string) ConnectionDict
BuildProfile builds the profile for a kind from the form's values. uuid is supplied rather than generated so an edit rewrites the profile it is editing instead of creating a second one.
type ConnectionType ¶
type ConnectionType int
ConnectionType is NM's PrimaryConnectionType (ConnectionType::from_nm_type).
const ( ConnectionNone ConnectionType = iota ConnectionWifi ConnectionWired ConnectionVPN ConnectionWireGuard ConnectionBluetooth ConnectionOther )
Connection types; ConnectionOther is any type without its own.
type DeviceReason ¶
type DeviceReason uint32
DeviceReason is NMDeviceStateReason (the values the connect watch reads).
const ( DeviceReasonNone DeviceReason = 0 DeviceReasonUnknown DeviceReason = 1 DeviceReasonIPConfigExpired DeviceReason = 6 DeviceReasonNoSecrets DeviceReason = 7 DeviceReasonSupplicantDisconnect DeviceReason = 8 DeviceReasonSupplicantConfigFailed DeviceReason = 9 DeviceReasonSupplicantFailed DeviceReason = 10 DeviceReasonSupplicantTimeout DeviceReason = 11 DeviceReasonUserRequested DeviceReason = 39 DeviceReasonSSIDNotFound DeviceReason = 53 DeviceReasonNewActivation DeviceReason = 60 )
Device state reasons.
type DeviceState ¶
type DeviceState uint32
DeviceState is NMDeviceState.
const ( DeviceUnknown DeviceState = 0 DeviceUnmanaged DeviceState = 10 DeviceDisconnected DeviceState = 30 DevicePrepare DeviceState = 40 DeviceConfig DeviceState = 50 DeviceNeedAuth DeviceState = 60 DeviceIPConfig DeviceState = 70 DeviceIPCheck DeviceState = 80 DeviceSecondaries DeviceState = 90 DeviceActivated DeviceState = 100 DeviceDeactivating DeviceState = 110 DeviceFailed DeviceState = 120 )
Device states.
type KeyPair ¶
type KeyPair struct {
// Private is this end's private-key.
Private string
// Public is what to hand whoever runs the other end.
Public string
}
KeyPair is a freshly generated private key and the public key derived from it, both base64 as WireGuard writes them.
func GenerateKeyPair ¶
func GenerateKeyPair() KeyPair
GenerateKeyPair makes a new WireGuard key pair from the OS random source. Keys are X25519 in WireGuard's encoding: 32 raw bytes, standard base64 with padding, which is what wg prints and NM stores.
type ListedNetwork ¶
type ListedNetwork struct {
AccessPoint
// Known is a network with a saved profile: it connects without
// asking for the password.
Known bool
// Stale was seen by an earlier scan but NM has pruned it; its path
// is dead, and connecting means scanning for it first.
Stale bool
}
ListedNetwork is one row of the dropdown's network list.
func MergeWithCache ¶
func MergeWithCache(live, cached []ListedNetwork, connected string, known map[string]bool) []ListedNetwork
MergeWithCache folds the live list over the one already shown, so a network NM pruned stays listed (stale) instead of vanishing. Live entries win and come first; the rest follow in their previous order; the connected SSID is dropped from both; Known is recomputed.
func SortedUniqueNetworks ¶
func SortedUniqueNetworks(aps []AccessPoint, connected string, known map[string]bool) []ListedNetwork
SortedUniqueNetworks deduplicates by SSID (strongest wins), drops hidden and enterprise networks and the connected SSID, and sorts by strength descending (sorted_unique_access_points).
type Profile ¶
type Profile struct {
// Path is the Settings.Connection object, which activation takes.
Path dbus.ObjectPath
// UUID is stable across renames.
UUID string
// ID is the user-facing name.
ID string
// Type is connection.type: "vpn", "wireguard", "802-11-wireless", ...
Type string
// SSID is 802-11-wireless.ssid for a wifi profile, nil otherwise.
SSID []byte
}
Profile is one saved NetworkManager connection, the fields of core/settings_connection's ConnectionSettings the service reads.
type SaveOffer ¶ added in v0.2.0
type SaveOffer struct {
UUID, Name string
Entry VaultEntry
}
SaveOffer is a sign-in the user typed that the vault could keep: the profile it answered, once that profile connected with it.
type SecretPrompt ¶
type SecretPrompt interface {
// Request is the prompt waiting on the user, if any.
Request() (secrets.Request, bool)
// Submit answers the pending prompt; with none waiting it is
// dropped.
Submit(values map[string]string)
// Cancel dismisses the pending prompt, failing the activation.
Cancel()
// Changes ticks when a prompt goes up or comes down.
Changes(ctx context.Context) <-chan struct{}
}
SecretPrompt is the agent's face toward the UI: the credential prompt NM is blocked on, and the two ways to answer it.
type SecurityType ¶
type SecurityType int
SecurityType is an access point's security classification.
const ( SecurityNone SecurityType = iota SecurityWEP SecurityWPA SecurityWPA2 SecurityWPA3 SecurityEnterprise )
Security types.
func (SecurityType) RequiresPassword ¶
func (s SecurityType) RequiresPassword() bool
RequiresPassword reports whether connecting asks for a password first; enterprise networks need more than one and are not offered.
func (SecurityType) String ¶
func (s SecurityType) String() string
String is the English name (SecurityType::as_str).
type Service ¶
type Service struct {
// Settings is the live list of saved profiles.
Settings *Settings
// Wifi is the wireless device, nil when there is none.
Wifi *Wifi
// Agent is the secret agent's prompt state: the credential prompt
// NM is blocked on, answered with Submit or Cancel.
Agent *Agent
// VPN is every VPN profile and its live state.
VPN *VPNService
}
Service is the network service beyond the bar's status read (service.rs's NetworkService): saved profiles, the wifi device, the secret agent, and the VPNs.
func Start ¶
Start brings the service up on conn (the system bus) until ctx ends. The secret agent is served before anything can activate: a VPN that needs a password has nowhere to ask otherwise. openconnect VPNs sign in natively (NativeSignIn); other secrets come from vault when it has them (nil for no vault), else from the user.
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
Settings is the live list of saved profiles (core/settings), kept current by NM's NewConnection / ConnectionRemoved signals and each profile's Updated signal (a rename lands without a rebuild of anything else).
func (*Settings) Add ¶
func (s *Settings) Add(ctx context.Context, dict ConnectionDict) (dbus.ObjectPath, error)
Add saves a new profile to disk (AddConnection).
func (*Settings) DeleteForSSID ¶
DeleteForSSID deletes every saved profile of a wifi network (delete_connections_for_ssid): one refusal is logged and does not stop the rest.
func (*Settings) ForSSID ¶
ForSSID lists the saved profiles for a wifi network (connections_for_ssid).
func (*Settings) Get ¶
func (s *Settings) Get(ctx context.Context, path dbus.ObjectPath) (ConnectionDict, error)
Get reads a saved profile's settings.
func (*Settings) Update ¶
func (s *Settings) Update(ctx context.Context, path dbus.ObjectPath, dict ConnectionDict) error
Update rewrites a saved profile in place.
type SignIn ¶
type SignIn interface {
// ProfileFrom recognises an openconnect profile in NM's connection
// dictionary.
ProfileFrom(conn ConnectionDict, uuid, name string) (openconnect.Profile, bool)
// IsSupported reports whether lys-shell signs into this profile itself.
IsSupported(p openconnect.Profile) bool
// Authenticate signs in and returns the plugin's secrets.
Authenticate(ctx context.Context, p openconnect.Profile, requestNew, unattended bool, prompter secrets.Prompter) (map[string]string, error)
// Forget drops whatever is cached for a deleted profile.
Forget(uuid string)
// DeliverSSOCallback hands a globalprotectcallback: URI to a
// waiting browser sign-in, reporting whether one was waiting.
DeliverSSOCallback(uri string) bool
}
SignIn is the agent's seam to the native openconnect sign-ins: an openconnect VPN's secrets are the result of a sign-in, not something a person can type, so the agent performs it rather than putting an un-fillable box on screen. NativeSignIn is package openconnect; tests substitute a fake. A nil SignIn leaves every openconnect request to another agent (NoSecrets).
var NativeSignIn SignIn = nativeSignIn{}
NativeSignIn is the real sign-in, package openconnect.
type Snapshot ¶
type Snapshot struct {
// WifiEnabled is NM's WirelessEnabled.
WifiEnabled bool
// Primary is the type of NM's primary connection.
Primary ConnectionType
// HasWifi and HasWired report a wireless and an ethernet device;
// Wifi and Wired are their connectivity, the best device's when
// there are several.
HasWifi, HasWired bool
Wifi, Wired Status
// The active access point's SSID, strength, and frequency (MHz),
// and the device's first IPv4 address, when wifi is connected.
WifiSSID string
WifiStrength uint8
WifiFrequency uint32
WifiIP4 string
// The link speed in Mb/s and first IPv4 address, when wired is
// connected.
WiredSpeed uint32
WiredIP4 string
}
Snapshot is one network state read.
type Source ¶
type Source interface {
Read(ctx context.Context) (Snapshot, error)
// Subscribe ticks on NM state changes. The channel closes when ctx
// completes; stop releases the match.
Subscribe(ctx context.Context) (<-chan struct{}, func(), error)
}
Source is the module's seam.
type Status ¶
type Status int
Status is a device's connectivity (NetworkStatus), ordered so the better of two is the greater.
type System ¶
type System struct {
// contains filtered or unexported fields
}
System reads the real NetworkManager.
type VPN ¶
type VPN struct {
// UUID is NM's profile UUID, stable across renames.
UUID string
// Name is the profile's id.
Name string
// WireGuard is a native WireGuard profile rather than a plugin VPN.
WireGuard bool
// State is the live state.
State VPNState
// Detail is why the last attempt failed, "" when it did not.
Detail string
}
VPN is one profile's row: identity, live state, and why the last attempt failed.
type VPNChoice ¶
type VPNChoice struct {
// Value is what is stored in the profile.
Value string
// Label is what the picker calls it.
Label string
// NativeSignIn says whether lys-shell signs into this choice itself;
// the form says so while the choice is made, instead of the first
// connect failing with "no native sign-in".
NativeSignIn bool
}
VPNChoice is one choice of a field that is a picker.
type VPNField ¶
type VPNField struct {
// Key is where the value goes, interpreted per kind by the profile
// builder.
Key string
// Label is the English label.
Label string
// Secret masks the input and keeps it out of the profile's data.
Secret bool
// Required refuses a save without it.
Required bool
// Placeholder is an example value.
Placeholder string
// Choices are the values a picker accepts; empty is free text.
Choices []VPNChoice
// Format is what a value has to look like.
Format VPNFormat
// Section groups the form, as a slug the UI turns into a heading;
// empty stands on its own.
Section string
}
VPNField is one field of the add/edit form.
type VPNFormat ¶
type VPNFormat int
VPNFormat is what a field's value has to look like to be worth sending to NetworkManager. NM validates too but refuses with a raw D-Bus error, and the address builder silently drops what it cannot parse, so checking here makes the complaint name the field.
const ( // FormatText is anything non-empty. FormatText VPNFormat = iota // FormatHost is a hostname or address, no scheme and no path. FormatHost // FormatHostPort is a host with a port: vpn.example.com:51820. FormatHostPort // FormatIPList is one or more IP addresses, comma separated. FormatIPList // FormatCIDRList is one or more addresses, each optionally with a // prefix length. FormatCIDRList // FormatKey is a base64 X25519 key, as WireGuard writes them. FormatKey // FormatNumber is a non-negative whole number. FormatNumber )
Field formats.
type VPNKind ¶
type VPNKind struct {
// ID is WireGuard or the plugin's D-Bus service name.
ID string
// Label is what the picker calls it.
Label string
// Fields to ask for; empty means only the free-form editor.
Fields []VPNField
}
VPNKind is a kind of VPN that can be created here.
func AvailableKinds ¶
func AvailableKinds() []VPNKind
AvailableKinds lists every VPN kind this machine can run, WireGuard first. the protocol free text.
type VPNService ¶
type VPNService struct {
// contains filtered or unexported fields
}
VPNService is every VPN NetworkManager knows about plus the aggregate the bar icon reads (VpnService).
func (*VPNService) Add ¶
Add creates a profile from a kind and form values. It appears in the rows on its own once NM announces it. It is the running user's own when NM can run it that way (canBePrivate) and system-wide otherwise.
func (*VPNService) Aggregate ¶
func (s *VPNService) Aggregate() VPNState
Aggregate is the state the module icon shows: connected beats connecting beats failed beats disconnected, so one connected VPN lights the indicator while another negotiates.
func (*VPNService) Changes ¶
func (s *VPNService) Changes(ctx context.Context) <-chan struct{}
Changes ticks whenever a row or the list changes.
func (*VPNService) Connect ¶
func (s *VPNService) Connect(ctx context.Context, uuid string) error
Connect brings the tunnel up if it is not already. The connecting state is read back off the active connection NM creates, not guessed: one gone before it could be read is left to the sweep NM's list change sets off. A refusal (a missing plugin, a polkit denial, a profile NM cannot make sense of) is also published on the row, where the user is looking when it fails.
func (*VPNService) DeliverSSOCallback ¶
func (s *VPNService) DeliverSSOCallback(uri string) bool
DeliverSSOCallback hands a globalprotectcallback: URI to a waiting GlobalProtect browser sign-in, reporting whether one was waiting; a callback with nothing waiting is stale and dropped.
func (*VPNService) Disconnect ¶
func (s *VPNService) Disconnect(ctx context.Context, uuid string) error
Disconnect tears the tunnel down; already down is not an error. An openconnect session ends with it: the plugin stops openconnect with the signal that logs off, and the next connect signs in afresh.
func (*VPNService) Entries ¶
func (s *VPNService) Entries() []VPN
Entries snapshots the rows in NM's profile order.
func (*VPNService) Get ¶
func (s *VPNService) Get(uuid string) (VPN, bool)
Get is the row with this UUID.
func (*VPNService) IsEmpty ¶
func (s *VPNService) IsEmpty() bool
IsEmpty reports whether NM knows of no VPN at all (vpn-show = auto).
func (*VPNService) Remove ¶
func (s *VPNService) Remove(ctx context.Context, uuid string) error
Remove deletes a profile and whatever lys-shell cached for it: leaving a cached cookie or password behind would keep a live credential on disk for a profile that no longer exists. Nothing is forgotten when NM refuses: the profile is still there.
func (*VPNService) SettingsOf ¶
func (s *VPNService) SettingsOf(ctx context.Context, uuid string) (ConnectionDict, error)
SettingsOf reads a profile's saved settings, for prefilling the edit form.
func (*VPNService) Toggle ¶
func (s *VPNService) Toggle(ctx context.Context, uuid string) error
Toggle connects when down, and disconnects when up or connecting (clicking a connecting row cancels, which is a disconnect).
func (*VPNService) Update ¶
func (s *VPNService) Update(ctx context.Context, uuid, kind, name string, values map[string]string) error
Update rewrites a profile in place, keeping its UUID so anything referring to it (a cached session included) still matches. Saved from here it becomes the user's own when a new profile would be.
type VPNState ¶
type VPNState int
VPNState is one VPN's state as the bar and the dropdown show it.
const ( // VPNDisconnected is down with nothing in flight. VPNDisconnected VPNState = iota // VPNConnecting is an attempt in flight: NM negotiating, or the // plugin waiting on credentials. VPNConnecting // VPNConnected is the tunnel up. VPNConnected // VPNFailed is the last attempt failed; the row shows why. VPNFailed )
VPN states.
func (VPNState) IsConnected ¶
IsConnected reports whether the state counts as "a VPN is up".
func (VPNState) IsConnecting ¶
IsConnecting reports whether an attempt is in flight.
type Vault ¶ added in v0.2.0
type Vault interface {
// Entry is the entry stored for the connection profile named name;
// false when there is none, or the store is locked.
Entry(name string) (VaultEntry, bool)
// Saveable reports whether an entry for the profile named name can
// be saved now: the store is open, saving is configured, and it
// holds none for that name yet.
Saveable(name string) bool
}
Vault is a password store the secret agent answers from before it asks the user.
type VaultEntry ¶ added in v0.2.0
VaultEntry is one stored credential: a login's username and password, and extra fields by name.
type Wifi ¶
type Wifi struct {
// Device is the wireless device's object path.
Device dbus.ObjectPath
// contains filtered or unexported fields
}
Wifi is the wireless device and its controls.
func (*Wifi) AccessPoints ¶
func (w *Wifi) AccessPoints(ctx context.Context) ([]AccessPoint, error)
AccessPoints reads every visible access point.
func (*Wifi) ActiveSSID ¶
ActiveSSID is the SSID of the access point the device is on, "" when it is on none.
func (*Wifi) Connect ¶
func (w *Wifi) Connect(ctx context.Context, apPath dbus.ObjectPath, password string) (dbus.ObjectPath, error)
Connect joins an access point. A saved profile for its SSID is reused (its password updated when one is given); otherwise a new profile is made, locked to the BSSID for a manufacturer-default SSID. It returns the active connection.
func (*Wifi) ConnectAndWait ¶
func (w *Wifi) ConnectAndWait(ctx context.Context, apPath dbus.ObjectPath, password string, progress func(DeviceState)) error
ConnectAndWait connects and follows the device until it is up, fails, or ConnectTimeout passes, reporting each intermediate state to progress (the connection watcher) from the caller's goroutine. Subscribed before connecting, so a fast activation is not missed.
func (*Wifi) Disconnect ¶
Disconnect deactivates the device's connection; none is a no-op.
func (*Wifi) KnownSSIDs ¶
KnownSSIDs are the SSIDs a saved profile exists for.
func (*Wifi) LastScan ¶
LastScan is the device's LastScan stamp; NM bumps it when a scan finishes, the only real "done" signal.
func (*Wifi) Scan ¶
Scan asks NM for a fresh scan. A refusal is usually NM saying one is already running, which still ends with a LastScan bump.
func (*Wifi) ScanAndWait ¶
ScanAndWait scans and returns once LastScan moves past its value before the request, or after timeout.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package openconnect produces the NetworkManager openconnect plugin's secrets without an openconnect binary, the Go counterpart of crates/wayle-network/src/vpn/openconnect.
|
Package openconnect produces the NetworkManager openconnect plugin's secrets without an openconnect binary, the Go counterpart of crates/wayle-network/src/vpn/openconnect. |
|
openconnecttest
Package openconnecttest holds the fakes the NM secret agent's tests need from the openconnect sign-in (the Rust's openconnect::testing::{silent_gateway, reached}).
|
Package openconnecttest holds the fakes the NM secret agent's tests need from the openconnect sign-in (the Rust's openconnect::testing::{silent_gateway, reached}). |
|
Package secrets holds the credential-prompt contract shared by the NetworkManager secret agent and the VPN sign-ins that run inside it, the Go counterpart of crates/wayle-network's types/agent.rs and the VPN variants of error.rs.
|
Package secrets holds the credential-prompt contract shared by the NetworkManager secret agent and the VPN sign-ins that run inside it, the Go counterpart of crates/wayle-network's types/agent.rs and the VPN variants of error.rs. |