1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #!/usr/bin/lua
- local uci = require('luci.model.uci').cursor()
- local iwinfo = require "iwinfo"
- function get_available_wifi_networks()
- local radios = {}
- uci:foreach('wireless', 'wifi-device',
- function(s)
- radios[s['.name']] = {}
- end
- )
- for radio, _ in pairs(radios) do
- local wifitype = iwinfo.type(radio)
- local iw = iwinfo[wifitype]
- if iw then
- local tmplist = iw.scanlist(radio)
- for _, net in ipairs(tmplist) do
- if net.ssid and net.bssid then
- if net.ssid:match('.*[Ff][Rr][Ee][Ii][Ff][Uu][Nn][Kk].*') then
- table.insert (radios[radio], net)
- end
- end
- end
- end
- end
- return radios
- end
- function get_update_hosts(branch)
- local hosts = {}
- local mirrors = uci:get_list('autoupdater', branch, 'mirror')
- for _, mirror in ipairs(mirrors) do
- local host = mirror:match("://%[?([a-zA-Z0-9\:\.]+)%]?/")
- table.insert(hosts, 1, host)
- end
- return hosts
- end
|