diff options
author | Steven Barth <steven@midlink.org> | 2008-05-08 16:07:00 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-05-08 16:07:00 +0000 |
commit | f3b7e588e127774e85ebe244ca6ae22d8a8b25e5 (patch) | |
tree | f58e10fd01406d68156dd1b35c9d7a9f78dd797f /modules/freifunk/src/controller | |
parent | 214bfdc19887c3df373d1323afd9738eee4f64ca (diff) |
* WTF SVN oO
Diffstat (limited to 'modules/freifunk/src/controller')
-rw-r--r-- | modules/freifunk/src/controller/admin/index/wizard.lua | 171 | ||||
-rw-r--r-- | modules/freifunk/src/controller/public/index.lua | 1 | ||||
-rw-r--r-- | modules/freifunk/src/controller/public/olsr.lua | 137 | ||||
-rw-r--r-- | modules/freifunk/src/controller/public/status.lua | 21 | ||||
-rw-r--r-- | modules/freifunk/src/controller/rpc/luciinfo.lua | 41 | ||||
-rw-r--r-- | modules/freifunk/src/controller/sudo/status.lua | 1 |
6 files changed, 0 insertions, 372 deletions
diff --git a/modules/freifunk/src/controller/admin/index/wizard.lua b/modules/freifunk/src/controller/admin/index/wizard.lua deleted file mode 100644 index c7064bb1b..000000000 --- a/modules/freifunk/src/controller/admin/index/wizard.lua +++ /dev/null @@ -1,171 +0,0 @@ -module("ffluci.controller.admin.index.wizard", package.seeall) - -function action() - if ffluci.http.formvalue("ip") then - return configure_freifunk() - end - - local ifaces = {} - local wldevs = ffluci.model.uci.sections("wireless") - - if wldevs then - for k, v in pairs(wldevs) do - if v[".type"] == "wifi-device" then - table.insert(ifaces, k) - end - end - end - - ffluci.template.render("admin_index/wizard", {ifaces=ifaces}) -end - -function configure_freifunk() - local ip = ffluci.http.formvalue("ip") - local uci = ffluci.model.uci.Session() - - -- Load UCI - uci:t_load("network") - uci:t_load("dhcp") - uci:t_load("freifunk") - uci:t_load("luci_splash") - uci:t_load("olsr") - uci:t_load("wireless") - - - -- Configure FF-Interface - uci:t_del("network", "ff") - uci:t_del("network", "ffdhcp") - - uci:t_set("network", "ff", nil, "interface") - uci:t_set("network", "ff", "type", "bridge") - uci:t_set("network", "ff", "proto", "static") - uci:t_set("network", "ff", "ipaddr", ip) - uci:t_set("network", "ff", "netmask", uci:t_get("freifunk", "community", "mask")) - uci:t_set("network", "ff", "dns", uci:t_get("freifunk", "community", "dns")) - - -- Enable internal routing - uci:t_set("freifunk", "routing", "internal", "1") - - -- Enable internet routing - if ffluci.http.formvalue("shareinet") then - uci:t_set("freifunk", "routing", "internet", "1") - else - uci:t_set("freifunk", "routing", "internet", "0") - end - - -- Configure DHCP - if ffluci.http.formvalue("dhcp") then - local dhcpnet = uci:t_get("freifunk", "community", "dhcp"):match("^([0-9]+)") - local dhcpip = ip:gsub("^[0-9]+", dhcpnet) - - uci:t_set("network", "ffdhcp", nil, "interface") - uci:t_set("network", "ffdhcp", "proto", "static") - uci:t_set("network", "ffdhcp", "ifname", "br-ff:dhcp") - uci:t_set("network", "ffdhcp", "ipaddr", dhcpip) - uci:t_set("network", "ffdhcp", "netmask", uci:t_get("freifunk", "community", "dhcpmask")) - - local dhcp = uci:t_sections("dhcp") - if dhcp then - for k, v in pairs(dhcp) do - if v[".type"] == "dhcp" and v.interface == "ffdhcp" then - uci:t_del("dhcp", k) - end - end - - local dhcpbeg = 48 + tonumber(ip:match("[0-9]+$")) * 4 - - local sk = uci:t_add("dhcp", "dhcp") - uci:t_set("dhcp", sk, "interface", "ffdhcp") - uci:t_set("dhcp", sk, "start", dhcpbeg) - uci:t_set("dhcp", sk, "limit", (dhcpbeg < 252) and 3 or 2) - uci:t_set("dhcp", sk, "leasetime", "30m") - end - - local splash = uci:t_sections("luci_splash") - if splash then - for k, v in pairs(splash) do - if v[".type"] == "iface" then - uci:t_del("luci_splash", k) - end - end - - local sk = uci:t_add("luci_splash", "iface") - uci:t_set("luci_splash", sk, "network", "ffdhcp") - end - end - - -- Configure OLSR - if ffluci.http.formvalue("olsr") and uci:t_sections("olsr") then - for k, v in pairs(uci:t_sections("olsr")) do - if v[".type"] == "Interface" or v[".type"] == "LoadPlugin" then - uci:t_del("olsr", k) - end - end - - if ffluci.http.formvalue("shareinet") then - uci:t_set("olsr", "dyn_gw", nil, "LoadPlugin") - uci:t_set("olsr", "dyn_gw", "Library", "olsrd_dyn_gw.so.0.4") - end - - uci:t_set("olsr", "nameservice", nil, "LoadPlugin") - uci:t_set("olsr", "nameservice", "Library", "olsrd_nameservice.so.0.3") - uci:t_set("olsr", "nameservice", "name", ip:gsub("%.", "-")) - uci:t_set("olsr", "nameservice", "hosts_file", "/var/etc/hosts") - uci:t_set("olsr", "nameservice", "suffix", ".olsr") - uci:t_set("olsr", "nameservice", "latlon_infile", "/tmp/latlon.txt") - - uci:t_set("olsr", "txtinfo", nil, "LoadPlugin") - uci:t_set("olsr", "txtinfo", "Library", "olsrd_txtinfo.so.0.1") - uci:t_set("olsr", "txtinfo", "Accept", "127.0.0.1") - - local oif = uci:t_add("olsr", "Interface") - uci:t_set("olsr", oif, "Interface", "ff") - uci:t_set("olsr", oif, "HelloInterval", "6.0") - uci:t_set("olsr", oif, "HelloValidityTime", "108.0") - uci:t_set("olsr", oif, "TcInterval", "4.0") - uci:t_set("olsr", oif, "TcValidityTime", "324.0") - uci:t_set("olsr", oif, "MidInterval", "18.0") - uci:t_set("olsr", oif, "MidValidityTime", "324.0") - uci:t_set("olsr", oif, "HnaInterval", "18.0") - uci:t_set("olsr", oif, "HnaValidityTime", "108.0") - end - - -- Configure Wifi - local wcfg = uci:t_sections("wireless") - if wcfg then - for iface, v in pairs(wcfg) do - if v[".type"] == "wifi-device" and ffluci.http.formvalue("wifi."..iface) then - -- Cleanup - for k, j in pairs(wcfg) do - if j[".type"] == "wifi-iface" and j.device == iface then - uci:t_del("wireless", k) - end - end - - uci:t_set("wireless", iface, "disabled", "0") - uci:t_set("wireless", iface, "mode", "11g") - uci:t_set("wireless", iface, "txantenna", 1) - uci:t_set("wireless", iface, "rxantenna", 1) - uci:t_set("wireless", iface, "channel", uci:t_get("freifunk", "community", "channel")) - - local wif = uci:t_add("wireless", "wifi-iface") - uci:t_set("wireless", wif, "device", iface) - uci:t_set("wireless", wif, "network", "ff") - uci:t_set("wireless", wif, "mode", "adhoc") - uci:t_set("wireless", wif, "ssid", uci:t_get("freifunk", "community", "essid")) - uci:t_set("wireless", wif, "bssid", uci:t_get("freifunk", "community", "bssid")) - uci:t_set("wireless", wif, "txpower", 13) - end - end - end - - -- Save UCI - uci:t_save("network") - uci:t_save("dhcp") - uci:t_save("freifunk") - uci:t_save("luci_splash") - uci:t_save("olsr") - uci:t_save("wireless") - - ffluci.http.redirect(ffluci.dispatcher.build_url("admin", "uci", "changes")) -end
\ No newline at end of file diff --git a/modules/freifunk/src/controller/public/index.lua b/modules/freifunk/src/controller/public/index.lua deleted file mode 100644 index f65478c05..000000000 --- a/modules/freifunk/src/controller/public/index.lua +++ /dev/null @@ -1 +0,0 @@ -module("ffluci.controller.public.index", package.seeall)
\ No newline at end of file diff --git a/modules/freifunk/src/controller/public/olsr.lua b/modules/freifunk/src/controller/public/olsr.lua deleted file mode 100644 index d41f5ed41..000000000 --- a/modules/freifunk/src/controller/public/olsr.lua +++ /dev/null @@ -1,137 +0,0 @@ -module("ffluci.controller.public.olsr", package.seeall) -require("ffluci.sys") - -function action_index() - local data = fetch_txtinfo("links") - - if not data or not data.Links then - ffluci.template.render("public_olsr/error_olsr") - return nil - end - - local function compare(a, b) - if tonumber(a.ETX) == 0 then - return false - end - - if tonumber(b.ETX) == 0 then - return true - end - - return tonumber(a.ETX) < tonumber(b.ETX) - end - - table.sort(data.Links, compare) - - ffluci.template.render("public_olsr/index", {links=data.Links}) -end - -function action_routes() - local data = fetch_txtinfo("routes") - - if not data or not data.Routes then - ffluci.template.render("public_olsr/error_olsr") - return nil - end - - local function compare(a, b) - if tonumber(a.ETX) == 0 then - return false - end - - if tonumber(b.ETX) == 0 then - return true - end - - return tonumber(a.ETX) < tonumber(b.ETX) - end - - table.sort(data.Routes, compare) - - ffluci.template.render("public_olsr/routes", {routes=data.Routes}) -end - -function action_topology() - local data = fetch_txtinfo("topology") - - if not data or not data.Topology then - ffluci.template.render("public_olsr/error_olsr") - return nil - end - - local function compare(a, b) - return a["Destination IP"] < b["Destination IP"] - end - - table.sort(data.Topology, compare) - - ffluci.template.render("public_olsr/topology", {routes=data.Topology}) -end - -function action_hna() - local data = fetch_txtinfo("hna") - - if not data or not data.HNA then - ffluci.template.render("public_olsr/error_olsr") - return nil - end - - local function compare(a, b) - return a.Network < b.Network - end - - table.sort(data.HNA, compare) - - ffluci.template.render("public_olsr/hna", {routes=data.HNA}) -end - -function action_mid() - local data = fetch_txtinfo("mid") - - if not data or not data.MID then - ffluci.template.render("public_olsr/error_olsr") - return nil - end - - local function compare(a, b) - return a.IP < b.IP - end - - table.sort(data.MID, compare) - - ffluci.template.render("public_olsr/mid", {mids=data.MID}) -end - - --- Internal -function fetch_txtinfo(otable) - otable = otable or "" - local rawdata = ffluci.sys.httpget("http://127.0.0.1:2006/"..otable) - - if #rawdata == 0 then - return nil - end - - local data = {} - - local tables = ffluci.util.split(ffluci.util.trim(rawdata), "\n\n") - - - for i, tbl in ipairs(tables) do - local lines = ffluci.util.split(tbl, "\n") - local name = table.remove(lines, 1):sub(8) - local keys = ffluci.util.split(table.remove(lines, 1), "\t") - - data[name] = {} - - for j, line in ipairs(lines) do - local fields = ffluci.util.split(line, "\t") - data[name][j] = {} - for k, key in pairs(keys) do - data[name][j][key] = fields[k] - end - end - end - - return data -end
\ No newline at end of file diff --git a/modules/freifunk/src/controller/public/status.lua b/modules/freifunk/src/controller/public/status.lua deleted file mode 100644 index 8d2f7a303..000000000 --- a/modules/freifunk/src/controller/public/status.lua +++ /dev/null @@ -1,21 +0,0 @@ -module("ffluci.controller.public.status", package.seeall) - -function action_index() - local data = {} - - data.s, data.m, data.r = ffluci.sys.sysinfo() - - data.wifi = ffluci.sys.wifi.getiwconfig() - - data.routes = {} - for i, r in pairs(ffluci.sys.net.routes()) do - if r.Destination == "00000000" then - table.insert(data.routes, r) - end - end - - - ffluci.template.render("public_status/index", data) -end - - diff --git a/modules/freifunk/src/controller/rpc/luciinfo.lua b/modules/freifunk/src/controller/rpc/luciinfo.lua deleted file mode 100644 index 611423fbb..000000000 --- a/modules/freifunk/src/controller/rpc/luciinfo.lua +++ /dev/null @@ -1,41 +0,0 @@ -module("ffluci.controller.rpc.luciinfo", package.seeall) - -function action_index() - local uci = ffluci.model.uci.StateSession() - - ffluci.http.prepare_content("text/plain") - - -- General - print("luciinfo.api=1") - print("luciinfo.version=" .. tostring(ffluci.__version__)) - - -- Sysinfo - local s, m, r = ffluci.sys.sysinfo() - local dr = ffluci.sys.net.defaultroute() - dr = dr and ffluci.sys.net.hexip4(dr.Gateway) or "" - local l1, l5, l15 = ffluci.sys.loadavg() - - print("sysinfo.system=" .. sanitize(s)) - print("sysinfo.cpu=" .. sanitize(m)) - print("sysinfo.ram=" .. sanitize(r)) - print("sysinfo.hostname=" .. sanitize(ffluci.sys.hostname())) - print("sysinfo.load1=" .. tostring(l1)) - print("sysinfo.load5=" .. tostring(l5)) - print("sysinfo.load15=" .. tostring(l15)) - print("sysinfo.defaultgw=" .. dr) - - - -- Freifunk - local ff = uci:sections("freifunk") or {} - for k, v in pairs(ff) do - if k:sub(1, 1) ~= "." then - for i, j in pairs(v) do - print("freifunk." .. k .. "." .. i .. "=" .. j) - end - end - end -end - -function sanitize(val) - return val:gsub("\n", "\t") -end
\ No newline at end of file diff --git a/modules/freifunk/src/controller/sudo/status.lua b/modules/freifunk/src/controller/sudo/status.lua deleted file mode 100644 index fd5127d2c..000000000 --- a/modules/freifunk/src/controller/sudo/status.lua +++ /dev/null @@ -1 +0,0 @@ -module("ffluci.controller.sudo.status", package.seeall)
\ No newline at end of file |