Compare commits

...

2 commits

2 changed files with 22 additions and 5 deletions

View file

@ -154,11 +154,11 @@ func (b *WPABackend) IsScanning() (bool, error) {
func (b *WPABackend) Connect(ssid, password string) error { func (b *WPABackend) Connect(ssid, password string) error {
// Create network configuration // Create network configuration
config := make(map[string]interface{}) config := make(map[string]interface{})
config["ssid"] = fmt.Sprintf("\"%s\"", ssid) // wpa_supplicant expects quoted SSID config["ssid"] = ssid // Raw SSID string, no quotes
if password != "" { if password != "" {
// For WPA/WPA2-PSK networks // For WPA/WPA2-PSK networks
config["psk"] = fmt.Sprintf("\"%s\"", password) config["psk"] = password // Raw password string, no quotes
} else { } else {
// For open networks // For open networks
config["key_mgmt"] = "NONE" config["key_mgmt"] = "NONE"

View file

@ -137,13 +137,13 @@ func (b *BSS) GetSignal() (int16, error) {
// DetermineSecurityType determines the security type based on BSS properties // DetermineSecurityType determines the security type based on BSS properties
func (p *BSSProperties) DetermineSecurityType() string { func (p *BSSProperties) DetermineSecurityType() string {
// Check for WPA2 (RSN) // Check for WPA2 (RSN) - need to check if KeyMgmt has actual values
if len(p.RSN) > 0 { if hasKeyManagement(p.RSN) {
return "psk" return "psk"
} }
// Check for WPA // Check for WPA
if len(p.WPA) > 0 { if hasKeyManagement(p.WPA) {
return "psk" return "psk"
} }
@ -155,3 +155,20 @@ func (p *BSSProperties) DetermineSecurityType() string {
// Open network // Open network
return "open" return "open"
} }
// hasKeyManagement checks if a WPA/RSN map contains actual key management methods
func hasKeyManagement(secMap map[string]dbus.Variant) bool {
if len(secMap) == 0 {
return false
}
// Check if KeyMgmt field exists and has values
if keyMgmtVariant, ok := secMap["KeyMgmt"]; ok {
// KeyMgmt is an array of strings
if keyMgmt, ok := keyMgmtVariant.Value().([]string); ok {
return len(keyMgmt) > 0
}
}
return false
}