mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
Add wifi security settings.
This commit is contained in:
1 parent
f63d8d29de
commit
f0c5cd080c
3 files changed
+60
-6
No files matched your search
+22
-2
@@ -19,6 +19,7 @@
|
||||
Helper functions for working with network manager.
|
||||
"""
|
||||
|
||||
from dbus.exceptions import DBusException
|
||||
from gettext import gettext as _
|
||||
import NetworkManager
|
||||
import uuid
|
||||
@@ -115,7 +116,9 @@ def edit_ethernet_connection(conn, name, ipv4_method, ipv4_address):
|
||||
conn.Update(new_settings)
|
||||
|
||||
|
||||
def edit_wifi_connection(conn, name, ssid, ipv4_method, ipv4_address):
|
||||
def edit_wifi_connection(conn, name,
|
||||
ssid, auth_mode, passphrase,
|
||||
ipv4_method, ipv4_address):
|
||||
settings = conn.GetSettings()
|
||||
|
||||
new_settings = {
|
||||
@@ -129,6 +132,14 @@ def edit_wifi_connection(conn, name, ssid, ipv4_method, ipv4_address):
|
||||
},
|
||||
'ipv4': {'method': ipv4_method},
|
||||
}
|
||||
|
||||
if auth_mode == 'wpa' and passphrase:
|
||||
new_settings['connection']['security'] = '802-11-wireless-security'
|
||||
new_settings['802-11-wireless-security'] = {
|
||||
'key-mgmt': 'wpa-psk',
|
||||
'psk': passphrase,
|
||||
}
|
||||
|
||||
if ipv4_method == 'manual' and ipv4_address:
|
||||
new_settings['ipv4']['addresses'] = [
|
||||
(ipv4_address,
|
||||
@@ -206,7 +217,9 @@ def add_ethernet_connection(name, ipv4_method, ipv4_address):
|
||||
NetworkManager.Settings.AddConnection(conn)
|
||||
|
||||
|
||||
def add_wifi_connection(name, ssid, ipv4_method, ipv4_address):
|
||||
def add_wifi_connection(name,
|
||||
ssid, auth_mode, passphrase,
|
||||
ipv4_method, ipv4_address):
|
||||
conn = {
|
||||
'connection': {
|
||||
'id': name,
|
||||
@@ -219,6 +232,13 @@ def add_wifi_connection(name, ssid, ipv4_method, ipv4_address):
|
||||
'ipv4': {'method': ipv4_method},
|
||||
}
|
||||
|
||||
if auth_mode == 'wpa' and passphrase:
|
||||
conn['connection']['security'] = '802-11-wireless-security'
|
||||
conn['802-11-wireless-security'] = {
|
||||
'key-mgmt': 'wpa-psk',
|
||||
'psk': passphrase,
|
||||
}
|
||||
|
||||
if ipv4_method == 'manual' and ipv4_address:
|
||||
conn['ipv4']['addresses'] = [
|
||||
(ipv4_address,
|
||||
|
||||
Reference in new issue
Block a user