mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
networks: Configure wireless BSSID, band, channel
Select the frequency band (2.4 GHz vs. 5 GHz) is a prerequisite for selecting the channel. Channel selection is useful primarily as follow: - Restrict to a particular access point when multiple access points use the same SSID (AP name) but are available on different frequencies. - Configure for a particular ad-hoc mesh network. - Setup multiple access points from a single FreedomBox on multiple channels to maximize the throughput and number of simultaneous clients. Ability to specify a particular BSSID will help associate with a particular access point when multiple access points use the same SSID (AP name). This is also makes it slightly harder to trick clients into connection to a malicious device. Also configuring BATMAN-adv seems to require setting a particular BSSID.
This commit is contained in:
parent
a9ca2d7cc3
commit
28a9933fd9
@ -188,8 +188,9 @@ class PPPoEForm(EthernetForm):
|
|||||||
|
|
||||||
class WifiForm(ConnectionForm):
|
class WifiForm(ConnectionForm):
|
||||||
"""Form to create/edit a Wi-Fi connection."""
|
"""Form to create/edit a Wi-Fi connection."""
|
||||||
field_order = ['name', 'interface', 'zone', 'ssid', 'mode', 'auth_mode',
|
field_order = ['name', 'interface', 'zone', 'ssid', 'mode', 'band',
|
||||||
'passphrase', 'ipv4_method', 'ipv4_address', 'ipv4_netmask',
|
'channel', 'bssid', 'auth_mode', 'passphrase',
|
||||||
|
'ipv4_method', 'ipv4_address', 'ipv4_netmask',
|
||||||
'ipv4_gateway', 'ipv4_dns', 'ipv4_second_dns']
|
'ipv4_gateway', 'ipv4_dns', 'ipv4_second_dns']
|
||||||
|
|
||||||
ssid = forms.CharField(
|
ssid = forms.CharField(
|
||||||
@ -200,6 +201,27 @@ class WifiForm(ConnectionForm):
|
|||||||
choices=[('infrastructure', _('Infrastructure')),
|
choices=[('infrastructure', _('Infrastructure')),
|
||||||
('ap', _('Access Point')),
|
('ap', _('Access Point')),
|
||||||
('adhoc', _('Ad-hoc'))])
|
('adhoc', _('Ad-hoc'))])
|
||||||
|
band = forms.ChoiceField(
|
||||||
|
label=_('Frequency Band'),
|
||||||
|
choices=[('auto', _('Automatic')),
|
||||||
|
('a', _('A (5 GHz)')),
|
||||||
|
('bg', _('B/G (2.4 GHz)'))])
|
||||||
|
channel = forms.IntegerField(
|
||||||
|
label=_('Channel'),
|
||||||
|
help_text=_('Optional value. Wireless channel in the selected '
|
||||||
|
'frequency band to restrict to. Blank or 0 value means '
|
||||||
|
'automatic selection.'),
|
||||||
|
min_value=0,
|
||||||
|
max_value=255,
|
||||||
|
required=False)
|
||||||
|
bssid = forms.RegexField(
|
||||||
|
label=_('BSSID'),
|
||||||
|
help_text=_('Optional value. Unique identifier for the access point. '
|
||||||
|
'When connecting to an access point, connect only if the '
|
||||||
|
'BSSID of the access point matches the one provided. '
|
||||||
|
'Example: 00:11:22:aa:bb:cc.'),
|
||||||
|
regex=r'^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$',
|
||||||
|
required=False)
|
||||||
auth_mode = forms.ChoiceField(
|
auth_mode = forms.ChoiceField(
|
||||||
label=_('Authentication Mode'),
|
label=_('Authentication Mode'),
|
||||||
help_text=_('Select WPA if the wireless network is secured and \
|
help_text=_('Select WPA if the wireless network is secured and \
|
||||||
@ -224,6 +246,9 @@ requires clients to have the password to connect.'),
|
|||||||
settings['wireless'] = {
|
settings['wireless'] = {
|
||||||
'ssid': self.cleaned_data['ssid'],
|
'ssid': self.cleaned_data['ssid'],
|
||||||
'mode': self.cleaned_data['mode'],
|
'mode': self.cleaned_data['mode'],
|
||||||
|
'band': self.cleaned_data['band'],
|
||||||
|
'channel': self.cleaned_data['channel'],
|
||||||
|
'bssid': self.cleaned_data['bssid'],
|
||||||
'auth_mode': self.cleaned_data['auth_mode'],
|
'auth_mode': self.cleaned_data['auth_mode'],
|
||||||
'passphrase': self.cleaned_data['passphrase'],
|
'passphrase': self.cleaned_data['passphrase'],
|
||||||
}
|
}
|
||||||
|
|||||||
@ -164,6 +164,9 @@ def edit(request, uuid):
|
|||||||
settings_wireless = connection.get_setting_wireless()
|
settings_wireless = connection.get_setting_wireless()
|
||||||
form_data['ssid'] = settings_wireless.get_ssid().get_data()
|
form_data['ssid'] = settings_wireless.get_ssid().get_data()
|
||||||
form_data['mode'] = settings_wireless.get_mode()
|
form_data['mode'] = settings_wireless.get_mode()
|
||||||
|
form_data['band'] = settings_wireless.get_band() or 'auto'
|
||||||
|
form_data['channel'] = settings_wireless.get_channel()
|
||||||
|
form_data['bssid'] = settings_wireless.get_bssid()
|
||||||
try:
|
try:
|
||||||
wifi_sec = connection.get_setting_wireless_security()
|
wifi_sec = connection.get_setting_wireless_security()
|
||||||
if wifi_sec:
|
if wifi_sec:
|
||||||
@ -328,6 +331,7 @@ def add_wifi(request, ssid=None, interface_name=None):
|
|||||||
'zone': 'external',
|
'zone': 'external',
|
||||||
'ssid': ssid,
|
'ssid': ssid,
|
||||||
'mode': 'infrastructure',
|
'mode': 'infrastructure',
|
||||||
|
'band': 'auto',
|
||||||
'auth_mode': 'wpa',
|
'auth_mode': 'wpa',
|
||||||
'ipv4_method': 'auto'}
|
'ipv4_method': 'auto'}
|
||||||
|
|
||||||
|
|||||||
@ -383,6 +383,14 @@ def _update_wireless_settings(connection, wireless):
|
|||||||
ssid_gbytes = glib.Bytes.new(wireless['ssid'].encode())
|
ssid_gbytes = glib.Bytes.new(wireless['ssid'].encode())
|
||||||
settings.set_property(nm.SETTING_WIRELESS_SSID, ssid_gbytes)
|
settings.set_property(nm.SETTING_WIRELESS_SSID, ssid_gbytes)
|
||||||
settings.set_property(nm.SETTING_WIRELESS_MODE, wireless['mode'])
|
settings.set_property(nm.SETTING_WIRELESS_MODE, wireless['mode'])
|
||||||
|
band = wireless['band'] if wireless['band'] != 'auto' else None
|
||||||
|
settings.set_property(nm.SETTING_WIRELESS_BAND, band)
|
||||||
|
channel = wireless['channel']
|
||||||
|
if wireless['band'] == 'auto' or not wireless['channel']:
|
||||||
|
channel = 0
|
||||||
|
|
||||||
|
settings.set_property(nm.SETTING_WIRELESS_CHANNEL, channel)
|
||||||
|
settings.set_property(nm.SETTING_WIRELESS_BSSID, wireless['bssid'] or None)
|
||||||
|
|
||||||
# Wireless Security
|
# Wireless Security
|
||||||
if wireless['auth_mode'] == 'wpa' and wireless['passphrase']:
|
if wireless['auth_mode'] == 'wpa' and wireless['passphrase']:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user