mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
Add AP and adhoc wifi modes, and shared IPv4 addressing mode.
This commit is contained in:
parent
8d9b388375
commit
2441caf647
@ -39,7 +39,9 @@ available over this interfaces. Select Internal only for trusted networks.'),
|
||||
choices=[('external', 'External'), ('internal', 'Internal')])
|
||||
ipv4_method = forms.ChoiceField(
|
||||
label=_('IPv4 Addressing Method'),
|
||||
choices=[('auto', 'Automatic (DHCP)'), ('manual', 'Manual')])
|
||||
choices=[('auto', 'Automatic (DHCP)'),
|
||||
('shared', 'Shared'),
|
||||
('manual', 'Manual')])
|
||||
ipv4_address = forms.CharField(
|
||||
label=_('Address'),
|
||||
validators=[validators.validate_ipv4_address],
|
||||
@ -57,15 +59,28 @@ available over this interfaces. Select Internal only for trusted networks.'),
|
||||
ssid = forms.CharField(
|
||||
label=_('SSID'),
|
||||
help_text=_('The visible name of the network.'))
|
||||
mode = forms.ChoiceField(
|
||||
label=_('Mode'),
|
||||
choices=[('infrastructure', 'Infrastructure'),
|
||||
('ap', 'Access Point'),
|
||||
('adhoc', 'Ad-hoc')])
|
||||
auth_mode = forms.ChoiceField(
|
||||
label=_('Authentication Mode'),
|
||||
help_text=_('Select WPA if the wireless network is secured and \
|
||||
requires clients to have the password to connect.'),
|
||||
choices=[('wpa', 'WPA'), ('open', 'Open')])
|
||||
passphrase = forms.CharField(label=_('Passphrase'), required=False)
|
||||
passphrase = forms.CharField(
|
||||
label=_('Passphrase'),
|
||||
validators=[validators.MinLengthValidator(8)],
|
||||
required=False)
|
||||
ipv4_method = forms.ChoiceField(
|
||||
label=_('IPv4 Addressing Method'),
|
||||
choices=[('auto', 'Automatic (DHCP)'), ('manual', 'Manual')])
|
||||
choices=[('auto', 'Automatic (DHCP)'),
|
||||
('shared', 'Shared'),
|
||||
('manual', 'Manual')],
|
||||
help_text=_('Select Automatic (DHCP) if you are connecting to an \
|
||||
existing wireless network. Shared mode is useful when running an Access \
|
||||
Point.'))
|
||||
ipv4_address = forms.CharField(
|
||||
label=_('Address'),
|
||||
validators=[validators.validate_ipv4_address],
|
||||
|
||||
@ -86,12 +86,13 @@ def edit(request, conn_id):
|
||||
ipv4_method, ipv4_address)
|
||||
elif settings['connection']['type'] == '802-11-wireless':
|
||||
ssid = form.cleaned_data['ssid']
|
||||
mode = form.cleaned_data['mode']
|
||||
auth_mode = form.cleaned_data['auth_mode']
|
||||
passphrase = form.cleaned_data['passphrase']
|
||||
|
||||
network.edit_wifi_connection(
|
||||
conn, name, zone,
|
||||
ssid, auth_mode, passphrase,
|
||||
ssid, mode, auth_mode, passphrase,
|
||||
ipv4_method, ipv4_address)
|
||||
else:
|
||||
messages.error(
|
||||
@ -117,6 +118,7 @@ def edit(request, conn_id):
|
||||
|
||||
if settings['connection']['type'] == '802-11-wireless':
|
||||
form_data['ssid'] = settings['802-11-wireless']['ssid']
|
||||
form_data['mode'] = settings['802-11-wireless']['mode']
|
||||
try:
|
||||
if (settings['802-11-wireless']['security'] == '802-11-wireless-security'
|
||||
and settings['802-11-wireless-security']['key-mgmt'] == 'wpa-psk'):
|
||||
@ -272,6 +274,7 @@ def add_wifi(request):
|
||||
name = form.cleaned_data['name']
|
||||
zone = form.cleaned_data['zone']
|
||||
ssid = form.cleaned_data['ssid']
|
||||
mode = form.cleaned_data['mode']
|
||||
auth_mode = form.cleaned_data['auth_mode']
|
||||
passphrase = form.cleaned_data['passphrase']
|
||||
ipv4_method = form.cleaned_data['ipv4_method']
|
||||
@ -279,7 +282,7 @@ def add_wifi(request):
|
||||
|
||||
network.add_wifi_connection(
|
||||
name, zone,
|
||||
ssid, auth_mode, passphrase,
|
||||
ssid, mode, auth_mode, passphrase,
|
||||
ipv4_method, ipv4_address)
|
||||
return redirect(reverse_lazy('networks:index'))
|
||||
else:
|
||||
|
||||
@ -118,7 +118,7 @@ def edit_ethernet_connection(conn, name, zone, ipv4_method, ipv4_address):
|
||||
|
||||
|
||||
def edit_wifi_connection(conn, name, zone,
|
||||
ssid, auth_mode, passphrase,
|
||||
ssid, mode, auth_mode, passphrase,
|
||||
ipv4_method, ipv4_address):
|
||||
settings = conn.GetSettings()
|
||||
|
||||
@ -131,6 +131,7 @@ def edit_wifi_connection(conn, name, zone,
|
||||
},
|
||||
'802-11-wireless': {
|
||||
'ssid': ssid,
|
||||
'mode': mode,
|
||||
},
|
||||
'ipv4': {'method': ipv4_method},
|
||||
}
|
||||
@ -221,7 +222,7 @@ def add_ethernet_connection(name, zone, ipv4_method, ipv4_address):
|
||||
|
||||
|
||||
def add_wifi_connection(name, zone,
|
||||
ssid, auth_mode, passphrase,
|
||||
ssid, mode, auth_mode, passphrase,
|
||||
ipv4_method, ipv4_address):
|
||||
conn = {
|
||||
'connection': {
|
||||
@ -232,6 +233,7 @@ def add_wifi_connection(name, zone,
|
||||
},
|
||||
'802-11-wireless': {
|
||||
'ssid': ssid,
|
||||
'mode': mode,
|
||||
},
|
||||
'ipv4': {'method': ipv4_method},
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ class TestNetwork(unittest.TestCase):
|
||||
'auto', '')
|
||||
network.add_wifi_connection(
|
||||
'plinth_test_wifi', 'external',
|
||||
'plinthtestwifi', 'open', '',
|
||||
'plinthtestwifi', 'adhoc', 'open', '',
|
||||
'auto', '')
|
||||
|
||||
@classmethod
|
||||
@ -72,13 +72,15 @@ class TestNetwork(unittest.TestCase):
|
||||
conn = network.get_connection('plinth_test_wifi')
|
||||
network.edit_wifi_connection(
|
||||
conn, 'plinth_test_wifi', 'external',
|
||||
'plinthtestwifi2', 'wpa', 'secretpassword',
|
||||
'plinthtestwifi2', 'infrastructure', 'wpa', 'secretpassword',
|
||||
'auto', '')
|
||||
conn = network.get_connection('plinth_test_wifi')
|
||||
|
||||
self.assertEqual(conn.GetSettings()['connection']['zone'], 'external')
|
||||
self.assertEqual(
|
||||
conn.GetSettings()['802-11-wireless']['ssid'], 'plinthtestwifi2')
|
||||
self.assertEqual(
|
||||
conn.GetSettings()['802-11-wireless']['mode'], 'infrastructure')
|
||||
self.assertEqual(
|
||||
conn.GetSettings()['802-11-wireless-security']['key-mgmt'],
|
||||
'wpa-psk')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user