luci-mod-network: wireless.js: add wifi-iface macaddr random support 5896/head
authorManas Sambhus <manas.sambhus+github@gmail.com>
Mon, 19 Jun 2023 18:19:19 +0000 (23:49 +0530)
committerChristian Marangi <ansuelsmth@gmail.com>
Sat, 24 Jun 2023 22:20:54 +0000 (00:20 +0200)
Add ability to choose random or custom mac address for wifi-iface.
By default the driver mac address is used and this special feature needs
to be supported by the wireless driver.

Signed-off-by: Manas Sambhus <manas.sambhus+github@gmail.com>
[ drop redundant tags and improve commit description ]
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
modules/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js

index 6b1bd262fb7afe2e2b6f7e42fa90b3c84da6eb91..5eb07ae41e3e4f48ee4b7dee9e5598fb718be3a1 100644 (file)
@@ -1157,10 +1157,11 @@ return view.extend({
                                        if (/^radio\d+\.network/.test(o.placeholder))
                                                o.placeholder = '';
 
+                                       var macaddr = uci.get('wireless', radioNet.getName(), 'macaddr');
                                        o = ss.taboption('advanced', form.Value, 'macaddr', _('MAC address'), _('Override default MAC address - the range of usable addresses might be limited by the driver'));
-                                       o.optional = true;
-                                       o.placeholder = radioNet.getActiveBSSID();
-                                       o.datatype = 'macaddr';
+                                       o.value('', _('driver default (%s)').format(!macaddr ? radioNet.getActiveBSSID() : _('no override')));
+                                       o.value('random', _('randomly generated'));
+                                       o.datatype = "or('random',macaddr)";
 
                                        o = ss.taboption('advanced', form.Flag, 'short_preamble', _('Short Preamble'));
                                        o.default = o.enabled;