diff options
Diffstat (limited to 'modules/luci-mod-network/luasrc')
5 files changed, 53 insertions, 307 deletions
diff --git a/modules/luci-mod-network/luasrc/controller/admin/network.lua b/modules/luci-mod-network/luasrc/controller/admin/network.lua index a200f79b51..1da5eac464 100644 --- a/modules/luci-mod-network/luasrc/controller/admin/network.lua +++ b/modules/luci-mod-network/luasrc/controller/admin/network.lua @@ -321,7 +321,7 @@ function wifi_scan_trigger(radio, update) return end - luci.http.status(200, "Scan scheduled") + luci.http.status(204, "Scan scheduled") if nixio.fork() == 0 then io.stderr:close() diff --git a/modules/luci-mod-network/luasrc/model/cbi/admin_network/wifi.lua b/modules/luci-mod-network/luasrc/model/cbi/admin_network/wifi.lua index 8ed39df486..9ab282c3ab 100644 --- a/modules/luci-mod-network/luasrc/model/cbi/admin_network/wifi.lua +++ b/modules/luci-mod-network/luasrc/model/cbi/admin_network/wifi.lua @@ -17,7 +17,9 @@ local acct_port, acct_secret, acct_server, anonymous_identity, ant1, ant2, privkeypwd2, r0_key_lifetime, r0kh, r1_key_holder, r1kh, reassociation_deadline, retry_timeout, ssid, st, tp, wepkey, wepslot, wmm, wpakey, wps, disassoc_low_ack, short_preamble, beacon_int, dtim_period, - wparekey, inactivitypool, maxinactivity, listeninterval + wparekey, inactivitypool, maxinactivity, listeninterval, + dae_client, dae_port, dae_port + arg[1] = arg[1] or "" @@ -755,6 +757,30 @@ acct_secret:depends({mode="ap-wds", encryption="wpa2"}) acct_secret.rmempty = true acct_secret.password = true +dae_client = s:taboption("encryption", Value, "dae_client", translate("DAE-Client")) +dae_client:depends({mode="ap", encryption="wpa"}) +dae_client:depends({mode="ap", encryption="wpa2"}) +dae_client:depends({mode="ap-wds", encryption="wpa"}) +dae_client:depends({mode="ap-wds", encryption="wpa2"}) +dae_client.rmempty = true +dae_client.datatype = "host(0)" + +dae_port = s:taboption("encryption", Value, "dae_port", translate("DAE-Port"), translatef("Default %d", 3799)) +dae_port:depends({mode="ap", encryption="wpa"}) +dae_port:depends({mode="ap", encryption="wpa2"}) +dae_port:depends({mode="ap-wds", encryption="wpa"}) +dae_port:depends({mode="ap-wds", encryption="wpa2"}) +dae_port.rmempty = true +dae_port.datatype = "port" + +dae_secret = s:taboption("encryption", Value, "dae_secret", translate("DAE-Secret")) +dae_secret:depends({mode="ap", encryption="wpa"}) +dae_secret:depends({mode="ap", encryption="wpa2"}) +dae_secret:depends({mode="ap-wds", encryption="wpa"}) +dae_secret:depends({mode="ap-wds", encryption="wpa2"}) +dae_secret.rmempty = true +dae_secret.password = true + wpakey = s:taboption("encryption", Value, "_wpa_key", translate("Key")) wpakey:depends("encryption", "psk") wpakey:depends("encryption", "psk2") @@ -872,12 +898,14 @@ if hwtype == "mac80211" or hwtype == "prism2" then ft_psk_generate_local = s:taboption("encryption", Flag, "ft_psk_generate_local", translate("Generate PMK locally"), - translate("When using a PSK, the PMK can be generated locally without inter AP communications")) + translate("When using a PSK, the PMK can be automatically generated. When enabled, the R0/R1 key options below are not applied. Disable this to use the R0 and R1 key options.")) ft_psk_generate_local:depends({ieee80211r="1"}) + ft_psk_generate_local.default = ft_psk_generate_local.enabled + ft_psk_generate_local.rmempty = false r0_key_lifetime = s:taboption("encryption", Value, "r0_key_lifetime", translate("R0 Key Lifetime"), translate("minutes")) - r0_key_lifetime:depends({ieee80211r="1", ft_psk_generate_local=""}) + r0_key_lifetime:depends({ieee80211r="1"}) r0_key_lifetime.placeholder = "10000" r0_key_lifetime.datatype = "uinteger" r0_key_lifetime.rmempty = true @@ -885,13 +913,13 @@ if hwtype == "mac80211" or hwtype == "prism2" then r1_key_holder = s:taboption("encryption", Value, "r1_key_holder", translate("R1 Key Holder"), translate("6-octet identifier as a hex string - no colons")) - r1_key_holder:depends({ieee80211r="1", ft_psk_generate_local=""}) + r1_key_holder:depends({ieee80211r="1"}) r1_key_holder.placeholder = "00004f577274" r1_key_holder.datatype = "and(hexstring,rangelength(12,12))" r1_key_holder.rmempty = true pmk_r1_push = s:taboption("encryption", Flag, "pmk_r1_push", translate("PMK R1 Push")) - pmk_r1_push:depends({ieee80211r="1", ft_psk_generate_local=""}) + pmk_r1_push:depends({ieee80211r="1"}) pmk_r1_push.placeholder = "0" pmk_r1_push.rmempty = true @@ -901,7 +929,7 @@ if hwtype == "mac80211" or hwtype == "prism2" then "<br />This list is used to map R0KH-ID (NAS Identifier) to a destination " .. "MAC address when requesting PMK-R1 key from the R0KH that the STA " .. "used during the Initial Mobility Domain Association.")) - r0kh:depends({ieee80211r="1", ft_psk_generate_local=""}) + r0kh:depends({ieee80211r="1"}) r0kh.rmempty = true r1kh = s:taboption("encryption", DynamicList, "r1kh", translate("External R1 Key Holder List"), @@ -910,7 +938,7 @@ if hwtype == "mac80211" or hwtype == "prism2" then "<br />This list is used to map R1KH-ID to a destination MAC address " .. "when sending PMK-R1 key from the R0KH. This is also the " .. "list of authorized R1KHs in the MD that can request PMK-R1 keys.")) - r1kh:depends({ieee80211r="1", ft_psk_generate_local=""}) + r1kh:depends({ieee80211r="1"}) r1kh.rmempty = true -- End of 802.11r options diff --git a/modules/luci-mod-network/luasrc/view/admin_network/iface_status.htm b/modules/luci-mod-network/luasrc/view/admin_network/iface_status.htm index 34be35dd20..a75b2755cd 100644 --- a/modules/luci-mod-network/luasrc/view/admin_network/iface_status.htm +++ b/modules/luci-mod-network/luasrc/view/admin_network/iface_status.htm @@ -1,66 +1,12 @@ <%+cbi/valueheader%> -<script type="text/javascript">//<![CDATA[ - XHR.poll(5, '<%=url('admin/network/iface_status', self.network)%>', null, - function(x, ifc) - { - if (ifc && (ifc = ifc[0])) - { - var s = document.getElementById('<%=self.option%>-ifc-status'), - img = s.querySelector('img'), - info = s.querySelector('span'), - html = '<strong><%:Device%>:</strong> %h<br />'.format(ifc.ifname); - - if (ifc.ifname) - { - if (ifc.is_up) - html += String.format('<strong><%:Uptime%>:</strong> %t<br />', ifc.uptime); - - if (ifc.macaddr) - html += String.format('<strong><%:MAC%>:</strong> %s<br />', ifc.macaddr); - - html += String.format( - '<strong><%:RX%></strong>: %.2mB (%d <%:Pkts.%>)<br />' + - '<strong><%:TX%></strong>: %.2mB (%d <%:Pkts.%>)<br />', - ifc.rx_bytes, ifc.rx_packets, - ifc.tx_bytes, ifc.tx_packets - ); - - if (ifc.ipaddrs && ifc.ipaddrs.length) - for (var i = 0; i < ifc.ipaddrs.length; i++) - html += String.format( - '<strong><%:IPv4%>:</strong> %s<br />', - ifc.ipaddrs[i] - ); - - if (ifc.ip6addrs && ifc.ip6addrs.length) - for (var i = 0; i < ifc.ip6addrs.length; i++) - html += String.format( - '<strong><%:IPv6%>:</strong> %s<br />', - ifc.ip6addrs[i] - ); - - if (ifc.ip6prefix) - html += String.format('<strong><%:IPv6-PD%>:</strong> %s<br />', ifc.ip6prefix); - - info.innerHTML = html; - } - else - { - info.innerHTML = '<em><%:Interface not present or not connected yet.%></em>'; - } - - img.src = '<%=resource%>/icons/%s%s.png'.format(ifc.type, ifc.is_up ? '' : '_disabled'); - } - } - ); -//]]></script> - -<span class="ifacebadge large" id="<%=self.option%>-ifc-status"> +<span class="ifacebadge large"<%=attr("data-iface-status", self.network)%>> <img src="<%=resource%>/icons/ethernet_disabled.png" /> <span> - <em><%:Collecting data...%></em> + <em class="spinning"><%:Collecting data...%></em> </span> </span> +<script type="text/javascript" src="<%=resource%>/view/network/iface_status.js"></script> + <%+cbi/valuefooter%> diff --git a/modules/luci-mod-network/luasrc/view/admin_network/wifi_join.htm b/modules/luci-mod-network/luasrc/view/admin_network/wifi_join.htm index 987123642f..5a61ba099c 100644 --- a/modules/luci-mod-network/luasrc/view/admin_network/wifi_join.htm +++ b/modules/luci-mod-network/luasrc/view/admin_network/wifi_join.htm @@ -19,185 +19,18 @@ <%+header%> -<script type="text/javascript">//<![CDATA[ - var xhr = new XHR(), - poll = null; - - function format_signal(bss) { - var qval = bss.quality || 0, - qmax = bss.quality_max || 100, - scale = 100 / qmax * qval, - range = 'none'; - - if (!bss.bssid || bss.bssid == '00:00:00:00:00:00') - range = 'none'; - else if (scale < 15) - range = '0'; - else if (scale < 35) - range = '0-25'; - else if (scale < 55) - range = '25-50'; - else if (scale < 75) - range = '50-75'; - else - range = '75-100'; - - return E('span', { - class: 'ifacebadge', - title: '<%:Signal%>: %d<%:dB%> / <%:Quality%>: %d/%d'.format(bss.signal, qval, qmax) - }, [ - E('img', { src: '<%=resource%>/icons/signal-%s.png'.format(range) }), - ' %d%%'.format(scale) - ]); - } - - function format_encryption(bss) { - var enc = bss.encryption || { } - - if (enc.wep === true) - return 'WEP'; - else if (enc.wpa > 0) - return E('abbr', { - title: 'Pairwise: %h / Group: %h'.format( - enc.pair_ciphers.join(', '), - enc.group_ciphers.join(', ')) - }, - '%h - %h'.format( - (enc.wpa === 3) ? '<%:mixed WPA/WPA2%>' : (enc.wpa === 2 ? 'WPA2' : 'WPA'), - enc.auth_suites.join(', '))); - else if (enc.enabled) - return '<em><%:unknown%></em>'; - else - return '<em><%:open%></em>'; - } - - function format_actions(bss) { - var enc = bss.encryption || { }, - input = [ - E('input', { type: 'submit', class: 'cbi-button cbi-button-action important', value: '<%:Join Network%>' }), - E('input', { type: 'hidden', name: 'token', value: '<%=token%>' }), - E('input', { type: 'hidden', name: 'device', value: '<%=dev%>' }), - E('input', { type: 'hidden', name: 'join', value: bss.ssid }), - E('input', { type: 'hidden', name: 'mode', value: bss.mode }), - E('input', { type: 'hidden', name: 'bssid', value: bss.bssid }), - E('input', { type: 'hidden', name: 'channel', value: bss.channel }), - E('input', { type: 'hidden', name: 'clbridge', value: <%=iw.type == "wl" and 1 or 0%> }), - E('input', { type: 'hidden', name: 'wep', value: enc.wep ? 1 : 0 }) - ]; - - if (enc.wpa) { - input.push(E('input', { type: 'hidden', name: 'wpa_version', value: enc.wpa })); - - enc.auth_suites.forEach(function(s) { - input.push(E('input', { type: 'hidden', name: 'wpa_suites', value: s })); - }); - - enc.group_ciphers.forEach(function(s) { - input.push(E('input', { type: 'hidden', name: 'wpa_group', value: s })); - }); - - enc.pair_ciphers.forEach(function(s) { - input.push(E('input', { type: 'hidden', name: 'wpa_pairwise', value: s })); - }); - } - - return E('form', { - class: 'inline', - method: 'post', - action: '<%=url("admin/network/wireless_join")%>' - }, input); - } - - function fade(bss, content) { - if (bss.stale) - return E('span', { style: 'opacity:0.5' }, content); - else - return content; - } - - function flush() { - XHR.stop(poll); - XHR.halt(); - - scan(); - } - - function scan() { - var tbl = document.getElementById('scan_results'); - - cbi_update_table(tbl, [], '<em><img src="<%=resource%>/icons/loading.gif" class="middle" /> <%:Starting wireless scan...%></em>'); - - xhr.post('<%=url("admin/network/wireless_scan_trigger", dev)%>', { token: '<%=token%>' }, - function(s) { - if (s.status !== 200) { - cbi_update_table(tbl, [], '<em><%:Scan request failed%></em>'); - return; - } - - var count = 0; - - poll = XHR.poll(3, '<%=url("admin/network/wireless_scan_results", dev)%>', null, - function(s, results) { - if (Array.isArray(results)) { - var bss = []; - - results.sort(function(a, b) { - var diff = (b.quality - a.quality) || (a.channel - b.channel); - - if (diff) - return diff; - - if (a.ssid < b.ssid) - return -1; - else if (a.ssid > b.ssid) - return 1; - - if (a.bssid < b.bssid) - return -1; - else if (a.bssid > b.bssid) - return 1; - }).forEach(function(res) { - bss.push([ - fade(res, format_signal(res)), - fade(res, res.ssid ? '%h'.format(res.ssid) : E('em', {}, '<%:hidden%>')), - fade(res, res.channel), - fade(res, res.mode), - fade(res, res.bssid), - fade(res, format_encryption(res)), - format_actions(res) - ]); - }); - - cbi_update_table(tbl, bss, '<em><img src="<%=resource%>/icons/loading.gif" class="middle" /> <%:No scan results available yet...%>'); - } - - if (count++ >= 3) { - count = 0; - xhr.post('<%=url("admin/network/wireless_scan_trigger", dev, "1")%>', - { token: '<%=token%>' }, function() { }); - } - }); - - XHR.run(); - }); - } - - document.addEventListener('DOMContentLoaded', scan); - -//]]></script> - <h2 name="content"><%:Join Network: Wireless Scan%></h2> <div class="cbi-map"> <div class="cbi-section"> - <div class="table" id="scan_results"> + <div class="table"<%=attr("data-wifi-scan", dev) .. attr("data-wifi-type", iw.type)%>> <div class="tr table-titles"> - <div class="th col-1 middle center"><%:Signal%></div> - <div class="th col-5 middle left"><%:SSID%></div> - <div class="th col-2 middle center"><%:Channel%></div> - <div class="th col-2 middle left"><%:Mode%></div> - <div class="th col-3 middle left"><%:BSSID%></div> - <div class="th col-2 middle left"><%:Encryption%></div> + <div class="th col-2 middle center"><%:Signal%></div> + <div class="th col-4 middle left"><%:SSID%></div> + <div class="th col-2 middle center hide-xs"><%:Channel%></div> + <div class="th col-2 middle left hide-xs"><%:Mode%></div> + <div class="th col-3 middle left hide-xs"><%:BSSID%></div> + <div class="th col-3 middle left"><%:Encryption%></div> <div class="th cbi-section-actions"> </div> </div> @@ -221,4 +54,6 @@ </form> </div> +<script type="text/javascript" src="<%=resource%>/view/network/wifi_join.js"></script> + <%+footer%> diff --git a/modules/luci-mod-network/luasrc/view/admin_network/wifi_status.htm b/modules/luci-mod-network/luasrc/view/admin_network/wifi_status.htm index bfad3d0804..93ae2f51fb 100644 --- a/modules/luci-mod-network/luasrc/view/admin_network/wifi_status.htm +++ b/modules/luci-mod-network/luasrc/view/admin_network/wifi_status.htm @@ -1,77 +1,14 @@ <%+cbi/valueheader%> -<script type="text/javascript">//<![CDATA[ - XHR.poll(5, '<%=url('admin/network/wireless_status', self.ifname)%>', null, - function(x, iw) - { - if (iw && (iw = iw[0])) - { - var is_assoc = (iw.bssid && iw.bssid != '00:00:00:00:00:00' && iw.channel && !iw.disabled); - var p = iw.quality; - var q = iw.disabled ? -1 : p; - - var icon; - if (q < 0) - icon = "<%=resource%>/icons/signal-none.png"; - else if (q == 0) - icon = "<%=resource%>/icons/signal-0.png"; - else if (q < 25) - icon = "<%=resource%>/icons/signal-0-25.png"; - else if (q < 50) - icon = "<%=resource%>/icons/signal-25-50.png"; - else if (q < 75) - icon = "<%=resource%>/icons/signal-50-75.png"; - else - icon = "<%=resource%>/icons/signal-75-100.png"; - - var s = document.getElementById('<%=self.option%>-iw-status'), - small = s.querySelector('small'), - info = s.querySelector('span'); - - small.innerHTML = info.innerHTML = String.format( - '<img src="%s" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%>" /> <br />%d%% ', - icon, iw.signal, iw.noise, p - ); - - if (is_assoc) - info.innerHTML = String.format( - '<strong><%:Mode%>:</strong> %s | ' + - '<strong><%:SSID%>:</strong> %h<br />' + - '<strong><%:BSSID%>:</strong> %s<br />' + - '<strong><%:Encryption%>:</strong> %s<br />' + - '<strong><%:Channel%>:</strong> %d (%.3f <%:GHz%>)<br />' + - '<strong><%:Tx-Power%>:</strong> %d <%:dBm%><br />' + - '<strong><%:Signal%>:</strong> %d <%:dBm%> | ' + - '<strong><%:Noise%>:</strong> %d <%:dBm%><br />' + - '<strong><%:Bitrate%>:</strong> %.1f <%:Mbit/s%> | ' + - '<strong><%:Country%>:</strong> %s', - iw.mode, iw.ssid, iw.bssid, - iw.encryption ? iw.encryption : '<%:None%>', - iw.channel, iw.frequency ? iw.frequency : 0, - iw.txpower, iw.signal, iw.noise, - iw.bitrate ? iw.bitrate : 0, iw.country - ); - else - info.innerHTML = String.format( - '<strong><%:SSID%>:</strong> %h | ' + - '<strong><%:Mode%>:</strong> %s<br />' + - '<em>%s</em>', - iw.ssid || '?', iw.mode, - iw.disabled ? '<em><%:Wireless is disabled%></em>' - : '<em><%:Wireless is not associated%></em>' - ); - } - } - ); -//]]></script> - -<span class="ifacebadge large" id="<%=self.option%>-iw-status"> +<span class="ifacebadge large"<%=attr("data-wifi-status", self.ifname)%>> <small> <img src="<%=resource%>/icons/signal-none.png" title="<%:Not associated%>" />  </small> <span> - <em><%:Collecting data...%></em> + <em class="spinning"><%:Collecting data...%></em> </span> </span> +<script type="text/javascript" src="<%=resource%>/view/network/wifi_status.js"></script> + <%+cbi/valuefooter%> |