From 800309f84e17626c64c8bbf80600796b4a6a230f Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Tue, 5 Nov 2013 10:17:00 -0500 Subject: [PATCH 001/196] removed unneeded old commotion helpers --- luasrc/commotion_helpers.lua | 203 ----------------------------------- 1 file changed, 203 deletions(-) delete mode 100644 luasrc/commotion_helpers.lua diff --git a/luasrc/commotion_helpers.lua b/luasrc/commotion_helpers.lua deleted file mode 100644 index 162c66b..0000000 --- a/luasrc/commotion_helpers.lua +++ /dev/null @@ -1,203 +0,0 @@ -function DIE(str) - luci.http.status(500, "Internal Server Error") - luci.http.write(str) - luci.http.close() -end - ---- Redirects a page to https if the path is within the "node" path. --- @param node node path to check. format as such -> "/NODE/" --- @param env A table containing the REQUEST_URI and the SERVER_NAME. Can take full luci.http.getenv() --- @return True if page is to be redirected. False if path does not include node or if https is already on. -function check_https(node, env) - if string.match(env.REQUEST_URI, node) then - if env.HTTPS ~= "on" then - luci.http.redirect("https://"..env.SERVER_NAME..env.REQUEST_URI) - return true - end - return false - end - return false -end - ---- Gives the md5 and sha1 fingerprints of uhttpd server. ---- Call as such: md5, sha1 = ssl_cert_fingerprints() If you only give one var name it will only give you md5. Call like: _, sha1 = to throw away md5 --- @return md5 and sha1 hash of uhttpd. -function ssl_cert_fingerprints() - --get cert file from /etc/config/uhttpd - local uci = luci.model.uci.cursor() - local cert = uci:get('uhttpd','main','cert') - --get md5 and sha1 hash's of cert file - local md5 = luci.sys.exec("md5sum "..cert) - local sha1 = luci.sys.exec("sha1sum "..cert) - -- remove the filename and extra spaces then uppercase the cert string - sha1 = string.upper(sha1:match("(%w*)%s*"..cert)) - md5 = string.upper(md5:match("(%w*)%s*"..cert)) - --add colons between pairs of two chars - sha1 = sha1:gsub("(%w%w)", "%1:") - md5 = md5:gsub("(%w%w)", "%1:") - --remove the final colon - sha1 = sha1:sub(1, -2) - md5 = md5:sub(1,-2) - return md5, sha1 -end - -function uci_encode(str) - if (str) then - str = string.gsub (str, "([^%w])", function(c) return '_' .. tostring(string.byte(c)) end) - end - return str -end - -function html_encode(str) - return string.gsub(str,"[<>&\n\r\"]",function(c) return html_replacements[c] or c end) -end - -function url_encode(str) - local uri_util = require "uri._util" - return uri_util.uri_encode(str,"^A-Za-z0-9%-_.!~*'():/") -end - -function printf(tmpl,t) - return (tmpl:gsub('($%b{})', function(w) return t[w:sub(3, -2)] or w end)) -end - -function log(msg) - if (type(msg) == "table") then - for key, val in pairs(msg) do - log('{') - log(key) - log(':') - log(val) - log('}') - end - else - luci.sys.exec("logger -t luci \"" .. tostring(msg) .. '"') - end -end - -function is_ip4addr(str) - local i,j, _1, _2, _3, _4 = string.find(str, '^(%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?)%.(%d%d?%d?)$') - if (i and - (tonumber(_1) >= 0 and tonumber(_1) <= 255) and - (tonumber(_2) >= 0 and tonumber(_2) <= 255) and - (tonumber(_3) >= 0 and tonumber(_3) <= 255) and - (tonumber(_4) >= 0 and tonumber(_4) <= 255)) then - return true - end - return false -end - -function is_ip4addr_cidr(str) - local i,j, _1, _2 = string.find(str, '^(.+)/(%d+)$') - if i and is_ip4addr(_1) and tonumber(_2) >= 0 and tonumber(_2) <= 32 then - return true - end - return false -end - -function is_ssid(str) - -- SSID can have almost anything in it - if #tostring(str) < 32 then - return tostring(str):match("[%w%p]+[%s]*[%w%p]*]*") - else - return nil - end -end - -function is_mode(str) - -- Modes are simple, but also match the "-" in Ad-Hoc - return tostring(str):match("[%w%-]*") -end - -function is_chan(str) - -- Channels are plain digits - return tonumber(string.match(str, "[%d]+")) -end - -function is_bitRate(br) - -- Bitrate can start with a space and we want to display Mb/s - return br:match("[%s]?[%d%.]*[%s][%/%a]+") -end - -function is_email(email) - return tostring(email):match("[A-Za-z0-9%.%%%+%-]+@[A-Za-z0-9%.%%%+%-]+%.%w%w%w?%w?") -end - -function is_hostname(str) ---alphanumeric and hyphen Less than 63 chars ---cannot start or end with a hyphen - if #tostring(str) < 63 then - return tostring(str):match("^%w[%w%-]*%w$") - else - return nil - end -end - -function is_fqdn(str) --- alphanumeric and hyphen less than 255 chars --- each label must be less than 63 chars - if #tostring(str) < 255 then - -- Should check that each label is < 63 chars -- - return tostring(str):match("^[%w%.%-]+$") - else - return nil - end -end - -function is_macaddr(str) - local i,j, _1, _2, _3, _4, _5, _6 = string.find(str, '^(%x%x):(%x%x):(%x%x):(%x%x):(%x%x):(%x%x)$') - if i then return true end - return false -end - -function is_uint(str) - return str:find("^%d+$") -end - -function is_hex(str) - return str:find("^%x+$") -end - -function is_port(str) - return is_uint(str) and tonumber(str) >= 0 and tonumber(str) <= 65535 -end - -function is_valid_uci(str) - return str:find("^[%w_]+$") -end - -function pass_to_shell(str) - return str:gsub("$(","\\$"):gsub("`","\\`") -end - -function table.contains(table, element) - for _, value in pairs(table) do - if value == element then - return true - end - end - return false -end - -function list_ifaces() - local uci = luci.model.uci.cursor() - local r = {zone_to_iface = {}, iface_to_zone = {}} - uci:foreach("network", "interface", - function(zone) - if zone['.name'] == 'loopback' then return end - local iface = luci.sys.exec("ubus call network.interface." .. zone['.name'] .. " status |grep '\"device\"' | cut -d '\"' -f 4"):gsub("%s$","") - r.zone_to_iface[zone['.name']]=iface - r.iface_to_zone[iface]=zone['.name'] - end - ) - return r -end - -html_replacements = { - ["<"] = "<", - [">"] = ">", - ["&"] = "&", - ["\n"] = " ", - ["\r"] = " ", - ["\""] = """ - } From d0842bda99d78b812d39d13d2ba62606fd3c49d0 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 25 Nov 2013 09:15:53 -0500 Subject: [PATCH 002/196] adding basic quickstart menu dispatcher based flow models --- luasrc/controller/commotion/basic_config.lua | 58 +++++++++++++ luasrc/model/cbi/commotion/basic.lua | 20 +++++ luasrc/model/cbi/commotion/basic_nets.lua | 57 +++++++++++++ luasrc/model/cbi/commotion/basic_ns.lua | 89 ++++++++++++++++++++ luasrc/quickstart.lua | 13 +++ 5 files changed, 237 insertions(+) create mode 100644 luasrc/controller/commotion/basic_config.lua create mode 100644 luasrc/model/cbi/commotion/basic.lua create mode 100644 luasrc/model/cbi/commotion/basic_nets.lua create mode 100644 luasrc/model/cbi/commotion/basic_ns.lua create mode 100644 luasrc/quickstart.lua diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua new file mode 100644 index 0000000..2df15d9 --- /dev/null +++ b/luasrc/controller/commotion/basic_config.lua @@ -0,0 +1,58 @@ +--[[ +LuCI - Lua Development Framework + +Copyright 2013 - Seamus Tuohy + +With Thanks to the niu suite built by Steven Barth + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +]]-- + +module "luci.controller.commotion.basic_config" + + +function index() + local confirm = {on_success_to={"confirm_config"}} + + local conf_pg = entry({"commotion, confirm_config"}, cbi("commotion/"), title=translate("Confirm your Changes")) + + entry({"commotion", "Basic"}, cbi("commotion/basic", confirm), title=translate("Basic Configuration"), order=1) + +end + + + + +--[[ +function index() + local basic_main = {on_success_to={"niu"}} + + local e = entry({"niu", "network"}, alias("niu"), "Network", 10) + e.niu_dbtemplate = "niu/network" + e.niu_dbtasks = true + e.niu_dbicon = "icons32/network-workgroup.png" + + entry({"niu", "network", "wan"}, + cbi("niu/network/wan", toniu), "Configure Internet Connection", 1) + + entry({"niu", "network", "lan"}, + cbi("niu/network/lan", toniu), "Configure Local Network", 2) + + uci.inst_state:foreach("dhcp", "dhcp", function(s) + if s.interface == "lan" and s.ignore ~= "1" then + entry({"niu", "network", "assign"}, cbi("niu/network/assign", + toniu), "Manage Address Assignment", 30) + end + end) + + if fs.access("/etc/config/ddns") then + entry({"niu", "network", "ddns"}, cbi("niu/network/ddns", toniu), + "Configure Dynamic-DNS names", 60) + end +end +]]-- diff --git a/luasrc/model/cbi/commotion/basic.lua b/luasrc/model/cbi/commotion/basic.lua new file mode 100644 index 0000000..385e4f3 --- /dev/null +++ b/luasrc/model/cbi/commotion/basic.lua @@ -0,0 +1,20 @@ +local cursor = require "luci.model.uci".cursor() + +local d = Delegator() +d.allow_finish = false +d.allow_back = true +d.allow_cancel = false +d.allow_reset = true + +d:add("Node Settings", "commotion/basic_ns") +d:add("Network Settings", "commotion/basic_nets") +d:add("Mesh Network", "commotion/basic_mn") +d:add("Wireless Network", "commotion/basic_wn") + +function d.on_done() + --Here he wave the cursor commit all the places required earler from the confirmation page. +-- cursor:commit("network") +-- cursor:commit("wireless") +end + +return d diff --git a/luasrc/model/cbi/commotion/basic_nets.lua b/luasrc/model/cbi/commotion/basic_nets.lua new file mode 100644 index 0000000..ffdf91a --- /dev/null +++ b/luasrc/model/cbi/commotion/basic_nets.lua @@ -0,0 +1,57 @@ +local uci = require "luci.model.uci" +local utils = require "luci.util" +--local QS = require "luci.commotion.quickstart" + +local m = Map("wireless", translate("Network Interfaces"), translate("Every Commotion node must have one mesh network connection or interface. Commotion can mesh over wireless or wired interfaces. The Setup Wizard has detected all of the network interfaces on this device. Select the network interface that will connect to the mesh.")) + +local wifi_dev = {} +uci.foreach("wireless", "wifi-device", + function(s) + local name = s[".name"] + local mode = s.mode + wifi_dev.insert({name, channel}) + end +) + +rsec = m:section(TypedSection, "wifi-device", translate("Wireless Interface"), translate("Select the wireless network interface to use for your access point.")) + +radios = rsec:option(ListValue, "_dummy", translate("")) + +--add all the radios we found into this with channels attached +5ghz = {"11a", "11adt", '11na'} +for _,dev in pairs(wifi_dev) do + if utils.contains(5ghz, dev[2]) then + local freq = "5 GHz" + else + local freq = "2.4 GHz" + end + radios:value(dev[1].." "..freq, freq) +end + + +channel = rsec:option(ListValue, "_dummy", translate("")) +--Need to exact results when parsing a wireless config +channel:depends() + +protocol = uci.get("wireless", "wifi-device", "hwmode") + +if protocol == '11na' then + c = e:option(ListValue, "channel", translate("5GHz Channel"), translate("The 5GHz backhaul channel of the mesh network, if applicable.")) + c:value(36, "Channel 36 (5.180 GHz)") + c:value(40, "Channel 40 (5.200 GHz)") + c:value(44, "Channel 44 (5.220 GHz)") + c:value(48, "Channel 48 (5.240 GHz)") + c:value(149, "Channel 149 (5.745 GHz)") + c:value(153, "Channel 153 (5.765 GHz)") + c:value(157, "Channel 157 (5.785 GHz)") + c:value(161, "Channel 161 (5.805 GHz)") + c:value(165, "Channel 165 (5.825 GHz)") +else + c = e:option(ListValue, "channel", translate("2GHz Channel"), translate("The 2.4GHz backhaul channel of the mesh network, if applicable")) + for i=1, 11, 1 do + c:value(i, "Channel " .. i .. " (" .. tostring(2.407+(i*0.005)) .. " GHz)") + end +end + + +return m diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua new file mode 100644 index 0000000..a552210 --- /dev/null +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -0,0 +1,89 @@ +local QS = require "luci.commotion.quickstart" + +--Main title and system config map for hostname value +local m = Map("system", translate("Basic Configuration"), translate("In this section you'll set the basic required settings for this device, and the basic network settings required to connect this device to a Commotion Mesh network. You will be prompted to save your settings along the way and apply them at the end.")) + +--HOSTNAME + +--load up system section +local shn = m:section(TypedSection, "system") +--Don't display it +shn.anonymous = true + +--Create a value field for hostname +local hname = shn:option(Value, hostname, translate("Node Name"), translate("The node name (hostname) is a unique name for this device, visible to other devices and users on the network. Name this device in the field provided.")) + +--PASSWORDS + +local v0 = true -- track password success across maps + +-- Allow incorrect root password to prevent settings change +-- Don't prompt for password if none has been set +if luci.sys.user.getpasswd("root") then + s0 = m:section(TypedSection, "_dummy", translate("Current Password"), + translate("Current password required to make changes on this page")) + s0.addremove = false + s0.anonymous = true + + pw0 = s0:option(Value, "pw0", translate("Current Password")) + pw0.password = true + -- fail by default + v0 = false + + function s0.cfgsections() + return { "_pass0" } + end +end + + +if QS.status() then + local pw_text = "This password will be used to make changes to this device after initial setup has been completed. The administration username is “root." +else + local pw_text = "This password is used to make changes to this device. The administration username is “root." +end + +s = m:section(TypedSection, "_dummy", translate("Administration Password"), translate(pw_text)) +s.addremove = false +s.anonymous = true + +pw1 = s:option(Value, "pw1", translate("Password")) +pw1.password = true + +pw2 = s:option(Value, "pw2", translate("Confirmation")) +pw2.password = true + +function s.cfgsections() + return { "_pass" } +end + +function m.on_before_commit(map) + -- if existing password, make sure user has old password + if s0 then + v0 = luci.sys.user.checkpasswd("root", pw0:formvalue("_pass0")) + end + + if v0 == false then + m.message = translate("Incorrect password. Changes rejected!") + m.save=v0 + m2.save=v0 + end +end + +function m.on_commit(map) + local v1 = pw1:formvalue("_pass") + local v2 = pw2:formvalue("_pass") + + if v0 == true and v1 and v2 and #v1 > 0 and #v2 > 0 then + if v1 == v2 then + if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then + m.message = translate("Password successfully changed!") + else + m.message = translate("Unknown Error, password not changed!") + end + else + m.message = translate("Given password confirmation did not match, password not changed!") + end + end +end + +return m diff --git a/luasrc/quickstart.lua b/luasrc/quickstart.lua new file mode 100644 index 0000000..cdf8501 --- /dev/null +++ b/luasrc/quickstart.lua @@ -0,0 +1,13 @@ +module "luci.commotion.quickstart" + +local QS = {} + +--! @name status +--! @brief Checks the status of quickstart +--! @return true if on, false if completed +--! @TODO IMPLEMENT THIS: Currently placeholder +function QS.status() + return true +end + +return QS From 460c6d8d61ae6be7d0a35e1c23050131c6f5f714 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 25 Nov 2013 16:47:47 -0500 Subject: [PATCH 003/196] finished basic development and testing on flow model. This commit proves functionality, it does NOT show a working implementation of the flow model for the basic menu. But, this does put a pause to issue 77 until all pages are completed. --- luasrc/controller/commotion/basic_config.lua | 55 +++-------- luasrc/model/cbi/commotion/basic_nets.lua | 91 ++++++++++++------- luasrc/model/cbi/commotion/basic_ns.lua | 14 +-- .../commotion/{basic.lua => quickstart.lua} | 9 +- 4 files changed, 85 insertions(+), 84 deletions(-) rename luasrc/model/cbi/commotion/{basic.lua => quickstart.lua} (68%) diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index 2df15d9..81f8554 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -12,47 +12,22 @@ You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ]]-- - module "luci.controller.commotion.basic_config" - function index() - local confirm = {on_success_to={"confirm_config"}} - - local conf_pg = entry({"commotion, confirm_config"}, cbi("commotion/"), title=translate("Confirm your Changes")) - - entry({"commotion", "Basic"}, cbi("commotion/basic", confirm), title=translate("Basic Configuration"), order=1) - -end - - - - ---[[ -function index() - local basic_main = {on_success_to={"niu"}} - - local e = entry({"niu", "network"}, alias("niu"), "Network", 10) - e.niu_dbtemplate = "niu/network" - e.niu_dbtasks = true - e.niu_dbicon = "icons32/network-workgroup.png" - - entry({"niu", "network", "wan"}, - cbi("niu/network/wan", toniu), "Configure Internet Connection", 1) - - entry({"niu", "network", "lan"}, - cbi("niu/network/lan", toniu), "Configure Local Network", 2) - - uci.inst_state:foreach("dhcp", "dhcp", function(s) - if s.interface == "lan" and s.ignore ~= "1" then - entry({"niu", "network", "assign"}, cbi("niu/network/assign", - toniu), "Manage Address Assignment", 30) - end - end) - - if fs.access("/etc/config/ddns") then - entry({"niu", "network", "ddns"}, cbi("niu/network/ddns", toniu), - "Configure Dynamic-DNS names", 60) - end + local QS = require "luci.commotion.quickstart" + + if QS.status() then + local confirm = {on_success_to={"admin", "commotion", "confirm_config"}} + entry({"admin", "commotion", "confirm_config"}, cbi("commotion/confirm_config"), translate("Confirm your Changes")) + entry({"admin", "commotion", "quickstart"}, cbi("commotion/quickstart", confirm), translate("Basic Configuration"), 15) + else + --Create regular "Basic Config" menu. + entry({"admin", "commotion", "basic"}, alias({"admin", "commotion", "basic", "node_settings"}), translate("Basic Configuration"), 10).index = true + entry({"admin", "commotion", "basic", "node_settings"}, cbi("commotion/basic_ns"), translate("Node Settings"), 20) + entry({"admin", "commotion", "basic", "network_settings"}, alias({"admin", "commotion", "basic", "mesh_network"}), translate("Network Settings"), 30) + entry({"admin", "commotion", "basic", "mesh_network"}, cbi("commotion/basic_mn"), translate("Mesh Network"), 40) + entry({"admin", "commotion", "basic", "wireless_network"}, cbi("commotion/basic_wn"), translate("Wireless Network"), 50) + entry({"admin", "commotion", "basic", "addtl_net_ifaces"}, cbi("commotion/basic_ani"), translate("Additional Netork Interfaces"), 60) + end end -]]-- diff --git a/luasrc/model/cbi/commotion/basic_nets.lua b/luasrc/model/cbi/commotion/basic_nets.lua index ffdf91a..d328b8d 100644 --- a/luasrc/model/cbi/commotion/basic_nets.lua +++ b/luasrc/model/cbi/commotion/basic_nets.lua @@ -1,5 +1,6 @@ -local uci = require "luci.model.uci" +local uci = require "luci.model.uci".cursor() local utils = require "luci.util" +--local db = require "luci.commotion.debugger" --local QS = require "luci.commotion.quickstart" local m = Map("wireless", translate("Network Interfaces"), translate("Every Commotion node must have one mesh network connection or interface. Commotion can mesh over wireless or wired interfaces. The Setup Wizard has detected all of the network interfaces on this device. Select the network interface that will connect to the mesh.")) @@ -8,50 +9,74 @@ local wifi_dev = {} uci.foreach("wireless", "wifi-device", function(s) local name = s[".name"] - local mode = s.mode - wifi_dev.insert({name, channel}) + local mode = s.hwmode + table.insert(wifi_dev, {name, mode}) end ) -rsec = m:section(TypedSection, "wifi-device", translate("Wireless Interface"), translate("Select the wireless network interface to use for your access point.")) - -radios = rsec:option(ListValue, "_dummy", translate("")) - ---add all the radios we found into this with channels attached -5ghz = {"11a", "11adt", '11na'} -for _,dev in pairs(wifi_dev) do - if utils.contains(5ghz, dev[2]) then - local freq = "5 GHz" +function check_ghz(hwm) + local five_ghz = {"11a", "11adt", '11na'} + if utils.contains(five_ghz, hwm) then + freq = "5GHz" else - local freq = "2.4 GHz" + freq = "2.4GHz" end - radios:value(dev[1].." "..freq, freq) + return freq end +local function get_freqs(freq) + if freq == "5GHz" then + return {{36, "Channel 36 (5.180 GHz)"}, + {40, "Channel 40 (5.200 GHz)"}, + {44, "Channel 44 (5.220 GHz)"}, + {48, "Channel 48 (5.240 GHz)"}, + {149, "Channel 149 (5.745 GHz)"}, + {153, "Channel 153 (5.765 GHz)"}, + {157, "Channel 157 (5.785 GHz)"}, + {161, "Channel 161 (5.805 GHz)"}, + {165, "Channel 165 (5.825 GHz)"}} + else + if freq == "2.4GHz" then + local set = {} + for i=1, 11, 1 do + table.insert(set, {i, "Channel " .. i .. " (" .. tostring(2.407+(i*0.005)) .. " GHz)"}) + end + return set + end + end +end -channel = rsec:option(ListValue, "_dummy", translate("")) ---Need to exact results when parsing a wireless config -channel:depends() +local this_dev = nil +devices = m:section(TypedSection,"_dummy", "") +devices.anonymous = true +--Check for more than one radio, and if not don't offer to change radio's. +if #wifi_dev > 1 then + radios = devices:option(ListValue, "_dummy", translate("wifi-device"), translate("Wireless Interface"), translate("Select the wireless network interface to use for your access point.")) + for _,dev in pairs(wifi_dev) do + local freq = check_ghz(dev[2]) -protocol = uci.get("wireless", "wifi-device", "hwmode") + radios:value(dev[1].." "..freq, {dev[1]}) -if protocol == '11na' then - c = e:option(ListValue, "channel", translate("5GHz Channel"), translate("The 5GHz backhaul channel of the mesh network, if applicable.")) - c:value(36, "Channel 36 (5.180 GHz)") - c:value(40, "Channel 40 (5.200 GHz)") - c:value(44, "Channel 44 (5.220 GHz)") - c:value(48, "Channel 48 (5.240 GHz)") - c:value(149, "Channel 149 (5.745 GHz)") - c:value(153, "Channel 153 (5.765 GHz)") - c:value(157, "Channel 157 (5.785 GHz)") - c:value(161, "Channel 161 (5.805 GHz)") - c:value(165, "Channel 165 (5.825 GHz)") + local radio = m:section(NamedSection, dev[1] ,translate(""), translate("")) + radio.anonymous = true + radio.depends("radios", dev[1]) + + local channels = radio:option(ListValue, "channel", translate("Channel"), translate("The channel of this wireless interface.")) + + --adds the values to the list based on frequency + for _,x in pairs((get_freqs(freq))) do + channels:value(x[1], x[2]) + end + end else - c = e:option(ListValue, "channel", translate("2GHz Channel"), translate("The 2.4GHz backhaul channel of the mesh network, if applicable")) - for i=1, 11, 1 do - c:value(i, "Channel " .. i .. " (" .. tostring(2.407+(i*0.005)) .. " GHz)") + radios = devices:option(ListValue, "_dummy", translate("wifi-device"), translate("Wireless Interface"), translate("Select the wireless network interface to use for your access point.")) + + local radio = m:section(NamedSection, wifi_dev[1][1] ,translate(""), translate("")) + + local channels = radio:option(ListValue, "channel", translate("Channel"), translate("The channel of this wireless interface.")) + for _,x in pairs(get_freqs(check_ghz(wifi_dev[1][2]))) do + channels:value(x[1], x[2]) end end - return m diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index a552210..821c282 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -1,4 +1,5 @@ local QS = require "luci.commotion.quickstart" +local db = require "luci.commotion.debugger" --Main title and system config map for hostname value local m = Map("system", translate("Basic Configuration"), translate("In this section you'll set the basic required settings for this device, and the basic network settings required to connect this device to a Commotion Mesh network. You will be prompted to save your settings along the way and apply them at the end.")) @@ -11,7 +12,7 @@ local shn = m:section(TypedSection, "system") shn.anonymous = true --Create a value field for hostname -local hname = shn:option(Value, hostname, translate("Node Name"), translate("The node name (hostname) is a unique name for this device, visible to other devices and users on the network. Name this device in the field provided.")) +local hname = shn:option(Value, "hostname", translate("Node Name"), translate("The node name (hostname) is a unique name for this device, visible to other devices and users on the network. Name this device in the field provided.")) --PASSWORDS @@ -35,11 +36,10 @@ if luci.sys.user.getpasswd("root") then end end - if QS.status() then - local pw_text = "This password will be used to make changes to this device after initial setup has been completed. The administration username is “root." + pw_text = "This password will be used to make changes to this device after initial setup has been completed. The administration username is “root." else - local pw_text = "This password is used to make changes to this device. The administration username is “root." + pw_text = "This password is used to make changes to this device. The administration username is “root." end s = m:section(TypedSection, "_dummy", translate("Administration Password"), translate(pw_text)) @@ -59,13 +59,13 @@ end function m.on_before_commit(map) -- if existing password, make sure user has old password if s0 then - v0 = luci.sys.user.checkpasswd("root", pw0:formvalue("_pass0")) + v0 = luci.sys.user.checkpasswd("root", formvalue("_pass0")) end if v0 == false then m.message = translate("Incorrect password. Changes rejected!") - m.save=v0 - m2.save=v0 + m.save=v0 + m2.save=v0 end end diff --git a/luasrc/model/cbi/commotion/basic.lua b/luasrc/model/cbi/commotion/quickstart.lua similarity index 68% rename from luasrc/model/cbi/commotion/basic.lua rename to luasrc/model/cbi/commotion/quickstart.lua index 385e4f3..e4b04df 100644 --- a/luasrc/model/cbi/commotion/basic.lua +++ b/luasrc/model/cbi/commotion/quickstart.lua @@ -1,19 +1,20 @@ local cursor = require "luci.model.uci".cursor() local d = Delegator() -d.allow_finish = false +d.allow_finish = true d.allow_back = true d.allow_cancel = false d.allow_reset = true d:add("Node Settings", "commotion/basic_ns") d:add("Network Settings", "commotion/basic_nets") -d:add("Mesh Network", "commotion/basic_mn") -d:add("Wireless Network", "commotion/basic_wn") +--TODO add back in after testing +--d:add("Mesh Network", "commotion/basic_mn") +--d:add("Wireless Network", "commotion/basic_wn") function d.on_done() --Here he wave the cursor commit all the places required earler from the confirmation page. --- cursor:commit("network") + cursor:commit("network") -- cursor:commit("wireless") end From a26db2b03a966fd92d53c3e980bc14d3fd03f352 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Tue, 26 Nov 2013 11:44:08 -0500 Subject: [PATCH 004/196] created controllers for new menu structure and touched the files required for the new structure. --- luasrc/{ => commotion}/quickstart.lua | 0 .../commotion/application_config.lua | 25 +++++++++++++++++++ luasrc/controller/commotion/basic_config.lua | 6 +++++ luasrc/controller/commotion/client_config.lua | 23 +++++++++++++++++ .../controller/commotion/security_config.lua | 23 +++++++++++++++++ luasrc/controller/commotion/status_config.lua | 19 ++++++++++++++ .../model/cbi/commotion/application_add.lua | 0 .../model/cbi/commotion/application_list.lua | 0 .../model/cbi/commotion/application_set.lua | 0 luasrc/model/cbi/commotion/basic_ani.lua | 0 .../{basic_nets.lua => basic_mn.lua} | 0 luasrc/model/cbi/commotion/basic_wn.lua | 0 luasrc/model/cbi/commotion/client_bc.lua | 0 luasrc/model/cbi/commotion/client_wp.lua | 0 luasrc/model/cbi/commotion/confirm_config.lua | 5 ++++ luasrc/model/cbi/commotion/security_pass.lua | 0 luasrc/model/cbi/commotion/security_smk.lua | 0 luasrc/view/commotion/status.htm | 0 18 files changed, 101 insertions(+) rename luasrc/{ => commotion}/quickstart.lua (100%) create mode 100644 luasrc/controller/commotion/application_config.lua create mode 100644 luasrc/controller/commotion/client_config.lua create mode 100644 luasrc/controller/commotion/security_config.lua create mode 100644 luasrc/controller/commotion/status_config.lua create mode 100644 luasrc/model/cbi/commotion/application_add.lua create mode 100644 luasrc/model/cbi/commotion/application_list.lua create mode 100644 luasrc/model/cbi/commotion/application_set.lua create mode 100644 luasrc/model/cbi/commotion/basic_ani.lua rename luasrc/model/cbi/commotion/{basic_nets.lua => basic_mn.lua} (100%) create mode 100644 luasrc/model/cbi/commotion/basic_wn.lua create mode 100644 luasrc/model/cbi/commotion/client_bc.lua create mode 100644 luasrc/model/cbi/commotion/client_wp.lua create mode 100644 luasrc/model/cbi/commotion/confirm_config.lua create mode 100644 luasrc/model/cbi/commotion/security_pass.lua create mode 100644 luasrc/model/cbi/commotion/security_smk.lua create mode 100644 luasrc/view/commotion/status.htm diff --git a/luasrc/quickstart.lua b/luasrc/commotion/quickstart.lua similarity index 100% rename from luasrc/quickstart.lua rename to luasrc/commotion/quickstart.lua diff --git a/luasrc/controller/commotion/application_config.lua b/luasrc/controller/commotion/application_config.lua new file mode 100644 index 0000000..f1fa7d3 --- /dev/null +++ b/luasrc/controller/commotion/application_config.lua @@ -0,0 +1,25 @@ +--[[ +LuCI - Lua Development Framework + +Copyright 2013 - Seamus Tuohy + +With Thanks to the niu suite built by Steven Barth + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +]]-- +module "luci.controller.commotion.application_config" + +function index() + entry({"admin", "commotion", "basic"}, alias({"admin", "commotion", "application", "list"}), translate("Applications"), 30).index = true + + entry({"admin", "commotion", "application", "list"}, cbi("commotion/application_list"), translate("List"), 40) + + entry({"admin", "commotion", "application", "add"}, cbi("commotion/application_add"), translate("Add"), 50) + + entry({"admin", "commotion", "application", "settings"}, cbi("commotion/application_set"), translate("Settings"), 60) +end diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index 81f8554..f500ef6 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -24,10 +24,16 @@ function index() else --Create regular "Basic Config" menu. entry({"admin", "commotion", "basic"}, alias({"admin", "commotion", "basic", "node_settings"}), translate("Basic Configuration"), 10).index = true + entry({"admin", "commotion", "basic", "node_settings"}, cbi("commotion/basic_ns"), translate("Node Settings"), 20) + entry({"admin", "commotion", "basic", "network_settings"}, alias({"admin", "commotion", "basic", "mesh_network"}), translate("Network Settings"), 30) + entry({"admin", "commotion", "basic", "mesh_network"}, cbi("commotion/basic_mn"), translate("Mesh Network"), 40) + entry({"admin", "commotion", "basic", "wireless_network"}, cbi("commotion/basic_wn"), translate("Wireless Network"), 50) + entry({"admin", "commotion", "basic", "addtl_net_ifaces"}, cbi("commotion/basic_ani"), translate("Additional Netork Interfaces"), 60) + end end diff --git a/luasrc/controller/commotion/client_config.lua b/luasrc/controller/commotion/client_config.lua new file mode 100644 index 0000000..b612d1d --- /dev/null +++ b/luasrc/controller/commotion/client_config.lua @@ -0,0 +1,23 @@ +--[[ +LuCI - Lua Development Framework + +Copyright 2013 - Seamus Tuohy + +With Thanks to the niu suite built by Steven Barth + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +]]-- +module "luci.controller.commotion.client_config" + +function index() + entry({"admin", "commotion", "client"}, alias({"admin", "commotion", "client", "welcome_page"}), translate("Client Controls"), 20).index = true + + entry({"admin", "commotion", "client", "welcome_page"}, cbi("commotion/client_wp"), translate("Welcome Page"), 30) + + entry({"admin", "commotion", "client", "bandwidth_controls"}, cbi("commotion/client_bc"), translate("Bandwidth Controls"), 40) +end diff --git a/luasrc/controller/commotion/security_config.lua b/luasrc/controller/commotion/security_config.lua new file mode 100644 index 0000000..ef17939 --- /dev/null +++ b/luasrc/controller/commotion/security_config.lua @@ -0,0 +1,23 @@ +--[[ +LuCI - Lua Development Framework + +Copyright 2013 - Seamus Tuohy + +With Thanks to the niu suite built by Steven Barth + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +]]-- +module "luci.controller.commotion.security_config" + +function index() + entry({"admin", "commotion", "security"}, alias({"admin", "commotion", "security", "passwords"}), translate("Security"), 40).index = true + + entry({"admin", "commotion", "security", "passwords"}, cbi("commotion/security_pass"), translate("Passwords"), 50) + + entry({"admin", "commotion", "security", "shared_mesh_keychain"}, cbi("commotion/security_smk"), translate("Shared Mesh Keychain"), 60) +end diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua new file mode 100644 index 0000000..7cb3633 --- /dev/null +++ b/luasrc/controller/commotion/status_config.lua @@ -0,0 +1,19 @@ +--[[ +LuCI - Lua Development Framework + +Copyright 2013 - Seamus Tuohy + +With Thanks to the niu suite built by Steven Barth + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +]]-- +module "luci.controller.commotion.status_config" + +function index() + entry({"admin", "commotion", "status"}, template("commotion/status"), translate("Staus"), 1) +end diff --git a/luasrc/model/cbi/commotion/application_add.lua b/luasrc/model/cbi/commotion/application_add.lua new file mode 100644 index 0000000..e69de29 diff --git a/luasrc/model/cbi/commotion/application_list.lua b/luasrc/model/cbi/commotion/application_list.lua new file mode 100644 index 0000000..e69de29 diff --git a/luasrc/model/cbi/commotion/application_set.lua b/luasrc/model/cbi/commotion/application_set.lua new file mode 100644 index 0000000..e69de29 diff --git a/luasrc/model/cbi/commotion/basic_ani.lua b/luasrc/model/cbi/commotion/basic_ani.lua new file mode 100644 index 0000000..e69de29 diff --git a/luasrc/model/cbi/commotion/basic_nets.lua b/luasrc/model/cbi/commotion/basic_mn.lua similarity index 100% rename from luasrc/model/cbi/commotion/basic_nets.lua rename to luasrc/model/cbi/commotion/basic_mn.lua diff --git a/luasrc/model/cbi/commotion/basic_wn.lua b/luasrc/model/cbi/commotion/basic_wn.lua new file mode 100644 index 0000000..e69de29 diff --git a/luasrc/model/cbi/commotion/client_bc.lua b/luasrc/model/cbi/commotion/client_bc.lua new file mode 100644 index 0000000..e69de29 diff --git a/luasrc/model/cbi/commotion/client_wp.lua b/luasrc/model/cbi/commotion/client_wp.lua new file mode 100644 index 0000000..e69de29 diff --git a/luasrc/model/cbi/commotion/confirm_config.lua b/luasrc/model/cbi/commotion/confirm_config.lua new file mode 100644 index 0000000..2fdc1ad --- /dev/null +++ b/luasrc/model/cbi/commotion/confirm_config.lua @@ -0,0 +1,5 @@ +local cursor = require "luci.model.uci".cursor() +--Main title and system config map for hostname value +local m = Map("system", translate("Basic Configuration"), translate("In this section you'll set the basic required settings for this device, and the basic network settings required to connect this device to a Commotion Mesh network. You will be prompted to save your settings along the way and apply them at the end.")) + +return m diff --git a/luasrc/model/cbi/commotion/security_pass.lua b/luasrc/model/cbi/commotion/security_pass.lua new file mode 100644 index 0000000..e69de29 diff --git a/luasrc/model/cbi/commotion/security_smk.lua b/luasrc/model/cbi/commotion/security_smk.lua new file mode 100644 index 0000000..e69de29 diff --git a/luasrc/view/commotion/status.htm b/luasrc/view/commotion/status.htm new file mode 100644 index 0000000..e69de29 From 6e7840a83a9c972a4e6fb68299c3a7da8c0a9fb6 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Tue, 26 Nov 2013 14:53:36 -0500 Subject: [PATCH 005/196] added status page template and controller hooks for all tabs. --- luasrc/controller/commotion/status_config.lua | 6 +++ luasrc/view/commotion/status.htm | 43 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index 7cb3633..36e03b1 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -16,4 +16,10 @@ module "luci.controller.commotion.status_config" function index() entry({"admin", "commotion", "status"}, template("commotion/status"), translate("Staus"), 1) + + entry({"admin", "commotion", "status", "nearby_md"}, template("commotion/nearby_md"), translate("Nearby Mesh Devices")) + entry({"admin", "commotion", "status", "mesh_viz"}, template("commotion/mesh_viz"), translate("Mesh Visualizer")) + entry({"admin", "commotion", "status", "conn_clnts"}, template("commotion/conn_clnts"), translate("Connected Clients")) + entry({"admin", "commotion", "status", "dbg_rpt"}, template("commotion/dbg_rpt"), translate("Debug Report")) + end diff --git a/luasrc/view/commotion/status.htm b/luasrc/view/commotion/status.htm index e69de29..b6951e5 100644 --- a/luasrc/view/commotion/status.htm +++ b/luasrc/view/commotion/status.htm @@ -0,0 +1,43 @@ +<%#- +--! @param gateway_provided String "Yes" if node is providing gateway to (mesh/ap?) "No" if not providing a gateway. +--! @param ifaces Table. Looks like this -> {["interface 1 name"] = {["status"]="On/Off", ["sec"]="Secured/Insecure", ["conn"]="## Connections/nil"}, ["interface 2 name"] = {["status"]="On/Off", ["sec"]="Secured/Insecure", ["conn"]="## Connections/nil"}, etc } +-%> + +<%+header%> + + + + +
+
+

<%:Providing Gateway%><%=gateway_provided%>

+
+
+<%- for iface,prop in pairs(ifaces) -%> +

<%=iface%><%=prop.status%> <%=prop.sec%> <%=prop.conn%>

+
+
+<%end%> + + From 64251e68ea505156fefe8b82e96b7c5531492a64 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 9 Dec 2013 15:20:22 -0500 Subject: [PATCH 035/196] Added required uci hooks for nodogsplash basic ucitrack integration --- files/etc/init.d/ucidog | 42 ++++++++++++++++++++++++ files/etc/uci-defaults/ucitrack-updates | 9 +++++ luasrc/model/cbi/commotion/client_wp.lua | 15 +++++++-- 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 files/etc/init.d/ucidog create mode 100644 files/etc/uci-defaults/ucitrack-updates diff --git a/files/etc/init.d/ucidog b/files/etc/init.d/ucidog new file mode 100644 index 0000000..1bf1ec6 --- /dev/null +++ b/files/etc/init.d/ucidog @@ -0,0 +1,42 @@ +#!/bin/sh /etc/rc.common + +#simple barely functional nodogsplash uci-track script to set nodogsplash uci values that were set. + +. /lib/functions/commotion.sh +. /lib/config/uci.sh + +START=19 +STOP=91 + +reload() { + #nodogsplash configuration file. + local conffile=/etc/nodogsplash/nodogsplash.conf + #disable/enable nodogsplash + local enable=$(uci_get nodogsplash settings enable) + if [ "$enable" == 1 ]; then #this might come back as a string and not as a intiger. Check and fix that. + /etc/init.d/nodogsplash disable || return 0 + else + /etc/init.d/nodogsplash enable || return 0 + fi + + #convert splash page time into minues + local splash_time=$(uci_get nodogsplash settings splashtime) + local splash_unit=$(uci_get nodogsplash settings splashunit) + if [ "$splash_unit" == "days" ]; then + splash_time=$(($splash_time*60)) + elif [ "$splash_unit" == "hours" ]; then + splash_time=$(($splash_time*24*60)) + elif [ "$splash_unit" == "seconds" ]; then + splash_time=$(($splash_time/60)) + fi + #set splashpage time + sed -i "s/^\(ClientIdleTimeout \).*/\1 $splash_time/" $conffile || return 0 + sed -i "s/^\(ClientForceTimeout \).*/\1 $splash_time/" $conffile || return 0 + #get and set interface name + local interface=$(uci_get nodogsplash interfaces interface) + local network=$(uci_get wireless $interface network) + '{print$2}'| sed 's/"\(\w*\)",/\1/') + sed -i "s/^\(GatewayInterface \).*/\1 $iface_name/" $conffile || return 0 + /etc/init.d/nodogsplash stop && sleep 1 + /etc/init.d/nodogsplash start +} diff --git a/files/etc/uci-defaults/ucitrack-updates b/files/etc/uci-defaults/ucitrack-updates new file mode 100644 index 0000000..246fe81 --- /dev/null +++ b/files/etc/uci-defaults/ucitrack-updates @@ -0,0 +1,9 @@ +#!/bin/sh + +. /etc/functions.sh + +config_load ucitrack +uci_add ucitrack nodogsplash nodogsplash +uci_set ucitrack nodogsplash init ucidog +uci_commit ucitrack +/etc/init.d/ucidog enable diff --git a/luasrc/model/cbi/commotion/client_wp.lua b/luasrc/model/cbi/commotion/client_wp.lua index 7732888..7858878 100644 --- a/luasrc/model/cbi/commotion/client_wp.lua +++ b/luasrc/model/cbi/commotion/client_wp.lua @@ -19,9 +19,14 @@ local utils = require "luci.util" local db = require "luci.commotion.debugger" local uci = require "luci.model.uci".cursor() local fs = require "nixio.fs" +local cdisp = require "luci.commotion.dispatch" m = Map("nodogsplash", translate("Welcome Page")) +--redirect on saved and changed to check changes. +m.on_after_save = cdisp.conf_page + + enable = m:section(TypedSection, "settings", translate("On/Off"), translate("Users can be redirected to a “welcome page” when they first connect to this node.")) enable.anonymous = true toggle = enable:option(Flag, "enable") @@ -89,24 +94,28 @@ end uploader = splshtxt:option(FileUpload, "_upload", "UPLOADER TEXT HERE") function m.on_parse(self) - if luci.http.formvalue("cbid.nodogsplash._page._page") ~= "Edit" then + local b_press = luci.http.formvalue("cbid.nodogsplash._page._page") + if b_press ~= "Edit" then function t.render() return nil end function help.render() return nil end end - if luci.http.formvalue("cbid.nodogsplash._page._page") ~= "Upload" then + if b_press ~= "Upload" then function uploader.render() return nil end end uploaded = "/lib/uci/upload/cbid.nodogsplash._page._upload" if luci.fs.isfile(uploaded) then local nfs = require "nixio.fs" nfs.move(uploaded, splashtextfile) + m.message = "file uploaded!" end text = luci.http.formvalue("cbid.nodogsplash._page.text") - if text then + if text and not b_press then if text ~= "" then fs.writefile(splashtextfile, text:gsub("\r\n", "\n")) + m.message = "Splashpage updated successfully!" else fs.unlink(splashtextfile) + m.message ="Default Splash page selected!" end end return true From d5896fef76fe241d0623674cb266e9f878a15774 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 9 Dec 2013 15:21:44 -0500 Subject: [PATCH 036/196] removed init script that used suffix in favor of non-suffixed version... it was a silly idea to use a suffix really --- files/etc/init.d/ucidog.sh | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 files/etc/init.d/ucidog.sh diff --git a/files/etc/init.d/ucidog.sh b/files/etc/init.d/ucidog.sh deleted file mode 100644 index 2f71e05..0000000 --- a/files/etc/init.d/ucidog.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -#simple barely functional nodogsplash uci-track script to set nodogsplash uci values that were set. - -. /lib/functions/commotion.sh -. /lib/config/uci.sh - -start() { - #nodogsplash configuration file. - local conffile=/etc/nodogsplash/nodogsplash.conf - #disable/enable nodogsplash - local enable=$(uci_get nodogsplash settings enable) - if [ "$enable" == 1 ]; then #this might come back as a string and not as a intiger. Check and fix that. - /etc/init.d/nodogsplash disable - else - /etc/init.d/nodogsplash enable - fi - - #convert splash page time into minues - local splash_time=$(uci_get nodogsplash settings splashtime) - local splash_unit=$(uci_get nodogsplash settings splashunit) - if [ "$splash_unit" == "days" ]; then - splash_time=$(($splash_time*60)) - elif [ "$splash_unit" == "hours" ]; then - splash_time=$(($splash_time*24*60)) - elif [ "$splash_unit" == "seconds" ]; then - splash_time=$(($splash_time/60)) - fi - #set splashpage time - sed -i 's/^\(ClientIdleTimeout \).*/\1 $splash_time/' $conffile - sed -i 's/^\(ClientForceTimeout \).*/\1 $splash_time/' $conffile - #get and set interface name - local interface=$(uci_get nodogsplash interfaces interface) - local network=$(uci_get wireless $interface network) - local iface_name=$(ubus call network.interface.$network status |grep \"device\" |awk '{print$2}'| sed 's/"\(\w*\)",/\1/') - sed -i 's/^\(GatewayInterface \).*/\1 $iface_name/' $conffile -} From 46d84aa3f9ea7f18d5330d95e8f43f5915364e62 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 9 Dec 2013 15:23:00 -0500 Subject: [PATCH 037/196] moved the initial creation of uci objects into a uci-defaults script where it rightfully should go. Why run the logic everytime when we can do it only once. --- files/etc/uci-defaults/luci-quickstart-setup | 11 +++++++++++ luasrc/model/cbi/commotion/basic_ns.lua | 9 --------- 2 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 files/etc/uci-defaults/luci-quickstart-setup diff --git a/files/etc/uci-defaults/luci-quickstart-setup b/files/etc/uci-defaults/luci-quickstart-setup new file mode 100644 index 0000000..99b3552 --- /dev/null +++ b/files/etc/uci-defaults/luci-quickstart-setup @@ -0,0 +1,11 @@ +#!/bin/sh + +. /etc/functions.sh +#set up all interfaces needed for the quickstart process +config_load wireless +uci_add wireless wifi-iface quickstartAP +uci_set wireless quickstartAP mode ap +uci_set wireless quickstartAP network client +uci_add wireless wifi-iface quickstartMesh +uci_set wireless quickstartAP mode adhoc +uci_commit wireless diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index fd07e69..8501f10 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -6,15 +6,6 @@ local uci = require "luci.model.uci".cursor() --Main title and system config map for hostname value local m = Map("system", translate("Basic Configuration"), translate("In this section you'll set the basic required settings for this device, and the basic network settings required to connect this device to a Commotion Mesh network. You will be prompted to save your settings along the way and apply them at the end.")) --- Add Wireless Interfaces for rest of quickstart process -function m.on_parse() - if QS.status() then - uci:section("wireless", "wifi-iface", "quickstartAP", {mode="ap", network="client"}) - uci:section("wireless", "wifi-iface", "quickstartMesh", {mode="adhoc"}) - uci:save("wireless") - uci:commit("wireless") - end -end --HOSTNAME From 2bc91bfe7b782396b031e45088cafb86124eb6c1 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 9 Dec 2013 15:24:46 -0500 Subject: [PATCH 038/196] removed save-as and reset buttons from all non-quickstart page to make room for new lua-helpers confirmation page function. Also added proper subheader flags to menu items that are major topics according to UX document. --- .../commotion/application_config.lua | 11 ++-- luasrc/controller/commotion/basic_config.lua | 56 ++++++++++++++----- luasrc/controller/commotion/client_config.lua | 5 +- .../controller/commotion/security_config.lua | 6 +- 4 files changed, 50 insertions(+), 28 deletions(-) diff --git a/luasrc/controller/commotion/application_config.lua b/luasrc/controller/commotion/application_config.lua index 867515e..51847cb 100644 --- a/luasrc/controller/commotion/application_config.lua +++ b/luasrc/controller/commotion/application_config.lua @@ -15,11 +15,8 @@ You may obtain a copy of the License at module "luci.controller.commotion.application_config" function index() - entry({"admin", "commotion", "basic"}, alias("admin", "commotion", "application", "list"), translate("Applications"), 30).index = true - - entry({"admin", "commotion", "application", "list"}, cbi("commotion/application_list"), translate("List"), 40) - - entry({"admin", "commotion", "application", "add"}, cbi("commotion/application_add"), translate("Add"), 50) - - entry({"admin", "commotion", "application", "settings"}, cbi("commotion/application_set"), translate("Settings"), 60) +-- entry({"admin", "commotion", "basic"}, alias("admin", "commotion", "application", "list"), translate("Applications"), 30).index = true + -- entry({"admin", "commotion", "application", "list"}, cbi("commotion/application_list", {hideapplybtn=true, hideresetbtn=true}), translate("List"), 40).subsection=true +-- entry({"admin", "commotion", "application", "add"}, cbi("commotion/application_add", {hideapplybtn=true, hideresetbtn=true}), translate("Add"), 50).subsection=true +-- entry({"admin", "commotion", "application", "settings"}, cbi("commotion/application_set", {hideapplybtn=true, hideresetbtn=true}), translate("Settings"), 60).subsection=true end diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index 92676ea..5e6c624 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -1,9 +1,23 @@ --[[ -LuCI - Lua Development Framework Modifications +Copyright (C) 2013 Seamus Tuohy -Copyright 2013 - Seamus Tuohy +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + + You should have received a copy of the GNU General Public License +along with this program. If not, see . -With Thanks to the niu suite built by Steven Barth +HUGE Thanks to the niu suite!!! +]]-- +--[[ + Copyright (C) 2008 Steven Barth Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,26 +30,38 @@ module ("luci.controller.commotion.basic_config", package.seeall) local db = require "luci.commotion.debugger" function index() + entry({"admin", "commotion"}, alias("admin", "commotion", "basic"), translate("Commotion"), 20) local QS = require "luci.commotion.quickstart" local redir = luci.http.formvalue("redir", true) or - luci.dispatcher.build_url(unpack(luci.dispatcher.context.request)) - - entry({"admin", "commotion", "confirm"}, call("action_changes"), translate("Confirm"), 40).query = {redir=redir} - entry({"admin", "commotion", "revert"}, call("action_revert")).query = {redir=redir} - entry({"admin", "commotion", "saveapply"}, call("action_apply")).query = {redir=redir} + luci.dispatcher.build_url(unpack(luci.dispatcher.context.request)) + + cnfm = entry({"admin", "commotion", "confirm"}, call("action_changes"), translate("Confirm"), 40) + cnfm.query = {redir=redir} + cnfm.hidden = true + + rvt = entry({"admin", "commotion", "revert"}, call("action_revert")) + rvt.query = {redir=redir} + rvt.hidden = true + + sva = entry({"admin", "commotion", "saveapply"}, call("action_apply")) + sva.query = {redir=redir} + sva.hidden = true if QS.status() then local confirm = {on_success_to={"admin", "commotion", "confirm"}} - entry({"admin", "commotion", "confirm_config"}, cbi("commotion/confirm_config"), translate("Confirm your Changes")) - entry({"admin", "commotion", "quickstart"}, cbi("commotion/quickstart", confirm), translate("Basic Configuration"), 15) + entry({"admin", "commotion", "quickstart"}, cbi("commotion/quickstart", confirm), translate("Basic Configuration"), 15).hidden=true else --Create regular "Basic Config" menu. entry({"admin", "commotion", "basic"}, alias("admin", "commotion", "basic", "node_settings"), translate("Basic Configuration"), 10).index = true - entry({"admin", "commotion", "basic", "node_settings"}, cbi("commotion/basic_ns"), translate("Node Settings"), 20) - entry({"admin", "commotion", "basic", "network_settings"}, alias("admin", "commotion", "basic", "mesh_network"), translate("Network Settings"), 30) - entry({"admin", "commotion", "basic", "mesh_network"}, cbi("commotion/basic_mn"), translate("Mesh Network"), 40) - entry({"admin", "commotion", "basic", "wireless_network"}, cbi("commotion/basic_wn"), translate("Wireless Network"), 50) - entry({"admin", "commotion", "basic", "addtl_net_ifaces"}, cbi("commotion/basic_ani"), translate("Additional Netork Interfaces"), 60) + + --No Subsection for Node Settings? + entry({"admin", "commotion", "basic", "node_settings"}, cbi("commotion/basic_ns", {hideapplybtn=true, hideresetbtn=true}), translate("Node Settings"), 20).subsection=true + + --Subsection Network Settings + entry({"admin", "commotion", "basic", "network_settings"}, alias("admin", "commotion", "basic", "mesh_network"), translate("Network Settings"), 30).subsection=true + entry({"admin", "commotion", "basic", "mesh_network"}, cbi("commotion/basic_mn", {hideapplybtn=true, hideresetbtn=true}), translate("Mesh Network"), 40) + entry({"admin", "commotion", "basic", "wireless_network"}, cbi("commotion/basic_wn", {hideapplybtn=true, hideresetbtn=true}), translate("Wireless Network"), 50) + entry({"admin", "commotion", "basic", "addtl_net_ifaces"}, cbi("commotion/basic_ani", {hideapplybtn=true, hideresetbtn=true}), translate("Additional Netork Interfaces"), 60) end end diff --git a/luasrc/controller/commotion/client_config.lua b/luasrc/controller/commotion/client_config.lua index 35b542d..eb1b1fa 100644 --- a/luasrc/controller/commotion/client_config.lua +++ b/luasrc/controller/commotion/client_config.lua @@ -15,9 +15,8 @@ You may obtain a copy of the License at module "luci.controller.commotion.client_config" function index() - entry({"admin", "commotion"}, alias("admin", "commotion", "client"), translate("Client Controls"), 20) entry({"admin", "commotion", "client"}, alias("admin", "commotion", "client", "welcome_page"), translate("Client Controls"), 20) - entry({"admin", "commotion", "client", "welcome_page"}, cbi("commotion/client_wp"), translate("Welcome Page"), 30).index = true - entry({"admin", "commotion", "client", "bandwidth_controls"}, cbi("commotion/client_bc"), translate("Bandwidth Controls"), 40) + entry({"admin", "commotion", "client", "welcome_page"}, cbi("commotion/client_wp", {hideapplybtn=true, hideresetbtn=true}), translate("Welcome Page"), 30).index = true + entry({"admin", "commotion", "client", "bandwidth_controls"}, cbi("commotion/client_bc", {hideapplybtn=true, hideresetbtn=true}), translate("Bandwidth Controls"), 40) end diff --git a/luasrc/controller/commotion/security_config.lua b/luasrc/controller/commotion/security_config.lua index 2321ddf..b98e2a3 100644 --- a/luasrc/controller/commotion/security_config.lua +++ b/luasrc/controller/commotion/security_config.lua @@ -14,10 +14,10 @@ You may obtain a copy of the License at ]]-- module "luci.controller.commotion.security_config" -function index() +function index() entry({"admin", "commotion", "security"}, alias("admin", "commotion", "security", "passwords"), translate("Security"), 40).index = true - entry({"admin", "commotion", "security", "passwords"}, cbi("commotion/security_pass"), translate("Passwords"), 50) + entry({"admin", "commotion", "security", "passwords"}, cbi("commotion/security_pass", {hideapplybtn=true, hideresetbtn=true}), translate("Passwords"), 50).subsection=true - entry({"admin", "commotion", "security", "shared_mesh_keychain"}, cbi("commotion/security_smk"), translate("Shared Mesh Keychain"), 60) + entry({"admin", "commotion", "security", "shared_mesh_keychain"}, cbi("commotion/security_smk", {hideapplybtn=true, hideresetbtn=true}), translate("Shared Mesh Keychain"), 60).subsection=true end From ec9b8347a3e6f32866d5bfb689438c85ded97746 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 9 Dec 2013 15:37:11 -0500 Subject: [PATCH 039/196] updated quickstart delegator days ago and have no idea what I have changed. But, this delegator works for all four quickstart pages and concludes with the confirmation page as required --- luasrc/model/cbi/commotion/quickstart.lua | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/luasrc/model/cbi/commotion/quickstart.lua b/luasrc/model/cbi/commotion/quickstart.lua index e4b04df..37ebb3a 100644 --- a/luasrc/model/cbi/commotion/quickstart.lua +++ b/luasrc/model/cbi/commotion/quickstart.lua @@ -7,15 +7,11 @@ d.allow_cancel = false d.allow_reset = true d:add("Node Settings", "commotion/basic_ns") -d:add("Network Settings", "commotion/basic_nets") ---TODO add back in after testing ---d:add("Mesh Network", "commotion/basic_mn") ---d:add("Wireless Network", "commotion/basic_wn") +d:add("Mesh Network", "commotion/basic_mn") +d:add("Wireless Network", "commotion/basic_wn") +d:add("Additional Network Interfaces", "commotion/basic_ani") function d.on_done() - --Here he wave the cursor commit all the places required earler from the confirmation page. - cursor:commit("network") --- cursor:commit("wireless") end return d From ddd506e48c56c8edf29b8bb588f72702723b7e53 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 9 Dec 2013 15:43:32 -0500 Subject: [PATCH 040/196] updated maps to use confirmation page when save is used --- luasrc/model/cbi/commotion/basic_ani.lua | 6 +++++ luasrc/model/cbi/commotion/basic_mn.lua | 13 +++------- luasrc/model/cbi/commotion/basic_ns.lua | 25 +++++++++++++++++--- luasrc/model/cbi/commotion/basic_wn.lua | 6 +++++ luasrc/model/cbi/commotion/client_bc.lua | 4 ++++ luasrc/model/cbi/commotion/security_pass.lua | 13 +++++++--- 6 files changed, 51 insertions(+), 16 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_ani.lua b/luasrc/model/cbi/commotion/basic_ani.lua index efaed54..cd98657 100644 --- a/luasrc/model/cbi/commotion/basic_ani.lua +++ b/luasrc/model/cbi/commotion/basic_ani.lua @@ -20,9 +20,15 @@ local cnw = require "luci.commotion.network" local db = require "luci.commotion.debugger" local http = require "luci.http" local QS = require "luci.commotion.quickstart" +local cdisp = require "luci.commotion.dispatch" m = Map("network", translate("Internet Gateway"), translate("If desired, you can configure your gateway interface here.")) +--redirect on saved and changed to check changes. +if not QS.status() then + m.on_after_save = cdisp.conf_page +end + p = m:section(NamedSection, "plug") p.anonymous = true diff --git a/luasrc/model/cbi/commotion/basic_mn.lua b/luasrc/model/cbi/commotion/basic_mn.lua index fb117fb..d988a5a 100644 --- a/luasrc/model/cbi/commotion/basic_mn.lua +++ b/luasrc/model/cbi/commotion/basic_mn.lua @@ -21,21 +21,14 @@ local cnw = require "luci.commotion.network" local db = require "luci.commotion.debugger" local http = require "luci.http" local QS = require "luci.commotion.quickstart" ---local db = require "luci.commotion.debugger" +local cdisp = require "luci.commotion.dispatch" local m = Map("wireless", translate("Network Interfaces"), translate("Every Commotion node must have one mesh network connection or interface. Commotion can mesh over wireless or wired interfaces.")) -m.flow.hideapplybtn = true -m.flow.hideresetbtn = true ---when this map is committed make sure that the commotionMesh default interface is also created so that there is always a default profile applied. If still in quickstart, make sure that there is a default template for the wifi-iface section +--redirect on saved and changed to check changes. if not QS.status() then - function m.on_after_save(self) - for i,x in pairs(self) do db.log(tostring(i).." "..tostring(x)) end - if self.save and self.changed then - http.redirect(luci.dispatcher.build_url("admin", "commotion", "confirm")) - end - end + m.on_after_save = cdisp.conf_page end function m.on_before_commit() diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index 8501f10..0ab83ea 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -1,13 +1,32 @@ +--[[ +Copyright (C) 2013 Seamus Tuohy + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + + You should have received a copy of the GNU General Public License +along with this program. If not, see . +]]-- + local QS = require "luci.commotion.quickstart" local db = require "luci.commotion.debugger" local uci = require "luci.model.uci".cursor() +local cdisp = require "luci.commotion.dispatch" --Main title and system config map for hostname value local m = Map("system", translate("Basic Configuration"), translate("In this section you'll set the basic required settings for this device, and the basic network settings required to connect this device to a Commotion Mesh network. You will be prompted to save your settings along the way and apply them at the end.")) - - ---HOSTNAME +--redirect on saved and changed to check changes. +if not QS.status() then + m.on_after_save = cdisp.conf_page +end --load up system section local shn = m:section(TypedSection, "system") diff --git a/luasrc/model/cbi/commotion/basic_wn.lua b/luasrc/model/cbi/commotion/basic_wn.lua index ceb6024..80803ee 100644 --- a/luasrc/model/cbi/commotion/basic_wn.lua +++ b/luasrc/model/cbi/commotion/basic_wn.lua @@ -21,9 +21,15 @@ local cnw = require "luci.commotion.network" local db = require "luci.commotion.debugger" local http = require "luci.http" local QS = require "luci.commotion.quickstart" +local cdisp = require "luci.commotion.dispatch" local m = Map("wireless", translate("Wireless Network"), translate("Turning on an Access Point provides a wireless network for people to connect to using a laptop or other wireless devices.")) +--redirect on saved and changed to check changes. +if not QS.status() then + m.on_after_save = cdisp.conf_page +end + s = m:section(TypedSection, "wifi-iface", translate("Access Point"), translate("Turning on an Access Point provides a wireless network for people to connect to using a laptop or other wireless devices.")) s.optional = false s.anonymous = true diff --git a/luasrc/model/cbi/commotion/client_bc.lua b/luasrc/model/cbi/commotion/client_bc.lua index 035c22d..81f2e9b 100644 --- a/luasrc/model/cbi/commotion/client_bc.lua +++ b/luasrc/model/cbi/commotion/client_bc.lua @@ -29,10 +29,14 @@ $Id: p2pblock.lua 5448 2009-10-31 15:54:11Z jow $ ]]-- local sys = require "luci.sys" +local cdisp = require "luci.commotion.dispatch" m = Map("freifunk_p2pblock", translate("Bandwidth Controls"), translate("You can disable potentially high-bandwith applications here. ")) +--redirect on saved and changed to check changes. +m.on_after_save = cdisp.conf_page + s = m:section(NamedSection, "p2pblock", "settings", "Settings") s.anonymous = true s.addremove = false diff --git a/luasrc/model/cbi/commotion/security_pass.lua b/luasrc/model/cbi/commotion/security_pass.lua index 240d515..4d5d443 100644 --- a/luasrc/model/cbi/commotion/security_pass.lua +++ b/luasrc/model/cbi/commotion/security_pass.lua @@ -1,6 +1,13 @@ local db = require "luci.commotion.debugger" +local http = require "luci.http" +local cdisp = require "luci.commotion.dispatch" + local m = Map("wireless", translate("Passwords"), translate("Commotion basic security settings places all the passwords and other security features in one place for quick configuration. ")) +--redirect on saved and changed to check changes. +m.on_after_save = cdisp.conf_page + + --PASSWORDS local v0 = true -- track password success across maps @@ -94,10 +101,10 @@ for i,iface in ipairs(interfaces) do end end -function m.on_before_commit(map) +function m.on_before_save(map) -- if existing password, make sure user has old password if s0 then - v0 = luci.sys.user.checkpasswd("root", formvalue("_pass0")) + v0 = luci.sys.user.checkpasswd("root", http.formvalue("_pass0")) end if v0 == false then @@ -107,7 +114,7 @@ function m.on_before_commit(map) end end -function m.on_commit(map) +function m.on_save(map) local v1 = pw1:formvalue("_pass") local v2 = pw2:formvalue("_pass") if v0 == true and v1 and v2 and #v1 > 0 and #v2 > 0 then From c26c5a3415d6c4cfd505c86971eed1c8cfd45ee7 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 9 Dec 2013 19:17:13 -0500 Subject: [PATCH 041/196] modified enc flag variable write and remove functions to set the section 'changed' value to true so that the config confirmation hooks go off and capture a user. Also, identified that all config values that commotiond uses need to include the proper commotion functions for changing them. Possibly a check that allows me to simple have each map query commotiond on parse and see if it is changing a commotiond value, and change it in the commotion profile as well. --- luasrc/model/cbi/commotion/basic_mn.lua | 19 +++- luasrc/model/cbi/commotion/basic_wn.lua | 20 +++- luasrc/model/cbi/commotion/security_pass.lua | 113 +++++++++++++++---- 3 files changed, 126 insertions(+), 26 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_mn.lua b/luasrc/model/cbi/commotion/basic_mn.lua index d988a5a..9a2fbc5 100644 --- a/luasrc/model/cbi/commotion/basic_mn.lua +++ b/luasrc/model/cbi/commotion/basic_mn.lua @@ -117,11 +117,24 @@ enc.default = "none" --default must == disabled value for rmempty to work --Have enc flag also remove the encryption key when deleted function enc.remove(self, section) - local key = self.map:del(section, "key") - local enc = self.map:del(section, self.option) - return key and enc or false + value = self.map:get(section, self.option) + if value ~= self.disabled then + local key = self.map:del(section, "key") + local enc = self.map:del(section, self.option) + self.section.changed = true + return key and enc or false + end end +function enc.write(self, section, fvalue) + value = self.map:get(section, self.option) + if value ~= fvalue then + self.section.changed = true + return self.map:set(section, self.option, fvalue) + end +end + + --dummy value set to not reveal password pw1 = s:option(Value, "_pw1", translate("Mesh Encryption Password"), translate("To encrypt data between devices, each device must share a common mesh encryption password.")) pw1.password = true diff --git a/luasrc/model/cbi/commotion/basic_wn.lua b/luasrc/model/cbi/commotion/basic_wn.lua index 80803ee..d1087aa 100644 --- a/luasrc/model/cbi/commotion/basic_wn.lua +++ b/luasrc/model/cbi/commotion/basic_wn.lua @@ -106,11 +106,23 @@ enc.enabled = "psk2" enc.rmempty = true enc.default = "none" --default must == disabled value for rmempty to work ---Have enc flag also remove the encryption key when deleted +--Have enc flag also remove the encryption key when deleted and mark as changed. function enc.remove(self, section) - local key = self.map:del(section, "key") - local enc = self.map:del(section, self.option) - return key and enc or false + value = self.map:get(section, self.option) + if value ~= self.disabled then + local key = self.map:del(section, "key") + local enc = self.map:del(section, self.option) + self.section.changed = true + return key and enc or false + end +end +--have a flag to mark enc as changed when changed. +function enc.write(self, section, fvalue) + value = self.map:get(section, self.option) + if value ~= fvalue then + self.section.changed = true + return self.map:set(section, self.option, fvalue) + end end --dummy value set to not reveal password diff --git a/luasrc/model/cbi/commotion/security_pass.lua b/luasrc/model/cbi/commotion/security_pass.lua index 4d5d443..fac1a76 100644 --- a/luasrc/model/cbi/commotion/security_pass.lua +++ b/luasrc/model/cbi/commotion/security_pass.lua @@ -7,7 +7,6 @@ local m = Map("wireless", translate("Passwords"), translate("Commotion basic sec --redirect on saved and changed to check changes. m.on_after_save = cdisp.conf_page - --PASSWORDS local v0 = true -- track password success across maps @@ -18,7 +17,7 @@ if luci.sys.user.getpasswd("root") then s0 = m:section(TypedSection, "_dummy", translate("Current Password"), translate("Current password required to make changes on this page")) s0.addremove = false s0.anonymous = true - pw0 = s0:option(Value, "pw0") + pw0 = s0:option(Value, "_pw0") pw0.password = true -- fail by default v0 = false @@ -42,16 +41,74 @@ uci.foreach("wireless", "wifi-iface", --! @name pw_sec_opt --! @brief create password options to add to interface passed- function pw_sec_opt(pw_s, iface) + --section options pw_s.addremove = false pw_s.anonymous = true - pw1 = pw_s:option(Value, (iface.name.."_key")) + + --encryption toggle + enc = pw_s:option(Flag, "encryption", translate("Require a Password?"), translate("When people connect to this access point, should a password be required?")) + enc.disabled = "none" + enc.enabled = "psk2" + enc.rmempty = true + enc.default = enc.disabled --default must == disabled value for rmempty to work + +function enc.remove(self, section) + value = self.map:get(section, self.option) + if value ~= self.disabled then + local key = self.map:del(section, "key") + local enc = self.map:del(section, self.option) + self.section.changed = true + return key and enc or false + end +end + +function enc.write(self, section, fvalue) + value = self.map:get(section, self.option) + if value ~= fvalue then + self.section.changed = true + return self.map:set(section, self.option, fvalue) + end +end + + --password options + pw1 = pw_s:option(Value, (iface.name.."_pass1")) pw1.password = true pw1.anonymous = true - pw2 = pw_s:option(Value, iface.name.."_conf", nil, translate("Confirm Password")) + pw1:depends("encryption", "psk2") + --confirmation password + pw2 = pw_s:option(Value, iface.name.."_pass2", nil, translate("Confirm Password")) pw2.password = true pw2.anonymous = true - function pw_s.cfgsections() - return { "_pass" } + pw2:depends("encryption", "psk2") + + --password should write to the key, not to the dummy value + function pw1.write(self, section, value) + return self.map:set(section, "key", value) + end + + function pw2.write() return true end + + --make sure passwords are equal + function pw1.validate(self, value, section) + local v1 = value + local v2 = pw2:formvalue(section) + --local v2 = http.formvalue(string.gsub(self:cbid(section), "%d$", "2")) + if v1 and v2 and #v1 > 0 and #v2 > 0 then + if v1 == v2 then + if m.message == nil then + m.message = translate("Password successfully changed!") + end + return value + else + m.message = translate("Error, no changes saved. See below.") + self:add_error(section, translate("Given password confirmation did not match, password not changed!")) + return nil + end + else + m.message = translate("Error, no changes saved. See below.") + self:add_error(section, translate("Unknown Error, password not changed!")) + return nil + end end end @@ -101,20 +158,37 @@ for i,iface in ipairs(interfaces) do end end -function m.on_before_save(map) - -- if existing password, make sure user has old password - if s0 then - v0 = luci.sys.user.checkpasswd("root", http.formvalue("_pass0")) - end - - if v0 == false then - m.message = translate("Incorrect password. Changes rejected!") - m.save=v0 - m2.save=v0 - end +function m.on_parse(map) + local form = http.formvaluetable("cbid.wireless") + local check = nil + local conf_pass = nil + for field,val in pairs(form) do + string.gsub(field, ".-_pw(%d)$", + function(num) + if tonumber(num) == 0 then + conf_pass = val + end + if val then + check = true + end + end) + end + if check ~= nil then + db.log("not nil") + if conf_pass then + v0 = luci.sys.user.checkpasswd("root", conf_pass) + if v0 ~= true then + m.message = translate("Incorrect password. Changes rejected!") + m.save = false + function m.on_after_save() return true end --Don't redirect on error + end + else + m.message = translate("Please enter your old password. Changes rejected!") + m.save = false + end + end end - -function m.on_save(map) +function m.on_save(self) local v1 = pw1:formvalue("_pass") local v2 = pw2:formvalue("_pass") if v0 == true and v1 and v2 and #v1 > 0 and #v2 > 0 then @@ -133,6 +207,7 @@ end + return m From f74d390fec328cc015ad9418a4a11b706daa0bd0 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Tue, 10 Dec 2013 14:24:06 -0500 Subject: [PATCH 042/196] added serval mesh keychain options and enabled my serval init.d script in uci-defaults. NOTE the servald commands in the init.d script are temporary and will be replaced with working commotiond calls. --- files/etc/config/serval | 7 ++ files/etc/init.d/serval | 46 +++++++++++ files/etc/uci-defaults/luci-serval | 14 ++++ luasrc/model/cbi/commotion/security_smk.lua | 87 +++++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 files/etc/config/serval create mode 100644 files/etc/init.d/serval create mode 100644 files/etc/uci-defaults/luci-serval diff --git a/files/etc/config/serval b/files/etc/config/serval new file mode 100644 index 0000000..4f9aba2 --- /dev/null +++ b/files/etc/config/serval @@ -0,0 +1,7 @@ +config settings settings + option enabled 'true' + option primary_keyring '/etc/serval' + option olsrd_mdp_keyring '/etc/commotion/keys.d/mdp' + option update_primary_keyring 'false' + option update_mdp_keyring 'false' + option new_mdp_keyring 'false' \ No newline at end of file diff --git a/files/etc/init.d/serval b/files/etc/init.d/serval new file mode 100644 index 0000000..7e9fcc1 --- /dev/null +++ b/files/etc/init.d/serval @@ -0,0 +1,46 @@ +#!/bin/sh /etc/rc.common +# UCI file to allow basic serval modifications through LuCI with proper UI feel + +. /lib/functions/commotion.sh +. /lib/config/uci.sh + +START=19 +STOP=91 + +reload() { + local upload=cbid.serval.settings._upload + local update_mdp=$(uci_get serval settings update_mdp_keyring) + echo $update_mdp + local mdp_keyring=$(uci_get serval settings olsrd_mdp_keyring) + local update_primary=$(uci_get serval settings update_primary_keyring) + local primary_keyring=$(uci_get serval settings primary_keyring) + local new_mdp=$(uci_get serval settings new_mdp_keyring) + echo $new_mdp + if [ "$update_mdp" == "true" ]; then + echo $upload + mv /lib/uci/upload/$upload $mdp_keyring/serval.keyring || return 1 + export SERVALINSTANCE_PATH=$mdp_keyring + servald stop && sleep 1 + servald start || return 1 + elif [ -e "/lib/uci/upload/$upload" ]; then + rm /lib/uci/upload/$upload || return 1 + fi + uci_set serval settings update_mdp_keyring 'false' + if [ "$update_mdp" == "true" ]; then + mv /lib/uci/upload/$upload $primary_keyring/serval.keyring || return 1 + export SERVALINSTANCE_PATH=$primary_keyring + servald stop && sleep 1 + servald start + elif [ -e "/lib/uci/upload/$upload" ]; then + rm /lib/uci/upload/$upload || return 1 + fi + if [ "$new_mdp" == "true" ]; then + echo $new_mdp + rm $mdp_keyring/serval.keyring || return 1 + export SERVALINSTANCE_PATH=$mdp_keyring + servald stop && sleep 1 + servald start + fi + uci_set serval settings new_mdp_keyring 'false' + uci_commit serval +} diff --git a/files/etc/uci-defaults/luci-serval b/files/etc/uci-defaults/luci-serval new file mode 100644 index 0000000..1f853d2 --- /dev/null +++ b/files/etc/uci-defaults/luci-serval @@ -0,0 +1,14 @@ +#!/bin/sh + +. /etc/functions.sh + +config_load serval +uci_add serval settings settings +uci_set serval settings enabled false +uci_set serval settings primary_keyring /etc/serval/serval.keyring +uci_set serval settings olsrd_mdp_keyring /etc/commotion/keys.d/mdp/serval.keyring +uci_set serval settings update_primary_keyring false +uci_set serval settings update_mdp_keyring false +uci_set serval settings new_mdp_keyring false +uci_commit serval +/etc/init.d/serval enable diff --git a/luasrc/model/cbi/commotion/security_smk.lua b/luasrc/model/cbi/commotion/security_smk.lua index e69de29..647ead9 100644 --- a/luasrc/model/cbi/commotion/security_smk.lua +++ b/luasrc/model/cbi/commotion/security_smk.lua @@ -0,0 +1,87 @@ +--[[ + Copyright (C) 2013 Seamus Tuohy + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + + You should have received a copy of the GNU General Public License +along with this program. If not, see . +]]-- + +local cdisp = require "luci.commotion.dispatch" +local db = require "luci.commotion.debugger" +local uci = require "luci.model.uci".cursor() + +m = Map("serval", translate("Shared Mesh Keychain"), translate("To ensure that only authorized devices can route traffic on your Commotion mesh network, one Shared Mesh Keychain file can be generated and shared by all devices.")) + +--redirect on saved and changed to check changes. +m.on_after_save = cdisp.conf_page + +s = m:section(TypedSection, "settings", translate("Use a Shared Mesh Keychain to sign mesh routes. Yes/No"), translate("Check the box to use a Shared Mesh Keychain on this device. You'll also be required to upload or generate a Shared Mesh Keychain.")) +toggle = s:option(Flag, "enabled") +s.anonymous = true + +toggle.disabled = "false" +toggle.enabled = "true" +toggle.rmempty = true +toggle.default = toggle.disabled +toggle.title = nil + +--Make flag actually check for section.changed and set that flag for the confirmation page to work +--TODO make this a commotion function. It is repeated in multiple cbi models. +function toggle.remove(self, section) + value = self.map:get(section, self.option) + if value ~= self.disabled then + self.section.changed = true + return self.map:del(section, self.option) + end +end + +function toggle.write(self, section, fvalue) + db.log("toggle write function") + db.log(fvalue) + value = self.map:get(section, self.option) + if value ~= fvalue then + self.section.changed = true + return self.map:set(section, self.option, value) + end +end + +uploader = s:option(FileUpload, "_upload", translate("Upload Shared Mesh Keychain File"), translate("If a Shared Mesh Keychain file was provided to you by a network administrator or another community member, select and upload it here to join this device to an existing mesh network.")) +uploader:depends("enabled", "true") +uploader.anonymous = true + +dwnld = s:option(Button, "_dummy", translate("Download Shared Mesh Keychain"), translate("Download a copy of this device's existing Shared Mesh Keychain. Use this feature to make a backup of this file, or to share it with people putting up new devices on your Commotion mesh network.")) +dwnld.anonymous = true +dwnld:depends("enabled", "true") + +function dwnld.write(self, section, value) + keyring = uci:get("serval", "settings", "olsrd_mdp_keyring") + local f = io.open(keyring) + if not f then + self:add_error(section, translate("No Current Serval Key To Download.")) + return nil + end + luci.http.prepare_content("application/force-download") + luci.http.header("Content-Disposition", "attachment; filename=serval.keyring") + luci.ltn12.pump.all(luci.ltn12.source.file(f), luci.http.write) + io.close(f) + return true +end + +new = s:option(Button, "_dummy2", translate("Create a new Shared Mesh Keychain file"), translate("Click on the button below to create a new Shared Mesh Keychain file. This will DELETE the existing Shared Mesh Keychain on this device. Use this option if you are creating a brand new Commotion mesh network, or if you are changing the Shared Mesh Keyhchain on an existing network. In either case, create a backup of the existing Shared Mesh Keychain first.")) +new:depends("enabled", "true") +new.anonymous = true + +function new.write(self, section, value) + return self.map:set(section, "new_mdp_keyring", "true") +end + +return m From 13fdffff7a40062fa0d74c681c4aff4f4cbeef9f Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Tue, 10 Dec 2013 14:38:28 -0500 Subject: [PATCH 043/196] added a write check for correct file formatting of uploaded serval files... don't know if it works yet. Still need some more info on serval calls before work can continue. --- luasrc/model/cbi/commotion/security_smk.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/luasrc/model/cbi/commotion/security_smk.lua b/luasrc/model/cbi/commotion/security_smk.lua index 647ead9..baf87fd 100644 --- a/luasrc/model/cbi/commotion/security_smk.lua +++ b/luasrc/model/cbi/commotion/security_smk.lua @@ -58,6 +58,18 @@ uploader = s:option(FileUpload, "_upload", translate("Upload Shared Mesh Keychai uploader:depends("enabled", "true") uploader.anonymous = true +--! TODO test this function to ensure that it checks for a good key and then writes the new_mdp_keyring value to true if so. +function uploader.write(self, section, value) + local keyring = luci.sys.exec("SERVALINSTANCE_PATH=/lib/uci/upload/ servald keyring list") + local key = string.match(keyring, "^(%w*):%w*:") + if key == nil or string.len(key) ~= 64 then + self:add_error(section, translate("The file supplied is not a proper keyring, or is password protected. Please upload another key.")) + else + return self.map:set(section, "new_mdp_keyring", "true") + end +end + + dwnld = s:option(Button, "_dummy", translate("Download Shared Mesh Keychain"), translate("Download a copy of this device's existing Shared Mesh Keychain. Use this feature to make a backup of this file, or to share it with people putting up new devices on your Commotion mesh network.")) dwnld.anonymous = true dwnld:depends("enabled", "true") From d408edf852058c374542f02e2d8421f4c54a356f Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Tue, 10 Dec 2013 14:38:53 -0500 Subject: [PATCH 044/196] fixed some spacing issues --- luasrc/model/cbi/commotion/security_pass.lua | 71 ++++++++++---------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/luasrc/model/cbi/commotion/security_pass.lua b/luasrc/model/cbi/commotion/security_pass.lua index fac1a76..cfc50c9 100644 --- a/luasrc/model/cbi/commotion/security_pass.lua +++ b/luasrc/model/cbi/commotion/security_pass.lua @@ -44,32 +44,34 @@ function pw_sec_opt(pw_s, iface) --section options pw_s.addremove = false pw_s.anonymous = true - + --encryption toggle enc = pw_s:option(Flag, "encryption", translate("Require a Password?"), translate("When people connect to this access point, should a password be required?")) enc.disabled = "none" enc.enabled = "psk2" enc.rmempty = true enc.default = enc.disabled --default must == disabled value for rmempty to work - -function enc.remove(self, section) - value = self.map:get(section, self.option) - if value ~= self.disabled then - local key = self.map:del(section, "key") - local enc = self.map:del(section, self.option) - self.section.changed = true - return key and enc or false + + --Make enc flag actually check for section.changed and set that flag for the confirmation page to work + --TODO make this a commotion function. It is repeated in multiple cbi models. + function enc.remove(self, section) + value = self.map:get(section, self.option) + if value ~= self.disabled then + local key = self.map:del(section, "key") + local enc = self.map:del(section, self.option) + self.section.changed = true + return key and enc or false + end end -end - -function enc.write(self, section, fvalue) - value = self.map:get(section, self.option) - if value ~= fvalue then - self.section.changed = true - return self.map:set(section, self.option, fvalue) + + function enc.write(self, section, fvalue) + value = self.map:get(section, self.option) + if value ~= fvalue then + self.section.changed = true + return self.map:set(section, self.option, fvalue) + end end -end - + --password options pw1 = pw_s:option(Value, (iface.name.."_pass1")) pw1.password = true @@ -87,7 +89,7 @@ end end function pw2.write() return true end - + --make sure passwords are equal function pw1.validate(self, value, section) local v1 = value @@ -158,6 +160,7 @@ for i,iface in ipairs(interfaces) do end end +--!brief This map checks for the admin password field and denies all saving and removes the confirmation page redirect if it is there. function m.on_parse(map) local form = http.formvaluetable("cbid.wireless") local check = nil @@ -174,7 +177,6 @@ function m.on_parse(map) end) end if check ~= nil then - db.log("not nil") if conf_pass then v0 = luci.sys.user.checkpasswd("root", conf_pass) if v0 ~= true then @@ -188,26 +190,25 @@ function m.on_parse(map) end end end + function m.on_save(self) local v1 = pw1:formvalue("_pass") local v2 = pw2:formvalue("_pass") - if v0 == true and v1 and v2 and #v1 > 0 and #v2 > 0 then - if v1 == v2 then - if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then - m.message = translate("Password successfully changed!") - else - m.message = translate("Unknown Error, password not changed!") - end - else - m.message = translate("Given password confirmation did not match, password not changed!") - end - end + if v0 == true and v1 and v2 and #v1 > 0 and #v2 > 0 then + if v1 == v2 then + if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then + --TODO WAIT @critzo/@georgiamoon decide upon administration password experience for confirmation page. +-- eg. function m.on_after_save() return true end --Don't redirect on admin pw success as it is not a uci value and shows up as nil. + m.message = translate("Admin Password successfully changed!") + else + m.message = translate("Unknown Error, password not changed!") + end + else + m.message = translate("Given password confirmation did not match, password not changed!") + end + end end - - - - return m From 1e4bea7d564d8de194fac12a24176e2eb02bea68 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Tue, 10 Dec 2013 14:40:33 -0500 Subject: [PATCH 045/196] updated security config to work with mesh keyring --- .../controller/commotion/security_config.lua | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/luasrc/controller/commotion/security_config.lua b/luasrc/controller/commotion/security_config.lua index b98e2a3..36e6393 100644 --- a/luasrc/controller/commotion/security_config.lua +++ b/luasrc/controller/commotion/security_config.lua @@ -1,17 +1,20 @@ --[[ -LuCI - Lua Development Framework - -Copyright 2013 - Seamus Tuohy - -With Thanks to the niu suite built by Steven Barth - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - + Copyright (C) 2013 Seamus Tuohy + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . ]]-- + module "luci.controller.commotion.security_config" function index() @@ -21,3 +24,4 @@ function index() entry({"admin", "commotion", "security", "shared_mesh_keychain"}, cbi("commotion/security_smk", {hideapplybtn=true, hideresetbtn=true}), translate("Shared Mesh Keychain"), 60).subsection=true end + From 02224be3e25cc253282b78a5b8749b7cfa17c2c9 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 10:36:58 -0500 Subject: [PATCH 046/196] removed unneeded todo comment --- luasrc/model/cbi/commotion/client_wp.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/luasrc/model/cbi/commotion/client_wp.lua b/luasrc/model/cbi/commotion/client_wp.lua index 7858878..d4cfca4 100644 --- a/luasrc/model/cbi/commotion/client_wp.lua +++ b/luasrc/model/cbi/commotion/client_wp.lua @@ -59,7 +59,6 @@ timeopt:value("seconds") timeopt:value("minutes") timeopt:value("hours") timeopt:value("days") ---TODO apply spashtime to nodogsplash config on apply in seconds. splshtxt = m:section(TypedSection, "_page", translate("Edit Welcome Page Text"), translate("The welcome page can include terms of service, advertisements, or other information. Edit the welcome page text here or upload an HTML file.")) splshtxt.cfgsections = function() return { "_page" } end From 3fd5072c8eb97338803fc2296ccb7445c35c707f Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 15:01:09 -0500 Subject: [PATCH 047/196] moved all application funcationality into application repo --- .../commotion/application_config.lua | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 luasrc/controller/commotion/application_config.lua diff --git a/luasrc/controller/commotion/application_config.lua b/luasrc/controller/commotion/application_config.lua deleted file mode 100644 index 51847cb..0000000 --- a/luasrc/controller/commotion/application_config.lua +++ /dev/null @@ -1,22 +0,0 @@ ---[[ -LuCI - Lua Development Framework - -Copyright 2013 - Seamus Tuohy - -With Thanks to the niu suite built by Steven Barth - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -]]-- -module "luci.controller.commotion.application_config" - -function index() --- entry({"admin", "commotion", "basic"}, alias("admin", "commotion", "application", "list"), translate("Applications"), 30).index = true - -- entry({"admin", "commotion", "application", "list"}, cbi("commotion/application_list", {hideapplybtn=true, hideresetbtn=true}), translate("List"), 40).subsection=true --- entry({"admin", "commotion", "application", "add"}, cbi("commotion/application_add", {hideapplybtn=true, hideresetbtn=true}), translate("Add"), 50).subsection=true --- entry({"admin", "commotion", "application", "settings"}, cbi("commotion/application_set", {hideapplybtn=true, hideresetbtn=true}), translate("Settings"), 60).subsection=true -end From df9bd3f261558d60d5def42e4d4f1c621a6dc423 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 15:02:50 -0500 Subject: [PATCH 048/196] starting the final clean up of the setup wizard --- luasrc/controller/commotion/basic_config.lua | 18 +++++++++++++++++- luasrc/model/cbi/commotion/setup_wizard.lua | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 luasrc/model/cbi/commotion/setup_wizard.lua diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index 5e6c624..0be6e10 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -30,8 +30,11 @@ module ("luci.controller.commotion.basic_config", package.seeall) local db = require "luci.commotion.debugger" function index() + entry({"admin", "commotion"}, alias("admin", "commotion", "basic"), translate("Commotion"), 20) + local QS = require "luci.commotion.quickstart" + local redir = luci.http.formvalue("redir", true) or luci.dispatcher.build_url(unpack(luci.dispatcher.context.request)) @@ -48,9 +51,21 @@ function index() sva.hidden = true if QS.status() then + local root = node() + root.target = alias("commotion", "setup_wizard") + root.index = true + local confirm = {on_success_to={"admin", "commotion", "confirm"}} - entry({"admin", "commotion", "quickstart"}, cbi("commotion/quickstart", confirm), translate("Basic Configuration"), 15).hidden=true + entry({"commotion", "setup_wizard"}, cbi("commotion/setup_wizard", confirm), translate("Basic Configuration"), 15).hidden=true + else + local root = node() + if not root.lock then + root.target = alias("apps") + root.index = true + end + + entry({"commotion"}, alias("apps")) --Create regular "Basic Config" menu. entry({"admin", "commotion", "basic"}, alias("admin", "commotion", "basic", "node_settings"), translate("Basic Configuration"), 10).index = true @@ -62,6 +77,7 @@ function index() entry({"admin", "commotion", "basic", "mesh_network"}, cbi("commotion/basic_mn", {hideapplybtn=true, hideresetbtn=true}), translate("Mesh Network"), 40) entry({"admin", "commotion", "basic", "wireless_network"}, cbi("commotion/basic_wn", {hideapplybtn=true, hideresetbtn=true}), translate("Wireless Network"), 50) entry({"admin", "commotion", "basic", "addtl_net_ifaces"}, cbi("commotion/basic_ani", {hideapplybtn=true, hideresetbtn=true}), translate("Additional Netork Interfaces"), 60) + end end diff --git a/luasrc/model/cbi/commotion/setup_wizard.lua b/luasrc/model/cbi/commotion/setup_wizard.lua new file mode 100644 index 0000000..37ebb3a --- /dev/null +++ b/luasrc/model/cbi/commotion/setup_wizard.lua @@ -0,0 +1,17 @@ +local cursor = require "luci.model.uci".cursor() + +local d = Delegator() +d.allow_finish = true +d.allow_back = true +d.allow_cancel = false +d.allow_reset = true + +d:add("Node Settings", "commotion/basic_ns") +d:add("Mesh Network", "commotion/basic_mn") +d:add("Wireless Network", "commotion/basic_wn") +d:add("Additional Network Interfaces", "commotion/basic_ani") + +function d.on_done() +end + +return d From 109522dcb9160c901882af63275693428cbc9202 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 15:03:35 -0500 Subject: [PATCH 049/196] actually moved all functionality of applications to the app repo --- luasrc/model/cbi/commotion/application_add.lua | 0 luasrc/model/cbi/commotion/application_list.lua | 0 luasrc/model/cbi/commotion/application_set.lua | 0 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 luasrc/model/cbi/commotion/application_add.lua delete mode 100644 luasrc/model/cbi/commotion/application_list.lua delete mode 100644 luasrc/model/cbi/commotion/application_set.lua diff --git a/luasrc/model/cbi/commotion/application_add.lua b/luasrc/model/cbi/commotion/application_add.lua deleted file mode 100644 index e69de29..0000000 diff --git a/luasrc/model/cbi/commotion/application_list.lua b/luasrc/model/cbi/commotion/application_list.lua deleted file mode 100644 index e69de29..0000000 diff --git a/luasrc/model/cbi/commotion/application_set.lua b/luasrc/model/cbi/commotion/application_set.lua deleted file mode 100644 index e69de29..0000000 From f5c96aa454e2a18dba4108cb34d63e591f18abc9 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 15:06:06 -0500 Subject: [PATCH 050/196] added some external functionality clean up to functions created before condesing down. --- luasrc/model/cbi/commotion/basic_wn.lua | 9 +-------- luasrc/model/cbi/commotion/client_wp.lua | 1 + 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_wn.lua b/luasrc/model/cbi/commotion/basic_wn.lua index d1087aa..f52f0e3 100644 --- a/luasrc/model/cbi/commotion/basic_wn.lua +++ b/luasrc/model/cbi/commotion/basic_wn.lua @@ -105,6 +105,7 @@ enc.disabled = "none" enc.enabled = "psk2" enc.rmempty = true enc.default = "none" --default must == disabled value for rmempty to work +enc.write=ccbi.flag_write --Have enc flag also remove the encryption key when deleted and mark as changed. function enc.remove(self, section) @@ -116,14 +117,6 @@ function enc.remove(self, section) return key and enc or false end end ---have a flag to mark enc as changed when changed. -function enc.write(self, section, fvalue) - value = self.map:get(section, self.option) - if value ~= fvalue then - self.section.changed = true - return self.map:set(section, self.option, fvalue) - end -end --dummy value set to not reveal password pw1 = s:option(Value, "_pw1", translate("Password"), translate("Enter the password people should use to connect to this access point. Commotion uses WPA2 security for Access Point passwords.")) diff --git a/luasrc/model/cbi/commotion/client_wp.lua b/luasrc/model/cbi/commotion/client_wp.lua index d4cfca4..a074f9f 100644 --- a/luasrc/model/cbi/commotion/client_wp.lua +++ b/luasrc/model/cbi/commotion/client_wp.lua @@ -53,6 +53,7 @@ stime.anonymous = true tfield = stime:option(Value, "splashtime") tfield.datatype = "uinteger" +tfield.forcewrite = true timeopt = stime:option(ListValue, "splashunit") timeopt:value("seconds") From e00a73e8a5a4869498607e1243db3304e58d0deb Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 15:09:25 -0500 Subject: [PATCH 051/196] removed old controller functions --- luasrc/controller/commotion/commotion.lua | 50 --- luasrc/controller/commotion/meshprofile.lua | 376 -------------------- 2 files changed, 426 deletions(-) delete mode 100644 luasrc/controller/commotion/commotion.lua delete mode 100644 luasrc/controller/commotion/meshprofile.lua diff --git a/luasrc/controller/commotion/commotion.lua b/luasrc/controller/commotion/commotion.lua deleted file mode 100644 index 519972f..0000000 --- a/luasrc/controller/commotion/commotion.lua +++ /dev/null @@ -1,50 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Josh King - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -]]-- - -module("luci.controller.commotion.commotion", package.seeall) - -function index() - require("luci.i18n").loadc("commotion") - local i18n = luci.i18n.translate - - local page = node() - page.lock = true - page.target = alias("commotion") - page.subindex = true - page.index = false - - - local root = node() - if not root.lock then - root.target = alias("commotion") - root.index = true - end - - entry({"commotion"}, alias("commotion", "index"), i18n("Commotion"), 10) - entry({"commotion", "index"}, alias("commotion", "index", "index"), i18n("Overview"), 10).index = true - entry({"commotion", "index", "index"}, template("commotion/splash"), i18n("Front Page"), 10).ignoreindex = true - entry({"commotion", "index", "olsr-viz"}, template("olsr-viz/olsr-viz"), _("OLSR-Viz"), 90) - - entry({"commotion", "about"}, template("commotion/about"), i18n("About"), 10) - entry({"commotion", "help"}, template("commotion/help"), i18n("Help"), 10) - entry({"commotion", "license"}, template("commotion/license"), i18n("License"), 10) - - - local config = entry({"admin", "commotion"}, alias("admin", "commotion", "meshconfig"), i18n("Commotion"), 10) - config.sysauth = "root" - config.sysauth_authenticator = "htmlauth" - config.index = true - - entry({"admin", "commotion", "meshconfig"}, cbi("commotion/meshconfig"), i18n("Mesh Configuration (Manual)"), 20) -end - diff --git a/luasrc/controller/commotion/meshprofile.lua b/luasrc/controller/commotion/meshprofile.lua deleted file mode 100644 index 2dde528..0000000 --- a/luasrc/controller/commotion/meshprofile.lua +++ /dev/null @@ -1,376 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Josh King -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -]]-- - -module("luci.controller.commotion.meshprofile", package.seeall) - -require "luci.model.uci" -require "luci.fs" -require "luci.sys" -local fs = require "nixio.fs" - -local profileDir = "/etc/commotion/profiles.d/" - -function index() - require("luci.i18n").loadc("commotion") - local i18n = luci.i18n.translate - - entry({"admin", "commotion", "meshprofile_submit"}, call("ifprocess")) - entry({"admin", "commotion", "meshprofile_down"}, call("down")) - entry({"admin", "commotion", "meshprofile_up"}, call("up")) - entry({"admin", "commotion", "meshprofile"}, call("main"), i18n("Mesh Profile"), 20).dependent=false -end - -function main(ERR, isDuplicate, ul) - local debug = require "luci.commotion.debugger" - debug.log("main started") - if not ERR then - ERR = nil - end - local uci = luci.model.uci.cursor() - local rawProfiles = luci.fs.dir(profileDir) - local available = {} - uci:get_all('network') - uci:foreach('network', 'interface', - function(s) - if s['.name'] and s.profile then - table.insert(available, {s['.name'], s.profile}) - --debug.log(s['.name'] .. " uses " .. s.profile) - end - end) - local profiles = {} - for i,p in ipairs(rawProfiles) do - if not string.find(p, "^%.*$") then - table.insert(profiles, p) - end - end - luci.http.prepare_content("text/html") - luci.template.render("commotion/meshprofile", {available = available, profiles = profiles, ERR = ERR, isDuplicate = isDuplicate, ul = ul}) - -end - -function ifprocess() - local debug = require "luci.commotion.debugger" - debug.log("Processing profile application...") - local error = nil - local values = luci.http.formvalue() - local tif = values["interfaces"] - local p = values["profiles"] - local uci = luci.model.uci.cursor() - debug.log("Applying " .. p .. " to " .. tif) - old_prof = uci:get('network', tif, "profile") - local wireless = false - uci:foreach('wireless','wifi-iface', - function(iface) - if iface.network == tif then - wireless = true - end - end - ) - if wireless then - error = flush_wireless_profile(old_prof, p, tif) - end - uci:set('network', tif, "profile", p) - uci:commit('network') - uci:save('network') - if error ~= nil then - main(error) - else - finish() - end -end - - -function finish() - luci.template.render("QS/module/applyreboot", {redirect_location=("http://"..luci.http.getenv("SERVER_NAME").."/cgi-bin/luci/admin/commotion/meshprofile")}) - luci.http.close() - --luci.sys.call("/etc/init.d/commotiond restart") - --luci.sys.call("sleep 2; /etc/init.d/network restart") - --In order to ensure that everything works cleanly a restart is required - p = luci.sys.reboot() - return({'complete'}) -end - -function checkFile(file) - local debug = require "luci.commotion.debugger" - --[=[ - Checks the uploaded profile to ensure the required settings are there. - --]=] - debug.log("file check started") - local error = nil - if luci.fs.isfile(file) then - --required fields for a commotion profile - required = { - "ip", - "ipgenerate", - "netmask", - "dns", - "type", - "mode"} - --Parse uploaded file for settings - fields = {} - for line in io.lines(file) do - setting = line:split("=") - if setting[2] and setting[1] ~= "" and setting[1] ~= nil then - table.insert(fields, setting[1]) - end - end - --on line 113, the if statement that if the file is empty does not have an else statement that says (if the file is empty, pass an error) - if fields ~= {} then - --Check to see if there are missing fields - missing = {} - for _,x in pairs(required) do - contained = nil - for _,m in pairs(fields) do - if x == m then - contained = 1 - end - end - if not contained then - table.insert(missing, x) - debug.log("Field "..x.." is missing.") - end - end - end - --If missing fields create error - if next(missing) ~= nil then - misStr = table.concat(missing, ", ") - error = "Your uploaded profile seem incomplete. You are missing at LEAST the values for "..misStr..". Please edit your profile and re-upload." - --remove file because it is BAD - removed = luci.sys.call('rm ' .. file) - else - debug.log("Profile seems to be correctly formatted.") - end - else - error = "There does not seem to be a file here..." - debug.log("File is missing") - end - if error then - return error - else - return nil - end - return nil -end - -function string:split(sep) - local sep, fields = sep or ":", {} - local pattern = string.format("([^%s]+)", sep) - self:gsub(pattern, function(c) fields[#fields+1] = c end) - return fields -end - - -function up() - --[=[calls the file uploader and checks if the file is a correct config. - --]=] - local debug = require "luci.commotion.debugger" - debug.log("up started") - local error = nil - local isDuplicate = false - setFileHandler("/tmp/", "config") - local values = luci.http.formvalue() - - local overwrite = values["overwrite"] - - local ul = values["config"] - - --TODO add logging to checkfile to identify why it does not work - file = "/tmp/" .. ul - error = checkFile(file) - - if error ~= nil then - main(error) - - else - - -- check for extant profiles with the same name - iterator, is_match = fs.glob("/etc/commotion/profiles.d/" .. ul) - - log(overwrite) - - -- if there is a conflict, inform the user - if is_match > 0 then - if overwrite == "yes" then - result = fs.copy("/tmp/" .. ul, "/etc/commotion/profiles.d/" .. ul) - main(nil) - end - if overwrite == "no" then - main(nil) - end - if overwrite == nil then - error = "There is a conflict: The profile "..ul.." already exists." - - isDuplicate = true - - main(error, isDuplicate, ul) - - log("There is a conflict: The profile "..ul.." already exists.") - end - -- if no conflict exists, copy the new profile to etc/commotion/profiles.d - else - result = fs.copy("/tmp/" .. ul, "/etc/commotion/profiles.d/" .. ul) - main(nil) - - end - - end -end - -function down() - local values = luci.http.formvalue() - local dl = values["dl_profile"] - if dl ~= '' then - download(dl) - end - main() -end - -function download(filename) - --TODO remove the luci.http.status calls and replace them with calls to main(error) with the appropriate text to inform the user of why they cannot download it. - debug.log("download started") - -- no file name provided - if not filename then - luci.http.status(403, "Forbidden") - return - end - -- no relative paths with backrefs - if filename:find("%.%.") then - luci.http.status(403, "Access denied") - return - end - -- no absolute paths - if # filename > 0 and filename:sub(1,1) == '/' then - luci.http.status(403, "Access denied") - return - end - local f = io.open(profileDir .. filename) - -- file does not exist - if not f then - luci.http.status(403, "Access denied") - return - end - -- send it - luci.http.prepare_content("application/force-download") - luci.http.header("Content-Disposition", "attachment; filename=" .. filename) - luci.ltn12.pump.all(luci.ltn12.source.file(f), luci.http.write) - - io.close(f) -end - -function setFileHandler(location, input_name, file_name) - --[=[Uploads a file to a specified location, and possible file name. - - Use: - add a call to this function within the index entry function called by an submit button on a luci page. - eg. - function index() - entry({"admin", "commotion", "submit_clicked"}, call("start_upload")) - end - function start_upload() - setFileHandler("/tmp/", "image", "tmp_image.jpg") - local values = luci.http.formvalue() - local dl = values["image"] reload_page() - end - - Inputs: - location: (string) The full path to where the file should be saved. - input_name: (string) The name specified by the input html field. - file_name: (string, optional) The optional name you would like the file to be saved as. If left blank the file keeps its uploaded name. - - --]=] - local debug = require "luci.commotion.debugger" - local sys = require "luci.sys" - local fs = require "luci.fs" - local configLoc = location - local fp - luci.http.setfilehandler( - function(meta, chunk, eof) - if not fp then - complete = nil - if meta and meta.name == input_name then - if file_name ~= nil then - debug.log("starting download") - fp = io.open(configLoc .. file_name, "w") - else - debug.log("starting download") - fp = io.open(configLoc .. meta.file, "w") - end - else - debug.log("file not of specified input type (input name variable)") - end - end - if chunk then - fp:write(chunk) - end - if eof then - fp:close() - debug.log("file downloaded") - end - end) -end - - -function flush_wireless_profile(old_profile, new_profile, interface) - --TODO need a userspace warning that channel settings will not take effect and need to be done in the settings page. - local debug = require "luci.commotion.debugger" - local uci = luci.model.uci.cursor() - local found = nil - local old_dev = nil - local name = nil - local error = nil - settings = get_commotion_settings(new_profile) - uci:foreach("wireless", "wifi-iface", - function(s) - if s['.name'] == old_profile then - found = true - old_dev = s.device - name = s['.name'] - elseif s['.name'] == new_profile then - error = luci.i18n.translate("Each profile must have a seperate name. Please try with a unique profile.") - elseif s['.name'] ~= old_profile and s.network == interface then - error = luci.i18n.translate("You have multiple wireless interfaces on a single network interface. This is not allowed.") - end - end) - --debug.log(tostring(conflict).." is the conflict level") - if error ~= nil then - return error - else - uci:delete("wireless", name) - uci:section('wireless', 'wifi-iface', new_profile, - {device=old_dev, - network=interface, - ssid=settings['ssid'], - mode=settings['mode']}) - uci:save("wireless") - uci:commit("wireless") - end -end - -function get_commotion_settings(file) - settings = {} - for line in io.lines("/etc/commotion/profiles.d/"..file) do - setting = line:split("=") - if setting[1] ~= nil and setting[2] ~= nil then - settings[setting[1]] = setting[2] - end - end - if next(settings) then - return settings - end -end - -function string:split(sep) - local sep, fields = sep or ":", {} - local pattern = string.format("([^%s]+)", sep) - self:gsub(pattern, function(c) fields[#fields+1] = c end) - return fields -end From 56fd064294e31ab15cedc6631dc1e22ebfa7ad32 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 15:17:07 -0500 Subject: [PATCH 052/196] removed serval keyring from menu as it is not called through the basic menu. --- .../controller/commotion/serval_keyring.lua | 163 ------------------ 1 file changed, 163 deletions(-) delete mode 100644 luasrc/controller/commotion/serval_keyring.lua diff --git a/luasrc/controller/commotion/serval_keyring.lua b/luasrc/controller/commotion/serval_keyring.lua deleted file mode 100644 index cefa8ae..0000000 --- a/luasrc/controller/commotion/serval_keyring.lua +++ /dev/null @@ -1,163 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Josh King - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -]]-- - -module("luci.controller.commotion.serval_keyring", package.seeall) - -local key_file = "/etc/commotion/keys.d/mdp/" - -function index() - require("luci.i18n").loadc("commotion") - local i18n = luci.i18n.translate - - entry({"admin", "commotion", "serval_keyring_new"}, call("new_keyring")) - entry({"admin", "commotion", "serval_keyring_down"}, call("down")) - entry({"admin", "commotion", "serval_keyring_up"}, call("up")) - entry({"admin", "commotion", "serval_keyring"}, call("main"), "Serval Keyring", 20) -end - -function main(Err) - if not ERR then - ERR = nil - end - luci.http.prepare_content("text/html") - luci.template.render("commotion/serval_keyring", {Err = Err}) -end - -function new_keyring() - local debug = require "luci.commotion.debugger" - debug.log("Creating New Keyring...") - local values = luci.http.formvalue() - local new = values["new_keyring"] - local rm = luci.sys.call("rm "..key_file.."serval.keyring") - --Define the various serval code to run - local s_path = "SERVALINSTANCE_PATH=" - local s_start = s_path..key_file.." servald start" - local s_stop = s_path..key_file.." servald stop" - --local s_add_key = s_path..key_file.." servald keyring add" - --local s_list_key = s_path..key_file.." servald keyring list" - local AND = " && " - --Run the actual serval command to create a new keyring & key - local new_key = luci.sys.call(s_start..AND..s_stop) - --debug.log(luci.sys.exec(s_list_key)) - --If no errors occured in sys calls - if rm ~= 1 and new_key ~= 1 then - finish() - else - main("Serval process failed") - end -end - -function finish() - --TODO What kind of cleanup/setup do we need to do? - local olsrd = luci.sys.call("/etc/init.d/olsrd restart") - if olsrd == 0 then - main() - else - main("olsrd failed to restart") - end -end - ----calls the file uploader and checks if the file is a correct config. -function up() - local debug = require "luci.commotion.debugger" - debug.log("uploader started") - local error = nil - setFileHandler("/tmp/", "upload", "serval.keyring") - --debug.log(luci.sys.exec("md5sum /tmp/serval.keyring")) - local values = luci.http.formvalue() - local ul = values["upload"] - if ul ~= '' and ul ~= nil then - debug.log("checking file") - error = checkFile("/tmp/serval.keyring") - end - --remove file if errors, copy it to correct directory and finish if a keyring - if error ~= nil then - debug.log("error found") - local rm = luci.sys.call("rm /tmp/serval.keyring") - main(error) - else - local rm = luci.sys.call("rm "..key_file.."serval.keyring") - local cp = luci.sys.call("cp /tmp/serval.keyring "..key_file..".") - finish() - end -end - -function checkFile(file) - local keyring = luci.sys.exec("SERVALINSTANCE_PATH=/tmp/ servald keyring list") - local key = string.match(keyring, "^(%w*):%w*:") - if key == nil or string.len(key) ~= 64 then - return "The file supplied is not a proper keyring, or is password protected. Please upload another key." - end -end - - -function down() - local values = luci.http.formvalue() - download(key_file.."serval.keyring") - main() -end - -function download(filename) - local debug = require "luci.commotion.debugger" - --TODO remove the luci.http.status calls and replace them with calls to main(error) with the appropriate text to inform the user of why they cannot download it. - debug.log("download started") - local f = io.open(filename) - -- file does not exist - if not f then - debug.log("File Does Not Exist") - luci.http.status(403, "Access denied") - return - end - -- send it - luci.http.prepare_content("application/force-download") - luci.http.header("Content-Disposition", "attachment; filename=serval.keyring") - luci.ltn12.pump.all(luci.ltn12.source.file(f), luci.http.write) - io.close(f) -end - - ----Uploads a file to a specified location, and possible file name. ---@param location: (string) The full path to where the file should be saved. ---@param input_name: (string) The name specified by the input html field. ---@param file_name (string, optional) The optional name you would like the file to be saved as. If left blank the file keeps its uploaded name. -function setFileHandler(location, input_name, file_name) - local debug = require "luci.commotion.debugger" - local sys = require "luci.sys" - local fs = require "luci.fs" - local configLoc = location - local fp - luci.http.setfilehandler( - function(meta, chunk, eof) - if not fp then - complete = nil - if meta and meta.name == input_name then - if file_name ~= nil then - debug.log("starting download") - fp = io.open(configLoc .. file_name, "w") - else - debug.log("starting download") - fp = io.open(configLoc .. meta.file, "w") - end - else - debug.log("file not of specified input type (input name variable)") - end - end - if chunk then - fp:write(chunk) - end - if eof then - fp:close() - debug.log("file downloaded") - end - end) -end From e0ff38c2f5efecde8a31111b3cd0d93956a375ef Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 18:07:07 -0500 Subject: [PATCH 053/196] purged all mentions of quickstart from this process and replaced them with setup wizard --- .gitignore | 1 + files/etc/config/nodogsplash | 4 +- files/etc/uci-defaults/luci-commotion-setup | 11 ++++ files/etc/uci-defaults/luci-quickstart-setup | 11 ---- files/etc/uci-defaults/luci-serval | 0 files/etc/uci-defaults/ucitrack-updates | 0 luasrc/commotion/quickstart.lua | 13 ---- luasrc/controller/commotion/basic_config.lua | 2 +- luasrc/model/cbi/commotion/basic_ani.lua | 4 +- luasrc/model/cbi/commotion/basic_mn.lua | 8 +-- luasrc/model/cbi/commotion/basic_ns.lua | 6 +- luasrc/model/cbi/commotion/basic_wn.lua | 8 +-- luasrc/model/cbi/commotion/meshconfig.lua | 63 -------------------- luasrc/view/commotion/debug.htm | 4 +- 14 files changed, 30 insertions(+), 105 deletions(-) create mode 100644 .gitignore create mode 100755 files/etc/uci-defaults/luci-commotion-setup delete mode 100644 files/etc/uci-defaults/luci-quickstart-setup mode change 100644 => 100755 files/etc/uci-defaults/luci-serval mode change 100644 => 100755 files/etc/uci-defaults/ucitrack-updates delete mode 100644 luasrc/commotion/quickstart.lua delete mode 100644 luasrc/model/cbi/commotion/meshconfig.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..55d6ad1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +\#* \ No newline at end of file diff --git a/files/etc/config/nodogsplash b/files/etc/config/nodogsplash index 829df02..3c67dcf 100644 --- a/files/etc/config/nodogsplash +++ b/files/etc/config/nodogsplash @@ -1,7 +1,7 @@ config settings settings option enable '0' - option splashtime '32' + option splashtime '1' option splashunit 'hours' config interfaces interfaces - option interface 'quickstartSec' + option interface 'commotionAP' diff --git a/files/etc/uci-defaults/luci-commotion-setup b/files/etc/uci-defaults/luci-commotion-setup new file mode 100755 index 0000000..8f2ec4b --- /dev/null +++ b/files/etc/uci-defaults/luci-commotion-setup @@ -0,0 +1,11 @@ +#!/bin/sh + +. /etc/functions.sh +#set up all interfaces needed for the setup wizard process +config_load wireless +uci_add wireless wifi-iface commotionAP +uci_set wireless commotionAP mode ap +uci_set wireless commotionAP network client +uci_add wireless wifi-iface commotionMesh +uci_set wireless commotionAP mode adhoc +uci_commit wireless diff --git a/files/etc/uci-defaults/luci-quickstart-setup b/files/etc/uci-defaults/luci-quickstart-setup deleted file mode 100644 index 99b3552..0000000 --- a/files/etc/uci-defaults/luci-quickstart-setup +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -. /etc/functions.sh -#set up all interfaces needed for the quickstart process -config_load wireless -uci_add wireless wifi-iface quickstartAP -uci_set wireless quickstartAP mode ap -uci_set wireless quickstartAP network client -uci_add wireless wifi-iface quickstartMesh -uci_set wireless quickstartAP mode adhoc -uci_commit wireless diff --git a/files/etc/uci-defaults/luci-serval b/files/etc/uci-defaults/luci-serval old mode 100644 new mode 100755 diff --git a/files/etc/uci-defaults/ucitrack-updates b/files/etc/uci-defaults/ucitrack-updates old mode 100644 new mode 100755 diff --git a/luasrc/commotion/quickstart.lua b/luasrc/commotion/quickstart.lua deleted file mode 100644 index cdf8501..0000000 --- a/luasrc/commotion/quickstart.lua +++ /dev/null @@ -1,13 +0,0 @@ -module "luci.commotion.quickstart" - -local QS = {} - ---! @name status ---! @brief Checks the status of quickstart ---! @return true if on, false if completed ---! @TODO IMPLEMENT THIS: Currently placeholder -function QS.status() - return true -end - -return QS diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index 0be6e10..6ab9116 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -33,7 +33,7 @@ function index() entry({"admin", "commotion"}, alias("admin", "commotion", "basic"), translate("Commotion"), 20) - local QS = require "luci.commotion.quickstart" + local QS = require "luci.commotion.setup_wizard" local redir = luci.http.formvalue("redir", true) or luci.dispatcher.build_url(unpack(luci.dispatcher.context.request)) diff --git a/luasrc/model/cbi/commotion/basic_ani.lua b/luasrc/model/cbi/commotion/basic_ani.lua index cd98657..21f5b5c 100644 --- a/luasrc/model/cbi/commotion/basic_ani.lua +++ b/luasrc/model/cbi/commotion/basic_ani.lua @@ -19,13 +19,13 @@ local utils = require "luci.util" local cnw = require "luci.commotion.network" local db = require "luci.commotion.debugger" local http = require "luci.http" -local QS = require "luci.commotion.quickstart" +local SW = require "luci.commotion.startup_wizard" local cdisp = require "luci.commotion.dispatch" m = Map("network", translate("Internet Gateway"), translate("If desired, you can configure your gateway interface here.")) --redirect on saved and changed to check changes. -if not QS.status() then +if not SW.status() then m.on_after_save = cdisp.conf_page end diff --git a/luasrc/model/cbi/commotion/basic_mn.lua b/luasrc/model/cbi/commotion/basic_mn.lua index 9a2fbc5..26e7a3e 100644 --- a/luasrc/model/cbi/commotion/basic_mn.lua +++ b/luasrc/model/cbi/commotion/basic_mn.lua @@ -20,25 +20,25 @@ local utils = require "luci.util" local cnw = require "luci.commotion.network" local db = require "luci.commotion.debugger" local http = require "luci.http" -local QS = require "luci.commotion.quickstart" +local SW = require "luci.commotion.setup_wizard" local cdisp = require "luci.commotion.dispatch" local m = Map("wireless", translate("Network Interfaces"), translate("Every Commotion node must have one mesh network connection or interface. Commotion can mesh over wireless or wired interfaces.")) --redirect on saved and changed to check changes. -if not QS.status() then +if not SW.status() then m.on_after_save = cdisp.conf_page end function m.on_before_commit() - if QS.status() then + if SW.status() then cnw.commotion_set("commotionMesh", {values="mapvalues here"}) --TODO make commotion set actually work end end s = m:section(TypedSection, "wifi-iface") -if not QS.status() then --if not quickstart then allow for adding and removal +if not SW.status() then --if not setup wizard then allow for adding and removal s.addremove = true dflts = s:option(DummyValue, "_dummy_val01") --also add defaults if not in qs diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index 0ab83ea..60b1b2a 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -15,7 +15,7 @@ GNU General Public License for more details. along with this program. If not, see . ]]-- -local QS = require "luci.commotion.quickstart" +local SW = require "luci.commotion.setup_wizard" local db = require "luci.commotion.debugger" local uci = require "luci.model.uci".cursor() local cdisp = require "luci.commotion.dispatch" @@ -24,7 +24,7 @@ local cdisp = require "luci.commotion.dispatch" --Main title and system config map for hostname value local m = Map("system", translate("Basic Configuration"), translate("In this section you'll set the basic required settings for this device, and the basic network settings required to connect this device to a Commotion Mesh network. You will be prompted to save your settings along the way and apply them at the end.")) --redirect on saved and changed to check changes. -if not QS.status() then +if not SW.status() then m.on_after_save = cdisp.conf_page end @@ -58,7 +58,7 @@ if luci.sys.user.getpasswd("root") then end end -if QS.status() then +if SW.status() then pw_text = "This password will be used to make changes to this device after initial setup has been completed. The administration username is “root." else pw_text = "This password is used to make changes to this device. The administration username is “root." diff --git a/luasrc/model/cbi/commotion/basic_wn.lua b/luasrc/model/cbi/commotion/basic_wn.lua index f52f0e3..3d680f8 100644 --- a/luasrc/model/cbi/commotion/basic_wn.lua +++ b/luasrc/model/cbi/commotion/basic_wn.lua @@ -20,21 +20,21 @@ local utils = require "luci.util" local cnw = require "luci.commotion.network" local db = require "luci.commotion.debugger" local http = require "luci.http" -local QS = require "luci.commotion.quickstart" +local SW = require "luci.commotion.setup_wizard" local cdisp = require "luci.commotion.dispatch" local m = Map("wireless", translate("Wireless Network"), translate("Turning on an Access Point provides a wireless network for people to connect to using a laptop or other wireless devices.")) --redirect on saved and changed to check changes. -if not QS.status() then +if not SW.status() then m.on_after_save = cdisp.conf_page end s = m:section(TypedSection, "wifi-iface", translate("Access Point"), translate("Turning on an Access Point provides a wireless network for people to connect to using a laptop or other wireless devices.")) s.optional = false s.anonymous = true - --if not quickstart then allow for adding and removal and default addition -if not QS.status() then + --if not setup wizard then allow for adding and removal and default addition +if not SW.status() then s.addremove = true dflts = s:option(DummyValue, "_dummy_val01") diff --git a/luasrc/model/cbi/commotion/meshconfig.lua b/luasrc/model/cbi/commotion/meshconfig.lua deleted file mode 100644 index 6b8cfb5..0000000 --- a/luasrc/model/cbi/commotion/meshconfig.lua +++ /dev/null @@ -1,63 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2011 Josh King - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -]]-- - -local uci = require "luci.model.uci".cursor() -local sys = require "luci.sys" -local util = require "luci.util" - - -m = Map("wireless", translate("Configuration"), translate("This configuration wizard will assist you in setting up your router for a Commotion network.")) - -sctAP = m:section(NamedSection, "quickstartAP", "wifi-iface", translate("Access Point")) -sctAP.optional = true -sctAP:option(Value, "ssid", translate("Name (SSID)"), translate("The public facing name of this interface")) - -sctSecAP = m:section(NamedSection, "quickstartSec", "wifi-iface", translate("Secure Access Point")) -sctSecAP.optional = true -sctSecAP:option(Value, "ssid", translate("Name (SSID)"), translate("The public facing name of this interface")) - -sctMesh = m:section(NamedSection, "quickstartMesh", "wifi-iface", translate("Mesh Backhaul")) -sctMesh.optional = true -sctMesh:option(Value, "ssid", translate("Name (SSID)"), translate("The public facing name of this interface")) -sctMesh:option(Value, "bssid", translate("Device Designation (BSSID)"), translate("The device read name of this interface. (Letters A-F, and numbers 0-9 only)")) - -e = m:section(TypedSection, "wifi-device", translate("Network-wide Settings")) -e.anonymous = true - -protocol = uci.get("wireless", "wifi-device", "hwmode") - -if protocol == '11na' then - c = e:option(ListValue, "channel", translate("5GHz Channel"), translate("The 5GHz backhaul channel of the mesh network, if applicable.")) - c:value(36, "Channel 36 (5.180 GHz)") - c:value(40, "Channel 40 (5.200 GHz)") - c:value(44, "Channel 44 (5.220 GHz)") - c:value(48, "Channel 48 (5.240 GHz)") - c:value(149, "Channel 149 (5.745 GHz)") - c:value(153, "Channel 153 (5.765 GHz)") - c:value(157, "Channel 157 (5.785 GHz)") - c:value(161, "Channel 161 (5.805 GHz)") - c:value(165, "Channel 165 (5.825 GHz)") -else - c = e:option(ListValue, "channel", translate("2GHz Channel"), translate("The 2.4GHz backhaul channel of the mesh network, if applicable")) - for i=1, 11 do - c:value(i, "Channel " .. i .. " (" .. tostring(2.407+(i*0.005)) .. " GHz)") - end -end - -m2 = Map("commotiond") -node = m2:section(TypedSection, "node", translate("Settings specific to this node")) -node.anonymous = true -node.optional = true -node:option(Value, "dhcp_timeout", translate("DHCP Timeout"), translate("How many seconds to wait on boot for a DHCP lease from the gateway")) - -return m, m2 diff --git a/luasrc/view/commotion/debug.htm b/luasrc/view/commotion/debug.htm index d2efc7b..9b5dfb6 100644 --- a/luasrc/view/commotion/debug.htm +++ b/luasrc/view/commotion/debug.htm @@ -23,7 +23,7 @@
-

<%:Commotion Bug Info%>

+

<%:Commotion Bug Info%>

<%:Name%>:
@@ -48,7 +48,7 @@

<%:Debugging Info%>:

<%:Router Traffic Routing Rules%>
<%:All Info%>
-
+

From c67276341a2f725bef79ade1dd56ec5cf8095e75 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 18:32:00 -0500 Subject: [PATCH 054/196] removed depricated meshprofile html page from repo --- luasrc/view/commotion/meshprofile.htm | 89 --------------------------- 1 file changed, 89 deletions(-) delete mode 100644 luasrc/view/commotion/meshprofile.htm diff --git a/luasrc/view/commotion/meshprofile.htm b/luasrc/view/commotion/meshprofile.htm deleted file mode 100644 index 0d646cc..0000000 --- a/luasrc/view/commotion/meshprofile.htm +++ /dev/null @@ -1,89 +0,0 @@ - -<%+header%> - -<%- -uri = REQUEST_URI -uri_prefix, num_post = string.gsub(uri, "meshprofile_.*", "meshprofile") --%> - -

<%:Node Profiles%>

- -

If your node includes configuration profiles for multiple Commotion -networks, this form allows you to set your defaults. NOTE: Channel settings must be manually changed. -We recommend that you reboot your node after changing these settings.

- -<%-if ERR then-%> -
<%=ERR%>
-<%end%> - -<%-if isDuplicate == true then-%> -
-

Overwrite existing profile?

- -Yes, please overwrite the existing profile
-No, I will rename the file and upload it again
- -
-<%end%> - -
-

<%:Select an interface%>

-
    -
- - -

<%:Select a profile to apply%>

- - - -
- -

-

Download a Profile

-
- - - -
- -

Upload a Profile

-
-
-
- -
- - -
- Upload a config file from your own computer. -
-
-
-
- -
- - -<%+footer%> From 253d4fe017fe958f101a5b295e25cf3e68bdee1e Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 19:26:08 -0500 Subject: [PATCH 055/196] corrected spelling of SETUP wizard --- luasrc/model/cbi/commotion/basic_ani.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/model/cbi/commotion/basic_ani.lua b/luasrc/model/cbi/commotion/basic_ani.lua index 21f5b5c..8322852 100644 --- a/luasrc/model/cbi/commotion/basic_ani.lua +++ b/luasrc/model/cbi/commotion/basic_ani.lua @@ -19,7 +19,7 @@ local utils = require "luci.util" local cnw = require "luci.commotion.network" local db = require "luci.commotion.debugger" local http = require "luci.http" -local SW = require "luci.commotion.startup_wizard" +local SW = require "luci.commotion.setup_wizard" local cdisp = require "luci.commotion.dispatch" m = Map("network", translate("Internet Gateway"), translate("If desired, you can configure your gateway interface here.")) From 4ed959e119e7cc610dbb513f4c2f275ea450c974 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 20:32:27 -0500 Subject: [PATCH 056/196] updated status config to remove a failed call which caused the http content type to be replaced with plain text... which is a fun and hard to track down bug. --- luasrc/controller/commotion/status_config.lua | 29 +++++-------------- luasrc/view/commotion/status.htm | 10 ++----- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index f3c30ae..b2b0bfd 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -15,17 +15,18 @@ GNU General Public License for more details. along with this program. If not, see . ]]-- module ("luci.controller.commotion.status_config", package.seeall) + local sys = require "luci.sys" local util = require "luci.util" -function index() +function index() entry({"admin", "commotion", "status"}, alias("admin", "commotion", "status", "nearby_md"), translate("Status"), 10) - entry({"admin", "commotion", "status", "nearby_md"}, call("action_neigh")).hidden = true - entry({"admin", "commotion", "status", "mesh_viz"}, call("viz")).hidden = true - entry({"admin", "commotion", "status", "conn_clnts"}, call("conn_clnts")).hidden = true - if sys.exec("opkg list-installed | grep luci-commotion-debug") then - entry({"admin", "commotion", "status", "dbg_rpt"}, call("dbg_rpt")).hidden = true - end + entry({"admin", "commotion", "status", "nearby_md"}, call("action_neigh")).hidden = true + entry({"admin", "commotion", "status", "mesh_viz"}, call("viz")).hidden = true + entry({"admin", "commotion", "status", "conn_clnts"}, call("conn_clnts")).hidden = true + if sys.exec("opkg list-installed | grep luci-commotion-debug") then + entry({"admin", "commotion", "status", "dbg_rpt"}, call("dbg_rpt")).hidden = true + end end @@ -43,20 +44,6 @@ function viz() end function conn_clnts() ---[[ -client_id=0 -ip=103.114.207.62 -mac=10:0b:a9:ca:7b:14 -added=1386540225 -active=1386540231 -duration=6 -token=f9b38643 -state=Authenticated -downloaded=2 -avg_down_speed=3.212 -uploaded=1 -avg_up_speed=1.54133 -]]-- local convert = function(x) return tostring(tonumber(x)*60).." "..translate(minutes) end diff --git a/luasrc/view/commotion/status.htm b/luasrc/view/commotion/status.htm index cbb6ef5..0d6d9e5 100644 --- a/luasrc/view/commotion/status.htm +++ b/luasrc/view/commotion/status.htm @@ -2,6 +2,7 @@ --! @param gateway_provided String "Yes" if node is providing gateway to (mesh/ap?) "No" if not providing a gateway. -%> <% + sys = require "luci.sys" --Sets tabs to select current page tabs = {nd = "nearby_devices", mv = "mesh_visualizer", @@ -18,13 +19,6 @@ <%+header%> - - -

<%:Providing Gateway%><%=gateway_provided%>

@@ -46,7 +40,7 @@

<%=iface.name%><%=iface.status%> <%=iface.sec%> <%=iface.conn%>> <%:Connected Clients%> - <% if luci.sys.call("opkg list-installed |grep luci-commotion-debug") then %> + <% if sys.exec("opkg list-installed |grep luci-commotion-debug") then %>
  • > <%:Debug Report%>
  • From 2d391e4d8f586ee9a982e2fbe4794d72057bb031 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 20:48:11 -0500 Subject: [PATCH 057/196] added exit codes to uci-track scripts to allow openwrt to delete them on success and corrected a minor error assigning adhoc to the ap --- files/etc/uci-defaults/luci-commotion-setup | 4 +++- files/etc/uci-defaults/luci-serval | 2 ++ files/etc/uci-defaults/ucitrack-updates | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/files/etc/uci-defaults/luci-commotion-setup b/files/etc/uci-defaults/luci-commotion-setup index 8f2ec4b..b05c33a 100755 --- a/files/etc/uci-defaults/luci-commotion-setup +++ b/files/etc/uci-defaults/luci-commotion-setup @@ -7,5 +7,7 @@ uci_add wireless wifi-iface commotionAP uci_set wireless commotionAP mode ap uci_set wireless commotionAP network client uci_add wireless wifi-iface commotionMesh -uci_set wireless commotionAP mode adhoc +uci_set wireless commotionMesh mode adhoc uci_commit wireless + +exit 0 diff --git a/files/etc/uci-defaults/luci-serval b/files/etc/uci-defaults/luci-serval index 1f853d2..0c3e444 100755 --- a/files/etc/uci-defaults/luci-serval +++ b/files/etc/uci-defaults/luci-serval @@ -12,3 +12,5 @@ uci_set serval settings update_mdp_keyring false uci_set serval settings new_mdp_keyring false uci_commit serval /etc/init.d/serval enable + +exit 0 diff --git a/files/etc/uci-defaults/ucitrack-updates b/files/etc/uci-defaults/ucitrack-updates index 246fe81..5400c38 100755 --- a/files/etc/uci-defaults/ucitrack-updates +++ b/files/etc/uci-defaults/ucitrack-updates @@ -7,3 +7,5 @@ uci_add ucitrack nodogsplash nodogsplash uci_set ucitrack nodogsplash init ucidog uci_commit ucitrack /etc/init.d/ucidog enable + +exit 0 From 37ad1627c0b791519021bcf7133d33b4621de3ea Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 20:54:02 -0500 Subject: [PATCH 058/196] updated the menu ordering of various nodes as well as adding in some missing requirements and a note to add in a setup_wizard-end setting that will toggle the setup wizard function off after completion --- luasrc/controller/commotion/basic_config.lua | 29 +++++++++++-------- luasrc/controller/commotion/client_config.lua | 6 ++-- luasrc/model/cbi/commotion/basic_ns.lua | 3 ++ luasrc/model/cbi/commotion/basic_wn.lua | 1 + 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index 6ab9116..3ef5dd8 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -30,9 +30,22 @@ module ("luci.controller.commotion.basic_config", package.seeall) local db = require "luci.commotion.debugger" function index() - + entry({"admin", "commotion"}, alias("admin", "commotion", "basic"), translate("Commotion"), 20) + local page = node() + page.lock = true + page.target = alias("commotion") + page.subindex = true + page.index = false + + local root = node() + if not root.lock then + root.target = alias("commotion") + root.index = true + end + + local QS = require "luci.commotion.setup_wizard" local redir = luci.http.formvalue("redir", true) or @@ -51,26 +64,18 @@ function index() sva.hidden = true if QS.status() then - local root = node() - root.target = alias("commotion", "setup_wizard") - root.index = true + entry({"commotion"}, alias("commotion", "setup_wizard")) local confirm = {on_success_to={"admin", "commotion", "confirm"}} entry({"commotion", "setup_wizard"}, cbi("commotion/setup_wizard", confirm), translate("Basic Configuration"), 15).hidden=true else - local root = node() - if not root.lock then - root.target = alias("apps") - root.index = true - end - entry({"commotion"}, alias("apps")) --Create regular "Basic Config" menu. - entry({"admin", "commotion", "basic"}, alias("admin", "commotion", "basic", "node_settings"), translate("Basic Configuration"), 10).index = true + entry({"admin", "commotion", "basic"}, alias("admin", "commotion", "basic", "node_settings"), translate("Basic Configuration"), 25).index = true --No Subsection for Node Settings? - entry({"admin", "commotion", "basic", "node_settings"}, cbi("commotion/basic_ns", {hideapplybtn=true, hideresetbtn=true}), translate("Node Settings"), 20).subsection=true + entry({"admin", "commotion", "basic", "node_settings"}, cbi("commotion/basic_ns", {hideapplybtn=true, hideresetbtn=true}), translate("Node Settings"), 25).subsection=true --Subsection Network Settings entry({"admin", "commotion", "basic", "network_settings"}, alias("admin", "commotion", "basic", "mesh_network"), translate("Network Settings"), 30).subsection=true diff --git a/luasrc/controller/commotion/client_config.lua b/luasrc/controller/commotion/client_config.lua index eb1b1fa..3e1596d 100644 --- a/luasrc/controller/commotion/client_config.lua +++ b/luasrc/controller/commotion/client_config.lua @@ -15,8 +15,8 @@ You may obtain a copy of the License at module "luci.controller.commotion.client_config" function index() - entry({"admin", "commotion", "client"}, alias("admin", "commotion", "client", "welcome_page"), translate("Client Controls"), 20) - entry({"admin", "commotion", "client", "welcome_page"}, cbi("commotion/client_wp", {hideapplybtn=true, hideresetbtn=true}), translate("Welcome Page"), 30).index = true - entry({"admin", "commotion", "client", "bandwidth_controls"}, cbi("commotion/client_bc", {hideapplybtn=true, hideresetbtn=true}), translate("Bandwidth Controls"), 40) + entry({"admin", "commotion", "client"}, alias("admin", "commotion", "client", "welcome_page"), translate("Client Controls"), 30) + entry({"admin", "commotion", "client", "welcome_page"}, cbi("commotion/client_wp", {hideapplybtn=true, hideresetbtn=true}), translate("Welcome Page"), 40).index = true + entry({"admin", "commotion", "client", "bandwidth_controls"}, cbi("commotion/client_bc", {hideapplybtn=true, hideresetbtn=true}), translate("Bandwidth Controls"), 50) end diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index 60b1b2a..f41de7f 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -26,6 +26,9 @@ local m = Map("system", translate("Basic Configuration"), translate("In this sec --redirect on saved and changed to check changes. if not SW.status() then m.on_after_save = cdisp.conf_page +else + db.log("TODO") + --! TODO have network settings section add in a option to end quickstart that will be set in the last step on the confirmation page. end --load up system section diff --git a/luasrc/model/cbi/commotion/basic_wn.lua b/luasrc/model/cbi/commotion/basic_wn.lua index 3d680f8..35c321d 100644 --- a/luasrc/model/cbi/commotion/basic_wn.lua +++ b/luasrc/model/cbi/commotion/basic_wn.lua @@ -22,6 +22,7 @@ local db = require "luci.commotion.debugger" local http = require "luci.http" local SW = require "luci.commotion.setup_wizard" local cdisp = require "luci.commotion.dispatch" +local ccbi = require "luci.commotion.ccbi" local m = Map("wireless", translate("Wireless Network"), translate("Turning on an Access Point provides a wireless network for people to connect to using a laptop or other wireless devices.")) From 8d757f3f9f021406224a6e38034973287ed8d73e Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Wed, 11 Dec 2013 20:55:06 -0500 Subject: [PATCH 059/196] added the begginings of a welcome page. Still need graphics and some logic behind it. --- luasrc/view/commotion/meshprofile.htm | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 luasrc/view/commotion/meshprofile.htm diff --git a/luasrc/view/commotion/meshprofile.htm b/luasrc/view/commotion/meshprofile.htm new file mode 100644 index 0000000..209602a --- /dev/null +++ b/luasrc/view/commotion/meshprofile.htm @@ -0,0 +1,32 @@ +<%# +Copyright (C) 2013 Seamus Tuohy + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + + You should have received a copy of the GNU General Public License +along with this program. If not, see . +%> + +<%+header%> + +

    <%:Welcome to Commotion%>

    + +

    <%:This router has not yet been set up. Use the Setup Wizard for step-by-step configuration, upload a configuration file if you have one from a previously configured router, or choose Advanced for manual GUI or CLI configuration.%>

    + +
    + +
    + +<%+footer%> From 5406392b476552e9b4e42869aa385b00ceb448b7 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 09:23:57 -0500 Subject: [PATCH 060/196] added welcome page to quickstart process. --- luasrc/controller/commotion/basic_config.lua | 24 +++++++++---- luasrc/view/commotion/welcome.htm | 36 ++++++++++++++++++++ 2 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 luasrc/view/commotion/welcome.htm diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index 3ef5dd8..a9a7c2f 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -30,6 +30,7 @@ module ("luci.controller.commotion.basic_config", package.seeall) local db = require "luci.commotion.debugger" function index() + local SW = require "luci.commotion.setup_wizard" entry({"admin", "commotion"}, alias("admin", "commotion", "basic"), translate("Commotion"), 20) @@ -43,10 +44,7 @@ function index() if not root.lock then root.target = alias("commotion") root.index = true - end - - - local QS = require "luci.commotion.setup_wizard" + end local redir = luci.http.formvalue("redir", true) or luci.dispatcher.build_url(unpack(luci.dispatcher.context.request)) @@ -63,8 +61,11 @@ function index() sva.query = {redir=redir} sva.hidden = true - if QS.status() then - entry({"commotion"}, alias("commotion", "setup_wizard")) + if SW.status() then + entry({"commotion"}, alias("commotion", "welcome")) + entry({"commotion", "welcome"}, template("commotion/welcome"), translate("Welcome to Commotion")).hidden = true + entry({"commotion", "advanced"}, call("advanced")).hidden = true + local confirm = {on_success_to={"admin", "commotion", "confirm"}} entry({"commotion", "setup_wizard"}, cbi("commotion/setup_wizard", confirm), translate("Basic Configuration"), 15).hidden=true @@ -86,6 +87,17 @@ function index() end end +function advanced() + local uci = require "luci.model.uci".cursor() + local disp = require "luci.dispatcher" + local http = require "luci.http" + + uci:set("setup_wizard", "settings", "enabled", "0") + adv = disp.build_url("admin", "commotion") + http.redirect(adv) +end + + function action_changes() local uci = require "luci.model.uci".cursor() local changes = uci:changes() diff --git a/luasrc/view/commotion/welcome.htm b/luasrc/view/commotion/welcome.htm new file mode 100644 index 0000000..9cb3f00 --- /dev/null +++ b/luasrc/view/commotion/welcome.htm @@ -0,0 +1,36 @@ +<%# +Copyright (C) 2013 Seamus Tuohy + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + + You should have received a copy of the GNU General Public License +along with this program. If not, see . +%> +<%+header%> +<%- + local disp = require "luci.dispatcher" + local http = require "luci.http" + setup = disp.build_url("commotion", "setup_wizard") + advanced = disp.build_url("commotion", "advanced") + +-%> + +

    <%:Welcome to Commotion%>

    + +

    <%:This router has not yet been set up. Use the Setup Wizard for step-by-step configuration, upload a configuration file if you have one from a previously configured router, or choose Advanced for manual GUI or CLI configuration.%>

    + +
    + +
    +<%+footer%> From cac494eff37138ea8b1bea9260fffcd13f5f99be Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 09:26:07 -0500 Subject: [PATCH 061/196] added non admin confirmation menu to setup_wizard process --- luasrc/controller/commotion/basic_config.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index a9a7c2f..2e4078e 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -67,9 +67,22 @@ function index() entry({"commotion", "advanced"}, call("advanced")).hidden = true - local confirm = {on_success_to={"admin", "commotion", "confirm"}} + local confirm = {on_success_to={"commotion", "confirm"}} entry({"commotion", "setup_wizard"}, cbi("commotion/setup_wizard", confirm), translate("Basic Configuration"), 15).hidden=true + sw_cnfm = entry({"commotion", "confirm"}, call("action_changes"), translate("Confirm"), 40) + sw_cnfm.query = {redir=redir} + sw_cnfm.hidden = true + + sw_rvt = entry({"commotion", "revert"}, call("action_revert")) + sw_rvt.query = {redir=redir} + sw_rvt.hidden = true + + sw_sva = entry({"commotion", "saveapply"}, call("action_apply")) + sw_sva.query = {redir=redir} + sw_sva.hidden = true + + else entry({"commotion"}, alias("apps")) --Create regular "Basic Config" menu. From 2d06a969d5c78a1304dadc5b2473c5be003b3c89 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 10:43:52 -0500 Subject: [PATCH 062/196] fixed broken link --- luasrc/view/commotion/welcome.htm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/luasrc/view/commotion/welcome.htm b/luasrc/view/commotion/welcome.htm index 9cb3f00..39d2300 100644 --- a/luasrc/view/commotion/welcome.htm +++ b/luasrc/view/commotion/welcome.htm @@ -15,12 +15,12 @@ along with this program. If not, see . %> <%+header%> + <%- local disp = require "luci.dispatcher" local http = require "luci.http" setup = disp.build_url("commotion", "setup_wizard") advanced = disp.build_url("commotion", "advanced") - -%>

    <%:Welcome to Commotion%>

    @@ -29,8 +29,8 @@

    <%:Welcome to Commotion%>

    <%+footer%> From 8fb9e577ed5c894e8c7fec1b24410e6dc4305b52 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 10:44:50 -0500 Subject: [PATCH 063/196] changed header to represent the setup wizard process --- luasrc/controller/commotion/basic_config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index 2e4078e..12bfc89 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -68,7 +68,7 @@ function index() local confirm = {on_success_to={"commotion", "confirm"}} - entry({"commotion", "setup_wizard"}, cbi("commotion/setup_wizard", confirm), translate("Basic Configuration"), 15).hidden=true + entry({"commotion", "setup_wizard"}, cbi("commotion/setup_wizard", confirm), translate("Setup Wizard"), 15).hidden=true sw_cnfm = entry({"commotion", "confirm"}, call("action_changes"), translate("Confirm"), 40) sw_cnfm.query = {redir=redir} From 09e8adec572c33e541ed072dc5d2f29f59a8ef01 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 13:43:28 -0500 Subject: [PATCH 064/196] removed unneeded, and error filled line about enabling a init script from uci-defaults scripts --- files/etc/uci-defaults/luci-serval | 1 - files/etc/uci-defaults/ucitrack-updates | 1 - 2 files changed, 2 deletions(-) diff --git a/files/etc/uci-defaults/luci-serval b/files/etc/uci-defaults/luci-serval index 0c3e444..52ec833 100755 --- a/files/etc/uci-defaults/luci-serval +++ b/files/etc/uci-defaults/luci-serval @@ -11,6 +11,5 @@ uci_set serval settings update_primary_keyring false uci_set serval settings update_mdp_keyring false uci_set serval settings new_mdp_keyring false uci_commit serval -/etc/init.d/serval enable exit 0 diff --git a/files/etc/uci-defaults/ucitrack-updates b/files/etc/uci-defaults/ucitrack-updates index 5400c38..b902b81 100755 --- a/files/etc/uci-defaults/ucitrack-updates +++ b/files/etc/uci-defaults/ucitrack-updates @@ -6,6 +6,5 @@ config_load ucitrack uci_add ucitrack nodogsplash nodogsplash uci_set ucitrack nodogsplash init ucidog uci_commit ucitrack -/etc/init.d/ucidog enable exit 0 From fd415e2a2080827cd176c07ecb97b2500b032073 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 13:46:06 -0500 Subject: [PATCH 065/196] fixed bugs relating to apllying on quickstart which meant that I had to copy the application functions into a script that did not require root --- luasrc/controller/commotion/basic_config.lua | 6 +- luasrc/controller/commotion/setup_ctl.lua | 66 ++++++++++++++++++++ luasrc/model/cbi/commotion/setup_wizard.lua | 8 ++- luasrc/view/commotion/apply.htm | 2 +- luasrc/view/commotion/apply_xhr.htm | 43 +++++++++++++ luasrc/view/commotion/confirm.htm | 12 +++- 6 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 luasrc/controller/commotion/setup_ctl.lua create mode 100644 luasrc/view/commotion/apply_xhr.htm diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index 12bfc89..8fa1025 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -68,8 +68,8 @@ function index() local confirm = {on_success_to={"commotion", "confirm"}} - entry({"commotion", "setup_wizard"}, cbi("commotion/setup_wizard", confirm), translate("Setup Wizard"), 15).hidden=true - + entry({"commotion", "setup_wizard"}, cbi("commotion/setup_wizard", confirm, {noheader = true}), translate("Setup Wizard"), 15).hidden=true + sw_cnfm = entry({"commotion", "confirm"}, call("action_changes"), translate("Confirm"), 40) sw_cnfm.query = {redir=redir} sw_cnfm.hidden = true @@ -136,7 +136,7 @@ function action_apply() end end - luci.template.render("admin_uci/apply", { + luci.template.render("commotion/apply", { changes = next(changes) and changes, configs = reload }) diff --git a/luasrc/controller/commotion/setup_ctl.lua b/luasrc/controller/commotion/setup_ctl.lua new file mode 100644 index 0000000..9acbc7f --- /dev/null +++ b/luasrc/controller/commotion/setup_ctl.lua @@ -0,0 +1,66 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2010 Jo-Philipp Wich + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id: servicectl.lua 9558 2012-12-18 13:58:22Z jow $ +]]-- + +module("luci.controller.commotion.setup_ctl", package.seeall) + +function index() + SW = require "luci.commotion.setup_wizard" + if SW.status() then + entry({"setupctl"}, alias("setupctl", "status")) + entry({"setupctl", "status"}, call("action_status")).leaf = true + else + entry({"setupctl"}, alias("setupctl", "status")).sysauth = "root" + entry({"setupctl", "status"}, call("action_status")).leaf = true + end + entry({"setupctl", "restart"}, call("action_restart")).leaf = true +end + +function action_status() + local data = nixio.fs.readfile("/var/run/luci-reload-status") + if data then + luci.http.write("/etc/config/") + luci.http.write(data) + else + luci.http.write("finish") + end +end + +function action_restart(args) + local uci = require "luci.model.uci".cursor() + if args then + local service + local services = { } + + for service in args:gmatch("[%w_-]+") do + services[#services+1] = service + end + + local command = uci:apply(services, true) + if nixio.fork() == 0 then + local i = nixio.open("/dev/null", "r") + local o = nixio.open("/dev/null", "w") + + nixio.dup(i, nixio.stdin) + nixio.dup(o, nixio.stdout) + + i:close() + o:close() + + nixio.exec("/bin/sh", unpack(command)) + else + luci.http.write("OK") + os.exit(0) + end + end +end diff --git a/luasrc/model/cbi/commotion/setup_wizard.lua b/luasrc/model/cbi/commotion/setup_wizard.lua index 37ebb3a..2ad14ab 100644 --- a/luasrc/model/cbi/commotion/setup_wizard.lua +++ b/luasrc/model/cbi/commotion/setup_wizard.lua @@ -3,12 +3,18 @@ local cursor = require "luci.model.uci".cursor() local d = Delegator() d.allow_finish = true d.allow_back = true -d.allow_cancel = false +d.allow_cancel = true d.allow_reset = true +d.template = "cbi/commotion/delegator" +function d.on_cancel() +-- d.nodes["Additional Network Interfaces"] = nil + return true +end d:add("Node Settings", "commotion/basic_ns") d:add("Mesh Network", "commotion/basic_mn") d:add("Wireless Network", "commotion/basic_wn") +d:add("Configuration Complete", "commotion/basic_done") d:add("Additional Network Interfaces", "commotion/basic_ani") function d.on_done() diff --git a/luasrc/view/commotion/apply.htm b/luasrc/view/commotion/apply.htm index f2127e3..264aeed 100644 --- a/luasrc/view/commotion/apply.htm +++ b/luasrc/view/commotion/apply.htm @@ -18,7 +18,7 @@

    <%:Applying Changes%>

    <% if changes then %> - <%+cbi/apply_xhr%> + <%+commotion/apply_xhr%> <%+admin_uci/changelog%> <%- cbi_apply_xhr('uci-apply', configs) -%> diff --git a/luasrc/view/commotion/apply_xhr.htm b/luasrc/view/commotion/apply_xhr.htm new file mode 100644 index 0000000..87734f6 --- /dev/null +++ b/luasrc/view/commotion/apply_xhr.htm @@ -0,0 +1,43 @@ +<% export("cbi_apply_xhr", function(id, configs, redirect) -%> +
    + <%:Applying changes%> + + + <%:Loading%> + <%:Waiting for changes to be applied...%> +
    +<%- end) %> diff --git a/luasrc/view/commotion/confirm.htm b/luasrc/view/commotion/confirm.htm index 98eea7a..04fc8ab 100644 --- a/luasrc/view/commotion/confirm.htm +++ b/luasrc/view/commotion/confirm.htm @@ -47,13 +47,23 @@

    Review the settings you have chosen below. To finish the Setup Wizard click

    <% end %> - + <% SW = require "luci.commotion.setup_wizard" + sw_stat = SW.status()%>
    + <%if sw_stat then%> +
    + <%else%> + <%end%> + " />
    + <%if sw_stat then%> +
    + <%else%> + <%end%> " />
    From 144b39a0ece867e77e4dae2e3a1cce468a4442b9 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 13:47:11 -0500 Subject: [PATCH 066/196] created side menu capabilities in setup wizard, as well as early finish capabilities. --- luasrc/model/cbi/commotion/basic_done.lua | 25 ++++++++++++ luasrc/model/cbi/commotion/basic_ns.lua | 2 +- luasrc/view/cbi/commotion/delegator.htm | 49 +++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 luasrc/model/cbi/commotion/basic_done.lua create mode 100644 luasrc/view/cbi/commotion/delegator.htm diff --git a/luasrc/model/cbi/commotion/basic_done.lua b/luasrc/model/cbi/commotion/basic_done.lua new file mode 100644 index 0000000..fce4f61 --- /dev/null +++ b/luasrc/model/cbi/commotion/basic_done.lua @@ -0,0 +1,25 @@ +--[[ + Copyright (C) 2013 Seamus Tuohy + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + + You should have received a copy of the GNU General Public License +along with this program. If not, see . +]]-- + +m = Map("system", translate("Basic Configuration Complete!"), translate("You have completed all of the required steps to configure this mesh node.")) +m.skip_to_end = true + +s = m:section(SimpleSection, "stuff", "", translate("If you would like to configure additional network interfaces on this node, continue to Additional Network Settings below. Otherwise click Review & Apply.")) +s.anonymous = true + + +return m diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index f41de7f..55f3fd7 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -28,7 +28,7 @@ if not SW.status() then m.on_after_save = cdisp.conf_page else db.log("TODO") - --! TODO have network settings section add in a option to end quickstart that will be set in the last step on the confirmation page. + --! TODO have network settings section add in a option to end quickstart that will be set in the last step on the confirmation page. Or possibly do this in the last step in case they exit out after this? But, it wont save either way I don't think. Test on restart after this step to see if it does. end --load up system section diff --git a/luasrc/view/cbi/commotion/delegator.htm b/luasrc/view/cbi/commotion/delegator.htm new file mode 100644 index 0000000..770d4c2 --- /dev/null +++ b/luasrc/view/cbi/commotion/delegator.htm @@ -0,0 +1,49 @@ +<%+header%> +
    +
    + + + +
    +
    +
    + <% for _, x in ipairs(self.chain) do + local title = translate(x) + -%> + <%if x == self.current then%> +
    + <%else%> +
    + <%end%> +

    "<%=title%>" +

    +
    + <% end %> +
    +
    +
    + <%- self.active:render() %> +
    + +<% for _, x in ipairs(self.chain) do %> + +<% end %> +<% if not self.disallow_pageactions then %> + +<% if self.allow_finish and not self:get_next(self.current) then %> + +<% elseif self:get_next(self.current) then %> + +<% end %> +<% if self.current == "Configuration Complete" then %> + +<% end %> +<% if self.allow_reset then %> + +<% end %> +<% if self.allow_back and self:get_prev(self.current) then %> + +<% end %> +<% end %> + +
    From dde2a3162aa388baa3e4d52904a21591c0c41667 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 17:08:05 -0500 Subject: [PATCH 067/196] Added in node-id identifier to the end of the hostname. NOTE that this will have to be removed when we implement any of the threat model as it creates an identifier that is unique to the device. Though, it will be a great way to track down stolen and re-flashed nodes. --- luasrc/model/cbi/commotion/basic_ns.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index 55f3fd7..fa2aac1 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -19,7 +19,7 @@ local SW = require "luci.commotion.setup_wizard" local db = require "luci.commotion.debugger" local uci = require "luci.model.uci".cursor() local cdisp = require "luci.commotion.dispatch" - +local cnet = require "luci.commotion.network" --Main title and system config map for hostname value local m = Map("system", translate("Basic Configuration"), translate("In this section you'll set the basic required settings for this device, and the basic network settings required to connect this device to a Commotion Mesh network. You will be prompted to save your settings along the way and apply them at the end.")) @@ -38,6 +38,11 @@ shn.anonymous = true --Create a value field for hostname local hname = shn:option(Value, "hostname", translate("Node Name"), translate("The node name (hostname) is a unique name for this device, visible to other devices and users on the network. Name this device in the field provided.")) +function hname.write(self, section, value) + local node_id = cnet.nodeid() + local new_hn = value.."-"..string.sub(node_id, 1, 10) + return self.map:set(section, section, new_hn) +end --PASSWORDS From 393ab616abe38ac04745fba99681306febb0947e Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 17:11:58 -0500 Subject: [PATCH 068/196] created a more descriptive name for ucitrack-updates --- files/etc/uci-defaults/{ucitrack-updates => luci-nodog} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename files/etc/uci-defaults/{ucitrack-updates => luci-nodog} (100%) diff --git a/files/etc/uci-defaults/ucitrack-updates b/files/etc/uci-defaults/luci-nodog similarity index 100% rename from files/etc/uci-defaults/ucitrack-updates rename to files/etc/uci-defaults/luci-nodog From fa0e2815cf636187417c44371f1ca21a3caa191e Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 17:17:08 -0500 Subject: [PATCH 069/196] Added a setup_wizard config. Will have to add a setting to save on saved settings sysupgrade later. --- files/etc/config/setup_wizard | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 files/etc/config/setup_wizard diff --git a/files/etc/config/setup_wizard b/files/etc/config/setup_wizard new file mode 100644 index 0000000..1b44fa2 --- /dev/null +++ b/files/etc/config/setup_wizard @@ -0,0 +1,5 @@ +config settings settings + option enabled = '0' + +config uci tracking + option adminPass = 'false' \ No newline at end of file From 29b63d1420acdd1ffc6b79f325093a502e5d061b Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 17:18:36 -0500 Subject: [PATCH 070/196] Actually added the config setting to turn it on by default.. --- files/etc/config/setup_wizard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/etc/config/setup_wizard b/files/etc/config/setup_wizard index 1b44fa2..c6068d0 100644 --- a/files/etc/config/setup_wizard +++ b/files/etc/config/setup_wizard @@ -1,5 +1,5 @@ config settings settings - option enabled = '0' + option enabled = '1' config uci tracking option adminPass = 'false' \ No newline at end of file From fc26b80784108cc02dd43237e9fdd3d77e6865ec Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 18:32:36 -0500 Subject: [PATCH 071/196] added basic functionality for status header. Still need failsafe values and prettifying --- luasrc/controller/commotion/status_config.lua | 97 ++++++++++++++++++- 1 file changed, 93 insertions(+), 4 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index b2b0bfd..86a680a 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -31,11 +31,39 @@ end function status_builder(page, assets, active_tab) + local uci = require "luci.model.uci".cursor() + local cnet = require "luci.commotion.network" + ifaces = {} + zone_iface = cnet.list_ifaces() + splash_info = get_splash_iface_info() + uci:foreach("wireless", "wifi-iface", + function(s) + local name = s['.name'] + local device = s.device + local status = nil + local zone = zone_iface[s.network] + if uci:get("wireless", "wifi-device", device, "disabled") == '1' then + status = "Off" + else + status = "On" + end + if s.encryption then + local sec = "Secured" + else + local sec = "Unsecured" + end + local conn = splash_info[zone].connected + table.insert(ifaces, {name=name, status=status, sec=sec, conn=conn}) + end) + + --[[ ifaces = {{name="interface one", status="On", sec="Secured", conn="22"}} - gw = "Yes" + gw = "Yes"]]-- + + luci.template.render("commotion/status", {ifaces=ifaces, gateway_provided=gw, page=page, assets=assets, active_tab=active_tab}) end @@ -44,14 +72,74 @@ function viz() end function conn_clnts() + clients = get_client_splash_info() + status_builder("commotion/conn_clients", {clients=clients}, "connected_clients") +end + +--! @brief currently only gets number of connected clients... because that is what I needed +function get_iface_splash_info() + local splash = {} + local interface = nil + for line in util.execi("ndsctl status") do + string.gsub(i, "^(.-):%s(.*)$", + function(key, val) + if key == "Managed interface" then + interface = val + splash[interface] = {} + end + if key = "Current clients" then + splash[interface].connected = val + end + end) + end + return splash + + --[[================== +NoDogSplash Status +==== +Version: 0.9_beta9.9.6 +Uptime: 826d 6h 44m 26s +Gateway Name: Commotion +Managed interface: wlan0 +Managed IP range: 0.0.0.0/0 +Server listening: 103.6.53.1:2050 +Splashpage: /etc/nodogsplash/htdocs/splash.html +Traffic control: no +Total download: 0 kByte; avg: 0 kbit/s +Total upload: 0 kByte; avg: 0 kbit/s +==== +Client authentications since start: 0 +Httpd request threads created/current: 1/0 +Current clients: 1 + +Client 0 + IP: 103.6.53.62 MAC: 10:0b:a9:ca:7b:14 + Added: Thu Dec 12 22:38:10 2013 + Active: Thu Dec 12 22:38:10 2013 + Active duration: 0d 0h 0m 0s + Added duration: 0d 0h 1m 2s + Token: 31707a48 + State: Preauthenticated + Download: 0 kByte; avg: 0 kbit/s + Upload: 0 kByte; avg: 0 kbit/s + +==== +Blocked MAC addresses: none +Allowed MAC addresses: N/A +Trusted MAC addresses: none +======== + ]]-- +end + +function get_client_splash_info() local convert = function(x) - return tostring(tonumber(x)*60).." "..translate(minutes) + return tostring(tonumber(x)*60).." "..translate("minutes") end local function total_kB(a, b) return tostring(a+b).." kByte" end local function total_kb(a, b) return tostring(a+b).." kbit/s" end local clients = {} i = 0 - for line in util.execi("ndsctl status") do + for line in util.execi("ndsctl clients") do if string.match(line, "^%d*$") then i = i + 1 end @@ -66,9 +154,10 @@ function conn_clnts() clients[i].avg_spd = total_kb(clients[i].avg_down_speed, clients[i].avg_up_speed) end end - status_builder("commotion/conn_clients", {clients=clients}, "connected_clients") + return clients end + function dbg_rpt() status_builder("commotion/debug", nil, "debug_report") end From dfd89ac29852651667a5e0153add83f8245d926d Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 18:35:33 -0500 Subject: [PATCH 072/196] added failsafes to interface values --- luasrc/controller/commotion/status_config.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index 86a680a..b7565f2 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -53,7 +53,12 @@ function status_builder(page, assets, active_tab) local sec = "Unsecured" end local conn = splash_info[zone].connected - table.insert(ifaces, {name=name, status=status, sec=sec, conn=conn}) + if name then + table.insert(ifaces, {name=name, + status=status, + sec=sec or "Unsecured", + conn=conn or 0}) + end end) --[[ From a4ebb6cfdfa365730848307cf61558208c5368d4 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 19:13:11 -0500 Subject: [PATCH 073/196] Added simple gateway checker... Not proud of it, but it is there. --- luasrc/controller/commotion/status_config.lua | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index b7565f2..d110c38 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -33,9 +33,10 @@ end function status_builder(page, assets, active_tab) local uci = require "luci.model.uci".cursor() local cnet = require "luci.commotion.network" - ifaces = {} - zone_iface = cnet.list_ifaces() - splash_info = get_splash_iface_info() + local ifaces = {} + local gw = "No" + local zone_iface = cnet.list_ifaces() + local splash_info = get_splash_iface_info() uci:foreach("wireless", "wifi-iface", function(s) local name = s['.name'] @@ -57,18 +58,17 @@ function status_builder(page, assets, active_tab) table.insert(ifaces, {name=name, status=status, sec=sec or "Unsecured", - conn=conn or 0}) + conn=conn or "0"}) end end) - - --[[ - ifaces = {{name="interface one", - status="On", - sec="Secured", - conn="22"}} - gw = "Yes"]]-- - - + for line in util.execi("route -n") do + string.gsub(line, "^0%.0%.0%.0%[%s%t]+(%d+%.%d+)%.%d+%.%d)+[%s%t].+eth0$", + function(x) + if string.match(x, "^100%.64^") or string.match(x, "10%.%d+^") then + gw = "Yes" + end + end) + end luci.template.render("commotion/status", {ifaces=ifaces, gateway_provided=gw, page=page, assets=assets, active_tab=active_tab}) end @@ -86,7 +86,7 @@ function get_iface_splash_info() local splash = {} local interface = nil for line in util.execi("ndsctl status") do - string.gsub(i, "^(.-):%s(.*)$", + string.gsub(line, "^(.-):%s(.*)$", function(key, val) if key == "Managed interface" then interface = val From 253a559f5a5b86bfb5f78d24d1243405f4c3d2b7 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 12 Dec 2013 20:15:57 -0500 Subject: [PATCH 074/196] added links to take users from the confirmation and revoktion pages to the start of setup wizard and from the application page to the advanced menu. --- luasrc/view/commotion/apply.htm | 1 + luasrc/view/commotion/confirm.htm | 8 +++++--- luasrc/view/commotion/revert.htm | 8 ++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/luasrc/view/commotion/apply.htm b/luasrc/view/commotion/apply.htm index 264aeed..4040579 100644 --- a/luasrc/view/commotion/apply.htm +++ b/luasrc/view/commotion/apply.htm @@ -28,5 +28,6 @@

    <%:Applying Changes%>

    <% else %>

    <%:There are no pending changes to apply!%>

    <% end %> +<%:Administration%> <%+footer%> diff --git a/luasrc/view/commotion/confirm.htm b/luasrc/view/commotion/confirm.htm index 04fc8ab..da5b942 100644 --- a/luasrc/view/commotion/confirm.htm +++ b/luasrc/view/commotion/confirm.htm @@ -26,7 +26,7 @@ -%> <%+header%> - +<%SW = require "luci.commotion.setup_wizard"%>

    <%:Confirm Configuration%>

    @@ -38,6 +38,9 @@

    Review the settings you have chosen below. To finish the Setup Wizard click <% else %>

    <%:There are no pending changes!%>

    <% end %> + <% if SW.status() = true then %> + ">Start Over. + <% end%>
    <% local r = luci.http.formvalue("redir"); if r and #r > 0 then %> @@ -47,8 +50,7 @@

    Review the settings you have chosen below. To finish the Setup Wizard click

    <% end %> - <% SW = require "luci.commotion.setup_wizard" - sw_stat = SW.status()%> + <%sw_stat = SW.status()%>
    <%if sw_stat then%>
    diff --git a/luasrc/view/commotion/revert.htm b/luasrc/view/commotion/revert.htm index 26b420e..6de496c 100644 --- a/luasrc/view/commotion/revert.htm +++ b/luasrc/view/commotion/revert.htm @@ -14,18 +14,22 @@ -%> <%+header%> +<%SW = require "luci.commotion.setup_wizard"%> -

    <%:Configuration%> / <%:Revert%>

    +

    <%:Revert%>

    <% if changes then %> <%+cbi/apply_xhr%> <%+admin_uci/changelog%> -

    <%:The following changes have been reverted%>:

    <%- uci_changelog(changes) -%> <% else %>

    <%:There are no pending changes to revert!%>

    <% end %> +<% if SW.status() = true then %> +">Start Over. +<% end%> +
    "> From 66abee4698e31422596a09947bb09fadc45cbf43 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 08:22:01 -0500 Subject: [PATCH 075/196] setup_wizard core functions are now added upon starting instead of at boot to allow for easier saved settings sysupgrade --- files/etc/uci-defaults/luci-commotion-setup | 13 ------------- luasrc/controller/commotion/basic_config.lua | 16 ++++++++++++++-- luasrc/view/commotion/welcome.htm | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) delete mode 100755 files/etc/uci-defaults/luci-commotion-setup diff --git a/files/etc/uci-defaults/luci-commotion-setup b/files/etc/uci-defaults/luci-commotion-setup deleted file mode 100755 index b05c33a..0000000 --- a/files/etc/uci-defaults/luci-commotion-setup +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -. /etc/functions.sh -#set up all interfaces needed for the setup wizard process -config_load wireless -uci_add wireless wifi-iface commotionAP -uci_set wireless commotionAP mode ap -uci_set wireless commotionAP network client -uci_add wireless wifi-iface commotionMesh -uci_set wireless commotionMesh mode adhoc -uci_commit wireless - -exit 0 diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index 8fa1025..a2d1998 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -64,8 +64,8 @@ function index() if SW.status() then entry({"commotion"}, alias("commotion", "welcome")) entry({"commotion", "welcome"}, template("commotion/welcome"), translate("Welcome to Commotion")).hidden = true - entry({"commotion", "advanced"}, call("advanced")).hidden = true - + entry({"commotion", "advanced"}, call("advanced")).hidden = true + entry({"commotion", "setup_wizard", "start"}, call("start_setup")).hidden = true local confirm = {on_success_to={"commotion", "confirm"}} entry({"commotion", "setup_wizard"}, cbi("commotion/setup_wizard", confirm, {noheader = true}), translate("Setup Wizard"), 15).hidden=true @@ -110,6 +110,18 @@ function advanced() http.redirect(adv) end +function start_setup() + local uci = require "luci.model.uci".cursor() + local disp = require "luci.dispatcher" + local http = require "luci.http" + uci:section("wireless", "wifi-iface", "commotionAP", {mode="ap", network="client"}) + uci:section("wireless", "wifi-iface", "commotionMesh", {mode="adhoc"}) + uci:save("wireless") + uci:commit("wireless") + setup = disp.build_url("commotion", "setup_wizard") + http.redirect(setup) +end + function action_changes() local uci = require "luci.model.uci".cursor() diff --git a/luasrc/view/commotion/welcome.htm b/luasrc/view/commotion/welcome.htm index 39d2300..dc789a5 100644 --- a/luasrc/view/commotion/welcome.htm +++ b/luasrc/view/commotion/welcome.htm @@ -19,7 +19,7 @@ <%- local disp = require "luci.dispatcher" local http = require "luci.http" - setup = disp.build_url("commotion", "setup_wizard") + setup = disp.build_url("commotion", "setup_wizard", "start") advanced = disp.build_url("commotion", "advanced") -%> From c4c46b35bcdb4cd4789b962c723f4d400a0573f3 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 13:39:46 -0500 Subject: [PATCH 076/196] added working sidebar menu's to the setup wizard menu. --- luasrc/controller/commotion/basic_config.lua | 11 ++++--- luasrc/controller/commotion/status_config.lua | 2 +- luasrc/model/cbi/commotion/basic_ns.lua | 2 +- luasrc/model/cbi/commotion/setup_wizard.lua | 29 +++++++++++++++++-- luasrc/view/cbi/commotion/delegator.htm | 18 ++++++++++-- luasrc/view/commotion/apply.htm | 10 +++++-- luasrc/view/commotion/confirm.htm | 17 ++++++----- luasrc/view/commotion/revert.htm | 14 +++++---- 8 files changed, 78 insertions(+), 25 deletions(-) diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index a2d1998..a7e6d0f 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -62,13 +62,16 @@ function index() sva.hidden = true if SW.status() then + local sw_page = luci.http.formvalue("sw_page") or nil + entry({"commotion"}, alias("commotion", "welcome")) entry({"commotion", "welcome"}, template("commotion/welcome"), translate("Welcome to Commotion")).hidden = true - entry({"commotion", "advanced"}, call("advanced")).hidden = true - entry({"commotion", "setup_wizard", "start"}, call("start_setup")).hidden = true - + entry({"commotion", "advanced"}, call("advanced")).hidden = true + entry({"commotion", "setup_wizard", "start"}, call("start_setup")).hidden = true + local confirm = {on_success_to={"commotion", "confirm"}} - entry({"commotion", "setup_wizard"}, cbi("commotion/setup_wizard", confirm, {noheader = true}), translate("Setup Wizard"), 15).hidden=true + --Setup Wizard Delegator + entry({"commotion", "setup_wizard"}, cbi("commotion/setup_wizard", confirm, {noheader = true, sw_page=sw_page}), translate("Setup Wizard"), 15).hidden = true sw_cnfm = entry({"commotion", "confirm"}, call("action_changes"), translate("Confirm"), 40) sw_cnfm.query = {redir=redir} diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index d110c38..f0cdc13 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -92,7 +92,7 @@ function get_iface_splash_info() interface = val splash[interface] = {} end - if key = "Current clients" then + if key == "Current clients" then splash[interface].connected = val end end) diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index fa2aac1..e9e96b8 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -27,7 +27,7 @@ local m = Map("system", translate("Basic Configuration"), translate("In this sec if not SW.status() then m.on_after_save = cdisp.conf_page else - db.log("TODO") + db.log("TODO add option to end quickstart!") --! TODO have network settings section add in a option to end quickstart that will be set in the last step on the confirmation page. Or possibly do this in the last step in case they exit out after this? But, it wont save either way I don't think. Test on restart after this step to see if it does. end diff --git a/luasrc/model/cbi/commotion/setup_wizard.lua b/luasrc/model/cbi/commotion/setup_wizard.lua index 2ad14ab..2710e6f 100644 --- a/luasrc/model/cbi/commotion/setup_wizard.lua +++ b/luasrc/model/cbi/commotion/setup_wizard.lua @@ -6,8 +6,8 @@ d.allow_back = true d.allow_cancel = true d.allow_reset = true d.template = "cbi/commotion/delegator" + function d.on_cancel() --- d.nodes["Additional Network Interfaces"] = nil return true end @@ -17,7 +17,32 @@ d:add("Wireless Network", "commotion/basic_wn") d:add("Configuration Complete", "commotion/basic_done") d:add("Additional Network Interfaces", "commotion/basic_ani") -function d.on_done() + +function d.parse(self, ...) + local form = luci.http.formvalue() + local db = require "luci.commotion.debugger" + local page = form.sw_page + if page ~= nil then + db.log("page["..page.."]") + d.current = page + if page == '' then + db.log("EMPTY") + d.current = nil + s.active = self.chain[1] + end + end + return Delegator.parse(self, ...) end + +--[[function d.get_next(self, state) + local form = luci.http.formvalue() + local page = form.sw_page + if page then + return d:get(state) + else + return Delegator.get_next(self, state) + end + end]]-- + return d diff --git a/luasrc/view/cbi/commotion/delegator.htm b/luasrc/view/cbi/commotion/delegator.htm index 770d4c2..98120ca 100644 --- a/luasrc/view/cbi/commotion/delegator.htm +++ b/luasrc/view/cbi/commotion/delegator.htm @@ -2,18 +2,30 @@
    +
    -
    +
    - <% for _, x in ipairs(self.chain) do + <% for i, x in ipairs(self.chain) do local title = translate(x) -%> <%if x == self.current then%>
    <%else%> -
    +
    <%end%>

    "<%=title%>"

    diff --git a/luasrc/view/commotion/apply.htm b/luasrc/view/commotion/apply.htm index 4040579..5a9352f 100644 --- a/luasrc/view/commotion/apply.htm +++ b/luasrc/view/commotion/apply.htm @@ -12,9 +12,10 @@ $Id: apply.htm 9014 2012-08-14 13:08:18Z jow $ -%> - +<%SW = require "luci.commotion.setup_wizard"%> <%+header%> +

    <%:Applying Changes%>

    <% if changes then %> @@ -28,6 +29,11 @@

    <%:Applying Changes%>

    <% else %>

    <%:There are no pending changes to apply!%>

    <% end %> -<%:Administration%> + +
    + + + +
    <%+footer%> diff --git a/luasrc/view/commotion/confirm.htm b/luasrc/view/commotion/confirm.htm index da5b942..5051a43 100644 --- a/luasrc/view/commotion/confirm.htm +++ b/luasrc/view/commotion/confirm.htm @@ -25,8 +25,9 @@ -%> +<%SW = require "luci.commotion.setup_wizard" + disp = require "luci.dispatcher"%> <%+header%> -<%SW = require "luci.commotion.setup_wizard"%>

    <%:Confirm Configuration%>

    @@ -38,19 +39,21 @@

    Review the settings you have chosen below. To finish the Setup Wizard click <% else %>

    <%:There are no pending changes!%>

    <% end %> - <% if SW.status() = true then %> - ">Start Over. - <% end%>
    - <% local r = luci.http.formvalue("redir"); if r and #r > 0 then %> + <%sw_stat = SW.status()%> + <%if sw_stat then%>
    +
    + +
    + <%end%> + <% local r = luci.http.formvalue("redir"); if r and #r > 0 then %>
    -
    <% end %> - <%sw_stat = SW.status()%> +
    <%if sw_stat then%>
    diff --git a/luasrc/view/commotion/revert.htm b/luasrc/view/commotion/revert.htm index 6de496c..d7da693 100644 --- a/luasrc/view/commotion/revert.htm +++ b/luasrc/view/commotion/revert.htm @@ -13,8 +13,8 @@ -%> -<%+header%> <%SW = require "luci.commotion.setup_wizard"%> +<%+header%>

    <%:Revert%>

    @@ -26,12 +26,16 @@

    <%:Revert%>

    <% else %>

    <%:There are no pending changes to revert!%>

    <% end %> -<% if SW.status() = true then %> -">Start Over. -<% end%> -
    + <%sw_stat = SW.status()%> + <%if sw_stat then%> +
    + + + +
    + <%end%>
    ">
    From 4742a404382cd7ff8e1bcc3a36909e83edf0d637 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 14:11:11 -0500 Subject: [PATCH 077/196] Apply now turns off quickstart if it is on. --- luasrc/view/commotion/apply.htm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/luasrc/view/commotion/apply.htm b/luasrc/view/commotion/apply.htm index 5a9352f..b6713a4 100644 --- a/luasrc/view/commotion/apply.htm +++ b/luasrc/view/commotion/apply.htm @@ -13,6 +13,13 @@ -%> <%SW = require "luci.commotion.setup_wizard"%> + +<%-if SW.status() then +local uci = require "luci.model.uci".cursor() + uci:set("setup_wizard", "settings", "enabled", "0") + uci:save("setup_wizard") + uci:commit("setup_wizard") + -%> <%+header%> From f231b7f7598729545b4f057b242d5c2559dc7942 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 14:12:27 -0500 Subject: [PATCH 078/196] now it also ends the check for setup wizard so that it does not hang forever --- luasrc/view/commotion/apply.htm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/luasrc/view/commotion/apply.htm b/luasrc/view/commotion/apply.htm index b6713a4..568dba3 100644 --- a/luasrc/view/commotion/apply.htm +++ b/luasrc/view/commotion/apply.htm @@ -14,12 +14,15 @@ -%> <%SW = require "luci.commotion.setup_wizard"%> -<%-if SW.status() then -local uci = require "luci.model.uci".cursor() - uci:set("setup_wizard", "settings", "enabled", "0") - uci:save("setup_wizard") - uci:commit("setup_wizard") - -%> +<%- + if SW.status() then + local uci = require "luci.model.uci".cursor() + uci:set("setup_wizard", "settings", "enabled", "0") + uci:save("setup_wizard") + uci:commit("setup_wizard") + end + -%> + <%+header%> From 9e6da7b6932d879ff151d992a3c999f7d25d162e Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 14:30:41 -0500 Subject: [PATCH 079/196] removed unneeded comment --- luasrc/model/cbi/commotion/basic_ns.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index e9e96b8..d6390af 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -26,9 +26,6 @@ local m = Map("system", translate("Basic Configuration"), translate("In this sec --redirect on saved and changed to check changes. if not SW.status() then m.on_after_save = cdisp.conf_page -else - db.log("TODO add option to end quickstart!") - --! TODO have network settings section add in a option to end quickstart that will be set in the last step on the confirmation page. Or possibly do this in the last step in case they exit out after this? But, it wont save either way I don't think. Test on restart after this step to see if it does. end --load up system section From 7bc13e1e69fc2a3ab1a3319d70944591739ed5d0 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 14:53:59 -0500 Subject: [PATCH 080/196] hopfully that will allow the depends statement work --- luasrc/model/cbi/commotion/basic_ani.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/luasrc/model/cbi/commotion/basic_ani.lua b/luasrc/model/cbi/commotion/basic_ani.lua index 8322852..f331690 100644 --- a/luasrc/model/cbi/commotion/basic_ani.lua +++ b/luasrc/model/cbi/commotion/basic_ani.lua @@ -35,6 +35,7 @@ p.anonymous = true msh = p:option(Flag, "meshability", translate("Will you be meshing with other Commotion devices over the ethernet interface?")) msh.enabled = "true" msh.disabled = "false" +msh.default = "false" ance = p:option(Flag, "announceability", translate("Advertise your gateway to the mesh.")) ance.enabled = "true" From 46a542edd0b6609b8b0aa20dbd283e4b138062b6 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 15:07:21 -0500 Subject: [PATCH 081/196] added controllers that will allow for admin password changes to be tracked. --- luasrc/model/cbi/commotion/basic_ns.lua | 3 +++ luasrc/view/commotion/apply.htm | 1 + 2 files changed, 4 insertions(+) diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index d6390af..2b33074 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -104,6 +104,9 @@ function m.on_commit(map) if v1 == v2 then if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then m.message = translate("Password successfully changed!") + uci:set("setup_wizard", "tracking", "adminPass", 'true') + uci:save("setup_wizard") + uci:commit("setup_wizard") else m.message = translate("Unknown Error, password not changed!") end diff --git a/luasrc/view/commotion/apply.htm b/luasrc/view/commotion/apply.htm index 568dba3..4c96665 100644 --- a/luasrc/view/commotion/apply.htm +++ b/luasrc/view/commotion/apply.htm @@ -18,6 +18,7 @@ if SW.status() then local uci = require "luci.model.uci".cursor() uci:set("setup_wizard", "settings", "enabled", "0") + uci:set("setup_wizard", "tracking", "adminPass", "false") uci:save("setup_wizard") uci:commit("setup_wizard") end From fba2e5f917dd8f37f1478260717fcc2a1fe6594f Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 15:21:14 -0500 Subject: [PATCH 082/196] added new reset button language --- luasrc/view/commotion/confirm.htm | 18 ++++++++++-------- luasrc/view/commotion/revert.htm | 5 +++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/luasrc/view/commotion/confirm.htm b/luasrc/view/commotion/confirm.htm index 5051a43..ed7e985 100644 --- a/luasrc/view/commotion/confirm.htm +++ b/luasrc/view/commotion/confirm.htm @@ -45,14 +45,15 @@

    Review the settings you have chosen below. To finish the Setup Wizard click <%if sw_stat then%>
    - +
    - <%end%> + <%else%> <% local r = luci.http.formvalue("redir"); if r and #r > 0 then %>
    - <% end %> + <% end + end%>
    <%if sw_stat then%> @@ -60,17 +61,18 @@

    Review the settings you have chosen below. To finish the Setup Wizard click <%else%>
    <%end%> - " />
    <%if sw_stat then%>
    - <%else%> + " /> + + <%else%> - <%end%> - " /> - + " /> + + <%end%>

    diff --git a/luasrc/view/commotion/revert.htm b/luasrc/view/commotion/revert.htm index d7da693..0312cf0 100644 --- a/luasrc/view/commotion/revert.htm +++ b/luasrc/view/commotion/revert.htm @@ -32,13 +32,14 @@

    <%:Revert%>

    <%if sw_stat then%>
    - +
    - <%end%> + <%else%>
    ">
    + <%end%>
    <%+footer%> From a3b7fe102cf1aa8bc517d635a811ac1b32e33bd0 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 16:22:05 -0500 Subject: [PATCH 083/196] fixed setup wizard uci errors --- files/etc/config/setup_wizard | 4 ++-- luasrc/model/cbi/commotion/setup_wizard.lua | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/files/etc/config/setup_wizard b/files/etc/config/setup_wizard index c6068d0..10477da 100644 --- a/files/etc/config/setup_wizard +++ b/files/etc/config/setup_wizard @@ -1,5 +1,5 @@ config settings settings - option enabled = '1' + option enabled '1' config uci tracking - option adminPass = 'false' \ No newline at end of file + option adminPass 'false' \ No newline at end of file diff --git a/luasrc/model/cbi/commotion/setup_wizard.lua b/luasrc/model/cbi/commotion/setup_wizard.lua index 2710e6f..a4fcbd8 100644 --- a/luasrc/model/cbi/commotion/setup_wizard.lua +++ b/luasrc/model/cbi/commotion/setup_wizard.lua @@ -1,3 +1,4 @@ +local db = require "luci.commotion.debugger" local cursor = require "luci.model.uci".cursor() local d = Delegator() @@ -20,13 +21,10 @@ d:add("Additional Network Interfaces", "commotion/basic_ani") function d.parse(self, ...) local form = luci.http.formvalue() - local db = require "luci.commotion.debugger" local page = form.sw_page if page ~= nil then - db.log("page["..page.."]") d.current = page if page == '' then - db.log("EMPTY") d.current = nil s.active = self.chain[1] end From 8a8199e085aea09006b9d147e9a7b08c7769c502 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 16:22:55 -0500 Subject: [PATCH 084/196] added correct main admin menu --- luasrc/controller/commotion/basic_config.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index a7e6d0f..765faf8 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -32,7 +32,7 @@ local db = require "luci.commotion.debugger" function index() local SW = require "luci.commotion.setup_wizard" - entry({"admin", "commotion"}, alias("admin", "commotion", "basic"), translate("Commotion"), 20) + entry({"admin", "commotion"}, alias("admin", "commotion", "status"), translate("Commotion"), 20) local page = node() page.lock = true @@ -60,7 +60,8 @@ function index() sva = entry({"admin", "commotion", "saveapply"}, call("action_apply")) sva.query = {redir=redir} sva.hidden = true - + + --IF Setup Wizard is Active if SW.status() then local sw_page = luci.http.formvalue("sw_page") or nil From e27dc6b8cefafd82fbdc110a7be7fcfb843320e0 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 16:24:36 -0500 Subject: [PATCH 085/196] fixed status builder to correctly grab client info and not break on none --- luasrc/controller/commotion/status_config.lua | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index f0cdc13..15875fd 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -14,12 +14,14 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ]]-- -module ("luci.controller.commotion.status_config", package.seeall) -local sys = require "luci.sys" local util = require "luci.util" +module ("luci.controller.commotion.status_config", package.seeall) + function index() + local sys = require "luci.sys" + entry({"admin", "commotion", "status"}, alias("admin", "commotion", "status", "nearby_md"), translate("Status"), 10) entry({"admin", "commotion", "status", "nearby_md"}, call("action_neigh")).hidden = true entry({"admin", "commotion", "status", "mesh_viz"}, call("viz")).hidden = true @@ -33,6 +35,8 @@ end function status_builder(page, assets, active_tab) local uci = require "luci.model.uci".cursor() local cnet = require "luci.commotion.network" + local db = require "luci.commotion.debugger" + local ifaces = {} local gw = "No" local zone_iface = cnet.list_ifaces() @@ -42,18 +46,24 @@ function status_builder(page, assets, active_tab) local name = s['.name'] local device = s.device local status = nil + local sec = nil + local conn = nil local zone = zone_iface[s.network] if uci:get("wireless", "wifi-device", device, "disabled") == '1' then status = "Off" else status = "On" end - if s.encryption then - local sec = "Secured" + if s.encryption == "psk2" then + sec = "Secured" else - local sec = "Unsecured" + sec = "Unsecured" + end + for i,x in pairs(splash_info) do + if zone == i then + conn = splash_info[zone].connected + end end - local conn = splash_info[zone].connected if name then table.insert(ifaces, {name=name, status=status, @@ -82,7 +92,7 @@ function conn_clnts() end --! @brief currently only gets number of connected clients... because that is what I needed -function get_iface_splash_info() +function get_splash_iface_info() local splash = {} local interface = nil for line in util.execi("ndsctl status") do From 688114fecf1fb0b78241f11554a79e22ece8a650 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 16:25:28 -0500 Subject: [PATCH 086/196] Changed some broken cbi values --- luasrc/model/cbi/commotion/basic_mn.lua | 2 +- luasrc/model/cbi/commotion/basic_ns.lua | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_mn.lua b/luasrc/model/cbi/commotion/basic_mn.lua index 26e7a3e..0fc7b01 100644 --- a/luasrc/model/cbi/commotion/basic_mn.lua +++ b/luasrc/model/cbi/commotion/basic_mn.lua @@ -95,7 +95,7 @@ if #wifi_dev > 1 then end else --Default radio (don't render this. Just add it so that it gets added to UCI when created) - radio = s:option(DummyValue, "device") + radio = s:option(Value, "device") radio.default = wifi_dev[1][1] radio.render = function() end diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index 2b33074..543f6bd 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -35,10 +35,11 @@ shn.anonymous = true --Create a value field for hostname local hname = shn:option(Value, "hostname", translate("Node Name"), translate("The node name (hostname) is a unique name for this device, visible to other devices and users on the network. Name this device in the field provided.")) + function hname.write(self, section, value) local node_id = cnet.nodeid() local new_hn = value.."-"..string.sub(node_id, 1, 10) - return self.map:set(section, section, new_hn) + return self.map:set(section, "hostname", new_hn) end --PASSWORDS From 6d591322bcdcf9255616bdeb72bb6c83643565d7 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 16:26:36 -0500 Subject: [PATCH 087/196] moved the ordering of turning off setup wizard so it does not break the page xhr --- luasrc/view/commotion/apply.htm | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/luasrc/view/commotion/apply.htm b/luasrc/view/commotion/apply.htm index 4c96665..6310831 100644 --- a/luasrc/view/commotion/apply.htm +++ b/luasrc/view/commotion/apply.htm @@ -13,17 +13,6 @@ -%> <%SW = require "luci.commotion.setup_wizard"%> - -<%- - if SW.status() then - local uci = require "luci.model.uci".cursor() - uci:set("setup_wizard", "settings", "enabled", "0") - uci:set("setup_wizard", "tracking", "adminPass", "false") - uci:save("setup_wizard") - uci:commit("setup_wizard") - end - -%> - <%+header%> @@ -46,5 +35,14 @@

    <%:Applying Changes%>

    +<%- + if SW.status() then + local uci = require "luci.model.uci".cursor() + uci:set("setup_wizard", "settings", "enabled", "0") + uci:set("setup_wizard", "tracking", "adminPass", "false") + uci:save("setup_wizard") + uci:commit("setup_wizard") + end + -%> <%+footer%> From 48e47aa6da0c18cb93e1989eb54a4bc9493d3fca Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 17:32:05 -0500 Subject: [PATCH 088/196] added proper hostname support --- luasrc/model/cbi/commotion/basic_ns.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index 543f6bd..4c2a6d2 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -29,9 +29,12 @@ if not SW.status() then end --load up system section + local shn = m:section(TypedSection, "system") --Don't display it shn.anonymous = true +--Sure as Sugar don't remove it +shn.addremove = false --Create a value field for hostname local hname = shn:option(Value, "hostname", translate("Node Name"), translate("The node name (hostname) is a unique name for this device, visible to other devices and users on the network. Name this device in the field provided.")) @@ -39,9 +42,11 @@ local hname = shn:option(Value, "hostname", translate("Node Name"), translate("T function hname.write(self, section, value) local node_id = cnet.nodeid() local new_hn = value.."-"..string.sub(node_id, 1, 10) + luci.sys.hostname(new_hn) return self.map:set(section, "hostname", new_hn) end + --PASSWORDS local v0 = true -- track password success across maps From f0c11ce70269b8292253f6d69a85afca317a45cc Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 17:33:37 -0500 Subject: [PATCH 089/196] fixed some spacing and some spelling no logic modified --- luasrc/controller/commotion/basic_config.lua | 24 +++++++++----------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index 765faf8..34f8ae2 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -73,20 +73,19 @@ function index() local confirm = {on_success_to={"commotion", "confirm"}} --Setup Wizard Delegator entry({"commotion", "setup_wizard"}, cbi("commotion/setup_wizard", confirm, {noheader = true, sw_page=sw_page}), translate("Setup Wizard"), 15).hidden = true - - sw_cnfm = entry({"commotion", "confirm"}, call("action_changes"), translate("Confirm"), 40) - sw_cnfm.query = {redir=redir} - sw_cnfm.hidden = true - - sw_rvt = entry({"commotion", "revert"}, call("action_revert")) - sw_rvt.query = {redir=redir} - sw_rvt.hidden = true - sw_sva = entry({"commotion", "saveapply"}, call("action_apply")) - sw_sva.query = {redir=redir} - sw_sva.hidden = true + --Confirmation Pages + sw_cnfm = entry({"commotion", "confirm"}, call("action_changes"), translate("Confirm"), 40) + sw_cnfm.query = {redir=redir} + sw_cnfm.hidden = true + sw_rvt = entry({"commotion", "revert"}, call("action_revert")) + sw_rvt.query = {redir=redir} + sw_rvt.hidden = true + sw_sva = entry({"commotion", "saveapply"}, call("action_apply")) + sw_sva.query = {redir=redir} + sw_sva.hidden = true else entry({"commotion"}, alias("apps")) --Create regular "Basic Config" menu. @@ -99,8 +98,7 @@ function index() entry({"admin", "commotion", "basic", "network_settings"}, alias("admin", "commotion", "basic", "mesh_network"), translate("Network Settings"), 30).subsection=true entry({"admin", "commotion", "basic", "mesh_network"}, cbi("commotion/basic_mn", {hideapplybtn=true, hideresetbtn=true}), translate("Mesh Network"), 40) entry({"admin", "commotion", "basic", "wireless_network"}, cbi("commotion/basic_wn", {hideapplybtn=true, hideresetbtn=true}), translate("Wireless Network"), 50) - entry({"admin", "commotion", "basic", "addtl_net_ifaces"}, cbi("commotion/basic_ani", {hideapplybtn=true, hideresetbtn=true}), translate("Additional Netork Interfaces"), 60) - + entry({"admin", "commotion", "basic", "addtl_net_ifaces"}, cbi("commotion/basic_ani", {hideapplybtn=true, hideresetbtn=true}), translate("Additional Network Interfaces"), 60) end end From dbdc62176a0b5c4df492ed4e992797ef4e739700 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 18:19:08 -0500 Subject: [PATCH 090/196] removed broken dependencies --- luasrc/model/cbi/commotion/basic_ani.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/luasrc/model/cbi/commotion/basic_ani.lua b/luasrc/model/cbi/commotion/basic_ani.lua index f331690..51b3881 100644 --- a/luasrc/model/cbi/commotion/basic_ani.lua +++ b/luasrc/model/cbi/commotion/basic_ani.lua @@ -36,11 +36,13 @@ msh = p:option(Flag, "meshability", translate("Will you be meshing with other Co msh.enabled = "true" msh.disabled = "false" msh.default = "false" +msh.addremove = true ance = p:option(Flag, "announceability", translate("Advertise your gateway to the mesh.")) ance.enabled = "true" ance.disabled = "false" -ance:depends("meshability", "false") +ance.addremove = true +--ance:depends("meshability", "false") --!TODO Currently Flags do not have dependance capabilities it seems. I will add and patch in R1.1 config = p:option(ListValue, "plugability", translate("Gateway Configuration")) config:value("auto", translate("Automatically configure gateway on boot.")) From 7e8af2eaedcba92eaa213b4d3e513c340c4c034c Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 13 Dec 2013 18:19:39 -0500 Subject: [PATCH 091/196] added a correct admin password check. Still need to do changed password comparisons. --- luasrc/model/cbi/commotion/basic_ns.lua | 66 ++++++++++++++++--------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index 4c2a6d2..3a8bdbf 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -20,7 +20,7 @@ local db = require "luci.commotion.debugger" local uci = require "luci.model.uci".cursor() local cdisp = require "luci.commotion.dispatch" local cnet = require "luci.commotion.network" - +local http = require "luci.http" --Main title and system config map for hostname value local m = Map("system", translate("Basic Configuration"), translate("In this section you'll set the basic required settings for this device, and the basic network settings required to connect this device to a Commotion Mesh network. You will be prompted to save your settings along the way and apply them at the end.")) --redirect on saved and changed to check changes. @@ -48,22 +48,19 @@ end --PASSWORDS - local v0 = true -- track password success across maps +-- CURRENT PASSWORD -- Allow incorrect root password to prevent settings change -- Don't prompt for password if none has been set if luci.sys.user.getpasswd("root") then - s0 = m:section(TypedSection, "_dummy", translate("Current Password"), - translate("Current password required to make changes on this page")) + s0 = m:section(TypedSection, "_dummy", translate("Current Password"), translate("Current password required to make changes on this page")) s0.addremove = false s0.anonymous = true - - pw0 = s0:option(Value, "pw0", translate("Current Password")) + pw0 = s0:option(Value, "_pw0") pw0.password = true -- fail by default v0 = false - function s0.cfgsections() return { "_pass0" } end @@ -89,34 +86,55 @@ function s.cfgsections() return { "_pass" } end -function m.on_before_commit(map) - -- if existing password, make sure user has old password - if s0 then - v0 = luci.sys.user.checkpasswd("root", formvalue("_pass0")) - end - - if v0 == false then - m.message = translate("Incorrect password. Changes rejected!") - m.save=v0 - m2.save=v0 - end +function m.on_parse(map) + local form = http.formvaluetable("cbid") + local check = nil + local conf_pass = nil + for field,val in pairs(form) do + string.gsub(field, ".-_pw(%d)$", + function(num) + if tonumber(num) == 0 then + conf_pass = val + end + if val then + check = true + end + end) + end + if check ~= nil then + if conf_pass then + v0 = luci.sys.user.checkpasswd("root", conf_pass) + if v0 ~= true then + m.message = translate("Incorrect password. Changes rejected!") + m.save = false + function m.on_after_save() return true end --Don't redirect on error + end + else + m.message = translate("Please enter your old password. Changes rejected!") + m.save = false + end + end end -function m.on_commit(map) - local v1 = pw1:formvalue("_pass") - local v2 = pw2:formvalue("_pass") +function m.on_save(map) --! @TODO this does not check any of the pasword checks with the new form. + local v1 = pw1:formvalue("_pw1") + local v2 = pw2:formvalue("_pw2") if v0 == true and v1 and v2 and #v1 > 0 and #v2 > 0 then if v1 == v2 then if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then m.message = translate("Password successfully changed!") - uci:set("setup_wizard", "tracking", "adminPass", 'true') - uci:save("setup_wizard") - uci:commit("setup_wizard") + if SW.status() then + uci:set("setup_wizard", "tracking", "adminPass", 'true') + uci:save("setup_wizard") + uci:commit("setup_wizard") + end else + --function m.on_after_save() return true end m.message = translate("Unknown Error, password not changed!") end else + --function m.on_after_save() return true end m.message = translate("Given password confirmation did not match, password not changed!") end end From 3d52ab81c87be7e5a274bb1f4904492361cffc5e Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 14 Dec 2013 10:49:52 -0500 Subject: [PATCH 092/196] updated text to mention that the user will be asked to confirm creation before being allowed configuration --- luasrc/view/cbi/commotion/addAP.htm | 2 +- luasrc/view/cbi/commotion/addMesh.htm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/luasrc/view/cbi/commotion/addAP.htm b/luasrc/view/cbi/commotion/addAP.htm index 7193bb0..cae42a8 100644 --- a/luasrc/view/cbi/commotion/addAP.htm +++ b/luasrc/view/cbi/commotion/addAP.htm @@ -1,5 +1,5 @@ <%:Access Point%> -
    <%:Turning on an Access Point provides a wireless network for people to connect to using a laptop or other wireless devices.%>
    +
    <%:Click here to create a new access point. Once created you will be able to come back to this page to configure it.%>
    <% if self.anonymous then -%> diff --git a/luasrc/view/cbi/commotion/addMesh.htm b/luasrc/view/cbi/commotion/addMesh.htm index 79ea8ae..4d48754 100644 --- a/luasrc/view/cbi/commotion/addMesh.htm +++ b/luasrc/view/cbi/commotion/addMesh.htm @@ -1,5 +1,5 @@ <%:Mesh Network%> -
    <%:Click here to add a new mesh network interface.%>
    +
    <%:Click here to add a new mesh network interface. Once created you will be able to come back to this page to configure it%>
    <%if self.map.changed ~= true then %> <% if self.anonymous then -%> From 98d29e37be1728570886efd46698f6cbd1561c7e Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 14 Dec 2013 10:50:20 -0500 Subject: [PATCH 093/196] modified where the confirm controller is located and did some clean up on passwords and datatypes --- luasrc/model/cbi/commotion/basic_ani.lua | 4 ++-- luasrc/model/cbi/commotion/basic_mn.lua | 25 +++++++------------- luasrc/model/cbi/commotion/basic_ns.lua | 19 +++++++++------ luasrc/model/cbi/commotion/basic_wn.lua | 12 ++++++---- luasrc/model/cbi/commotion/client_bc.lua | 4 ++-- luasrc/model/cbi/commotion/client_wp.lua | 4 ++-- luasrc/model/cbi/commotion/quickstart.lua | 17 ------------- luasrc/model/cbi/commotion/security_pass.lua | 20 ++++++++++++++-- luasrc/model/cbi/commotion/security_smk.lua | 4 ++-- luasrc/model/cbi/commotion/setup_wizard.lua | 16 +++++++++++++ 10 files changed, 70 insertions(+), 55 deletions(-) delete mode 100644 luasrc/model/cbi/commotion/quickstart.lua diff --git a/luasrc/model/cbi/commotion/basic_ani.lua b/luasrc/model/cbi/commotion/basic_ani.lua index 51b3881..7426547 100644 --- a/luasrc/model/cbi/commotion/basic_ani.lua +++ b/luasrc/model/cbi/commotion/basic_ani.lua @@ -20,13 +20,13 @@ local cnw = require "luci.commotion.network" local db = require "luci.commotion.debugger" local http = require "luci.http" local SW = require "luci.commotion.setup_wizard" -local cdisp = require "luci.commotion.dispatch" +local ccbi = require "luci.commotion.ccbi" m = Map("network", translate("Internet Gateway"), translate("If desired, you can configure your gateway interface here.")) --redirect on saved and changed to check changes. if not SW.status() then - m.on_after_save = cdisp.conf_page + m.on_after_save = ccbi.conf_page end p = m:section(NamedSection, "plug") diff --git a/luasrc/model/cbi/commotion/basic_mn.lua b/luasrc/model/cbi/commotion/basic_mn.lua index 0fc7b01..03ea95d 100644 --- a/luasrc/model/cbi/commotion/basic_mn.lua +++ b/luasrc/model/cbi/commotion/basic_mn.lua @@ -21,14 +21,14 @@ local cnw = require "luci.commotion.network" local db = require "luci.commotion.debugger" local http = require "luci.http" local SW = require "luci.commotion.setup_wizard" -local cdisp = require "luci.commotion.dispatch" +local ccbi = require "luci.commotion.ccbi" local m = Map("wireless", translate("Network Interfaces"), translate("Every Commotion node must have one mesh network connection or interface. Commotion can mesh over wireless or wired interfaces.")) --redirect on saved and changed to check changes. if not SW.status() then - m.on_after_save = cdisp.conf_page + m.on_after_save = ccbi.conf_page end function m.on_before_commit() @@ -41,8 +41,9 @@ s = m:section(TypedSection, "wifi-iface") if not SW.status() then --if not setup wizard then allow for adding and removal s.addremove = true - dflts = s:option(DummyValue, "_dummy_val01") --also add defaults if not in qs + dflts = s:option(Value, "_dummy_val01") --also add defaults if not in qs dflts.anonymous = true + dflts.default = true function dflts.write(self, section, value) return self.map:set(section, "mode", "adhoc") @@ -56,8 +57,6 @@ function s:filter(section) return mode == "adhoc" or mode == nil end - - s.valuefooter = "cbi/full_valuefooter" s.template_addremove = "cbi/commotion/addMesh" --This template controls the addremove form for adding a new access point so that it has better wording. @@ -94,14 +93,12 @@ if #wifi_dev > 1 then end end else - --Default radio (don't render this. Just add it so that it gets added to UCI when created) - radio = s:option(Value, "device") - radio.default = wifi_dev[1][1] - radio.render = function() end local channels = s:option(ListValue, "channel", translate("Channel"), translate("The channel of your wireless interface.")) channels.default = uci:get("wireless", wifi_dev[1][1], "channel") function channels.write(self, section, value) + local enable = self.map:set(wifi_dev[1][1], "disabled", "0") -- enable the radio + self.map:set(section, "device", wifi_dev[1][1]) --set iface to use this device. return self.map:set(wifi_dev[1][1], "channel", value) end for _,x in pairs(cnw.get_channels(wifi_dev[1][2])) do @@ -115,6 +112,7 @@ enc.enabled = "psk2" enc.rmempty = true enc.default = "none" --default must == disabled value for rmempty to work +enc.write = ccbi.flag_write --Have enc flag also remove the encryption key when deleted function enc.remove(self, section) value = self.map:get(section, self.option) @@ -126,19 +124,13 @@ function enc.remove(self, section) end end -function enc.write(self, section, fvalue) - value = self.map:get(section, self.option) - if value ~= fvalue then - self.section.changed = true - return self.map:set(section, self.option, fvalue) - end -end --dummy value set to not reveal password pw1 = s:option(Value, "_pw1", translate("Mesh Encryption Password"), translate("To encrypt data between devices, each device must share a common mesh encryption password.")) pw1.password = true pw1:depends("encryption", "psk2") +pw1.datatype = "wpakey" --password should write to the key, not to the dummy value function pw1.write(self, section, value) @@ -177,5 +169,4 @@ function pw1.validate(self, value, section) end end - return m diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index 3a8bdbf..65e55eb 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -18,14 +18,15 @@ along with this program. If not, see . local SW = require "luci.commotion.setup_wizard" local db = require "luci.commotion.debugger" local uci = require "luci.model.uci".cursor() -local cdisp = require "luci.commotion.dispatch" local cnet = require "luci.commotion.network" local http = require "luci.http" +local ccbi = require "luci.commotion.ccbi" + --Main title and system config map for hostname value local m = Map("system", translate("Basic Configuration"), translate("In this section you'll set the basic required settings for this device, and the basic network settings required to connect this device to a Commotion Mesh network. You will be prompted to save your settings along the way and apply them at the end.")) --redirect on saved and changed to check changes. if not SW.status() then - m.on_after_save = cdisp.conf_page + m.on_after_save = ccbi.conf_page end --load up system section @@ -38,6 +39,7 @@ shn.addremove = false --Create a value field for hostname local hname = shn:option(Value, "hostname", translate("Node Name"), translate("The node name (hostname) is a unique name for this device, visible to other devices and users on the network. Name this device in the field provided.")) +hname.datatype = "hostname" function hname.write(self, section, value) local node_id = cnet.nodeid() @@ -76,10 +78,11 @@ s = m:section(TypedSection, "_dummy", translate("Administration Password"), tran s.addremove = false s.anonymous = true -pw1 = s:option(Value, "pw1", translate("Password")) +pw1 = s:option(Value, "_pw1", translate("Password")) pw1.password = true +pw1.datatype = [[]] -pw2 = s:option(Value, "pw2", translate("Confirmation")) +pw2 = s:option(Value, "_pw2", translate("Confirmation")) pw2.password = true function s.cfgsections() @@ -117,9 +120,9 @@ function m.on_parse(map) end function m.on_save(map) --! @TODO this does not check any of the pasword checks with the new form. - local v1 = pw1:formvalue("_pw1") - local v2 = pw2:formvalue("_pw2") - +-- db.log(http.formvalue()) + local v1 = pw1:formvalue("_pass") + local v2 = pw2:formvalue("_pass") if v0 == true and v1 and v2 and #v1 > 0 and #v2 > 0 then if v1 == v2 then if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then @@ -132,10 +135,12 @@ function m.on_save(map) --! @TODO this does not check any of the pasword checks else --function m.on_after_save() return true end m.message = translate("Unknown Error, password not changed!") + m.state = -1 end else --function m.on_after_save() return true end m.message = translate("Given password confirmation did not match, password not changed!") + m.state = -1 end end end diff --git a/luasrc/model/cbi/commotion/basic_wn.lua b/luasrc/model/cbi/commotion/basic_wn.lua index 35c321d..b249eb0 100644 --- a/luasrc/model/cbi/commotion/basic_wn.lua +++ b/luasrc/model/cbi/commotion/basic_wn.lua @@ -21,14 +21,13 @@ local cnw = require "luci.commotion.network" local db = require "luci.commotion.debugger" local http = require "luci.http" local SW = require "luci.commotion.setup_wizard" -local cdisp = require "luci.commotion.dispatch" local ccbi = require "luci.commotion.ccbi" local m = Map("wireless", translate("Wireless Network"), translate("Turning on an Access Point provides a wireless network for people to connect to using a laptop or other wireless devices.")) --redirect on saved and changed to check changes. if not SW.status() then - m.on_after_save = cdisp.conf_page + m.on_after_save = ccbi.conf_page end s = m:section(TypedSection, "wifi-iface", translate("Access Point"), translate("Turning on an Access Point provides a wireless network for people to connect to using a laptop or other wireless devices.")) @@ -38,8 +37,9 @@ s.anonymous = true if not SW.status() then s.addremove = true - dflts = s:option(DummyValue, "_dummy_val01") + dflts = s:option(Value, "_dummy_val01") dflts.anonymous = true + dflts.default = true function dflts.write(self, section, value) first = self.map:set(section, "mode", "adhoc") @@ -82,6 +82,7 @@ if #wifi_dev > 1 then end channels.default = uci:get("wireless", dev[1], "channel") function channels.write(self, section, value) + local enable = self.map:set(dev[1], "disabled", "0") -- enable the radio return self.map:set(dev[1], "channel", value) end end @@ -94,6 +95,8 @@ else local channels = s:option(ListValue, "channel", translate("Channel"), translate("The channel of your wireless interface.")) channels.default = uci:get("wireless", wifi_dev[1][1], "channel") function channels.write(self, section, value) + local enable = self.map:set(wifi_dev[1][1], "disabled", "0") -- enable the radio + self.map:set(section, "device", wifi_dev[1][1]) --set iface to use this device. return self.map:set(wifi_dev[1][1], "channel", value) end for _,x in pairs(cnw.get_channels(wifi_dev[1][2])) do @@ -106,8 +109,8 @@ enc.disabled = "none" enc.enabled = "psk2" enc.rmempty = true enc.default = "none" --default must == disabled value for rmempty to work -enc.write=ccbi.flag_write +enc.write=ccbi.flag_write --Have enc flag also remove the encryption key when deleted and mark as changed. function enc.remove(self, section) value = self.map:get(section, self.option) @@ -123,6 +126,7 @@ end pw1 = s:option(Value, "_pw1", translate("Password"), translate("Enter the password people should use to connect to this access point. Commotion uses WPA2 security for Access Point passwords.")) pw1.password = true pw1:depends("encryption", "psk2") +pw1.datatype = "wpakey" --password should write to the key, not to the dummy value function pw1.write(self, section, value) diff --git a/luasrc/model/cbi/commotion/client_bc.lua b/luasrc/model/cbi/commotion/client_bc.lua index 81f2e9b..98db872 100644 --- a/luasrc/model/cbi/commotion/client_bc.lua +++ b/luasrc/model/cbi/commotion/client_bc.lua @@ -29,13 +29,13 @@ $Id: p2pblock.lua 5448 2009-10-31 15:54:11Z jow $ ]]-- local sys = require "luci.sys" -local cdisp = require "luci.commotion.dispatch" +local ccbi = require "luci.commotion.ccbi" m = Map("freifunk_p2pblock", translate("Bandwidth Controls"), translate("You can disable potentially high-bandwith applications here. ")) --redirect on saved and changed to check changes. -m.on_after_save = cdisp.conf_page +m.on_after_save = ccbi.conf_page s = m:section(NamedSection, "p2pblock", "settings", "Settings") s.anonymous = true diff --git a/luasrc/model/cbi/commotion/client_wp.lua b/luasrc/model/cbi/commotion/client_wp.lua index a074f9f..00c9ffe 100644 --- a/luasrc/model/cbi/commotion/client_wp.lua +++ b/luasrc/model/cbi/commotion/client_wp.lua @@ -19,12 +19,12 @@ local utils = require "luci.util" local db = require "luci.commotion.debugger" local uci = require "luci.model.uci".cursor() local fs = require "nixio.fs" -local cdisp = require "luci.commotion.dispatch" +local ccbi = require "luci.commotion.ccbi" m = Map("nodogsplash", translate("Welcome Page")) --redirect on saved and changed to check changes. -m.on_after_save = cdisp.conf_page +m.on_after_save = ccbi.conf_page enable = m:section(TypedSection, "settings", translate("On/Off"), translate("Users can be redirected to a “welcome page” when they first connect to this node.")) diff --git a/luasrc/model/cbi/commotion/quickstart.lua b/luasrc/model/cbi/commotion/quickstart.lua deleted file mode 100644 index 37ebb3a..0000000 --- a/luasrc/model/cbi/commotion/quickstart.lua +++ /dev/null @@ -1,17 +0,0 @@ -local cursor = require "luci.model.uci".cursor() - -local d = Delegator() -d.allow_finish = true -d.allow_back = true -d.allow_cancel = false -d.allow_reset = true - -d:add("Node Settings", "commotion/basic_ns") -d:add("Mesh Network", "commotion/basic_mn") -d:add("Wireless Network", "commotion/basic_wn") -d:add("Additional Network Interfaces", "commotion/basic_ani") - -function d.on_done() -end - -return d diff --git a/luasrc/model/cbi/commotion/security_pass.lua b/luasrc/model/cbi/commotion/security_pass.lua index cfc50c9..e6257eb 100644 --- a/luasrc/model/cbi/commotion/security_pass.lua +++ b/luasrc/model/cbi/commotion/security_pass.lua @@ -1,11 +1,27 @@ +--[[ +Copyright (C) 2013 Seamus Tuohy + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + + You should have received a copy of the GNU General Public License +along with this program. If not, see . +]]-- local db = require "luci.commotion.debugger" local http = require "luci.http" -local cdisp = require "luci.commotion.dispatch" +local ccbi = require "luci.commotion.ccbi" local m = Map("wireless", translate("Passwords"), translate("Commotion basic security settings places all the passwords and other security features in one place for quick configuration. ")) --redirect on saved and changed to check changes. -m.on_after_save = cdisp.conf_page +m.on_after_save = ccbi.conf_page --PASSWORDS local v0 = true -- track password success across maps diff --git a/luasrc/model/cbi/commotion/security_smk.lua b/luasrc/model/cbi/commotion/security_smk.lua index baf87fd..cfc9f65 100644 --- a/luasrc/model/cbi/commotion/security_smk.lua +++ b/luasrc/model/cbi/commotion/security_smk.lua @@ -15,14 +15,14 @@ GNU General Public License for more details. along with this program. If not, see . ]]-- -local cdisp = require "luci.commotion.dispatch" +local ccbi = require "luci.commotion.ccbi" local db = require "luci.commotion.debugger" local uci = require "luci.model.uci".cursor() m = Map("serval", translate("Shared Mesh Keychain"), translate("To ensure that only authorized devices can route traffic on your Commotion mesh network, one Shared Mesh Keychain file can be generated and shared by all devices.")) --redirect on saved and changed to check changes. -m.on_after_save = cdisp.conf_page +m.on_after_save = ccbi.conf_page s = m:section(TypedSection, "settings", translate("Use a Shared Mesh Keychain to sign mesh routes. Yes/No"), translate("Check the box to use a Shared Mesh Keychain on this device. You'll also be required to upload or generate a Shared Mesh Keychain.")) toggle = s:option(Flag, "enabled") diff --git a/luasrc/model/cbi/commotion/setup_wizard.lua b/luasrc/model/cbi/commotion/setup_wizard.lua index a4fcbd8..18f3ee9 100644 --- a/luasrc/model/cbi/commotion/setup_wizard.lua +++ b/luasrc/model/cbi/commotion/setup_wizard.lua @@ -1,3 +1,19 @@ +--[[ +Copyright (C) 2013 Seamus Tuohy + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + + You should have received a copy of the GNU General Public License +along with this program. If not, see . +]]-- local db = require "luci.commotion.debugger" local cursor = require "luci.model.uci".cursor() From de9b9df6f35dac73f46a790501f65398496956ef Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 14 Dec 2013 13:21:54 -0500 Subject: [PATCH 094/196] removed bandwidth controlls per issue 73 --- luasrc/controller/commotion/client_config.lua | 2 - luasrc/model/cbi/commotion/client_bc.lua | 97 ------------------- 2 files changed, 99 deletions(-) delete mode 100644 luasrc/model/cbi/commotion/client_bc.lua diff --git a/luasrc/controller/commotion/client_config.lua b/luasrc/controller/commotion/client_config.lua index 3e1596d..b34d2dc 100644 --- a/luasrc/controller/commotion/client_config.lua +++ b/luasrc/controller/commotion/client_config.lua @@ -17,6 +17,4 @@ module "luci.controller.commotion.client_config" function index() entry({"admin", "commotion", "client"}, alias("admin", "commotion", "client", "welcome_page"), translate("Client Controls"), 30) entry({"admin", "commotion", "client", "welcome_page"}, cbi("commotion/client_wp", {hideapplybtn=true, hideresetbtn=true}), translate("Welcome Page"), 40).index = true - entry({"admin", "commotion", "client", "bandwidth_controls"}, cbi("commotion/client_bc", {hideapplybtn=true, hideresetbtn=true}), translate("Bandwidth Controls"), 50) - end diff --git a/luasrc/model/cbi/commotion/client_bc.lua b/luasrc/model/cbi/commotion/client_bc.lua deleted file mode 100644 index 98db872..0000000 --- a/luasrc/model/cbi/commotion/client_bc.lua +++ /dev/null @@ -1,97 +0,0 @@ ---[[ -Modifications Copyright (C) 2013 Seamus Tuohy - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - - You should have received a copy of the GNU General Public License -along with this program. If not, see . -]]-- ---[[ -LuCI - Lua Configuration Interface - -Copyright 2009 Jo-Philipp Wich - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id: p2pblock.lua 5448 2009-10-31 15:54:11Z jow $ -]]-- - -local sys = require "luci.sys" -local ccbi = require "luci.commotion.ccbi" - -m = Map("freifunk_p2pblock", translate("Bandwidth Controls"), - translate("You can disable potentially high-bandwith applications here. ")) - ---redirect on saved and changed to check changes. -m.on_after_save = ccbi.conf_page - -s = m:section(NamedSection, "p2pblock", "settings", "Settings") -s.anonymous = true -s.addremove = false - -en = s:option(Flag, "_enabled", translate("Enable/Disable Bandwidth Controls")) -en.rmempty = false - -function en.cfgvalue() - return ( sys.init.enabled("freifunk-p2pblock") and "1" or "0" ) -end - -function en.write(self, section, val) - if val == "1" then - sys.init.enable("freifunk-p2pblock") - else - sys.init.disable("freifunk-p2pblock") - end -end - ---s:option(Value, "portrange", translate("Portrange")) - ---s:option(Value, "blocktime", translate("Block Time"), --- translate("seconds")) - ---s:option(DynamicList, "whitelist", translate("Whitelisted IPs")) - -l7 = s:option(MultiValue, "layer7", translate("Layer7-Protocols")) -l7.widget = "checkbox" -l7:value("aim", "AIM Chat") -l7:value("bittorrent", "Bittorrent") -l7:value("edonkey", "eDonkey, eMule, Kademlia") -l7:value("fasttrack", "Fasttrack Protocol") -l7:value("ftp", "File Transfer Protocol") -l7:value("gnutella", "Gnutella") -l7:value("http", "Hypertext Transfer Protocol") -l7:value("ident", "Ident Protocol") -l7:value("irc", "Internet Relay Chat") -l7:value("jabber", "Jabber/XMPP") -l7:value("msnmessenger", "MSN Messenger") -l7:value("ntp", "Network Time Protocol") -l7:value("pop3", "POP3 Protocol") -l7:value("smtp", "SMTP Protocol") -l7:value("ssl", "SSL Protocol") -l7:value("vnc", "VNC Protocol") - -ipp2p = s:option(MultiValue, "ipp2p", translate("IP-P2P")) -ipp2p.widget = "checkbox" -ipp2p:value("edk", "eDonkey, eMule, Kademlia") -ipp2p:value("kazaa", "KaZaA, FastTrack") -ipp2p:value("gnu", "Gnutella") -ipp2p:value("dc", "Direct Connect") -ipp2p:value("bit", "BitTorrent, extended BT") -ipp2p:value("apple", "AppleJuice") -ipp2p:value("winmx", "WinMX") -ipp2p:value("soul", "SoulSeek") -ipp2p:value("ares", "AresLite") - -return m From 27cb609c0c424a649ad7dc2b49b4fda69b67de82 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 14 Dec 2013 14:05:37 -0500 Subject: [PATCH 095/196] updated page text --- luasrc/model/cbi/commotion/client_wp.lua | 28 ++++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/luasrc/model/cbi/commotion/client_wp.lua b/luasrc/model/cbi/commotion/client_wp.lua index 00c9ffe..30a8e53 100644 --- a/luasrc/model/cbi/commotion/client_wp.lua +++ b/luasrc/model/cbi/commotion/client_wp.lua @@ -65,24 +65,20 @@ splshtxt = m:section(TypedSection, "_page", translate("Edit Welcome Page Text"), splshtxt.cfgsections = function() return { "_page" } end splshtxt.anonymous = true edit = splshtxt:option(Button, "_page", translate("Edit")) ---edit.template = "cbi/cmtn_js_button" --The following removes the default title for a word button. edit.inputtitle = edit.title edit.title = nil upload = splshtxt:option(Button, "_page", translate("Upload")) ---edit.template = "cbi/cmtn_js_button" --The following removes the default title for a word button. upload.inputtitle = upload.title upload.title = nil local splashtextfile = "/usr/lib/lua/luci/view/commotion-splash/splashtext.htm" -help = splshtxt:option(DummyValue, "_dummy", translate("Edit Splash text"), - translate("You can enter your own text that is displayed to clients here.

    " .. - "It is possible to use the following markers:
    " .. - "$gatewayname: The value of GatewayName as set in nodogsplash.conf.
    " .. - "$authtarget: A URL which encodes a unique token and the URL of the user's original web request.
    " .. - "$imagesdir: The directory in nodogsplash's web hierarchy where images to be displayed in the splash page must be located.
    ")) + +local help_text = translate("You can enter text and HTML that will be displayed on the welcome page.").."

    "..translate("These variables can be used to provide custom values from this node on the welcome page :").."
    "..translate("$gatewayname: The value of GatewayName as set in the Welcome Page configuration file (/path/nodogsplash.conf).").."
    "..translate("$authtarget: The URL of the user's original web request.").."
    "..translate("$imagesdir: The directory in on this node where images to be displayed in the splash page must be located.").."
    "..translate("The welcome page might include terms of service, advertisements, or other information. Edit the welcome page text here or upload an HTML file.").."
    " + +help = splshtxt:option(DummyValue, "_dummy", translate("Edit Welcome Page Text"), help_text) help.template = "cbi/nullsection" t = splshtxt:option(TextValue, "text") t.rmempty = true @@ -91,7 +87,7 @@ function t.cfgvalue() return fs.readfile(splashtextfile) or "" end -uploader = splshtxt:option(FileUpload, "_upload", "UPLOADER TEXT HERE") +uploader = splshtxt:option(FileUpload, "_upload", help_text) function m.on_parse(self) local b_press = luci.http.formvalue("cbid.nodogsplash._page._page") @@ -106,19 +102,27 @@ function m.on_parse(self) if luci.fs.isfile(uploaded) then local nfs = require "nixio.fs" nfs.move(uploaded, splashtextfile) - m.message = "file uploaded!" + m.proceed = true + m.message = "Success! Your welcome page text has been updated!" + else + m.proceed = true + m.message = "Sorry! There was a problem updating your welcome page text. Please try again." end text = luci.http.formvalue("cbid.nodogsplash._page.text") if text and not b_press then if text ~= "" then fs.writefile(splashtextfile, text:gsub("\r\n", "\n")) - m.message = "Splashpage updated successfully!" + m.proceed = true + m.message = "Success! Your welcome page text has been updated!" else fs.unlink(splashtextfile) - m.message ="Default Splash page selected!" + m.proceed = true + m.message ="The default welcome page has been restored." end end return true end return m + + From 341c33a5d2be8c4a4e8cbd6bde9a6e232391315b Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 14 Dec 2013 14:06:34 -0500 Subject: [PATCH 096/196] added default values for adhoc and ap networks, including network and profile creation for mesh networks. --- luasrc/model/cbi/commotion/basic_mn.lua | 38 +++++++++++++++++++------ luasrc/model/cbi/commotion/basic_wn.lua | 20 +++++-------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_mn.lua b/luasrc/model/cbi/commotion/basic_mn.lua index 03ea95d..3712306 100644 --- a/luasrc/model/cbi/commotion/basic_mn.lua +++ b/luasrc/model/cbi/commotion/basic_mn.lua @@ -38,19 +38,41 @@ function m.on_before_commit() end s = m:section(TypedSection, "wifi-iface") +s.optional = false +s.anonymous = true + if not SW.status() then --if not setup wizard then allow for adding and removal s.addremove = true - dflts = s:option(Value, "_dummy_val01") --also add defaults if not in qs - dflts.anonymous = true - dflts.default = true - - function dflts.write(self, section, value) - return self.map:set(section, "mode", "adhoc") + md = s:option(Value, "mode") + md.default = 'adhoc' + md.render = function() end + function md:parse(section) + local cvalue = self:cfgvalue(section) + if not cvalue then + self:write(section, self.default) + end + end + + nwk = s:option(Value, "network") + --! @brief creates a network section and same named commotion profile when creating a mesh interface and assigns it to that mesh interface + function nwk:write(section, value) + db.log("starting") + network_name = uci:section("network", "interface", nil, {proto="commotion"}) + cnw.commotion_set(network_name) + uci:set("network", network_name, "profile", network_name) + uci:save("network") + return self.map:set(section, self.option, network_name) + end + nwk.render = function() end + function nwk:parse(section) + local cvalue = self:cfgvalue(section) + if not cvalue then + self:write(section, self.default) + end end end -s.optional = false -s.anonymous = true + function s:filter(section) mode = self.map:get(section, "mode") diff --git a/luasrc/model/cbi/commotion/basic_wn.lua b/luasrc/model/cbi/commotion/basic_wn.lua index b249eb0..abc5179 100644 --- a/luasrc/model/cbi/commotion/basic_wn.lua +++ b/luasrc/model/cbi/commotion/basic_wn.lua @@ -37,15 +37,13 @@ s.anonymous = true if not SW.status() then s.addremove = true - dflts = s:option(Value, "_dummy_val01") - dflts.anonymous = true - dflts.default = true - - function dflts.write(self, section, value) - first = self.map:set(section, "mode", "adhoc") - second = self.map:set(section, "network", "client") - return first and second or false - end + md = s:option(Value, "mode") + md.default = 'ap' + md.render = function() end + + nwk = s:option(Value, "network") + nwk.default = "client" + nwk.render = function() end end function s:filter(section) @@ -87,10 +85,6 @@ if #wifi_dev > 1 then end end else - --Default radio (don't render this. Just add it so that it gets added to UCI when created) - radio = s:option(DummyValue, "device") - radio.default = wifi_dev[1][1] - radio.render = function() end local channels = s:option(ListValue, "channel", translate("Channel"), translate("The channel of your wireless interface.")) channels.default = uci:get("wireless", wifi_dev[1][1], "channel") From 57dea48aaac99699736fbbfdc6eee2c62748561f Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 14 Dec 2013 14:23:38 -0500 Subject: [PATCH 097/196] Added correct text to interfaces. --- luasrc/view/commotion/conn_clients.htm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/luasrc/view/commotion/conn_clients.htm b/luasrc/view/commotion/conn_clients.htm index cd49263..ce2117c 100644 --- a/luasrc/view/commotion/conn_clients.htm +++ b/luasrc/view/commotion/conn_clients.htm @@ -91,7 +91,8 @@ if #clients > 0 then --Actually create the table below here. %> - +

    <%:Connected Clients!%>

    +

    A client is a device that has connected to this node. Information about clients is displayed below.

    @@ -104,6 +105,6 @@
    <%else%> -

    <%:No clients found!%>

    -

    <%:NEED HELP TEXT NEED HELP TEXT NEED HELP TEXT NEED HELP TEXT NEED HELP TEXT NEED HELP TEXT NEED HELP TEXT NEED HELP TEXTNEED HELP TEXT NEED HELP TEXT%>

    +

    <%:Connected Clients!%>

    +

    <%:No connected clients were found at this time. If a Welcome Page has been enabled, clients must click through it before being displayed here.%>

    <%end%> From cf3371f5d82423a2bb4094541b69c19dc17218f9 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 14 Dec 2013 14:49:26 -0500 Subject: [PATCH 098/196] updated page to reflect new conditions from JK --- luasrc/model/cbi/commotion/basic_ani.lua | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_ani.lua b/luasrc/model/cbi/commotion/basic_ani.lua index 7426547..b73845e 100644 --- a/luasrc/model/cbi/commotion/basic_ani.lua +++ b/luasrc/model/cbi/commotion/basic_ani.lua @@ -32,21 +32,22 @@ end p = m:section(NamedSection, "plug") p.anonymous = true -msh = p:option(Flag, "meshability", translate("Will you be meshing with other Commotion devices over the ethernet interface?")) +config = p:option(ListValue, "dhcp", translate("Gateway Configuration")) +config:value("auto", translate("Automatically configure gateway on boot.")) +config:value("client", translate("This device should ALWAYS try and acquire a DHCP lease.")) +config:value("server", translate("This device should ALWAYS provide DHCP leases to clients.")) +config:value("none", translate("This device should not do anything with DHCP.")) + +msh = p:option(Flag, "meshed", translate("Will you be meshing with other Commotion devices over the ethernet interface?")) msh.enabled = "true" msh.disabled = "false" msh.default = "false" -msh.addremove = true +msh.addremove = false -ance = p:option(Flag, "announceability", translate("Advertise your gateway to the mesh.")) +ance = p:option(Flag, "announced", translate("Advertise your gateway to the mesh.")) ance.enabled = "true" ance.disabled = "false" -ance.addremove = true ---ance:depends("meshability", "false") --!TODO Currently Flags do not have dependance capabilities it seems. I will add and patch in R1.1 - -config = p:option(ListValue, "plugability", translate("Gateway Configuration")) -config:value("auto", translate("Automatically configure gateway on boot.")) -config:value("client", translate("This device should try and acquire a DHCP lease")) -config:value("host", translate("This device should provide DHCP leases to clients.")) - +ance.addremove = false +ance.default = 'true' + return m From ebf807eca09a314820f9b0c08ae6b8f1f58d3762 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 14 Dec 2013 16:49:25 -0500 Subject: [PATCH 099/196] finalized status menu. All pages working fully. most work done on connected clients page and functions which I wrote without any clients. Suprised it was as close to working as it was. --- luasrc/controller/commotion/status_config.lua | 29 ++++++++++++----- luasrc/view/commotion/conn_clients.htm | 32 ++++++++++--------- luasrc/view/commotion/nearby_md.htm | 3 +- luasrc/view/commotion/status.htm | 2 +- 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index 15875fd..3982ba2 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -16,6 +16,8 @@ along with this program. If not, see . ]]-- local util = require "luci.util" +local db = require "luci.commotion.debugger" +local i18n = require "luci.i18n" module ("luci.controller.commotion.status_config", package.seeall) @@ -48,7 +50,7 @@ function status_builder(page, assets, active_tab) local status = nil local sec = nil local conn = nil - local zone = zone_iface[s.network] + local zone = zone_iface.zone_to_iface[s.network] if uci:get("wireless", "wifi-device", device, "disabled") == '1' then status = "Off" else @@ -59,6 +61,7 @@ function status_builder(page, assets, active_tab) else sec = "Unsecured" end + for i,x in pairs(splash_info) do if zone == i then conn = splash_info[zone].connected @@ -88,7 +91,8 @@ end function conn_clnts() clients = get_client_splash_info() - status_builder("commotion/conn_clients", {clients=clients}, "connected_clients") + splash = get_splash_iface_info() + status_builder("commotion/conn_clients", {clients=clients, splash=splash}, "connected_clients") end --! @brief currently only gets number of connected clients... because that is what I needed @@ -96,8 +100,11 @@ function get_splash_iface_info() local splash = {} local interface = nil for line in util.execi("ndsctl status") do - string.gsub(line, "^(.-):%s(.*)$", - function(key, val) + string.gsub(line, "^(.-:%s.*)$", + function(str) + local sstr = util.split(str, ":%s", nil, true) + local key = sstr[1] + local val = sstr[2] if key == "Managed interface" then interface = val splash[interface] = {} @@ -148,20 +155,26 @@ end function get_client_splash_info() local convert = function(x) - return tostring(tonumber(x)*60).." "..translate("minutes") + return tostring(math.floor(tonumber(x)/60)).." "..i18n.translate("minutes") end local function total_kB(a, b) return tostring(a+b).." kByte" end local function total_kb(a, b) return tostring(a+b).." kbit/s" end local clients = {} i = 0 for line in util.execi("ndsctl clients") do - if string.match(line, "^%d*$") then + if string.match(line, "^%d+$") then i = i + 1 + clients[i] = {} end - string.gsub(i, "^(.-)=(.*)$", - function(key, val) + string.gsub(line, "^(.+=.+)$", + function(str) + local sstr = util.split(str, "=") + local key = sstr[1] + local val = sstr[2] clients[i][key] = val end) + end + for i,x in ipairs(clients) do if clients[i] ~= nil then clients[i].curr_conn=false clients[i].duration = convert(clients[i].duration) diff --git a/luasrc/view/commotion/conn_clients.htm b/luasrc/view/commotion/conn_clients.htm index ce2117c..2028ec8 100644 --- a/luasrc/view/commotion/conn_clients.htm +++ b/luasrc/view/commotion/conn_clients.htm @@ -22,7 +22,7 @@ <%- local util = require "luci.util" - +local db = require "luci.commotion.debugger" --Rip open assets table to get its sweet innards (need this because of the open ended include) for name,obj in pairs(assets) do _G[name] = obj @@ -30,23 +30,25 @@ colors = {default="", grn="#00cc00", yellow="#ffcb05", orange="#ff6600", red="#bb3333" } -headers = {{title="IP-Address", help="HELP TEXT NEEDED", var="ip"}, - {title="Time Connected", help="HELP TEXT NEEDED", var="duration"}, - {title="Bandwidth Used", help="HELP TEXT NEEDED", var="bnd_wdth"}, - {title="Average Speed", help="HELP TEXT NEEDED", var="avg_spd"}, - {title="Currently Active", help="HELP TEXT NEEDED", var="curr_conn"}} +headers = {{title="IP-Address", var="ip"}, + {title="Time Connected", var="duration"}, + {title="Bandwidth Used", var="bnd_wdth"}, + {title="Average Speed", var="avg_spd"}, + {title="Currently Active", var="curr_conn"}} if #clients > 0 then - for i in util.execi("iw dev wlan0 station dump") do - string.gsub(i, "^Station%s(.-)%s%(", - function(mac) - for _,dossier in ipairs(clients) do - local c_idx = util.contains(dossier, mac) - if c_idx then - clients[c_idx].curr_conn = true + for iface_name, conn in pairs(splash) do + for i in util.execi("iw dev "..iface_name.." station dump") do + string.gsub(i, "^Station%s(.-)%s%(", + function(mac) + for client,dossier in ipairs(clients) do + local c_idx = util.contains(dossier, mac) + if c_idx then + clients[client].curr_conn = true + end end - end - end) + end) + end end end diff --git a/luasrc/view/commotion/nearby_md.htm b/luasrc/view/commotion/nearby_md.htm index e4d875d..007951a 100644 --- a/luasrc/view/commotion/nearby_md.htm +++ b/luasrc/view/commotion/nearby_md.htm @@ -66,8 +66,7 @@ var neigh = info[idx]; s += String.format( - '' + -udoadsfasdfasdasdf '%s', + '' + '%s', neigh.dfgcolor, neigh.rip, neigh.rip ); if (neigh.hn) { diff --git a/luasrc/view/commotion/status.htm b/luasrc/view/commotion/status.htm index 0d6d9e5..d22babb 100644 --- a/luasrc/view/commotion/status.htm +++ b/luasrc/view/commotion/status.htm @@ -26,9 +26,9 @@

    <%:Providing Gateway%><%=gateway_provided%>

    <%- for _,iface in pairs(ifaces) do -%>

    <%=iface.name%><%=iface.status%> <%=iface.sec%> <%=iface.conn%>

    +<%end%>
    -<%end%>
    • > From 9efb0483132ac2c584ded415565bdf9229d42052 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 14 Dec 2013 18:22:43 -0500 Subject: [PATCH 100/196] fixed a silly error where you could not pass this page in quickstart because it would stop even if all values were empty. --- luasrc/model/cbi/commotion/basic_ns.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index 65e55eb..5436353 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -99,7 +99,7 @@ function m.on_parse(map) if tonumber(num) == 0 then conf_pass = val end - if val then + if val ~= nil and val ~= "" then check = true end end) From b060e07f04a9679bc33f5267840ec414d4dd9870 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 14 Dec 2013 21:15:31 -0500 Subject: [PATCH 101/196] got buttons working across all basic menus and setup wizard. They could use for some proper floating. But, they look good. Also got the apply confirm and revert pages working better. Still need to customize the confirmation page html to collect similarly sectioned items and display them for users. --- luasrc/controller/commotion/basic_config.lua | 5 +- luasrc/controller/commotion/setup_ctl.lua | 72 ++++++++++++-------- luasrc/view/cbi/commotion/delegator.htm | 12 ++-- luasrc/view/commotion/apply.htm | 21 ++---- luasrc/view/commotion/apply_xhr.htm | 3 +- luasrc/view/commotion/confirm.htm | 15 ++-- luasrc/view/commotion/revert.htm | 15 ++-- 7 files changed, 76 insertions(+), 67 deletions(-) diff --git a/luasrc/controller/commotion/basic_config.lua b/luasrc/controller/commotion/basic_config.lua index 34f8ae2..abd3118 100644 --- a/luasrc/controller/commotion/basic_config.lua +++ b/luasrc/controller/commotion/basic_config.lua @@ -44,7 +44,7 @@ function index() if not root.lock then root.target = alias("commotion") root.index = true - end + end local redir = luci.http.formvalue("redir", true) or luci.dispatcher.build_url(unpack(luci.dispatcher.context.request)) @@ -152,8 +152,7 @@ function action_apply() luci.template.render("commotion/apply", { changes = next(changes) and changes, - configs = reload - }) + configs = reload}) end function action_revert() diff --git a/luasrc/controller/commotion/setup_ctl.lua b/luasrc/controller/commotion/setup_ctl.lua index 9acbc7f..55218ca 100644 --- a/luasrc/controller/commotion/setup_ctl.lua +++ b/luasrc/controller/commotion/setup_ctl.lua @@ -18,12 +18,12 @@ function index() SW = require "luci.commotion.setup_wizard" if SW.status() then entry({"setupctl"}, alias("setupctl", "status")) - entry({"setupctl", "status"}, call("action_status")).leaf = true else entry({"setupctl"}, alias("setupctl", "status")).sysauth = "root" - entry({"setupctl", "status"}, call("action_status")).leaf = true end + entry({"setupctl", "status"}, call("action_status")).leaf = true entry({"setupctl", "restart"}, call("action_restart")).leaf = true + entry({"setupctl", "complete"}, call("action_setup")).leaf = true end function action_status() @@ -32,35 +32,51 @@ function action_status() luci.http.write("/etc/config/") luci.http.write(data) else - luci.http.write("finish") + luci.http.write("finish") end end function action_restart(args) - local uci = require "luci.model.uci".cursor() - if args then - local service - local services = { } - - for service in args:gmatch("[%w_-]+") do - services[#services+1] = service - end - - local command = uci:apply(services, true) - if nixio.fork() == 0 then - local i = nixio.open("/dev/null", "r") - local o = nixio.open("/dev/null", "w") - - nixio.dup(i, nixio.stdin) - nixio.dup(o, nixio.stdout) - - i:close() - o:close() + local uci = require "luci.model.uci".cursor() + if args then + local service + local services = { } + + for service in args:gmatch("[%w_-]+") do + services[#services+1] = service + end + + local command = uci:apply(services, true) + if nixio.fork() == 0 then + local i = nixio.open("/dev/null", "r") + local o = nixio.open("/dev/null", "w") + + nixio.dup(i, nixio.stdin) + nixio.dup(o, nixio.stdout) + + i:close() + o:close() + + nixio.exec("/bin/sh", unpack(command)) + else + luci.http.write("OK") + os.exit(0) + end + end +end - nixio.exec("/bin/sh", unpack(command)) - else - luci.http.write("OK") - os.exit(0) - end - end +function action_setup() + local disp = require "luci.dispatcher" + local http = require "luci.http" + local uci = require "luci.model.uci".cursor() + local SW = require "luci.commotion.setup_wizard" + + if SW.status() then + uci:set("setup_wizard", "settings", "enabled", "0") + uci:set("setup_wizard", "tracking", "adminPass", "false") + uci:save("setup_wizard") + uci:commit("setup_wizard") + end + adv = disp.build_url("admin", "commotion") + http.redirect(adv) end diff --git a/luasrc/view/cbi/commotion/delegator.htm b/luasrc/view/cbi/commotion/delegator.htm index 98120ca..db17b6e 100644 --- a/luasrc/view/cbi/commotion/delegator.htm +++ b/luasrc/view/cbi/commotion/delegator.htm @@ -5,11 +5,11 @@ <%:Loading%> - <%:Waiting for changes to be applied...%> + <%:Applying changes... +Please be patient, this may take a few moments. Once the settings are complete you will be returned to the Administrative login.%> <%- end) %> diff --git a/luasrc/view/commotion/confirm.htm b/luasrc/view/commotion/confirm.htm index ed7e985..583510d 100644 --- a/luasrc/view/commotion/confirm.htm +++ b/luasrc/view/commotion/confirm.htm @@ -26,7 +26,9 @@ -%> <%SW = require "luci.commotion.setup_wizard" - disp = require "luci.dispatcher"%> + disp = require "luci.dispatcher" + util = require "luci.util"%> + <%+header%>

      <%:Confirm Configuration%>

      @@ -39,13 +41,12 @@

      Review the settings you have chosen below. To finish the Setup Wizard click <% else %>

      <%:There are no pending changes!%>

      <% end %> -
      <%sw_stat = SW.status()%> <%if sw_stat then%>
      - +
      <%else%> <% local r = luci.http.formvalue("redir"); if r and #r > 0 then %> @@ -54,27 +55,25 @@

      Review the settings you have chosen below. To finish the Setup Wizard click <% end end%> -

      <%if sw_stat then%>
      <%else%> <%end%> - " /> + " />
      <%if sw_stat then%>
      - " /> + " /> <%else%> - " /> + " /> <%end%>
      - <%+footer%> diff --git a/luasrc/view/commotion/revert.htm b/luasrc/view/commotion/revert.htm index 0312cf0..ffe0bd3 100644 --- a/luasrc/view/commotion/revert.htm +++ b/luasrc/view/commotion/revert.htm @@ -14,6 +14,10 @@ -%> <%SW = require "luci.commotion.setup_wizard"%> +<%if not SW.status() then + redirect = luci.dispatcher.build_url("admin","commotion") +end%> + <%+header%>

      <%:Revert%>

      @@ -26,20 +30,17 @@

      <%:Revert%>

      <% else %>

      <%:There are no pending changes to revert!%>

      <% end %> -
      - <%sw_stat = SW.status()%> - <%if sw_stat then%> + <%if SW.status() then%>
      - +
      <%else%> -
      "> - + +
      <%end%>
      - <%+footer%> From 9505e01f08a05098959bca5c171b5a7ceb1e8470 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 15 Dec 2013 13:25:56 -0500 Subject: [PATCH 102/196] migrating over to ubus based version of ifaces list --- luasrc/controller/commotion/status_config.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index 3982ba2..a692d84 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -41,7 +41,7 @@ function status_builder(page, assets, active_tab) local ifaces = {} local gw = "No" - local zone_iface = cnet.list_ifaces() + local zone_iface = cnet.ifaces_list() local splash_info = get_splash_iface_info() uci:foreach("wireless", "wifi-iface", function(s) @@ -50,7 +50,7 @@ function status_builder(page, assets, active_tab) local status = nil local sec = nil local conn = nil - local zone = zone_iface.zone_to_iface[s.network] + local zone = zone_iface[s.network] if uci:get("wireless", "wifi-device", device, "disabled") == '1' then status = "Off" else From 90dba93669279e2f839f525b4ee27b6b51c9a6e3 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 15 Dec 2013 14:29:55 -0500 Subject: [PATCH 103/196] added extra option for when the radio is unknown. --- luasrc/controller/commotion/status_config.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index a692d84..8b34a68 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -51,10 +51,14 @@ function status_builder(page, assets, active_tab) local sec = nil local conn = nil local zone = zone_iface[s.network] - if uci:get("wireless", "wifi-device", device, "disabled") == '1' then - status = "Off" + if device ~= nil then + if uci:get("wireless", "wifi-device", device, "disabled") == '1' then + status = "Off" + else + status = "On" + end else - status = "On" + status = "Unknown" end if s.encryption == "psk2" then sec = "Secured" From 090ac84867cacd661700f8604d2491e5a2538505 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 15 Dec 2013 15:56:18 -0500 Subject: [PATCH 104/196] don't check which user, since we don't have multiple users anyway currently. --- luasrc/model/cbi/commotion/basic_ns.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index 5436353..71b0301 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -89,7 +89,7 @@ function s.cfgsections() return { "_pass" } end -function m.on_parse(map) +function m.on_parse(map) --! @TODO this does not work local form = http.formvaluetable("cbid") local check = nil local conf_pass = nil @@ -125,7 +125,7 @@ function m.on_save(map) --! @TODO this does not check any of the pasword checks local v2 = pw2:formvalue("_pass") if v0 == true and v1 and v2 and #v1 > 0 and #v2 > 0 then if v1 == v2 then - if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then + if luci.sys.user.setpasswd("root", v1) == 0 then m.message = translate("Password successfully changed!") if SW.status() then uci:set("setup_wizard", "tracking", "adminPass", 'true') From 90804f93b5becc40ebbf818634f52b1d33f2def5 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 15 Dec 2013 15:58:13 -0500 Subject: [PATCH 105/196] Removing serval section as it will not be ready for R1 --- luasrc/controller/commotion/security_config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/controller/commotion/security_config.lua b/luasrc/controller/commotion/security_config.lua index 36e6393..5614449 100644 --- a/luasrc/controller/commotion/security_config.lua +++ b/luasrc/controller/commotion/security_config.lua @@ -22,6 +22,6 @@ function index() entry({"admin", "commotion", "security", "passwords"}, cbi("commotion/security_pass", {hideapplybtn=true, hideresetbtn=true}), translate("Passwords"), 50).subsection=true - entry({"admin", "commotion", "security", "shared_mesh_keychain"}, cbi("commotion/security_smk", {hideapplybtn=true, hideresetbtn=true}), translate("Shared Mesh Keychain"), 60).subsection=true + --[[ entry({"admin", "commotion", "security", "shared_mesh_keychain"}, cbi("commotion/security_smk", {hideapplybtn=true, hideresetbtn=true}), translate("Shared Mesh Keychain"), 60).subsection=true ]]-- end From 8c5856c89c8f721516ebd34969a51e398158cada Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 15 Dec 2013 15:58:52 -0500 Subject: [PATCH 106/196] added better error handling for uploads --- luasrc/model/cbi/commotion/client_wp.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/luasrc/model/cbi/commotion/client_wp.lua b/luasrc/model/cbi/commotion/client_wp.lua index 30a8e53..236e3f3 100644 --- a/luasrc/model/cbi/commotion/client_wp.lua +++ b/luasrc/model/cbi/commotion/client_wp.lua @@ -20,6 +20,7 @@ local db = require "luci.commotion.debugger" local uci = require "luci.model.uci".cursor() local fs = require "nixio.fs" local ccbi = require "luci.commotion.ccbi" +local lfs = require "luci.fs" m = Map("nodogsplash", translate("Welcome Page")) @@ -98,13 +99,12 @@ function m.on_parse(self) if b_press ~= "Upload" then function uploader.render() return nil end end - uploaded = "/lib/uci/upload/cbid.nodogsplash._page._upload" - if luci.fs.isfile(uploaded) then - local nfs = require "nixio.fs" - nfs.move(uploaded, splashtextfile) + uploaded = "cbid.nodogsplash._page._upload" + if lfs.isfile("/lib/uci/upload/"..uploaded) then + fs.move(uploaded, splashtextfile) m.proceed = true m.message = "Success! Your welcome page text has been updated!" - else + elseif luci.http.formvalue(uploaded) ~= nil then m.proceed = true m.message = "Sorry! There was a problem updating your welcome page text. Please try again." end From 6ca0b48e750c4415ab28e74d2988775eca4ebc29 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 15 Dec 2013 16:01:38 -0500 Subject: [PATCH 107/196] added check to include pretty button on setup wizard even though it is not a basic menu --- luasrc/view/commotion/apply.htm | 8 ++++++++ luasrc/view/commotion/confirm.htm | 8 +++++++- luasrc/view/commotion/revert.htm | 15 ++++++++++----- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/luasrc/view/commotion/apply.htm b/luasrc/view/commotion/apply.htm index 76d1e54..6014b8d 100644 --- a/luasrc/view/commotion/apply.htm +++ b/luasrc/view/commotion/apply.htm @@ -33,9 +33,17 @@

      <%:Applying Changes%>

      <% else %>

      <%:There are no pending changes to apply!%>

      <% end %> +<%sw_stat = SW.status()%> +<%if sw_stat then%> +
      +<%end%>
      +<%if sw_stat then%> +
      +<%end%> + <%+footer%> diff --git a/luasrc/view/commotion/confirm.htm b/luasrc/view/commotion/confirm.htm index 583510d..01e1cfb 100644 --- a/luasrc/view/commotion/confirm.htm +++ b/luasrc/view/commotion/confirm.htm @@ -41,8 +41,11 @@

      Review the settings you have chosen below. To finish the Setup Wizard click <% else %>

      <%:There are no pending changes!%>

      <% end %> +<%sw_stat = SW.status()%> +<%if sw_stat then%> +
      +<%end%>
      - <%sw_stat = SW.status()%> <%if sw_stat then%>
      @@ -76,4 +79,7 @@

      Review the settings you have chosen below. To finish the Setup Wizard click

      +<%if sw_stat then%> +
      +<%end%> <%+footer%> diff --git a/luasrc/view/commotion/revert.htm b/luasrc/view/commotion/revert.htm index ffe0bd3..838e022 100644 --- a/luasrc/view/commotion/revert.htm +++ b/luasrc/view/commotion/revert.htm @@ -14,9 +14,7 @@ -%> <%SW = require "luci.commotion.setup_wizard"%> -<%if not SW.status() then - redirect = luci.dispatcher.build_url("admin","commotion") -end%> +<%sw_stat = SW.status()%> <%+header%> @@ -25,13 +23,17 @@

      <%:Revert%>

      <% if changes then %> <%+cbi/apply_xhr%> <%+admin_uci/changelog%> -

      <%:The following changes have been reverted%>:

      +

      <%:Reverting changes... +Please be patient, this may take a few moments. Once the settings are reset click "Start Over" to return to the beginning of the Setup Wizard.%>:

      <%- uci_changelog(changes) -%> <% else %>

      <%:There are no pending changes to revert!%>

      <% end %> +<%if sw_stat then%> +
      +<%end%>
      - <%if SW.status() then%> + <%if sw_stat then%>
      @@ -43,4 +45,7 @@

      <%:Revert%>

      <%end%>
      +<%if sw_stat then%> +
      +<%end%> <%+footer%> From 93f90b5959f48f22d9c8083299676de4cbf1b399 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 15 Dec 2013 16:19:24 -0500 Subject: [PATCH 108/196] remove admin password check if during setup wizard... when you don't have an admin password. --- luasrc/model/cbi/commotion/basic_ns.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index 71b0301..cd4f125 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -105,16 +105,18 @@ function m.on_parse(map) --! @TODO this does not work end) end if check ~= nil then - if conf_pass then - v0 = luci.sys.user.checkpasswd("root", conf_pass) - if v0 ~= true then - m.message = translate("Incorrect password. Changes rejected!") + if not SW.status() then + if conf_pass then + v0 = luci.sys.user.checkpasswd("root", conf_pass) + if v0 ~= true then + m.message = translate("Incorrect password. Changes rejected!") + m.save = false + function m.on_after_save() return true end --Don't redirect on error + end + else + m.message = translate("Please enter your old password. Changes rejected!") m.save = false - function m.on_after_save() return true end --Don't redirect on error end - else - m.message = translate("Please enter your old password. Changes rejected!") - m.save = false end end end From 2e61c2997bf653d4dfccf40f57fe35e0340b3663 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 15 Dec 2013 17:31:48 -0500 Subject: [PATCH 109/196] condensed all setup uci-defaults files into one script --- files/etc/uci-defaults/luci-nodog | 10 ---------- .../uci-defaults/{luci-serval => luci-setup-wizard} | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) delete mode 100755 files/etc/uci-defaults/luci-nodog rename files/etc/uci-defaults/{luci-serval => luci-setup-wizard} (62%) diff --git a/files/etc/uci-defaults/luci-nodog b/files/etc/uci-defaults/luci-nodog deleted file mode 100755 index b902b81..0000000 --- a/files/etc/uci-defaults/luci-nodog +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -. /etc/functions.sh - -config_load ucitrack -uci_add ucitrack nodogsplash nodogsplash -uci_set ucitrack nodogsplash init ucidog -uci_commit ucitrack - -exit 0 diff --git a/files/etc/uci-defaults/luci-serval b/files/etc/uci-defaults/luci-setup-wizard similarity index 62% rename from files/etc/uci-defaults/luci-serval rename to files/etc/uci-defaults/luci-setup-wizard index 52ec833..8743703 100755 --- a/files/etc/uci-defaults/luci-serval +++ b/files/etc/uci-defaults/luci-setup-wizard @@ -2,6 +2,13 @@ . /etc/functions.sh +#setup ucitrack +config_load ucitrack +uci_add ucitrack nodogsplash nodogsplash +uci_set ucitrack nodogsplash init ucidog +uci_commit ucitrack + +#setup serval (Enable if in R1) config_load serval uci_add serval settings settings uci_set serval settings enabled false @@ -12,4 +19,7 @@ uci_set serval settings update_mdp_keyring false uci_set serval settings new_mdp_keyring false uci_commit serval +#use our help icon +cp /www/luci-static/commotion/help.png /www/luci-static/resources/cbi/help.gif + exit 0 From bdc1b72bab7e0fa7b2460d51d51c9a7b0c01926c Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 15 Dec 2013 17:32:35 -0500 Subject: [PATCH 110/196] finally fixed all password issues --- luasrc/model/cbi/commotion/basic_ns.lua | 16 +++------ luasrc/model/cbi/commotion/security_pass.lua | 37 +++++++++++--------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index cd4f125..647596e 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -80,7 +80,6 @@ s.anonymous = true pw1 = s:option(Value, "_pw1", translate("Password")) pw1.password = true -pw1.datatype = [[]] pw2 = s:option(Value, "_pw2", translate("Confirmation")) pw2.password = true @@ -89,7 +88,7 @@ function s.cfgsections() return { "_pass" } end -function m.on_parse(map) --! @TODO this does not work +function m.on_parse(self) local form = http.formvaluetable("cbid") local check = nil local conf_pass = nil @@ -111,7 +110,6 @@ function m.on_parse(map) --! @TODO this does not work if v0 ~= true then m.message = translate("Incorrect password. Changes rejected!") m.save = false - function m.on_after_save() return true end --Don't redirect on error end else m.message = translate("Please enter your old password. Changes rejected!") @@ -121,8 +119,7 @@ function m.on_parse(map) --! @TODO this does not work end end -function m.on_save(map) --! @TODO this does not check any of the pasword checks with the new form. --- db.log(http.formvalue()) +function m.on_save(self) local v1 = pw1:formvalue("_pass") local v2 = pw2:formvalue("_pass") if v0 == true and v1 and v2 and #v1 > 0 and #v2 > 0 then @@ -130,18 +127,15 @@ function m.on_save(map) --! @TODO this does not check any of the pasword checks if luci.sys.user.setpasswd("root", v1) == 0 then m.message = translate("Password successfully changed!") if SW.status() then - uci:set("setup_wizard", "tracking", "adminPass", 'true') + uci:set("setup_wizard", "passwords", "admin_pass", 'changed') uci:save("setup_wizard") - uci:commit("setup_wizard") end else - --function m.on_after_save() return true end - m.message = translate("Unknown Error, password not changed!") + m.message = translate("Unknown Error with Admin password change, password not changed!") m.state = -1 end else - --function m.on_after_save() return true end - m.message = translate("Given password confirmation did not match, password not changed!") + m.message = translate("Given Admin password confirmation did not match, password not changed!") m.state = -1 end end diff --git a/luasrc/model/cbi/commotion/security_pass.lua b/luasrc/model/cbi/commotion/security_pass.lua index e6257eb..f190371 100644 --- a/luasrc/model/cbi/commotion/security_pass.lua +++ b/luasrc/model/cbi/commotion/security_pass.lua @@ -17,6 +17,7 @@ along with this program. If not, see . local db = require "luci.commotion.debugger" local http = require "luci.http" local ccbi = require "luci.commotion.ccbi" +local uci = require "luci.model.uci".cursor() local m = Map("wireless", translate("Passwords"), translate("Commotion basic security settings places all the passwords and other security features in one place for quick configuration. ")) @@ -43,7 +44,7 @@ if luci.sys.user.getpasswd("root") then end local interfaces = {} -uci.foreach("wireless", "wifi-iface", +uci:foreach("wireless", "wifi-iface", function(s) local name = s[".name"] local key = s.key or "NONE" @@ -89,14 +90,14 @@ function pw_sec_opt(pw_s, iface) end --password options - pw1 = pw_s:option(Value, (iface.name.."_pass1")) + pw1 = pw_s:option(Value, (iface.name.."_pw1")) pw1.password = true - pw1.anonymous = true pw1:depends("encryption", "psk2") + pw1.datatype = "wpakey" + --confirmation password - pw2 = pw_s:option(Value, iface.name.."_pass2", nil, translate("Confirm Password")) + pw2 = pw_s:option(Value, iface.name.."_pw2", nil, translate("Confirm Password")) pw2.password = true - pw2.anonymous = true pw2:depends("encryption", "psk2") --password should write to the key, not to the dummy value @@ -104,13 +105,15 @@ function pw_sec_opt(pw_s, iface) return self.map:set(section, "key", value) end - function pw2.write() return true end + --Don't actually write this value, just return success + function pw2.write(self, section, value) + return true + end --make sure passwords are equal function pw1.validate(self, value, section) local v1 = value - local v2 = pw2:formvalue(section) - --local v2 = http.formvalue(string.gsub(self:cbid(section), "%d$", "2")) + local v2 = http.formvalue(string.gsub(self:cbid(section), "%d$", "2")) if v1 and v2 and #v1 > 0 and #v2 > 0 then if v1 == v2 then if m.message == nil then @@ -120,11 +123,13 @@ function pw_sec_opt(pw_s, iface) else m.message = translate("Error, no changes saved. See below.") self:add_error(section, translate("Given password confirmation did not match, password not changed!")) + m.state = -1 return nil end else m.message = translate("Error, no changes saved. See below.") self:add_error(section, translate("Unknown Error, password not changed!")) + m.state = -1 return nil end end @@ -146,8 +151,6 @@ if #mesh_ifaces > 1 then meshPW = pw_sec_opt(meshPW, x) end else - db.log("mesh ifaces") - db.log(mesh_ifaces[1].name) local meshPW = m:section(NamedSection, mesh_ifaces[1].name, "wifi-iface", mesh_ifaces[1].name, pw_text) meshPW = pw_sec_opt(meshPW, mesh_ifaces[1]) end @@ -177,7 +180,7 @@ for i,iface in ipairs(interfaces) do end --!brief This map checks for the admin password field and denies all saving and removes the confirmation page redirect if it is there. -function m.on_parse(map) +function m.on_parse(self) local form = http.formvaluetable("cbid.wireless") local check = nil local conf_pass = nil @@ -198,7 +201,6 @@ function m.on_parse(map) if v0 ~= true then m.message = translate("Incorrect password. Changes rejected!") m.save = false - function m.on_after_save() return true end --Don't redirect on error end else m.message = translate("Please enter your old password. Changes rejected!") @@ -207,20 +209,23 @@ function m.on_parse(map) end end +--! admin password changes checks function m.on_save(self) - local v1 = pw1:formvalue("_pass") - local v2 = pw2:formvalue("_pass") + local v1 = admin_pw1:formvalue("_pass") + local v2 = admin_pw2:formvalue("_pass") if v0 == true and v1 and v2 and #v1 > 0 and #v2 > 0 then if v1 == v2 then if luci.sys.user.setpasswd(luci.dispatcher.context.authuser, v1) == 0 then - --TODO WAIT @critzo/@georgiamoon decide upon administration password experience for confirmation page. --- eg. function m.on_after_save() return true end --Don't redirect on admin pw success as it is not a uci value and shows up as nil. m.message = translate("Admin Password successfully changed!") + uci:set("setup_wizard", "passwords", "admin_pass", 'changed') + uci:save("setup_wizard") else m.message = translate("Unknown Error, password not changed!") + m.state = -1 end else m.message = translate("Given password confirmation did not match, password not changed!") + m.state = -1 end end end From eacbd1236ad16e491e735ddb66d65958759b97d1 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 15 Dec 2013 17:33:50 -0500 Subject: [PATCH 111/196] changed the admin pass uci settings name --- files/etc/config/setup_wizard | 4 ++-- luasrc/controller/commotion/setup_ctl.lua | 2 +- luasrc/model/cbi/commotion/basic_done.lua | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/files/etc/config/setup_wizard b/files/etc/config/setup_wizard index 10477da..2ba59c0 100644 --- a/files/etc/config/setup_wizard +++ b/files/etc/config/setup_wizard @@ -1,5 +1,5 @@ config settings settings option enabled '1' -config uci tracking - option adminPass 'false' \ No newline at end of file +config uci passwords + option admin_pass 'false' \ No newline at end of file diff --git a/luasrc/controller/commotion/setup_ctl.lua b/luasrc/controller/commotion/setup_ctl.lua index 55218ca..eb7ced6 100644 --- a/luasrc/controller/commotion/setup_ctl.lua +++ b/luasrc/controller/commotion/setup_ctl.lua @@ -73,7 +73,7 @@ function action_setup() if SW.status() then uci:set("setup_wizard", "settings", "enabled", "0") - uci:set("setup_wizard", "tracking", "adminPass", "false") + uci:set("setup_wizard", "passwords", "admin_pass", 'false') uci:save("setup_wizard") uci:commit("setup_wizard") end diff --git a/luasrc/model/cbi/commotion/basic_done.lua b/luasrc/model/cbi/commotion/basic_done.lua index fce4f61..1427183 100644 --- a/luasrc/model/cbi/commotion/basic_done.lua +++ b/luasrc/model/cbi/commotion/basic_done.lua @@ -18,8 +18,8 @@ along with this program. If not, see . m = Map("system", translate("Basic Configuration Complete!"), translate("You have completed all of the required steps to configure this mesh node.")) m.skip_to_end = true -s = m:section(SimpleSection, "stuff", "", translate("If you would like to configure additional network interfaces on this node, continue to Additional Network Settings below. Otherwise click Review & Apply.")) +s = m:section(SimpleSection, "stuff", translate("If you would like to configure additional network interfaces on this node, continue to Additional Network Settings below. Otherwise click Review & Apply.")) s.anonymous = true - +s.title = nil return m From 55e5766d400f3238753fc28693b30b576321a450 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 15 Dec 2013 17:34:19 -0500 Subject: [PATCH 112/196] added save changes to flags in need, which were flags indeed. --- luasrc/model/cbi/commotion/basic_ani.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/luasrc/model/cbi/commotion/basic_ani.lua b/luasrc/model/cbi/commotion/basic_ani.lua index b73845e..33f0262 100644 --- a/luasrc/model/cbi/commotion/basic_ani.lua +++ b/luasrc/model/cbi/commotion/basic_ani.lua @@ -43,11 +43,13 @@ msh.enabled = "true" msh.disabled = "false" msh.default = "false" msh.addremove = false +msh.write = ccbi.flag_write ance = p:option(Flag, "announced", translate("Advertise your gateway to the mesh.")) ance.enabled = "true" ance.disabled = "false" ance.addremove = false ance.default = 'true' - +ance.write = ccbi.flag_write + return m From 0658f71c661c5cebc2464865fcb4cb34dbe2afc7 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 15 Dec 2013 19:15:34 -0500 Subject: [PATCH 113/196] formatted status header info items to look pretty --- luasrc/view/commotion/status.htm | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/luasrc/view/commotion/status.htm b/luasrc/view/commotion/status.htm index d22babb..11c161c 100644 --- a/luasrc/view/commotion/status.htm +++ b/luasrc/view/commotion/status.htm @@ -19,15 +19,21 @@ <%+header%> -
      -
      -

      <%:Providing Gateway%><%=gateway_provided%>

      -
      -
      -<%- for _,iface in pairs(ifaces) do -%> -

      <%=iface.name%><%=iface.status%> <%=iface.sec%> <%=iface.conn%>

      -<%end%> -
      +
      + + + + + +
      <%:Providing Gateway%><%=gateway_provided%>
      + + <%- for _,iface in pairs(ifaces) do -%> + + + + + <%end%> +
      <%=iface.name%><%=iface.status%><%=iface.sec%><%=iface.conn%> Connections
        From 8a74c7f7f8f3768ab51ebb64cc30bb247ecc534a Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 16 Dec 2013 09:57:21 -0500 Subject: [PATCH 114/196] corrected debug submit link to point to the correct directory. --- luasrc/view/commotion/debug.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/view/commotion/debug.htm b/luasrc/view/commotion/debug.htm index 9b5dfb6..fb6a7f1 100644 --- a/luasrc/view/commotion/debug.htm +++ b/luasrc/view/commotion/debug.htm @@ -18,7 +18,7 @@ } <%- - local debugurl = luci.dispatcher.build_url('admin', 'commotion', 'debug', 'submit') + local debugurl = luci.dispatcher.build_url('admin', 'status', 'debug', 'submit') -%>
        From 4f3044f5368f1ab376994e28c60a90ee29a37158 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 16 Dec 2013 10:01:45 -0500 Subject: [PATCH 115/196] moved theme based changes into the theme uci files --- files/etc/uci-defaults/luci-setup-wizard | 3 --- 1 file changed, 3 deletions(-) diff --git a/files/etc/uci-defaults/luci-setup-wizard b/files/etc/uci-defaults/luci-setup-wizard index 8743703..3e55cc3 100755 --- a/files/etc/uci-defaults/luci-setup-wizard +++ b/files/etc/uci-defaults/luci-setup-wizard @@ -19,7 +19,4 @@ uci_set serval settings update_mdp_keyring false uci_set serval settings new_mdp_keyring false uci_commit serval -#use our help icon -cp /www/luci-static/commotion/help.png /www/luci-static/resources/cbi/help.gif - exit 0 From 941e5491f3c901d8efdafaca0904e0f14a36d1c9 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 16 Dec 2013 10:17:53 -0500 Subject: [PATCH 116/196] changed setup_wiz button ordering --- luasrc/view/cbi/commotion/delegator.htm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/luasrc/view/cbi/commotion/delegator.htm b/luasrc/view/cbi/commotion/delegator.htm index db17b6e..2b5afdf 100644 --- a/luasrc/view/cbi/commotion/delegator.htm +++ b/luasrc/view/cbi/commotion/delegator.htm @@ -41,20 +41,19 @@

        "<%=title%>" <% end %> <% if not self.disallow_pageactions then %> - -<% if self.allow_finish and not self:get_next(self.current) then %> - -<% elseif self:get_next(self.current) then %> - -<% end %> -<% if self.current == "Configuration Complete" then %> - +<% if self.allow_back and self:get_prev(self.current) then %> + <% end %> <% if self.allow_reset then %> <% end %> -<% if self.allow_back and self:get_prev(self.current) then %> - +<% if self.current == "Configuration Complete" then %> + +<% end %> +<% if self.allow_finish and not self:get_next(self.current) then %> + +<% elseif self:get_next(self.current) then %> + <% end %> <% end %> From 1c777928b95bd2b51055cc2f76e6708d730c9ac0 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 16 Dec 2013 10:22:23 -0500 Subject: [PATCH 117/196] added title tag text to all movement buttons --- luasrc/view/cbi/commotion/delegator.htm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/luasrc/view/cbi/commotion/delegator.htm b/luasrc/view/cbi/commotion/delegator.htm index 2b5afdf..0434728 100644 --- a/luasrc/view/cbi/commotion/delegator.htm +++ b/luasrc/view/cbi/commotion/delegator.htm @@ -42,18 +42,18 @@

        "<%=title%>" <% end %> <% if not self.disallow_pageactions then %> <% if self.allow_back and self:get_prev(self.current) then %> - + <% end %> <% if self.allow_reset then %> - + <% end %> <% if self.current == "Configuration Complete" then %> - + <% end %> <% if self.allow_finish and not self:get_next(self.current) then %> - + <% elseif self:get_next(self.current) then %> - + <% end %> <% end %> From fd8dee9439f047b7bb2dec7dde5b5d44eaf3a663 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 16 Dec 2013 10:28:08 -0500 Subject: [PATCH 118/196] updated page titles to not use ironic quotes --- luasrc/view/cbi/commotion/delegator.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/view/cbi/commotion/delegator.htm b/luasrc/view/cbi/commotion/delegator.htm index 0434728..b33c78d 100644 --- a/luasrc/view/cbi/commotion/delegator.htm +++ b/luasrc/view/cbi/commotion/delegator.htm @@ -27,7 +27,7 @@ <%else%>
        <%end%> -

        "<%=title%>" +

        <%=title%>

        <% end %> From 142cb8a723818f7a1b75367d9395276970c66f19 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 16 Dec 2013 11:47:06 -0500 Subject: [PATCH 119/196] added checks for passwords that work in setup wizard --- luasrc/model/cbi/commotion/basic_ns.lua | 93 ++++++++++++++----------- 1 file changed, 51 insertions(+), 42 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_ns.lua b/luasrc/model/cbi/commotion/basic_ns.lua index 647596e..4f1434d 100644 --- a/luasrc/model/cbi/commotion/basic_ns.lua +++ b/luasrc/model/cbi/commotion/basic_ns.lua @@ -84,61 +84,70 @@ pw1.password = true pw2 = s:option(Value, "_pw2", translate("Confirmation")) pw2.password = true +--make sure passwords are equal +function pw1.validate(self, value, section) + local v1 = value + local v2 = pw2:formvalue(section) + --local v2 = http.formvalue(string.gsub(self:cbid(section), "%d$", "2")) + if root_pass_check() == true then + if v1 and v2 and #v1 > 0 and #v2 > 0 then + if v1 == v2 then + if m.message == nil then + m.message = translate("Password successfully changed!") + end + return value + else + m.message = translate("Error, no changes saved. See below.") + self:add_error(section, translate("Given confirmation password did not match, password not changed!")) + return nil + end + else + m.message = translate("Error, no changes saved. See below.") + self:add_error(section, translate("Unknown Error, password not changed!")) + return nil + end + end +end + function s.cfgsections() return { "_pass" } end -function m.on_parse(self) - local form = http.formvaluetable("cbid") - local check = nil - local conf_pass = nil - for field,val in pairs(form) do - string.gsub(field, ".-_pw(%d)$", - function(num) - if tonumber(num) == 0 then - conf_pass = val - end - if val ~= nil and val ~= "" then - check = true - end - end) - end - if check ~= nil then - if not SW.status() then +function root_pass_check() + if not SW.status() then + local form = http.formvaluetable("cbid") + local check = nil + local conf_pass = nil + for field,val in pairs(form) do + string.gsub(field, ".-_pw(%d)$", + function(num) + if tonumber(num) == 0 then + conf_pass = val + end + if val ~= nil and val ~= "" then + check = true + end + end) + end + if check ~= nil then if conf_pass then v0 = luci.sys.user.checkpasswd("root", conf_pass) if v0 ~= true then - m.message = translate("Incorrect password. Changes rejected!") + m.message = translate("Incorrect node administration password. Changes rejected!") m.save = false + return false + else + return true end else - m.message = translate("Please enter your old password. Changes rejected!") + m.message = translate("Please enter your old node administration password. Changes rejected!") m.save = false + return false end - end + else + return true + end end end -function m.on_save(self) - local v1 = pw1:formvalue("_pass") - local v2 = pw2:formvalue("_pass") - if v0 == true and v1 and v2 and #v1 > 0 and #v2 > 0 then - if v1 == v2 then - if luci.sys.user.setpasswd("root", v1) == 0 then - m.message = translate("Password successfully changed!") - if SW.status() then - uci:set("setup_wizard", "passwords", "admin_pass", 'changed') - uci:save("setup_wizard") - end - else - m.message = translate("Unknown Error with Admin password change, password not changed!") - m.state = -1 - end - else - m.message = translate("Given Admin password confirmation did not match, password not changed!") - m.state = -1 - end - end -end - return m From 17e3becd097ee199d5f0d218ace064ab7fa33dc8 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 16 Dec 2013 11:47:41 -0500 Subject: [PATCH 120/196] removed extra form header --- luasrc/view/cbi/commotion/delegator.htm | 1 - 1 file changed, 1 deletion(-) diff --git a/luasrc/view/cbi/commotion/delegator.htm b/luasrc/view/cbi/commotion/delegator.htm index b33c78d..4c46b9e 100644 --- a/luasrc/view/cbi/commotion/delegator.htm +++ b/luasrc/view/cbi/commotion/delegator.htm @@ -1,5 +1,4 @@ <%+header%> -
        @@ -24,7 +18,7 @@ <%if x == self.current then%>
        <%else%> -
        +
        <%end%>

        <%=title%>

        From b706f049083ac1a007bf910676890e3345f7837f Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 20 Dec 2013 13:43:16 -0500 Subject: [PATCH 162/196] made setup_wizard end on apply. --- luasrc/view/commotion/apply.htm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/luasrc/view/commotion/apply.htm b/luasrc/view/commotion/apply.htm index 6014b8d..4336927 100644 --- a/luasrc/view/commotion/apply.htm +++ b/luasrc/view/commotion/apply.htm @@ -16,6 +16,9 @@ <%+header%> <%if SW.status() then redirect = luci.dispatcher.build_url("setupctl", "complete") + uci = require "luci.model.uci".cursor() + uci:set("setup_wizard", "settings", "enabled", "0") + uci:save("setup_wizard") else redirect = luci.dispatcher.build_url("admin","commotion") end%> From d3294c033cfb1d39667c7454c2973ddcf946af79 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Fri, 20 Dec 2013 17:41:39 -0500 Subject: [PATCH 163/196] Made a requirement for mesh interfaces to have unique names before a network is created. Also, made them add themselves to the mesh firewall zone when the network is added. --- luasrc/model/cbi/commotion/basic_mn.lua | 84 ++++++++++++++++++------- 1 file changed, 60 insertions(+), 24 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_mn.lua b/luasrc/model/cbi/commotion/basic_mn.lua index 7d43c49..323c5f1 100644 --- a/luasrc/model/cbi/commotion/basic_mn.lua +++ b/luasrc/model/cbi/commotion/basic_mn.lua @@ -56,6 +56,19 @@ if not SW.status() then --if not setup wizard then allow for adding and removal end end + +function s:filter(section) + mode = self.map:get(section, "mode") + return mode == "adhoc" or mode == nil +end + +s.valuefooter = "cbi/full_valuefooter" +s.template_addremove = "cbi/commotion/addMesh" --This template controls the addremove form for adding a new access point so that it has better wording. + +name = s:option(Value, "ssid", translate("Mesh Network Name"), translate("Commotion networks share a network-wide name. This must be the same across all devices on the same mesh. This name cannot be greater than 15 characters.")) +name.default = "Commotion" +name.datatype = "maxlength(15)" + nwk = s:option(Value, "network") --! @brief checks for invalid ssid values and rejects the name it they exist. function nwk.datatype(val) @@ -65,39 +78,62 @@ function nwk.datatype(val) return false end end + --! @brief creates a network section and same named commotion profile when creating a mesh interface and assigns it to that mesh interface -function nwk:write(section, value) - net_name = name:formvalue(section) - if net_name ~= nil then - net_name = string.gsub(net_name, "[%p%s%z]", "_") - network_name = uci:section("network", "interface", net_name, {proto="commotion", class='mesh'}) - cnw.commotion_set(network_name) - uci:set("network", network_name, "profile", network_name) - uci:save("network") - return self.map:set(section, self.option, network_name) +function write_network(value) + local net_name = value + net_name = string.gsub(net_name, "[%p%s%z]", "_") + network_name = uci:section("network", "interface", net_name, {proto="commotion", class='mesh'}) + cnw.commotion_set(network_name) + uci:set("network", network_name, "profile", network_name) + uci:save("network") + if value ~= nil then + uci:foreach("firewall", "zone", + function(s) + if s.name and s.name == "mesh" then + local list = {value} + for _,x in ipairs(s.network) do + table.insert(list, x) + end + uci:set_list ("firewall", s[".name"], "network", list) + uci:save("firewall") + end + end + ) end end + +function check_name(section, value) + local uci = require "luci.model.uci".cursor() + local clean_name = string.gsub(value, "[%p%s%z]", "_") + local exist = uci:get("network", clean_name) + if exist ~= nil then + m.message = "You cannot have multiple interfaces with the same name." + m.state = -1 + name:add_error(section, nil, "This section is named the same as an existing interface.") + db.log("errors set because of existing network") + return nil + else + return true + end +end + nwk.render = function() end function nwk:parse(section) + db.log("parsing network") local cvalue = self:cfgvalue(section) - if not cvalue then - self:write(section, self.default) + local name = name:formvalue(section) + if name ~= nil and not cvalue then + if check_name(section, name) ~= nil then + write_network(name) + else + db.log("failed to write the network.") + end + else + db.log("Already set or a nil value.") end end -function s:filter(section) - mode = self.map:get(section, "mode") - return mode == "adhoc" or mode == nil -end - -s.valuefooter = "cbi/full_valuefooter" -s.template_addremove = "cbi/commotion/addMesh" --This template controls the addremove form for adding a new access point so that it has better wording. - - -name = s:option(Value, "ssid", translate("Mesh Network Name"), translate("Commotion networks share a network-wide name. This must be the same across all devices on the same mesh. This name cannot be greater than 15 characters.")) -name.default = "Commotion" -name.datatype = "maxlength(15)" - local wifi_dev = {} uci.foreach("wireless", "wifi-device", function(s) From dc63660c8ed7cd8b36a5eea700be9f00f0e12d13 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 21 Dec 2013 09:56:20 -0500 Subject: [PATCH 164/196] removed setup wizard switch that was stopping applied changes from sending responses back to unauthed user. --- luasrc/view/commotion/apply.htm | 3 --- 1 file changed, 3 deletions(-) diff --git a/luasrc/view/commotion/apply.htm b/luasrc/view/commotion/apply.htm index 4336927..6014b8d 100644 --- a/luasrc/view/commotion/apply.htm +++ b/luasrc/view/commotion/apply.htm @@ -16,9 +16,6 @@ <%+header%> <%if SW.status() then redirect = luci.dispatcher.build_url("setupctl", "complete") - uci = require "luci.model.uci".cursor() - uci:set("setup_wizard", "settings", "enabled", "0") - uci:save("setup_wizard") else redirect = luci.dispatcher.build_url("admin","commotion") end%> From 0479043de432a14f785e03447d40b2ce0406d208 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 21 Dec 2013 10:01:34 -0500 Subject: [PATCH 165/196] added redirect location for apply that turns off setup_wizard --- luasrc/view/commotion/apply.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/view/commotion/apply.htm b/luasrc/view/commotion/apply.htm index 6014b8d..77fa0f0 100644 --- a/luasrc/view/commotion/apply.htm +++ b/luasrc/view/commotion/apply.htm @@ -15,7 +15,7 @@ <%SW = require "luci.commotion.setup_wizard"%> <%+header%> <%if SW.status() then - redirect = luci.dispatcher.build_url("setupctl", "complete") + redirect = luci.dispatcher.build_url("commotion", "advanced") else redirect = luci.dispatcher.build_url("admin","commotion") end%> From 413b20d05ca897a6e67a4a5aa86234298809b204 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 21 Dec 2013 11:23:24 -0500 Subject: [PATCH 166/196] added uci.olsrd.LoadPlugin dynamic gateway plugin section removal and addition from additional network interfaces page. --- luasrc/model/cbi/commotion/basic_ani.lua | 49 +++++++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_ani.lua b/luasrc/model/cbi/commotion/basic_ani.lua index 3350faa..1a1cdce 100644 --- a/luasrc/model/cbi/commotion/basic_ani.lua +++ b/luasrc/model/cbi/commotion/basic_ani.lua @@ -45,11 +45,48 @@ msh.default = "false" msh.addremove = false msh.write = ccbi.flag_write -ance = p:option(Flag, "announced", translate("Advertise your gateway to the mesh.")) -ance.enabled = "true" -ance.disabled = "false" -ance.addremove = false -ance.default = 'true' -ance.write = ccbi.flag_write +ance = p:option(Flag, "_gateway", translate("Advertise your gateway to the mesh.")) +ance.addremove = true + +function dyn_exists() + local cvalue = nil + uci:foreach("olsrd", "LoadPlugin", + function(p) + if string.match(p.library, "^olsrd_dyn_gw_plain.*") then + cvalue = p[".name"] + end + end + ) + return cvalue +end + +function ance.cfgvalue(self, section) + if dyn_exists() ~= nil then + return '1' + else + return '0' + end +end + +function ance.write(self, section, fvalue) + if dyn_exists() == nil then + self.section.changed = true + --! @TODO Make this actually check the installed version and not just use 0.4. + uci:section("olsrd", "LoadPlugin", nil, {library="olsrd_dyn_gw_plain.so.0.4"}) + uci:save("olsrd") + return true + end +end + +function ance.remove(self, section) + local cvalue = dyn_exists() + if cvalue ~= nil then + self.section.changed = true + uci:delete("olsrd", cvalue) + uci:save("olsrd") + return true + end +end + return m From a1307ef813ae192340d2d1a6ba4f002dbb2fd83f Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 21 Dec 2013 12:36:24 -0500 Subject: [PATCH 167/196] added back in the wireless network stanza. --- luasrc/model/cbi/commotion/basic_mn.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_mn.lua b/luasrc/model/cbi/commotion/basic_mn.lua index 323c5f1..ace6987 100644 --- a/luasrc/model/cbi/commotion/basic_mn.lua +++ b/luasrc/model/cbi/commotion/basic_mn.lua @@ -81,8 +81,7 @@ end --! @brief creates a network section and same named commotion profile when creating a mesh interface and assigns it to that mesh interface function write_network(value) - local net_name = value - net_name = string.gsub(net_name, "[%p%s%z]", "_") + local net_name = string.gsub(value, "[%p%s%z]", "_") network_name = uci:section("network", "interface", net_name, {proto="commotion", class='mesh'}) cnw.commotion_set(network_name) uci:set("network", network_name, "profile", network_name) @@ -91,15 +90,16 @@ function write_network(value) uci:foreach("firewall", "zone", function(s) if s.name and s.name == "mesh" then - local list = {value} + local list = {net_name} for _,x in ipairs(s.network) do table.insert(list, x) end uci:set_list ("firewall", s[".name"], "network", list) - uci:save("firewall") + uci:save("firewall") end end ) + return net_name end end @@ -125,7 +125,8 @@ function nwk:parse(section) local name = name:formvalue(section) if name ~= nil and not cvalue then if check_name(section, name) ~= nil then - write_network(name) + local net_name = write_network(name) + self.map:set(section, "network", net_name) else db.log("failed to write the network.") end From 7d8f83247112a5a21cf4ff9ad04ad81208c3ea99 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 21 Dec 2013 14:25:06 -0500 Subject: [PATCH 168/196] made network settings that the node sets be set by uci instead of by the map, which does not set values on an error. The map received an error when the passwords were wrong, so the check for the network that usually allows existing nodes to not error out on having the same network name as themselves does not have a network name to pull from. --- luasrc/model/cbi/commotion/basic_mn.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_mn.lua b/luasrc/model/cbi/commotion/basic_mn.lua index ace6987..d13764a 100644 --- a/luasrc/model/cbi/commotion/basic_mn.lua +++ b/luasrc/model/cbi/commotion/basic_mn.lua @@ -103,16 +103,21 @@ function write_network(value) end end -function check_name(section, value) +function check_name(self, section, value) local uci = require "luci.model.uci".cursor() local clean_name = string.gsub(value, "[%p%s%z]", "_") local exist = uci:get("network", clean_name) if exist ~= nil then - m.message = "You cannot have multiple interfaces with the same name." - m.state = -1 - name:add_error(section, nil, "This section is named the same as an existing interface.") - db.log("errors set because of existing network") - return nil + local current = self.map:get(section, "network") + if current == clean_name then + return true + else + m.message = "You cannot have multiple interfaces with the same name." + m.state = -1 + name:add_error(section, nil, "This section is named the same as an existing interface.") + db.log("errors set because of existing network") + return nil + end else return true end @@ -124,10 +129,11 @@ function nwk:parse(section) local cvalue = self:cfgvalue(section) local name = name:formvalue(section) if name ~= nil and not cvalue then - if check_name(section, name) ~= nil then + if check_name(self, section, name) ~= nil then local net_name = write_network(name) - self.map:set(section, "network", net_name) - else + uci:set("wireless", section, "network", net_name) + uci:save("wireless") + else db.log("failed to write the network.") end else From fd37b1a561da309f340bcb8ad0f755615fcc09cb Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 21 Dec 2013 15:15:57 -0500 Subject: [PATCH 169/196] removed bug where serval keyring would write an empty keyring so get_sid would not create a new one. --- luasrc/model/cbi/commotion/security_smk.lua | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/luasrc/model/cbi/commotion/security_smk.lua b/luasrc/model/cbi/commotion/security_smk.lua index 4f3b9d3..92a83d6 100644 --- a/luasrc/model/cbi/commotion/security_smk.lua +++ b/luasrc/model/cbi/commotion/security_smk.lua @@ -198,13 +198,8 @@ function new.validate(self, section, value) db.log("new") m.save = true sys.exec("rm /etc/commotion/keys.d/mdp/serval.keyring") - local create = sys.exec("SERVALINSTANCE_PATH=/etc/commotion/keys.d/mdp/ serval-client keyring create") set_commotion() - if create then - return 'true' - else - return nil - end + return true end return m From f691a1d1af4d023fa27b722c0f1c67b548c55e00 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 21 Dec 2013 17:23:40 -0500 Subject: [PATCH 170/196] made the welcome page only choose br-lan when choosing interfaces as a quick fix to bridging creating confusion as to what iface to choose. --- luasrc/model/cbi/commotion/client_wp.lua | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/luasrc/model/cbi/commotion/client_wp.lua b/luasrc/model/cbi/commotion/client_wp.lua index c34a46e..a8831e4 100644 --- a/luasrc/model/cbi/commotion/client_wp.lua +++ b/luasrc/model/cbi/commotion/client_wp.lua @@ -27,16 +27,29 @@ m = Map("nodogsplash", translate("Welcome Page")) --redirect on saved and changed to check changes. m.on_after_save = ccbi.conf_page - enable = m:section(TypedSection, "settings", translate("On/Off"), translate("Users can be redirected to a “welcome page” when they first connect to this node.")) enable.anonymous = true toggle = enable:option(Flag, "enable") -toggle.write = ccbi.flag_write -toggle.remove = ccbi.flag_remove +function toggle.write(self, section, fvalue) + value = self.map:get(section, self.option) + if value ~= fvalue then + self.section.changed = true + self.map:set("interfaces", "interface", "br-lan") + return self.map:set(section, self.option, fvalue) + end +end -ifaces = m:section(TypedSection, "interfaces", translate("For which network connection should this welcome page be active?"), translate("Select list of Aps and /or defined networks on this node's interfaces Auto select the first AP interface if configured.")) +function toggle.remove(self, section) + value = self.map:get(section, self.option) + if value ~= self.disabled then + self.section.changed = true + return self.map:del(section, self.option) + end +end + +--[[ifaces = m:section(TypedSection, "interfaces", translate("For which network connection should this welcome page be active?"), translate("Select list of Aps and /or defined networks on this node's interfaces Auto select the first AP interface if configured.")) ifaces.anonymous = true iflist = ifaces:option(ListValue, "interface") @@ -51,6 +64,7 @@ uci.foreach("wireless", "wifi-iface", end end ) +]]-- stime = m:section(TypedSection, "settings", translate("Time until welcome page is shown again")) stime.anonymous = true From ee6b7ec807837aee032789893d0cb1edb935d13e Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 21 Dec 2013 19:03:39 -0500 Subject: [PATCH 171/196] added support for uploading and downloading serval key files. --- luasrc/model/cbi/commotion/security_smk.lua | 31 +++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/luasrc/model/cbi/commotion/security_smk.lua b/luasrc/model/cbi/commotion/security_smk.lua index 92a83d6..d141fe2 100644 --- a/luasrc/model/cbi/commotion/security_smk.lua +++ b/luasrc/model/cbi/commotion/security_smk.lua @@ -28,11 +28,15 @@ m = Map("olsrd", translate("Shared Mesh Keychain"), translate("To ensure that on --redirect on saved and changed to check changes. m.on_after_save = ccbi.conf_page -s = m:section(NamedSection, "LoadPlugin", "olsrd_mdp", translate("Use a Shared Mesh Keychain to sign mesh routes. Yes/No"), translate("Check the box to use a Shared Mesh Keychain on this device. You'll also be required to upload or generate a Shared Mesh Keychain.")) +s = m:section(TypedSection, "LoadPlugin", translate("Use a Shared Mesh Keychain to sign mesh routes. Yes/No"), translate("Check the box to use a Shared Mesh Keychain on this device. You'll also be required to upload or generate a Shared Mesh Keychain.")) s.addremove = true +s.anonymous = true + +function s.filter(self, section) + return self.map:get(section, "library") == "olsrd_mdp.so.0.1" +end function s.remove(self, section) - db.log("s.remove") unset_commotion() return self.map:del(section) end @@ -45,7 +49,7 @@ function s.parse(self, novld) else db.log("changes NOT found") end - NamedSection.parse(self, novld) + TypedSection.parse(self, novld) end lib = s:option(Value, "library") @@ -122,8 +126,8 @@ function get_sid(path) path = "/etc/commotion/keys.d/mdp/" end if not fs.isfile("/etc/commotion/keys.d/mdp/serval.keyring") then - sys.exec("SERVALINSTANCE_PATH="..path.." serval-client keyring create") - sys.exec("SERVALINSTANCE_PATH="..path.." serval-client keyring add") + sys.exec("SERVALINSTANCE_PATH=/etc/commotion/keys.d/mdp/ serval-client keyring create") + sys.exec("SERVALINSTANCE_PATH=/etc/commotion/keys.d/mdp/ serval-client keyring add") end local sid = sys.exec("SERVALINSTANCE_PATH="..path.." serval-client keyring list") local key = string.match(sid, "^(%w*):%w*:?") @@ -159,14 +163,13 @@ uploader.anonymous = true function uploader.write(self, section, value) db.log("uploader write") + local nfs = require "nixio.fs" + sys.exec("mv /lib/uci/upload/cbid.olsrd.*._upload /lib/uci/upload/serval.keyring") if get_sid("/lib/uci/upload/") ~= false then - local mv = sys.call("mv /lib/uci/upload/cbid.serval.settings._upload /etc/commotion/keys.d/mdp/serval.keyring") - if mv ~= 0 then - return false - else - set_commotion() - return true - end + local mv = nfs.move("/lib/uci/upload/serval.keyring", "/etc/commotion/keys.d/mdp/serval.keyring") + self.map:set(section, "sid", get_sid()) + set_commotion() + m.changed = true else return false end @@ -176,9 +179,9 @@ dwnld = s:option(Button, "_dummy", translate("Download Shared Mesh Keychain"), t dwnld.anonymous = true function dwnld.write(self, section, value) - db.log("write") + local ltn12 = require "luci.ltn12" keyring = uci:get("serval", "settings", "olsrd_mdp_keyring") - local f = io.open(keyring) + local f = io.open(keyring.."/serval.keyring") if not f then self:add_error(section, translate("No Current Serval Key To Download.")) return nil From 39e1d658495fb67c1f7bf2650c19d6258bf5c63c Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sat, 21 Dec 2013 19:04:22 -0500 Subject: [PATCH 172/196] added setup wizard to the files to keep if a node gets sysupgraded so that it stays disabled. --- files/etc/uci-defaults/luci-setup-wizard | 3 +++ 1 file changed, 3 insertions(+) diff --git a/files/etc/uci-defaults/luci-setup-wizard b/files/etc/uci-defaults/luci-setup-wizard index 529ea3d..564647b 100755 --- a/files/etc/uci-defaults/luci-setup-wizard +++ b/files/etc/uci-defaults/luci-setup-wizard @@ -8,4 +8,7 @@ uci_add ucitrack nodogsplash nodogsplash uci_set ucitrack nodogsplash init ucidog uci_commit ucitrack +#setup sysupgrade saves +echo /etc/config/setup_wizard >> /etc/sysupgrade.conf + exit 0 From de5364648e96a1b310b7bbb18f9d20b62a659214 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 10:17:15 -0500 Subject: [PATCH 173/196] gateways were not being reported correctly. a small string matching error as well as the fact that it was lookign for, and reporting if a gateway was NOT coming from the device and instead was being gathered over the mesh. This commit makes it report a gateway ONLY when it is providing a gateway over the ethernet port that is not coming from the mesh or cleint address space. --- luasrc/controller/commotion/status_config.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index 8b34a68..fd73e2b 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -40,7 +40,8 @@ function status_builder(page, assets, active_tab) local db = require "luci.commotion.debugger" local ifaces = {} - local gw = "No" + local internet = nil + local gw = false local zone_iface = cnet.ifaces_list() local splash_info = get_splash_iface_info() uci:foreach("wireless", "wifi-iface", @@ -79,14 +80,20 @@ function status_builder(page, assets, active_tab) end end) for line in util.execi("route -n") do - string.gsub(line, "^0%.0%.0%.0%[%s%t]+(%d+%.%d+)%.%d+%.%d)+[%s%t].+eth0$", + string.gsub(line, "^0%.0%.0%.0[%s%t]+(%d+%.%d+)%.%d+%.%d+[%s%t].+eth0$", function(x) - if string.match(x, "^100%.64^") or string.match(x, "10%.%d+^") then - gw = "Yes" + gw = true + if string.match(x, "^100%.64$") or string.match(x, "10%.%d+$") then + internet = "No" end end) end - luci.template.render("commotion/status", {ifaces=ifaces, gateway_provided=gw, page=page, assets=assets, active_tab=active_tab}) + if gw == true and internet == nil then + internet = "Yes" + elseif internet == nil then + internet = "No" + end + luci.template.render("commotion/status", {ifaces=ifaces, gateway_provided=internet, page=page, assets=assets, active_tab=active_tab}) end function viz() From 4a6484d3f52657fb14b0c8034ce29b7a4d1f19aa Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 11:50:58 -0500 Subject: [PATCH 174/196] some cleanup and copyright --- luasrc/model/cbi/commotion/basic_mn.lua | 7 ------- luasrc/model/cbi/commotion/confirm_config.lua | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/luasrc/model/cbi/commotion/basic_mn.lua b/luasrc/model/cbi/commotion/basic_mn.lua index d13764a..10a6a73 100644 --- a/luasrc/model/cbi/commotion/basic_mn.lua +++ b/luasrc/model/cbi/commotion/basic_mn.lua @@ -31,13 +31,6 @@ if not SW.status() then m.on_after_save = ccbi.conf_page end ---[[function m.on_before_commit() - if SW.status() then - db.log("set commotion values here") - cnw.commotion_set("commotionMesh", {values="mapvalues here"}) --TODO make commotion set actually work - end - end]]-- - s = m:section(TypedSection, "wifi-iface") s.optional = false s.anonymous = true diff --git a/luasrc/model/cbi/commotion/confirm_config.lua b/luasrc/model/cbi/commotion/confirm_config.lua index 2fdc1ad..fdf39f7 100644 --- a/luasrc/model/cbi/commotion/confirm_config.lua +++ b/luasrc/model/cbi/commotion/confirm_config.lua @@ -1,3 +1,20 @@ +--[[ +Copyright (C) 2013 Seamus Tuohy + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + + You should have received a copy of the GNU General Public License +along with this program. If not, see . +]]-- + local cursor = require "luci.model.uci".cursor() --Main title and system config map for hostname value local m = Map("system", translate("Basic Configuration"), translate("In this section you'll set the basic required settings for this device, and the basic network settings required to connect this device to a Commotion Mesh network. You will be prompted to save your settings along the way and apply them at the end.")) From 93f314bbeef30e04cf479789df0a0f1ff472586f Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 12:01:18 -0500 Subject: [PATCH 175/196] updated innit scripts to work --- files/etc/init.d/serval | 68 ----------------------------------------- files/etc/init.d/ucidog | 0 2 files changed, 68 deletions(-) delete mode 100644 files/etc/init.d/serval mode change 100644 => 100755 files/etc/init.d/ucidog diff --git a/files/etc/init.d/serval b/files/etc/init.d/serval deleted file mode 100644 index 32f305a..0000000 --- a/files/etc/init.d/serval +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh /etc/rc.common -# UCI file to allow basic serval modifications through LuCI with proper UI feel - -. /lib/functions/commotion.sh -. /lib/config/uci.sh - -START=19 -STOP=91 - -reload() { - #core vars - local enabled=$(uci_get serval settings enabled) - local upload=cbid.serval.settings._upload - - #mpd vars - local mdp_sid=$(uci_get serval settings mdp_sid) - local update_mdp=$(uci_get serval settings update_mdp_keyring) - local mdp_keyring=$(uci_get serval settings olsrd_mdp_keyring) - local new_mdp=$(uci_get serval settings new_mdp_keyring) - - #primary key vars - local update_primary=$(uci_get serval settings update_primary_keyring) - local primary_keyring=$(uci_get serval settings primary_keyring) - - if [ "$enabled" == "true" ]; then - uci_add "olsrd" "LoadPlugin" "olsrd-mdp" - uci_set "olsrd" $CONFIG_SECTION "library" "olsrd_mdp.so.0.1" - uci_set "olsrd" $CONFIG_SECTION "servalpath" $mdp_keyring - uci_set "olsrd" $CONFIG_SECTION "sid" $mdp_sid - else - uci_remove "olsrd" "olsrd-mdp" - fi - if [ "$update_mdp" == "true" ]; then - mv /lib/uci/upload/$upload $mdp_keyring/serval.keyring || return 1 - export SERVALINSTANCE_PATH=$mdp_keyring - serval-client stop && sleep 1 - serval-client start || return 1 - uci_set "olsrd" "olsrd-mdp" "sid" $mdp_sid - uci_set "olsrd" "olsrd-mdp" "servalpath" $mdp_keyring - elif [ -e "/lib/uci/upload/$upload" ]; then - rm /lib/uci/upload/$upload - fi - uci_set serval settings update_mdp_keyring 'false' - if [ "$update_primary" == "true" ]; then - mv /lib/uci/upload/$upload $primary_keyring/serval.keyring || return 1 - #restart servald to have settings restart - export SERVALINSTANCE_PATH=$primary_keyring - serval-client stop && sleep 1 - serval-client start - elif [ -e "/lib/uci/upload/$upload" ]; then - rm /lib/uci/upload/$upload - fi - if [ "$new_mdp" == "true" ]; then - #delete old key - rm $mdp_keyring/serval.keyring || return 1 - #have serval make a new key - export SERVALINSTANCE_PATH=$mdp_keyring - serval-client stop && sleep 1 - new_sid=serval-client start - #get sid from serval - #new_mdp_sid=???????????? - uci_set "olsrd" "mdpplugin" "sid" $new_sid - uci_set "olsrd" "mdpplugin" "servalpath" $mdp_keyring - fi - uci_set serval settings new_mdp_keyring 'false' - uci_commit serval - uci_commit olsrd -} diff --git a/files/etc/init.d/ucidog b/files/etc/init.d/ucidog old mode 100644 new mode 100755 From b17a79fbd7f5e96f055cfe2e8302ce0730880421 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 12:06:26 -0500 Subject: [PATCH 176/196] fixed errors in nodogsplash --- files/etc/init.d/ucidog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/etc/init.d/ucidog b/files/etc/init.d/ucidog index 87fa768..81c1988 100755 --- a/files/etc/init.d/ucidog +++ b/files/etc/init.d/ucidog @@ -32,11 +32,11 @@ reload() { #set splashpage time sed -i "s/^\(ClientIdleTimeout \).*/\1 $splash_time/" $conffile || return 0 sed -i "s/^\(ClientForceTimeout \).*/\1 $splash_time/" $conffile || return 0 + #get and set interface name local interface=$(uci_get nodogsplash interfaces interface) local network=$(uci_get wireless $interface network) - '{print$2}'| sed 's/"\(\w*\)",/\1/') - sed -i "s/^\(GatewayInterface \).*/\1 $iface_name/" $conffile || return 0 + sed -i "s/^\(GatewayInterface \).*/\1 $interface/" $conffile || return 0 /etc/init.d/nodogsplash stop && sleep 1 /etc/init.d/nodogsplash start } From b3ba5cef50ed05c08f174dcfbba403d98dbf69e8 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 12:09:18 -0500 Subject: [PATCH 177/196] reordered enabling and starting to make sure that a disabled nodogsplash is not started accidentially --- files/etc/init.d/ucidog | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/files/etc/init.d/ucidog b/files/etc/init.d/ucidog index 81c1988..a8cd404 100755 --- a/files/etc/init.d/ucidog +++ b/files/etc/init.d/ucidog @@ -11,13 +11,6 @@ STOP=91 reload() { #nodogsplash configuration file. local conffile=/etc/nodogsplash/nodogsplash.conf - #disable/enable nodogsplash - local enable=$(uci_get nodogsplash settings enable) - if [ "$enable" == '1' ]; then #this might come back as a string and not as a intiger. Check and fix that. - /etc/init.d/nodogsplash disable || return 0 - else - /etc/init.d/nodogsplash enable || return 0 - fi #convert splash page time into minues local splash_time=$(uci_get nodogsplash settings splashtime) @@ -38,5 +31,13 @@ reload() { local network=$(uci_get wireless $interface network) sed -i "s/^\(GatewayInterface \).*/\1 $interface/" $conffile || return 0 /etc/init.d/nodogsplash stop && sleep 1 - /etc/init.d/nodogsplash start + + #disable/enable nodogsplash + local enable=$(uci_get nodogsplash settings enable) + if [ "$enable" == '1' ]; then #this might come back as a string and not as a intiger. Check and fix that. + /etc/init.d/nodogsplash disable || return 0 + else + /etc/init.d/nodogsplash enable || return 0 + /etc/init.d/nodogsplash start || return 0 + fi } From ea61782cbd841ae98eec39574b6717d2dcb8a2ec Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 12:14:20 -0500 Subject: [PATCH 178/196] made enable enable, and disable disable. swapped if statement to correct params --- files/etc/init.d/ucidog | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/files/etc/init.d/ucidog b/files/etc/init.d/ucidog index a8cd404..9e2f662 100755 --- a/files/etc/init.d/ucidog +++ b/files/etc/init.d/ucidog @@ -34,10 +34,11 @@ reload() { #disable/enable nodogsplash local enable=$(uci_get nodogsplash settings enable) + echo "$enable" if [ "$enable" == '1' ]; then #this might come back as a string and not as a intiger. Check and fix that. - /etc/init.d/nodogsplash disable || return 0 - else /etc/init.d/nodogsplash enable || return 0 /etc/init.d/nodogsplash start || return 0 + else + /etc/init.d/nodogsplash disable || return 0 fi } From f958176a8deb572f43406255e9be499ce06f6429 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 12:46:49 -0500 Subject: [PATCH 179/196] clients are not identified if they are connected to the node, no matter what the interface name is and bridging is doing with its crazy ammount of names. --- luasrc/controller/commotion/status_config.lua | 8 ++++++-- luasrc/view/commotion/conn_clients.htm | 5 ++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index fd73e2b..9d172d4 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -102,8 +102,12 @@ end function conn_clnts() clients = get_client_splash_info() - splash = get_splash_iface_info() - status_builder("commotion/conn_clients", {clients=clients, splash=splash}, "connected_clients") + local ifaces = {} + for i in util.execi("ifconfig -a") do + string.gsub(i, "^([%S%T].-)[%s%t]", + function(x) db.log(x) table.insert(ifaces, x) end) + end + status_builder("commotion/conn_clients", {clients=clients, ifaces=ifaces}, "connected_clients") end --! @brief currently only gets number of connected clients... because that is what I needed diff --git a/luasrc/view/commotion/conn_clients.htm b/luasrc/view/commotion/conn_clients.htm index 77b1cfd..c32180d 100644 --- a/luasrc/view/commotion/conn_clients.htm +++ b/luasrc/view/commotion/conn_clients.htm @@ -35,10 +35,9 @@ {title="Bandwidth Used", var="bnd_wdth"}, {title="Average Speed", var="avg_spd"}, {title="Currently Active", var="curr_conn"}} - if #clients > 0 then - for iface_name, conn in pairs(splash) do - for i in util.execi("iw dev "..iface_name.." station dump") do + for _,iface in ipairs(ifaces) do + for i in util.execi("iw dev "..iface.." station dump") do string.gsub(i, "^Station%s(.-)%s%(", function(mac) for client,dossier in ipairs(clients) do From b9f1a50c34003193cb2ff2281d8aca19be5db407 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 12:50:33 -0500 Subject: [PATCH 180/196] multiple clients now shown in the connected clients status page... that would have been akward. --- luasrc/controller/commotion/status_config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index 9d172d4..a8cad1a 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -177,7 +177,7 @@ function get_client_splash_info() local clients = {} i = 0 for line in util.execi("ndsctl clients") do - if string.match(line, "^%d+$") then + if string.match(line, "^client_id.*$") then i = i + 1 clients[i] = {} end From 8eea439219b76b5542f91fd578f2b7c466ae39e7 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 12:53:02 -0500 Subject: [PATCH 181/196] removed excess precision in upload/download speed and total --- luasrc/controller/commotion/status_config.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index a8cad1a..0d65752 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -172,8 +172,8 @@ function get_client_splash_info() local convert = function(x) return tostring(math.floor(tonumber(x)/60)).." "..i18n.translate("minutes") end - local function total_kB(a, b) return tostring(a+b).." kByte" end - local function total_kb(a, b) return tostring(a+b).." kbit/s" end + local function total_kB(a, b) return tostring(math.floor(a+b)).." kByte" end + local function total_kb(a, b) return tostring(math.floor(a+b)).." kbit/s" end local clients = {} i = 0 for line in util.execi("ndsctl clients") do From 5a41418fedcc6c51e78284ab921474de9fd68b6a Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 14:03:46 -0500 Subject: [PATCH 182/196] added start of dhcp fallback. Also, removed %t as a tab string match char... that does not exist... why did I think it did? I honestly don't know. But, now I have to go search all my other string match functions to make sure it is not creeping in all over. --- luasrc/controller/commotion/status_config.lua | 54 +++++++------------ 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index 0d65752..d3a9238 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -80,7 +80,7 @@ function status_builder(page, assets, active_tab) end end) for line in util.execi("route -n") do - string.gsub(line, "^0%.0%.0%.0[%s%t]+(%d+%.%d+)%.%d+%.%d+[%s%t].+eth0$", + string.gsub(line, "^0%.0%.0%.0[%s]+(%d+%.%d+)%.%d+%.%d+[%s].+eth0$", function(x) gw = true if string.match(x, "^100%.64$") or string.match(x, "10%.%d+$") then @@ -104,7 +104,7 @@ function conn_clnts() clients = get_client_splash_info() local ifaces = {} for i in util.execi("ifconfig -a") do - string.gsub(i, "^([%S%T].-)[%s%t]", + string.gsub(i, "^([%S].-)[%s]", function(x) db.log(x) table.insert(ifaces, x) end) end status_builder("commotion/conn_clients", {clients=clients, ifaces=ifaces}, "connected_clients") @@ -130,45 +130,27 @@ function get_splash_iface_info() end) end return splash - - --[[================== -NoDogSplash Status -==== -Version: 0.9_beta9.9.6 -Uptime: 826d 6h 44m 26s -Gateway Name: Commotion -Managed interface: wlan0 -Managed IP range: 0.0.0.0/0 -Server listening: 103.6.53.1:2050 -Splashpage: /etc/nodogsplash/htdocs/splash.html -Traffic control: no -Total download: 0 kByte; avg: 0 kbit/s -Total upload: 0 kByte; avg: 0 kbit/s -==== -Client authentications since start: 0 -Httpd request threads created/current: 1/0 -Current clients: 1 +end -Client 0 - IP: 103.6.53.62 MAC: 10:0b:a9:ca:7b:14 - Added: Thu Dec 12 22:38:10 2013 - Active: Thu Dec 12 22:38:10 2013 - Active duration: 0d 0h 0m 0s - Added duration: 0d 0h 1m 2s - Token: 31707a48 - State: Preauthenticated - Download: 0 kByte; avg: 0 kbit/s - Upload: 0 kByte; avg: 0 kbit/s -==== -Blocked MAC addresses: none -Allowed MAC addresses: N/A -Trusted MAC addresses: none -======== - ]]-- +function dhcp_lease_fallback() + clients = {} + local i = 1 + for line in io.lines("/tmp/dhcp.leases") do + clients[i] = {} + clients[i].mac = string.match(line, "^[%d]*%s([%x%:]+)%s") + clients[i].ip = string.match(line, "^[%d]*%s[%x%:]+%s([%d%.]+)%s") + i = i + 1 + end + db.log(clients) + return clients end function get_client_splash_info() + local sys = require "luci.sys" + if sys.call("/etc/init.d/nodogsplash enabled") ~= "0" then + return dhcp_lease_fallback() + end local convert = function(x) return tostring(math.floor(tonumber(x)/60)).." "..i18n.translate("minutes") end From 1bc615a1237b45c48bc9d6e3617d16215a568c32 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 14:18:49 -0500 Subject: [PATCH 183/196] clients status page now (see last commit as well) checks if nodogsplash is enabled and will fall back to dhcp.leases as info source if it is disabled. --- luasrc/controller/commotion/status_config.lua | 12 ++++++------ luasrc/view/commotion/conn_clients.htm | 5 ++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index d3a9238..d93afcd 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -101,13 +101,13 @@ function viz() end function conn_clnts() - clients = get_client_splash_info() + clients, warning = get_client_splash_info() local ifaces = {} for i in util.execi("ifconfig -a") do string.gsub(i, "^([%S].-)[%s]", function(x) db.log(x) table.insert(ifaces, x) end) end - status_builder("commotion/conn_clients", {clients=clients, ifaces=ifaces}, "connected_clients") + status_builder("commotion/conn_clients", {clients=clients, ifaces=ifaces, warning=warning}, "connected_clients") end --! @brief currently only gets number of connected clients... because that is what I needed @@ -140,15 +140,15 @@ function dhcp_lease_fallback() clients[i] = {} clients[i].mac = string.match(line, "^[%d]*%s([%x%:]+)%s") clients[i].ip = string.match(line, "^[%d]*%s[%x%:]+%s([%d%.]+)%s") + clients[i].curr_conn = "No" i = i + 1 end - db.log(clients) - return clients + return clients, true end function get_client_splash_info() local sys = require "luci.sys" - if sys.call("/etc/init.d/nodogsplash enabled") ~= "0" then + if sys.call("/etc/init.d/nodogsplash enabled") ~= 0 then return dhcp_lease_fallback() end local convert = function(x) @@ -173,7 +173,7 @@ function get_client_splash_info() end for i,x in ipairs(clients) do if clients[i] ~= nil then - clients[i].curr_conn=false + clients[i].curr_conn = "No" clients[i].duration = convert(clients[i].duration) clients[i].bnd_wdth = total_kB(clients[i].downloaded, clients[i].uploaded) clients[i].avg_spd = total_kb(clients[i].avg_down_speed, clients[i].avg_up_speed) diff --git a/luasrc/view/commotion/conn_clients.htm b/luasrc/view/commotion/conn_clients.htm index c32180d..13fb256 100644 --- a/luasrc/view/commotion/conn_clients.htm +++ b/luasrc/view/commotion/conn_clients.htm @@ -43,7 +43,7 @@ for client,dossier in ipairs(clients) do local c_idx = util.contains(dossier, mac) if c_idx then - clients[client].curr_conn = true + clients[client].curr_conn = "Yes" end end end) @@ -94,6 +94,9 @@ %>

        <%:Connected Clients!%>

        A client is a device that has connected to this node. Information about clients is displayed below.

        + <% if warning then %> +

        <%:You are not using a welcome page (splash page/captive portal.) Without a splash page we can only show a clients ip-address and the status of their connection.%>

        + <%end%> From fcee405d76b1448335ac424d81b95bd7f94a9aac Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 14:20:48 -0500 Subject: [PATCH 184/196] updated olsrd configuration cbi page to use the full path to the serval keyring. --- luasrc/model/cbi/commotion/security_smk.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/model/cbi/commotion/security_smk.lua b/luasrc/model/cbi/commotion/security_smk.lua index d141fe2..84931f3 100644 --- a/luasrc/model/cbi/commotion/security_smk.lua +++ b/luasrc/model/cbi/commotion/security_smk.lua @@ -71,7 +71,7 @@ end sp = s:option(Value, "servalpath") -sp.default = "/etc/commotion/keys.d/mdp/" +sp.default = "/etc/commotion/keys.d/mdp/serval.keyring" sp.render = function() end function sp:parse(section) db.log("sp parse") From dd106d021347ca9820be414a9ab04c74439c15eb Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 14:47:40 -0500 Subject: [PATCH 185/196] Mesh and AP interfaces now correctly move a user to the confirmation page on removal. Mesh interfaces also remove their associated commotion profile, network interface, and firewall zone. --- luasrc/model/cbi/commotion/basic_mn.lua | 30 +++++++++++++++++++++++++ luasrc/model/cbi/commotion/basic_wn.lua | 4 ++++ 2 files changed, 34 insertions(+) diff --git a/luasrc/model/cbi/commotion/basic_mn.lua b/luasrc/model/cbi/commotion/basic_mn.lua index 10a6a73..d3ffb99 100644 --- a/luasrc/model/cbi/commotion/basic_mn.lua +++ b/luasrc/model/cbi/commotion/basic_mn.lua @@ -47,6 +47,11 @@ if not SW.status() then --if not setup wizard then allow for adding and removal self:write(section, self.default) end end + function s.remove(self, section) + m.changed = true + clean_network(name:formvalue(section)) + return self.map:del(section) + end end @@ -96,6 +101,31 @@ function write_network(value) end end +function clean_network(value) + local fs = require "luci.fs" + local net_name = string.gsub(value, "[%p%s%z]", "_") + uci:delete("network", net_name) + fs.unlink("/etc/commotion/profiles.d/"..net_name) + uci:save("network") + if value ~= nil then + uci:foreach("firewall", "zone", + function(s) + if s.name and s.name == "mesh" then + local list = {} + for _,x in ipairs(s.network) do + if x ~= net_name then + table.insert(list, x) + end + end + uci:set_list ("firewall", s[".name"], "network", list) + uci:save("firewall") + end + end + ) + return net_name + end +end + function check_name(self, section, value) local uci = require "luci.model.uci".cursor() local clean_name = string.gsub(value, "[%p%s%z]", "_") diff --git a/luasrc/model/cbi/commotion/basic_wn.lua b/luasrc/model/cbi/commotion/basic_wn.lua index ddab35b..017fac4 100644 --- a/luasrc/model/cbi/commotion/basic_wn.lua +++ b/luasrc/model/cbi/commotion/basic_wn.lua @@ -54,6 +54,10 @@ if not SW.status() then return self.map:set(section, self.option, value) end end + function s.remove(self, section) + m.changed = true + return self.map:del(section) + end end function s:filter(section) From 14ed5bbe0ef7132b1fa11b9beee69a5e4db27bdf Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Sun, 22 Dec 2013 16:48:46 -0500 Subject: [PATCH 186/196] created fallback condition for status top-header clients-connected section. --- luasrc/controller/commotion/status_config.lua | 42 +++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/luasrc/controller/commotion/status_config.lua b/luasrc/controller/commotion/status_config.lua index d93afcd..32f6451 100644 --- a/luasrc/controller/commotion/status_config.lua +++ b/luasrc/controller/commotion/status_config.lua @@ -34,16 +34,45 @@ function index() end +function fallback_splash_info() + local cnet = require "luci.commotion.network" + local sys = require "luci.sys" + local clients = dhcp_lease_fallback() + local cif = {} + local ifaces = cnet.ifaces_list() + if #clients > 0 then + local arp = sys.net.arptable() + for _,addr in ipairs(arp) do + if not cif[addr.Device] then + cif[addr.Device] = {} + cif[addr.Device].connected = 0 + end + for client,dossier in ipairs(clients) do + if dossier.mac == addr["HW address"] then + cif[addr.Device].connected = cif[addr.Device].connected + 1 + end + end + end + end + return cif +end + + function status_builder(page, assets, active_tab) local uci = require "luci.model.uci".cursor() local cnet = require "luci.commotion.network" - local db = require "luci.commotion.debugger" - + local sys = require "luci.sys" local ifaces = {} local internet = nil local gw = false + local splash_info = nil local zone_iface = cnet.ifaces_list() - local splash_info = get_splash_iface_info() + if sys.call("/etc/init.d/nodogsplash enabled") ~= 0 then + splash_info = fallback_splash_info() + else + splash_info = get_splash_iface_info() + end + uci:foreach("wireless", "wifi-iface", function(s) local name = s['.name'] @@ -105,7 +134,7 @@ function conn_clnts() local ifaces = {} for i in util.execi("ifconfig -a") do string.gsub(i, "^([%S].-)[%s]", - function(x) db.log(x) table.insert(ifaces, x) end) + function(x) table.insert(ifaces, x) end) end status_builder("commotion/conn_clients", {clients=clients, ifaces=ifaces, warning=warning}, "connected_clients") end @@ -135,7 +164,7 @@ end function dhcp_lease_fallback() clients = {} - local i = 1 + local i = 1 for line in io.lines("/tmp/dhcp.leases") do clients[i] = {} clients[i].mac = string.match(line, "^[%d]*%s([%x%:]+)%s") @@ -193,9 +222,6 @@ function action_neigh(json) status_builder("commotion/error_olsr", nil, "nearby_devices") return nil end --- table.sort currently breaks nearby_md --- table.sort(data.Links, compare_links) - status_builder("commotion/nearby_md", {links=data.Links}, "nearby_devices") end From f893a0d1b531f4f352087071f2483e7d1ec720e0 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 23 Dec 2013 10:40:17 -0500 Subject: [PATCH 187/196] added avahi daemon to the system uci file so that the hostname is changed in the avahi-daemon --- files/etc/uci-defaults/luci-setup-wizard | 1 + 1 file changed, 1 insertion(+) diff --git a/files/etc/uci-defaults/luci-setup-wizard b/files/etc/uci-defaults/luci-setup-wizard index 564647b..157242a 100755 --- a/files/etc/uci-defaults/luci-setup-wizard +++ b/files/etc/uci-defaults/luci-setup-wizard @@ -6,6 +6,7 @@ config_load ucitrack uci_add ucitrack nodogsplash nodogsplash uci_set ucitrack nodogsplash init ucidog +uci_set ucitrack system init avahi-daemon uci_commit ucitrack #setup sysupgrade saves From fc9d16c955f9454657910bbd1cc0380e2dd75eaa Mon Sep 17 00:00:00 2001 From: Andrew Reynolds Date: Mon, 23 Dec 2013 11:14:59 -0500 Subject: [PATCH 188/196] Added table id for proper table alignment in nearby_md.htm --- luasrc/view/commotion/nearby_md.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/view/commotion/nearby_md.htm b/luasrc/view/commotion/nearby_md.htm index 007951a..eb33ebf 100644 --- a/luasrc/view/commotion/nearby_md.htm +++ b/luasrc/view/commotion/nearby_md.htm @@ -105,7 +105,7 @@

        <%:OLSR connections%>

        <%:Overview of currently established OLSR connections%> -
        +
        From b7c0515e5b5e74696db1e37abcdf82eacbd26c44 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 23 Dec 2013 11:16:24 -0500 Subject: [PATCH 189/196] added avahi daemon to the ucitrack for any system file changes so that hostname gets updated in avahi daemon on change. --- files/etc/uci-defaults/luci-setup-wizard | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/files/etc/uci-defaults/luci-setup-wizard b/files/etc/uci-defaults/luci-setup-wizard index 157242a..a053c03 100755 --- a/files/etc/uci-defaults/luci-setup-wizard +++ b/files/etc/uci-defaults/luci-setup-wizard @@ -3,11 +3,12 @@ . /etc/functions.sh #setup ucitrack -config_load ucitrack -uci_add ucitrack nodogsplash nodogsplash -uci_set ucitrack nodogsplash init ucidog -uci_set ucitrack system init avahi-daemon -uci_commit ucitrack +uci add ucitrack nodogsplash +uci set ucitrack.@nodogsplash[0].init=ucidog +uci add_list ucitrack.@system[0].affects=avahi_daemon +uci add ucitrack avahi_daemon +uci set ucitrack.@avahi_daemon[0].init=avahi-daemon +uci commit ucitrack #setup sysupgrade saves echo /etc/config/setup_wizard >> /etc/sysupgrade.conf From 379467d4df9697e4c45919ef3015d2b21dbce4c7 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Mon, 23 Dec 2013 14:01:49 -0500 Subject: [PATCH 190/196] added error checking to ssid because jordan things that people want to shoot themselves in the foot. I agree with him. THIS TIME --- luasrc/model/cbi/commotion/basic_wn.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/luasrc/model/cbi/commotion/basic_wn.lua b/luasrc/model/cbi/commotion/basic_wn.lua index 017fac4..ab05508 100644 --- a/luasrc/model/cbi/commotion/basic_wn.lua +++ b/luasrc/model/cbi/commotion/basic_wn.lua @@ -71,6 +71,18 @@ s.template_addremove = "cbi/commotion/addAP" --This template controls the addrem name = s:option(Value, "ssid", translate("Name"), translate("The access point name (SSID) is the name that people will look for when connecting to this device.")) name.default = "CommotionWireless" +function name:validate(val) + if #val > 31 or #val == 0 then + return nil + elseif val:match("[%$\"%[%]%?%+%/]") then + return nil + elseif val:match("^[%s%!%#]") then + return nil + else + return val + end +end + local wifi_dev = {} uci.foreach("wireless", "wifi-device", function(s) From ee9bf959a655dd2ebaaed8bcf60b99f7e7fa83dc Mon Sep 17 00:00:00 2001 From: Chris Ritzo Date: Mon, 23 Dec 2013 15:52:56 -0500 Subject: [PATCH 191/196] updated license page- removed hyperlink inside of translation tags. --- luasrc/view/commotion/license.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/view/commotion/license.htm b/luasrc/view/commotion/license.htm index 601e29e..8ed2afd 100644 --- a/luasrc/view/commotion/license.htm +++ b/luasrc/view/commotion/license.htm @@ -9,7 +9,7 @@

        <%:Commotion License%>

        <%:You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.%>

        -

        <%:The OpenWrt distribution upon which Commotion is built bundles a lot of third party applications and modules which are available under various other Open Source licenses or Public Domain. The sources for those packages can be found on the OpenWrt mirror. Please refer to these source packages to find out which license applies to them.%>

        +

        <%:The OpenWrt distribution upon which Commotion is built bundles a lot of third party applications and modules which are available under various other Open Source licenses or Public Domain. The sources for those packages can be found on the OpenWrt mirrot at: http://downloads.openwrt.org/sources/ . Please refer to these source packages to find out which license applies to them.%>

        From 8e1a4d3292c2fae2050cee63e987e810fed8a59f Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 26 Dec 2013 11:10:23 -0500 Subject: [PATCH 192/196] added defaults to nodogsplash config to work after setup_wizard --- files/etc/config/nodogsplash | 4 ++-- files/etc/uci-defaults/luci-setup-wizard | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/files/etc/config/nodogsplash b/files/etc/config/nodogsplash index 3c67dcf..45504c1 100644 --- a/files/etc/config/nodogsplash +++ b/files/etc/config/nodogsplash @@ -1,7 +1,7 @@ config settings settings - option enable '0' + option enable '1' option splashtime '1' option splashunit 'hours' config interfaces interfaces - option interface 'commotionAP' + option interface 'br-lan' diff --git a/files/etc/uci-defaults/luci-setup-wizard b/files/etc/uci-defaults/luci-setup-wizard index a053c03..0e1cacc 100755 --- a/files/etc/uci-defaults/luci-setup-wizard +++ b/files/etc/uci-defaults/luci-setup-wizard @@ -8,6 +8,7 @@ uci set ucitrack.@nodogsplash[0].init=ucidog uci add_list ucitrack.@system[0].affects=avahi_daemon uci add ucitrack avahi_daemon uci set ucitrack.@avahi_daemon[0].init=avahi-daemon +uci add_list ucitrack.@setup_wizard[0].affects=nodogsplash uci commit ucitrack #setup sysupgrade saves From a4a7437212c8e24d5e144229cef6402e891640f8 Mon Sep 17 00:00:00 2001 From: Andrew Reynolds Date: Thu, 26 Dec 2013 11:57:17 -0500 Subject: [PATCH 193/196] Clarified connection language on status and nearby_md pages --- luasrc/view/commotion/nearby_md.htm | 4 ++-- luasrc/view/commotion/status.htm | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/luasrc/view/commotion/nearby_md.htm b/luasrc/view/commotion/nearby_md.htm index eb33ebf..5c5c5c7 100644 --- a/luasrc/view/commotion/nearby_md.htm +++ b/luasrc/view/commotion/nearby_md.htm @@ -100,10 +100,10 @@ //]]> -

        <%:OLSR connections%>

        +

        <%:OLSR Links%>

        - <%:Overview of currently established OLSR connections%> + <%:Overview of currently established OLSR connections (device-to-device)%>
        <%:Hostname%>
        diff --git a/luasrc/view/commotion/status.htm b/luasrc/view/commotion/status.htm index f68952c..1660cb3 100644 --- a/luasrc/view/commotion/status.htm +++ b/luasrc/view/commotion/status.htm @@ -27,7 +27,7 @@ <%- for _,iface in pairs(ifaces) do -%>
        <%=iface.name%> - (<%=iface.status%>) (<%=iface.sec%>) (<%=iface.conn%> <%:Connections%>) + (<%=iface.status%>) (<%=iface.sec%>) (<%=iface.conn%> <%:Client Connections%>)
        <%end%> From 59c3d8a65d45f76288ab77ba3d84798614a851e9 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 26 Dec 2013 13:34:19 -0500 Subject: [PATCH 194/196] added more clear language about adding/removing seval mesh keychains. --- luasrc/model/cbi/commotion/security_smk.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/model/cbi/commotion/security_smk.lua b/luasrc/model/cbi/commotion/security_smk.lua index 84931f3..2648f85 100644 --- a/luasrc/model/cbi/commotion/security_smk.lua +++ b/luasrc/model/cbi/commotion/security_smk.lua @@ -28,7 +28,7 @@ m = Map("olsrd", translate("Shared Mesh Keychain"), translate("To ensure that on --redirect on saved and changed to check changes. m.on_after_save = ccbi.conf_page -s = m:section(TypedSection, "LoadPlugin", translate("Use a Shared Mesh Keychain to sign mesh routes. Yes/No"), translate("Check the box to use a Shared Mesh Keychain on this device. You'll also be required to upload or generate a Shared Mesh Keychain.")) +s = m:section(TypedSection, "LoadPlugin", translate("Use a Shared Mesh Keychain to sign mesh routes. Yes/No"), translate("Add or remove a Shared Mesh Keychain on this device. You can also upload or generate a new Shared Mesh Keychain once you add a Shared Mesh Keychain to this device.")) s.addremove = true s.anonymous = true From 1a4cfc0b405c6706374d8b27589e2715c88f7082 Mon Sep 17 00:00:00 2001 From: Seamus Tuohy Date: Thu, 26 Dec 2013 14:06:42 -0500 Subject: [PATCH 195/196] added olsrd sid modifications on new key creation. --- luasrc/model/cbi/commotion/security_smk.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/luasrc/model/cbi/commotion/security_smk.lua b/luasrc/model/cbi/commotion/security_smk.lua index 2648f85..b91465c 100644 --- a/luasrc/model/cbi/commotion/security_smk.lua +++ b/luasrc/model/cbi/commotion/security_smk.lua @@ -196,7 +196,11 @@ end new = s:option(Button, "_dummy2", translate("Create a new Shared Mesh Keychain file"), translate("Click on the button below to create a new Shared Mesh Keychain file. This will DELETE the existing Shared Mesh Keychain on this device. Use this option if you are creating a brand new Commotion mesh network, or if you are changing the Shared Mesh Keyhchain on an existing network. In either case, create a backup of the existing Shared Mesh Keychain first.")) new.anonymous = true -function new.write() return true end +function new.write(self, section, value) + m.changed = true + return self.map:set(section, "sid", get_sid()) +end + function new.validate(self, section, value) db.log("new") m.save = true From 8f9c74acc5c950c682871b57353e93482a6989f7 Mon Sep 17 00:00:00 2001 From: Andrew Reynolds Date: Fri, 27 Dec 2013 21:22:56 -0500 Subject: [PATCH 196/196] Added id to conn_clients table for proper text alignment --- luasrc/view/commotion/conn_clients.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasrc/view/commotion/conn_clients.htm b/luasrc/view/commotion/conn_clients.htm index 13fb256..97063b5 100644 --- a/luasrc/view/commotion/conn_clients.htm +++ b/luasrc/view/commotion/conn_clients.htm @@ -97,7 +97,7 @@

        <%:Connected Clients!%>

        <% if warning then %>

        <%:You are not using a welcome page (splash page/captive portal.) Without a splash page we can only show a clients ip-address and the status of their connection.%>

        <%end%> -
        +
        <%create_table_header(headers)%>