luci-mod-network: wifi join: add option to lock bssid
authorJo-Philipp Wich <jo@mein.io>
Fri, 21 Feb 2020 20:30:06 +0000 (21:30 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 21 Feb 2020 20:30:06 +0000 (21:30 +0100)
Fixes: #3661
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js

index 1aafb2b77a13454c078781ef4cfd0e045315e480..171b8f3b3321d9734be35c084032a1bd48cf05f4 100644 (file)
@@ -1811,7 +1811,7 @@ return L.view.extend({
 
                                        rows.push([
                                                E('span', { 'style': s }, render_signal_badge(q, res.signal, res.noise)),
-                                               E('span', { 'style': s }, '%h'.format(res.ssid)),
+                                               E('span', { 'style': s }, (res.ssid != null) ? '%h'.format(res.ssid) : E('em', _('hidden'))),
                                                E('span', { 'style': s }, '%d'.format(res.channel)),
                                                E('span', { 'style': s }, '%h'.format(res.mode)),
                                                E('span', { 'style': s }, '%h'.format(res.bssid)),
@@ -1866,10 +1866,12 @@ return L.view.extend({
                s.handleJoinConfirm = function(radioDev, bss, form, ev) {
                        var nameopt = L.toArray(form.lookupOption('name', '_new_'))[0],
                            passopt = L.toArray(form.lookupOption('password', '_new_'))[0],
+                           bssidopt = L.toArray(form.lookupOption('bssid', '_new_'))[0],
                            zoneopt = L.toArray(form.lookupOption('zone', '_new_'))[0],
                            replopt = L.toArray(form.lookupOption('replace', '_new_'))[0],
                            nameval = (nameopt && nameopt.isValid('_new_')) ? nameopt.formvalue('_new_') : null,
                            passval = (passopt && passopt.isValid('_new_')) ? passopt.formvalue('_new_') : null,
+                           bssidval = (bssidopt && bssidopt.isValid('_new_')) ? bssidopt.formvalue('_new_') : null,
                            zoneval = zoneopt ? zoneopt.formvalue('_new_') : null,
                            enc = L.isObject(bss.encryption) ? bss.encryption : null,
                            is_wep = (enc && Array.isArray(enc.wep)),
@@ -1905,10 +1907,15 @@ return L.view.extend({
                                uci.set('wireless', section_id, 'mode', (bss.mode == 'Ad-Hoc') ? 'adhoc' : 'sta');
                                uci.set('wireless', section_id, 'network', nameval);
 
-                               if (bss.ssid != null)
+                               if (bss.ssid != null) {
                                        uci.set('wireless', section_id, 'ssid', bss.ssid);
-                               else if (bss.bssid != null)
+
+                                       if (bssidval == '1')
+                                               uci.set('wireless', section_id, 'bssid', bss.bssid);
+                               }
+                               else if (bss.bssid != null) {
                                        uci.set('wireless', section_id, 'bssid', bss.bssid);
+                               }
 
                                if (is_sae) {
                                        uci.set('wireless', section_id, 'encryption', 'sae');
@@ -1962,7 +1969,7 @@ return L.view.extend({
                            enc = L.isObject(bss.encryption) ? bss.encryption : null,
                            is_wep = (enc && Array.isArray(enc.wep)),
                            is_psk = (enc && Array.isArray(enc.wpa) && L.toArray(enc.authentication).filter(function(a) { return a == 'psk' || a == 'sae' })),
-                           replace, passphrase, name, zone;
+                           replace, passphrase, name, bssid, zone;
 
                        s2.render = function() {
                                return Promise.all([
@@ -1994,6 +2001,11 @@ return L.view.extend({
                                passphrase.rmempty = false;
                        }
 
+                       if (bss.ssid != null) {
+                               bssid = s2.option(form.Flag, 'bssid', _('Lock to BSSID'), _('Instead of joining any network with a matching SSID, only connect to the BSSID <code>%h</code>.').format(bss.bssid));
+                               bssid.default = '0';
+                       }
+
                        zone = s2.option(widgets.ZoneSelect, 'zone', _('Create / Assign firewall-zone'), _('Choose the firewall zone you want to assign to this interface. Select <em>unspecified</em> to remove the interface from the associated zone or fill out the <em>create</em> field to define a new zone and attach the interface to it.'));
                        zone.default = 'wan';