wpa_supplicant: Reuse existing networks and preserve saved ones on connect
Connect() called AddNetwork unconditionally, creating duplicate entries for the same SSID, and SelectNetwork's side-effect of disabling all other networks was being persisted by SaveConfig — making previously saved networks appear erased. Disconnect() also removed the current network from the config. Now reuse an existing network entry when the SSID matches, re-enable other networks after SelectNetwork, and keep entries on disconnect. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
08cbe4f9ff
commit
77370eff19
3 changed files with 102 additions and 23 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package wpasupplicant
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/godbus/dbus/v5"
|
||||
)
|
||||
|
||||
|
|
@ -39,3 +41,25 @@ func (n *Network) GetProperties() (map[string]dbus.Variant, error) {
|
|||
|
||||
return props, nil
|
||||
}
|
||||
|
||||
// GetSSID returns the configured SSID, stripping the wrapping quotes
|
||||
// that wpa_supplicant stores around string-form SSIDs.
|
||||
func (n *Network) GetSSID() (string, error) {
|
||||
props, err := n.GetProperties()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ssidVariant, ok := props["ssid"]
|
||||
if !ok {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
ssid, ok := ssidVariant.Value().(string)
|
||||
if !ok {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// wpa_supplicant returns quoted SSIDs like "MyNetwork"
|
||||
return strings.Trim(ssid, `"`), nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue