applications/ffwizard: Internationalize and code cleanup

This commit is contained in:
Manuel Munz 2011-01-28 22:56:17 +00:00
parent 487f3c7799
commit 2006a2a827

View file

@ -90,6 +90,78 @@ function gen_dhcp_range(n)
return "?" return "?"
end end
function cbi_meship(dev)
meship = f:field(Value, "meship_" .. dev, dev:upper() .. " " .. translate("Mesh IP address"),
translate("This is a unique address in the mesh (e.g. 10.1.1.1) and has to be registered at your local community."))
meship:depends("device_" .. dev, "1")
meship.rmempty = true
function meship.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "meship_" .. dev)
end
function meship.validate(self, value)
local x = ip.IPv4(value)
return ( x and x:prefix() == 32 ) and x:string() or ""
end
function meship.write(self, sec, value)
uci:set("freifunk", "wizard", "meship_" .. dev, value)
end
end
function cbi_meship6(dev)
local meship6 = f:field(Value, "meship6_" .. dev, dev:upper() .. " " .. translate("Mesh IPv6 Address"), translate("The ipv6 address is calculated auomatically."))
meship6:depends("device_" .. dev, "1")
meship6.rmempty = true
function meship6.cfgvalue(self, section)
return get_ula(get_mac(dev))
end
end
function cbi_netconf(dev)
local d = f:field(Flag, "device_" .. dev , " <b>" .. dev:upper() .. "</b>", "Configure this interface.")
d:depends("netconfig", "1")
d.rmempty = false
function d.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "device_" .. dev)
end
function d.write(self, sec, value)
if value then
uci:set("freifunk", "wizard", "device_" .. dev, value)
uci:save("freifunk")
end
end
end
function cbi_meshdhcp(dev)
local dhcpmesh = f:field(Value, "dhcpmesh_" .. dev, dev:upper() .. " " .. translate("DHCP IP range"),
translate("The IP range from which clients are assigned ip addresses (e.g. 10.1.2.1/28). If this is a range inside your mesh network range, then it will be announced as HNA. Any other range will use NAT. If left empty then the defaults from the community profile will be used."))
dhcpmesh:depends("client_" .. dev, "1")
dhcpmesh.rmempty = true
function dhcpmesh.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "dhcpmesh_" .. dev)
end
function dhcpmesh.validate(self, value)
local x = ip.IPv4(value)
return ( x and x:prefix() <= 30 and x:minhost()) and x:string() or ""
end
function dhcpmesh.write(self, sec, value)
uci:set("freifunk", "wizard", "dhcpmesh_" .. dev, value)
uci:save("freifunk")
end
end
function cbi_dhcp(dev)
local client = f:field(Flag, "client_" .. dev, dev:upper() .. " " .. translate("Enable DHCP"), translate("DHCP will automatically assign ip addresses to clients"))
client:depends("device_" .. dev, "1")
client.rmempty = true
function client.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "client_" .. dev)
end
function client.write(self, sec, value)
uci:set("freifunk", "wizard", "client_" .. dev, value)
uci:save("freifunk")
end
end
function hbconf(dev) function hbconf(dev)
if has_hb then if has_hb then
local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {} local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {}
@ -99,9 +171,36 @@ function hbconf(dev)
end end
end end
function uci_radvd(n)
uci:section("radvd", "interface", nil, {
interface =n,
AdvSendAdvert =1,
AdvManagedFlag =0,
AdvOtherConfigFlag =0,
ignore =0
})
uci:section("radvd", "prefix", nil, {
interface =n,
AdvOnLink =1,
AdvAutonomous =1,
AdvRouterAddr =0,
ignore =0,
})
uci:save("radvd")
end
function uci_clean_radvd (n)
uci:delete_all("radvd", "interface", {interface=n.."dhcp"})
uci:delete_all("radvd", "interface", {interface=n})
uci:delete_all("radvd", "prefix", {interface=n.."dhcp"})
uci:delete_all("radvd", "prefix", {interface=n})
end
-------------------- View -------------------- -------------------- View --------------------
f = SimpleForm("ffwizward", "Freifunkassistent", f = SimpleForm("ffwizward", translate("Wizard"),
translate("This wizard will assist you in setting up your router for your local Freifunk network or another similar wireless community network.")) translate("This wizard will assist you in setting up your router for Freifunk " ..
"or another similar wireless community network."))
-- if password is not set or default then force the user to set a new one -- if password is not set or default then force the user to set a new one
if sys.exec("diff /rom/etc/passwd /etc/passwd") == "" then if sys.exec("diff /rom/etc/passwd /etc/passwd") == "" then
@ -109,7 +208,7 @@ if sys.exec("diff /rom/etc/passwd /etc/passwd") == "" then
pw1.password = true pw1.password = true
pw1.rmempty = false pw1.rmempty = false
pw2 = f:field(Value, "pw2", translate("Confirmation")) pw2 = f:field(Value, "pw2", translate("Password confirmation"))
pw2.password = true pw2.password = true
pw2.rmempty = false pw2.rmempty = false
@ -123,184 +222,82 @@ end
local cc = uci:get(community, "wifi_device", "country") or "DE" local cc = uci:get(community, "wifi_device", "country") or "DE"
main = f:field(Flag, "netconfig", translate("Configure network"), translate("Select this checkbox to configure your network interfaces.")) main = f:field(Flag, "netconfig", translate("Configure network"), translate("Select this checkbox to configure your network interfaces."))
uci:foreach("wireless", "wifi-device",
function(section)
local device = section[".name"]
local hwtype = section.type
local syscc = section.country
if not syscc then uci:foreach("wireless", "wifi-device", function(section)
if hwtype == "atheros" then local device = section[".name"]
cc = sys.exec("grep -i '" .. cc .. "' /lib/wifi/cc_translate.txt |cut -d ' ' -f 2") or 0 local hwtype = section.type
sys.exec("echo " .. cc .. " > /proc/sys/dev/" .. device .. "/countrycode") local syscc = section.country
elseif hwtype == "mac80211" then
sys.exec("iw reg set " .. cc)
elseif hwtype == "broadcom" then
sys.exec ("wlc country " .. cc)
end
else
cc = syscc
end
local dev = f:field(Flag, "device_" .. device , "<b>Drahtloses Netzwerk \"" .. device:upper() .. "\"</b> ", "Konfigurieren Sie Ihre drahtlose " .. device:upper() .. "Schnittstelle (WLAN).") if not syscc then
dev:depends("netconfig", "1")
dev.rmempty = false
function dev.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "device_" .. device)
end
function dev.write(self, sec, value)
if value then
uci:set("freifunk", "wizard", "device_" .. device, value)
uci:save("freifunk")
end
end
local chan = f:field(ListValue, "chan_" .. device, device:upper() .. " Freifunk Kanal einrichten", "Ihr Gerät und benachbarte Freifunk Knoten müssen auf demselben Kanal senden. Je nach Gerätetyp können Sie zwischen verschiedenen 2,4Ghz und 5Ghz Kanälen auswählen.")
chan:depends("device_" .. device, "1")
chan.rmempty = true
function chan.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "chan_" .. device)
end
chan:value('default')
for _, f in ipairs(sys.wifi.channels(device)) do
if not f.restricted then
chan:value(f.channel)
end
end
function chan.write(self, sec, value)
if value then
uci:set("freifunk", "wizard", "chan_" .. device, value)
uci:save("freifunk")
end
end
local meship = f:field(Value, "meship_" .. device, device:upper() .. " Mesh IP Adresse einrichten", "Ihre Mesh IP Adresse erhalten Sie von der Freifunk Gemeinschaft in Ihrer Nachbarschaft. Es ist eine netzweit eindeutige Identifikation, z.B. 104.1.1.1.")
meship:depends("device_" .. device, "1")
meship.rmempty = true
function meship.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "meship_" .. device)
end
function meship.validate(self, value)
local x = ip.IPv4(value)
return ( x and x:prefix() == 32 ) and x:string() or ""
end
function meship.write(self, sec, value)
uci:set("freifunk", "wizard", "meship_" .. device, value)
end
if has_ipv6 then
local meship6 = f:field(Value, "meship6_" .. device, device:upper() .. " Mesh IPv6 Adresse einrichten", "Ihre Mesh IP Adresse wird automatisch berechnet")
meship6:depends("device_" .. device, "1")
meship6.rmempty = true
function meship6.cfgvalue(self, section)
return get_ula(get_mac(device))
end
end
local client = f:field(Flag, "client_" .. device, device:upper() .. " DHCP anbieten", "DHCP weist verbundenen Benutzern automatisch eine Adresse zu. Diese Option sollten Sie unbedingt aktivieren, wenn Sie Nutzer an der drahtlosen Schnittstelle erwarten.")
client:depends("device_" .. device, "1")
client.rmempty = true
function client.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "client_" .. device)
end
function client.write(self, sec, value)
uci:set("freifunk", "wizard", "client_" .. device, value)
uci:save("freifunk")
end
local dhcpmesh = f:field(Value, "dhcpmesh_" .. device, device:upper() .. " Mesh DHCP anbieten", "Bestimmen Sie den Adressbereich aus dem Ihre Nutzer IP Adressen erhalten. Es wird empfohlen einen Adressbereich aus Ihrer lokalen Freifunk Gemeinschaft zu nutzen. Der Adressbereich ist ein netzweit eindeutiger Netzbereich. z.B. 104.1.2.1/28")
dhcpmesh:depends("client_" .. device, "1")
dhcpmesh.rmempty = true
function dhcpmesh.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "dhcpmesh_" .. device)
end
function dhcpmesh.validate(self, value)
local x = ip.IPv4(value)
return ( x and x:minhost()) and x:string() or ""
end
function dhcpmesh.write(self, sec, value)
uci:set("freifunk", "wizard", "dhcpmesh_" .. device, value)
uci:save("freifunk")
end
local hwtype = section.type
if hwtype == "atheros" then if hwtype == "atheros" then
local vap = f:field(Flag, "vap_" .. device , "Virtueller Drahtloser Zugangspunkt", "Konfigurieren Sie Ihren Virtuellen AP") cc = sys.exec("grep -i '" .. cc .. "' /lib/wifi/cc_translate.txt |cut -d ' ' -f 2") or 0
vap:depends("client_" .. device, "1") sys.exec("echo " .. cc .. " > /proc/sys/dev/" .. device .. "/countrycode")
vap.rmempty = false elseif hwtype == "mac80211" then
function vap.cfgvalue(self, section) sys.exec("iw reg set " .. cc)
return uci:get("freifunk", "wizard", "vap_" .. device) elseif hwtype == "broadcom" then
end sys.exec ("wlc country " .. cc)
function vap.write(self, sec, value)
uci:set("freifunk", "wizard", "vap_" .. device, value)
uci:save("freifunk")
end
end end
end) else
cc = syscc
end
uci:foreach("network", "interface", cbi_netconf(device)
function(section) local chan = f:field(ListValue, "chan_" .. device, device:upper() .. " " .. translate("Channel"), translate("Your device and neighbouring nodes have to use the same channel."))
local device = section[".name"] chan:depends("device_" .. device, "1")
local ifname = uci_state:get("network",device,"ifname") chan.rmempty = true
if device ~= "loopback" and not string.find(device, "gvpn") and not string.find(device, "wifi") and not string.find(device, "wl") and not string.find(device, "wlan") and not string.find(device, "wireless") and not string.find(device, "radio") then function chan.cfgvalue(self, section)
dev = f:field(Flag, "device_" .. device , "<b>Drahtgebundenes Netzwerk \"" .. device:upper() .. "\"</b>", "Konfigurieren Sie Ihre drahtgebunde " .. device:upper() .. " Schnittstelle (LAN).") return uci:get("freifunk", "wizard", "chan_" .. device)
dev:depends("netconfig", "1") end
dev.rmempty = false chan:value('default')
function dev.cfgvalue(self, section) for _, f in ipairs(sys.wifi.channels(device)) do
return uci:get("freifunk", "wizard", "device_" .. device) if not f.restricted then
end chan:value(f.channel)
function dev.write(self, sec, value)
uci:set("freifunk", "wizard", "device_" .. device, value)
uci:save("freifunk")
end
meship = f:field(Value, "meship_" .. device, device:upper() .. " Mesh IP Adresse einrichten", "Ihre Mesh IP Adresse erhalten Sie von der Freifunk Gemeinschaft in Ihrer Nachbarschaft. Es ist eine netzweit eindeutige Identifikation, z.B. 104.1.1.1.")
meship:depends("device_" .. device, "1")
meship.rmempty = true
function meship.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "meship_" .. device)
end
function meship.validate(self, value)
local x = ip.IPv4(value)
return ( x and x:prefix() == 32 ) and x:string() or ""
end
function meship.write(self, sec, value)
uci:set("freifunk", "wizard", "meship_" .. device, value)
end
if has_ipv6 then
meship6 = f:field(Value, "meship6_" .. device, device:upper() .. " Mesh IPv6 Adresse einrichten", "Ihre Mesh IP Adresse wird automatisch berechnet")
meship6:depends("device_" .. device, "1")
meship6.rmempty = true
function meship6.cfgvalue(self, section)
return get_ula(get_mac(ifname))
end
end
client = f:field(Flag, "client_" .. device, device:upper() .. " DHCP anbieten","DHCP weist verbundenen Benutzern automatisch eine Adresse zu. Diese Option sollten Sie unbedingt aktivieren, wenn Sie Nutzer an der drahtlosen Schnittstelle erwarten.")
client:depends("device_" .. device, "1")
client.rmempty = false
function client.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "client_" .. device)
end
function client.write(self, sec, value)
uci:set("freifunk", "wizard", "client_" .. device, value)
uci:save("freifunk")
end
dhcpmesh = f:field(Value, "dhcpmesh_" .. device, device:upper() .. " Mesh DHCP anbieten ", "Bestimmen Sie den Adressbereich aus dem Ihre Nutzer IP Adressen erhalten. Es wird empfohlen einen Adressbereich aus Ihrer lokalen Freifunk Gemeinschaft zu nutzen. Der Adressbereich ist ein netzweit eindeutiger Netzbereich. z.B. 104.1.2.1/28")
dhcpmesh:depends("client_" .. device, "1")
dhcpmesh.rmempty = true
function dhcpmesh.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "dhcpmesh_" .. device)
end
function dhcpmesh.validate(self, value)
local x = ip.IPv4(value)
return ( x and x:prefix() <= 30 and x:minhost()) and x:string() or ""
end
function dhcpmesh.write(self, sec, value)
uci:set("freifunk", "wizard", "dhcpmesh_" .. device, value)
uci:save("freifunk")
end
end end
end) end
share = f:field(Flag, "sharenet", "Eigenen Internetzugang freigeben", "Geben Sie Ihren Internetzugang im Freifunknetz frei.") function chan.write(self, sec, value)
if value then
uci:set("freifunk", "wizard", "chan_" .. device, value)
uci:save("freifunk")
end
end
cbi_meship(device)
if has_ipv6 then
cbi_meship6(device)
end
cbi_dhcp(device)
cbi_meshdhcp(device)
local hwtype = section.type
if hwtype == "atheros" then
local vap = f:field(Flag, "vap_" .. device , " " .. translate("Virtual Access Point (VAP)"), translate("This will setup a new virtual wireless interface in Access Point mode."))
vap:depends("client_" .. device, "1")
vap.rmempty = false
function vap.cfgvalue(self, section)
return uci:get("freifunk", "wizard", "vap_" .. device)
end
function vap.write(self, sec, value)
uci:set("freifunk", "wizard", "vap_" .. device, value)
uci:save("freifunk")
end
end
end)
uci:foreach("network", "interface", function(section)
local device = section[".name"]
local ifname = uci_state:get("network",device,"ifname")
if device ~= "loopback" and not string.find(device, "gvpn") and not string.find(device, "wifi") and not string.find(device, "wl") and not string.find(device, "wlan") and not string.find(device, "wireless") and not string.find(device, "radio") then
cbi_netconf(device)
cbi_meship(device)
if has_ipv6 then
cbi_meship6(device)
end
cbi_dhcp(device)
cbi_meshdhcp(device)
end
end)
share = f:field(Flag, "sharenet", "<b>" .. translate("Share your internet connection") .. "</b>", translate("Select this to allow others to use your connection to access the internet."))
share.rmempty = false share.rmempty = false
share:depends("netconfig", "1") share:depends("netconfig", "1")
function share.cfgvalue(self, section) function share.cfgvalue(self, section)
@ -311,7 +308,7 @@ function share.write(self, section, value)
uci:save("freifunk") uci:save("freifunk")
end end
wanproto = f:field(ListValue, "wanproto", "Protokoll des Internetzugangs", "Geben Sie das Protokol an ueber das eine Internet verbindung hergestellt werden kann.") wanproto = f:field(ListValue, "wanproto", translate("Protocol"), translate ("The protocol to use for internet connectivity."))
wanproto:depends("sharenet", "1") wanproto:depends("sharenet", "1")
wanproto:value("static", translate("static", "static")) wanproto:value("static", translate("static", "static"))
wanproto:value("dhcp", translate("dhcp", "dhcp")) wanproto:value("dhcp", translate("dhcp", "dhcp"))
@ -324,7 +321,7 @@ function wanproto.write(self, section, value)
uci:set("network", "wan", "proto", value) uci:set("network", "wan", "proto", value)
uci:save("network") uci:save("network")
end end
wanip = f:field(Value, "wanipaddr", translate("ipaddress")) wanip = f:field(Value, "wanipaddr", translate("Ip address"))
wanip:depends("wanproto", "static") wanip:depends("wanproto", "static")
function wanip.cfgvalue(self, section) function wanip.cfgvalue(self, section)
return uci:get("network", "wan", "ipaddr") return uci:get("network", "wan", "ipaddr")
@ -333,7 +330,7 @@ function wanip.write(self, section, value)
uci:set("network", "wan", "ipaddr", value) uci:set("network", "wan", "ipaddr", value)
uci:save("network") uci:save("network")
end end
wannm = f:field(Value, "wannetmask", translate("netmask")) wannm = f:field(Value, "wannetmask", translate("Netmask"))
wannm:depends("wanproto", "static") wannm:depends("wanproto", "static")
function wannm.cfgvalue(self, section) function wannm.cfgvalue(self, section)
return uci:get("network", "wan", "netmask") return uci:get("network", "wan", "netmask")
@ -342,7 +339,7 @@ function wannm.write(self, section, value)
uci:set("network", "wan", "netmask", value) uci:set("network", "wan", "netmask", value)
uci:save("network") uci:save("network")
end end
wangw = f:field(Value, "wangateway", translate("gateway")) wangw = f:field(Value, "wangateway", translate("Gateway"))
wangw:depends("wanproto", "static") wangw:depends("wanproto", "static")
wangw.rmempty = true wangw.rmempty = true
function wangw.cfgvalue(self, section) function wangw.cfgvalue(self, section)
@ -352,7 +349,7 @@ function wangw.write(self, section, value)
uci:set("network", "wan", "gateway", value) uci:set("network", "wan", "gateway", value)
uci:save("network") uci:save("network")
end end
wandns = f:field(Value, "wandns", translate("dnsserver")) wandns = f:field(Value, "wandns", translate("DNS Server"))
wandns:depends("wanproto", "static") wandns:depends("wanproto", "static")
wandns.rmempty = true wandns.rmempty = true
function wandns.cfgvalue(self, section) function wandns.cfgvalue(self, section)
@ -362,7 +359,7 @@ function wandns.write(self, section, value)
uci:set("network", "wan", "dns", value) uci:set("network", "wan", "dns", value)
uci:save("network") uci:save("network")
end end
wanusr = f:field(Value, "wanusername", translate("username")) wanusr = f:field(Value, "wanusername", translate("Username"))
wanusr:depends("wanproto", "pppoe") wanusr:depends("wanproto", "pppoe")
wanusr:depends("wanproto", "pptp") wanusr:depends("wanproto", "pptp")
function wanusr.cfgvalue(self, section) function wanusr.cfgvalue(self, section)
@ -372,7 +369,7 @@ function wanusr.write(self, section, value)
uci:set("network", "wan", "username", value) uci:set("network", "wan", "username", value)
uci:save("network") uci:save("network")
end end
wanpwd = f:field(Value, "wanpassword", translate("password")) wanpwd = f:field(Value, "wanpassword", translate("Password"))
wanpwd.password = true wanpwd.password = true
wanpwd:depends("wanproto", "pppoe") wanpwd:depends("wanproto", "pppoe")
wanpwd:depends("wanproto", "pptp") wanpwd:depends("wanproto", "pptp")
@ -384,7 +381,8 @@ function wanpwd.write(self, section, value)
uci:save("network") uci:save("network")
end end
wansec = f:field(Flag, "wansec", "WAN-Zugriff auf Gateway beschränken", "Verbieten Sie Zugriffe auf Ihr lokales Netzwerk aus dem Freifunknetz.") wansec = f:field(Flag, "wansec", translate("Protect LAN"), translate("Check this to protect your LAN from other nodes or clients" .. " (" .. translate("recommended") .. ")."))
wansec.default = "1"
wansec.rmempty = false wansec.rmempty = false
wansec:depends("wanproto", "static") wansec:depends("wanproto", "static")
wansec:depends("wanproto", "dhcp") wansec:depends("wanproto", "dhcp")
@ -396,7 +394,7 @@ function wansec.write(self, section, value)
uci:save("freifunk") uci:save("freifunk")
end end
if has_qos then if has_qos then
wanqosdown = f:field(Value, "wanqosdown", "Download Bandbreite begrenzen", "kb/s") wanqosdown = f:field(Value, "wanqosdown", translate("Limit download bandwidth"), translate("kbit/s"))
wanqosdown:depends("sharenet", "1") wanqosdown:depends("sharenet", "1")
function wanqosdown.cfgvalue(self, section) function wanqosdown.cfgvalue(self, section)
return uci:get("qos", "wan", "download") return uci:get("qos", "wan", "download")
@ -405,7 +403,7 @@ if has_qos then
uci:set("qos", "wan", "download", value) uci:set("qos", "wan", "download", value)
uci:save("qos") uci:save("qos")
end end
wanqosup = f:field(Value, "wanqosup", "Upload Bandbreite begrenzen", "kb/s") wanqosup = f:field(Value, "wanqosup", translate("Limit upload bandwidth"), translate("kbit/s"))
wanqosup:depends("sharenet", "1") wanqosup:depends("sharenet", "1")
function wanqosup.cfgvalue(self, section) function wanqosup.cfgvalue(self, section)
return uci:get("qos", "wan", "upload") return uci:get("qos", "wan", "upload")
@ -417,7 +415,7 @@ if has_qos then
end end
if has_l2gvpn then if has_l2gvpn then
gvpn = f:field(Flag, "gvpn", "Freifunk Internet Tunnel", "Verbinden Sie ihren Router ueber das Internet mit anderen Freifunknetzen.") gvpn = f:field(Flag, "gvpn", translate("L2gvpn tunnel"), translate("Connect your node with other nodes with a tunnel via the internet."))
gvpn.rmempty = false gvpn.rmempty = false
gvpn:depends("sharenet", "1") gvpn:depends("sharenet", "1")
function gvpn.cfgvalue(self, section) function gvpn.cfgvalue(self, section)
@ -427,7 +425,7 @@ if has_l2gvpn then
uci:set("freifunk", "wizard", "gvpn", value) uci:set("freifunk", "wizard", "gvpn", value)
uci:save("freifunk") uci:save("freifunk")
end end
gvpnip = f:field(Value, "gvpnipaddr", translate("ipaddress")) gvpnip = f:field(Value, "gvpnipaddr", translate("IP address"))
gvpnip:depends("gvpn", "1") gvpnip:depends("gvpn", "1")
function gvpnip.cfgvalue(self, section) function gvpnip.cfgvalue(self, section)
return uci:get("l2gvpn", "bbb", "ip") or uci:get("network", "gvpn", "ipaddr") return uci:get("l2gvpn", "bbb", "ip") or uci:get("network", "gvpn", "ipaddr")
@ -439,7 +437,7 @@ if has_l2gvpn then
end end
if has_hb then if has_hb then
hb = f:field(Flag, "hb", "Heartbeat aktivieren","Dem Gerät erlauben anonyme Statistiken zu übertragen. (empfohlen)") hb = f:field(Flag, "hb", translate("Heartbeat"), translate("Allow to transfer anonymous statistics about this node" .. " (" .. translate("recommended") .. ")."))
hb.rmempty = false hb.rmempty = false
hb:depends("netconfig", "1") hb:depends("netconfig", "1")
function hb.cfgvalue(self, section) function hb.cfgvalue(self, section)
@ -538,11 +536,6 @@ function main.write(self, section, value)
local network local network
network = ip.IPv4(uci:get_first(community, "community", "mesh_network") or "104.0.0.0/8") network = ip.IPv4(uci:get_first(community, "community", "mesh_network") or "104.0.0.0/8")
-- Tune community settings
-- if community and uci:get("freifunk", community) then
-- uci:get_all(community)
-- end
-- Cleanup -- Cleanup
uci:delete_all("firewall","zone", {name="freifunk"}) uci:delete_all("firewall","zone", {name="freifunk"})
uci:delete_all("firewall","forwarding", {dest="freifunk"}) uci:delete_all("firewall","forwarding", {dest="freifunk"})
@ -551,7 +544,7 @@ function main.write(self, section, value)
uci:delete_all("firewall","rule", {src="freifunk"}) uci:delete_all("firewall","rule", {src="freifunk"})
uci:save("firewall") uci:save("firewall")
-- Create firewall zone and add default rules (first time) -- Create firewall zone and add default rules (first time)
-- firewall_create_zone("name" , "input" , "output", "forward ", Masqurade) -- firewall_create_zone("name" , "input" , "output", "forward ", Masqurade)
local newzone = tools.firewall_create_zone("freifunk", "ACCEPT", "ACCEPT", "REJECT" , true) local newzone = tools.firewall_create_zone("freifunk", "ACCEPT", "ACCEPT", "REJECT" , true)
if newzone then if newzone then
uci:foreach("freifunk", "fw_forwarding", function(section) uci:foreach("freifunk", "fw_forwarding", function(section)
@ -647,10 +640,7 @@ function main.write(self, section, value)
uci:delete_all("luci_splash", "iface", {network=nif.."dhcp", zone="freifunk"}) uci:delete_all("luci_splash", "iface", {network=nif.."dhcp", zone="freifunk"})
-- Delete old radvd -- Delete old radvd
if has_radvd then if has_radvd then
uci:delete_all("radvd", "interface", {interface=nif.."dhcp"}) uci_clean_radvd(nif)
uci:delete_all("radvd", "interface", {interface=nif})
uci:delete_all("radvd", "prefix", {interface=nif.."dhcp"})
uci:delete_all("radvd", "prefix", {interface=nif})
end end
-- New Config -- New Config
-- Tune wifi device -- Tune wifi device
@ -665,9 +655,9 @@ function main.write(self, section, value)
if sec.txantenna then if sec.txantenna then
devconfig.txantenna = sec.txantenna devconfig.txantenna = sec.txantenna
end end
if sec.rxantenna then if sec.rxantenna then
devconfig.rxantenna = sec.rxantenna devconfig.rxantenna = sec.rxantenna
end end
-- set bssid, see https://kifuse02.pberg.freifunk.net/moin/channel-bssid-essid for schema -- set bssid, see https://kifuse02.pberg.freifunk.net/moin/channel-bssid-essid for schema
if channel and channel ~= "default" then if channel and channel ~= "default" then
@ -713,21 +703,7 @@ function main.write(self, section, value)
end end
uci:section("network", "interface", nif, netconfig) uci:section("network", "interface", nif, netconfig)
if has_radvd then if has_radvd then
uci:section("radvd", "interface", nil, { uci_radvd(nif)
interface =nif,
AdvSendAdvert =1,
AdvManagedFlag =0,
AdvOtherConfigFlag =0,
ignore =0
})
uci:section("radvd", "prefix", nil, {
interface =nif,
AdvOnLink =1,
AdvAutonomous =1,
AdvRouterAddr =0,
ignore =0,
})
uci:save("radvd")
end end
tools.firewall_zone_add_interface("freifunk", nif) tools.firewall_zone_add_interface("freifunk", nif)
uci:save("firewall") uci:save("firewall")
@ -742,14 +718,6 @@ function main.write(self, section, value)
if client then if client then
local dhcpmeshnet = luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device)) local dhcpmeshnet = luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device))
hbconf(nif) hbconf(nif)
--[[
if has_hb then
local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {}
table.insert(ifacelist,nif .. "dhcp")
uci:set_list("manager", "heartbeat", "interface", ifacelist)
uci:save("manager")
end
]]
if dhcpmeshnet then if dhcpmeshnet then
if not dhcpmeshnet:minhost() or not dhcpmeshnet:mask() then if not dhcpmeshnet:minhost() or not dhcpmeshnet:mask() then
dhcpmesh.tag_missing[section] = true dhcpmesh.tag_missing[section] = true
@ -798,21 +766,7 @@ function main.write(self, section, value)
ssid ="AP-" .. ssid ssid ="AP-" .. ssid
}) })
if has_radvd then if has_radvd then
uci:section("radvd", "interface", nil, { uci_radvd(nif .. "dhcp")
interface =nif .. "dhcp",
AdvSendAdvert =1,
AdvManagedFlag =0,
AdvOtherConfigFlag =0,
ignore =0
})
uci:section("radvd", "prefix", nil, {
interface =nif .. "dhcp",
AdvOnLink =1,
AdvAutonomous =1,
AdvRouterAddr =0,
ignore =0
})
uci:save("radvd")
end end
tools.firewall_zone_add_interface("freifunk", nif .. "dhcp") tools.firewall_zone_add_interface("freifunk", nif .. "dhcp")
uci:save("wireless") uci:save("wireless")
@ -892,7 +846,7 @@ function main.write(self, section, value)
end end
if device ~= "loopback" and not string.find(device, "wifi") and not string.find(device, "wl") and not string.find(device, "wlan") and not string.find(device, "wireless") and not string.find(device, "radio") then if device ~= "loopback" and not string.find(device, "wifi") and not string.find(device, "wl") and not string.find(device, "wlan") and not string.find(device, "wireless") and not string.find(device, "radio") then
local node_ip local node_ip
node_ip = luci.http.formvalue("cbid.ffwizward.1.meship_" .. device) --and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.meship_" .. device)) node_ip = luci.http.formvalue("cbid.ffwizward.1.meship_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.meship_" .. device))
if has_ipv6 then if has_ipv6 then
node_ip6 = luci.http.formvalue("cbid.ffwizward.1.meship6_" .. device) --and ip.IPv6(luci.http.formvalue("cbid.ffwizward.1.meship6_" .. device)) node_ip6 = luci.http.formvalue("cbid.ffwizward.1.meship6_" .. device) --and ip.IPv6(luci.http.formvalue("cbid.ffwizward.1.meship6_" .. device))
end end
@ -913,10 +867,7 @@ function main.write(self, section, value)
-- Delete old splash -- Delete old splash
uci:delete_all("luci_splash", "iface", {network=device.."dhcp", zone="freifunk"}) uci:delete_all("luci_splash", "iface", {network=device.."dhcp", zone="freifunk"})
if has_radvd then if has_radvd then
uci:delete_all("radvd", "interface", {interface=device.."dhcp"}) uci_clean_radvd(device)
uci:delete_all("radvd", "interface", {interface=device})
uci:delete_all("radvd", "prefix", {interface=device.."dhcp"})
uci:delete_all("radvd", "prefix", {interface=device})
end end
-- New Config -- New Config
local netconfig = uci:get_all("freifunk", "interface") local netconfig = uci:get_all("freifunk", "interface")
@ -929,21 +880,7 @@ function main.write(self, section, value)
uci:section("network", "interface", device, netconfig) uci:section("network", "interface", device, netconfig)
uci:save("network") uci:save("network")
if has_radvd then if has_radvd then
uci:section("radvd", "interface", nil, { uci_radvd(device)
interface =device,
AdvSendAdvert =1,
AdvManagedFlag =0,
AdvOtherConfigFlag =0,
ignore =0
})
uci:section("radvd", "prefix", nil, {
interface =device,
AdvOnLink =1,
AdvAutonomous =1,
AdvRouterAddr =0,
ignore =0,
})
uci:save("radvd")
end end
tools.firewall_zone_add_interface("freifunk", device) tools.firewall_zone_add_interface("freifunk", device)
uci:save("firewall") uci:save("firewall")
@ -959,16 +896,7 @@ function main.write(self, section, value)
if client then if client then
local dhcpmeshnet = luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device)) local dhcpmeshnet = luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device))
hbconf(device) hbconf(device)
--[[
if has_hb then
hbconf(device)
local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {}
table.insert(ifacelist,device .. "dhcp")
uci:set_list("manager", "heartbeat", "interface", ifacelist)
uci:save("manager")
end
]]
if dhcpmeshnet then if dhcpmeshnet then
if not dhcpmeshnet:minhost() or not dhcpmeshnet:mask() then if not dhcpmeshnet:minhost() or not dhcpmeshnet:mask() then
dhcpmesh.tag_missing[section] = true dhcpmesh.tag_missing[section] = true