3. Run ./scripts/feeds update
- 4. Run ./scripts/feeds install ffluci
+ 4. Run ./scripts/feeds install ffluci-meta
5. Type make menuconfig and you will find ffluci in the menu "Administration"
--- /dev/null
+include build/config.mk
+
+MODULES = applications/* core modules/* themes/*
+LUA_TARGET = source
+
+
+.PHONY: all build clean host hostclean
+
+all: build
+
+build:
+ for i in $(MODULES); do make -C$$i $(LUA_TARGET); done
+
+clean:
+ for i in $(MODULES); do make -C$$i clean; done
+
+host: build
+ mkdir -p host/ffluci
+ for i in $(MODULES); do cp $$i/dist$(LUCI_INSTALLDIR) host/ffluci -R; done
+
+hostclean:
+ rm host -rf
\ No newline at end of file
+++ /dev/null
-FFLuCI - Freifunk Lua Configuration Interface
-
-This is a leightweight MVC-Webframework for small embedded devices.
-It uses the the Lua programming language and relies on Haserl.
-
-It consists of several parts:
-
-MVC Dispatcher
- Simple PATH_INFO based dispatching mechanism using Lua modules
-
-
-Template engine
- Support for plain and compiled templates, on-demand compiling support
- Short markups:
- <% Lua-Code %>
- <%= Lua-Code with return value %>
- <%:i18nkey default translation%>
- <%+template-to-be-included%>
- <%~uci.short.cut%>
-
- Predefined variables for controller dir and media dir
-
-
-Configuration Bind Interface (CBI)
- Generates and validates XHTML-Forms out of an UCI model description
- Makes it very easy to create webinterface pages that manipulate UCI files
-
-
-i18n Translation support
- Simple multi-language per-module internationalization support
-
-
-UCI wrapper support
- Lua UCI-Wrapper adapting the CLI of the uci binary
-
-
-Menu Building support
- Supports menu building for modules and exported actions
-
-
-HTTP-Abstraction and Formvalue validation support
- HTTP-Redirect, Statuscode, Content-Type abstraction
- Dynamic formvalue validation support including varaible type and
- value range validation
-
-
-Known issues:
- There is a bug in older versions of busybox-httpd (as those in Kamikaze 7.09)
- that do not handle Status-headers correctly making valid HTTP-Redirects impossible.
- Using a newer version of Kamikaze should fix this.
\ No newline at end of file
--- /dev/null
+include ../../build/config.mk
+include ../../build/module.mk
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+uci batch <<-EOF
+ set freifunk.community.name='Freifunk Leipzig'
+ set freifunk.community.homepage=http://leipzig.freifunk.net
+ set freifunk.community.essid=leipzig.freifunk.net
+ set freifunk.community.bssid=02:CA:FF:EE:BA:BE
+ set freifunk.community.realm=db.leipzig.freifunk.net
+ set freifunk.community.channel=1
+ set freifunk.community.net=104.0.0.0
+ set freifunk.community.mask=255.0.0.0
+ set freifunk.community.dhcp=10.0.0.0
+ set freifunk.community.dhcpmask=255.255.255.0
+ set freifunk.community.dns='88.198.178.18 141.54.1.1 212.204.49.83 208.67.220.220 208.67.222.222'
+EOF
+
\ No newline at end of file
--- /dev/null
+include ../../build/config.mk
+include ../../build/module.mk
\ No newline at end of file
--- /dev/null
+
+
\ No newline at end of file
--- /dev/null
+#!/bin/sh /etc/rc.common
+START=46
+
+apply_portfw() {
+ local cfg="$1"
+ config_get proto "$cfg" proto
+ config_get dport "$cfg" dport
+ config_get iface "$cfg" iface
+ config_get to "$cfg" to
+
+ ports=$(echo $to | cut -sd: -f2)
+ if [ -n "$ports" ]; then
+ ports="--dport $(echo $ports | sed -e 's/-/:/')"
+ else
+ ports="--dport $dport"
+ fi
+
+ ip=$(echo $to | cut -d: -f1)
+
+ if ([ "$proto" == "tcpudp" ] || [ "$proto" == "tcp" ]); then
+ iptables -t nat -A luci_fw_prerouting -i "$iface" -p tcp --dport "$dport" -j DNAT --to "$to"
+ iptables -A luci_fw_forward -i "$iface" -p tcp -d "$ip" $ports -j ACCEPT
+ fi
+
+ if ([ "$proto" == "tcpudp" ] || [ "$proto" == "udp" ]); then
+ iptables -t nat -A luci_fw_prerouting -i "$iface" -p udp --dport "$dport" -j DNAT --to "$to"
+ iptables -A luci_fw_forward -i "$iface" -p udp -d "$ip" $ports -j ACCEPT
+ fi
+}
+
+apply_rule() {
+ local cfg="$1"
+ local cmd=""
+
+ config_get chain "$cfg" chain
+ [ -n "$chain" ] || return 0
+ [ "$chain" == "forward" ] && cmd="$cmd -A luci_fw_forward"
+ [ "$chain" == "input" ] && cmd="$cmd -A luci_fw_input"
+ [ "$chain" == "output" ] && cmd="$cmd -A luci_fw_output"
+ [ "$chain" == "prerouting" ] && cmd="$cmd -t nat -A luci_fw_prerouting"
+ [ "$chain" == "postrouting" ] && cmd="$cmd -t nat -A luci_fw_postrouting"
+
+ config_get iface "$cfg" iface
+ [ -n "$iface" ] && cmd="$cmd -i $iface"
+
+ config_get oface "$cfg" oface
+ [ -n "$oface" ] && cmd="$cmd -o $oface"
+
+ config_get proto "$cfg" proto
+ [ -n "$proto" ] && cmd="$cmd -p $proto"
+
+ config_get source "$cfg" source
+ [ -n "$source" ] && cmd="$cmd -s $source"
+
+ config_get destination "$cfg" destination
+ [ -n "$destination" ] && cmd="$cmd -d $destination"
+
+ config_get sport "$cfg" sport
+ [ -n "$sport" ] && cmd="$cmd --sport $sport"
+
+ config_get dport "$cfg" dport
+ [ -n "$dport" ] && cmd="$cmd --dport $dport"
+
+ config_get todest "$cfg" todest
+ [ -n "$todest" ] && cmd="$cmd --to-destination $todest"
+
+ config_get tosrc "$cfg" tosrc
+ [ -n "$tosrc" ] && cmd="$cmd --to-source $tosrc"
+
+ config_get mac "$cfg" mac
+ [ -n "$mac" ] && cmd="$cmd -m mac --mac-source $mac"
+
+ config_get jump "$cfg" jump
+ [ -n "$jump" ] && cmd="$cmd -j $jump"
+
+ config_get command "$cfg" command
+ [ -n "$command" ] && cmd="$cmd $command"
+
+ iptables $cmd
+}
+
+start() {
+ ### Create subchains
+ iptables -N luci_fw_input
+ iptables -N luci_fw_output
+ iptables -N luci_fw_forward
+ iptables -t nat -N luci_fw_prerouting
+ iptables -t nat -N luci_fw_postrouting
+
+ ### Hook in the chains
+ iptables -A input_rule -j luci_fw_input
+ iptables -A output_rule -j luci_fw_output
+ iptables -A forwarding_rule -j luci_fw_forward
+ iptables -t nat -A prerouting_rule -j luci_fw_prerouting
+ iptables -t nat -A postrouting_rule -j luci_fw_postrouting
+
+ ### Read chains from config
+ config_load luci_fw
+ config_foreach apply_portfw portfw
+ config_foreach apply_rule rule
+}
+
+stop() {
+ ### Hook out the chains
+ iptables -D input_rule -j luci_fw_input
+ iptables -D output_rule -j luci_fw_output
+ iptables -D forwarding_rule -j luci_fw_forward
+ iptables -t nat -D prerouting_rule -j luci_fw_prerouting
+ iptables -t nat -D postrouting_rule -j luci_fw_postrouting
+
+ ### Clear subchains
+ iptables -F luci_fw_input
+ iptables -F luci_fw_output
+ iptables -F luci_fw_forward
+ iptables -t nat -F luci_fw_prerouting
+ iptables -t nat -F luci_fw_postrouting
+
+ ### Delete subchains
+ iptables -X luci_fw_input
+ iptables -X luci_fw_output
+ iptables -X luci_fw_forward
+ iptables -t nat -X luci_fw_prerouting
+ iptables -t nat -X luci_fw_postrouting
+}
--- /dev/null
+-- ToDo: Translate, Add descriptions and help texts
+m = Map("luci_fw", "Firewall", [[Mit Hilfe der Firewall können Zugriffe auf das Netzwerk
+erlaubt, verboten oder umgeleitet werden.]])
+
+s = m:section(TypedSection, "rule")
+s.addremove = true
+s.anonymous = true
+
+chain = s:option(ListValue, "chain", "Kette")
+chain:value("forward", "Forward")
+chain:value("input", "Input")
+chain:value("output", "Output")
+chain:value("prerouting", "Prerouting")
+chain:value("postrouting", "Postrouting")
+
+s:option(Value, "iface", "Eingangsschnittstelle").optional = true
+s:option(Value, "oface", "Ausgangsschnittstelle").optional = true
+
+proto = s:option(ListValue, "proto", "Protokoll")
+proto.optional = true
+proto:value("")
+proto:value("tcp", "TCP")
+proto:value("udp", "UDP")
+
+s:option(Value, "source", "Quelladresse").optional = true
+s:option(Value, "destination", "Zieladresse").optional = true
+s:option(Value, "mac", "MAC-Adresse").optional = true
+
+sport = s:option(Value, "sport", "Quellport")
+sport.optional = true
+sport:depends("proto", "tcp")
+sport:depends("proto", "udp")
+
+dport = s:option(Value, "dport", "Zielport")
+dport.optional = true
+dport:depends("proto", "tcp")
+dport:depends("proto", "udp")
+
+tosrc = s:option(Value, "tosrc", "Neue Quelladresse [SNAT]")
+tosrc.optional = true
+tosrc:depends("jump", "SNAT")
+
+tosrc = s:option(Value, "todest", "Neue Zieladresse [DNAT]")
+tosrc.optional = true
+tosrc:depends("jump", "DNAT")
+
+jump = s:option(ListValue, "jump", "Aktion")
+jump.rmempty = true
+jump:value("", "")
+jump:value("ACCEPT", "annehmen (ACCEPT)")
+jump:value("REJECT", "zurückweisen (REJECT)")
+jump:value("DROP", "verwerfen (DROP)")
+jump:value("LOG", "protokollieren (LOG)")
+jump:value("DNAT", "Ziel umschreiben (DNAT) [nur Prerouting]")
+jump:value("MASQUERADE", "maskieren (MASQUERADE) [nur Postrouting]")
+jump:value("SNAT", "Quelle umschreiben (SNAT) [nur Postrouting]")
+
+
+add = s:option(Value, "command", "Eigener Befehl")
+add.size = 50
+add.rmempty = true
+
+return m
--- /dev/null
+-- ToDo: Translate, Add descriptions and help texts
+require("ffluci.sys")
+m = Map("luci_fw", "Portweiterleitung", [[Portweiterleitungen ermöglichen es interne
+Netzwerkdienste von einem anderen externen Netzwerk aus erreichbar zu machen.]])
+
+s = m:section(TypedSection, "portfw")
+s.addremove = true
+s.anonymous = true
+
+iface = s:option(ListValue, "iface", "Externes Interface")
+iface:value("")
+for k,v in pairs(ffluci.sys.net.devices()) do
+ iface:value(v)
+end
+
+proto = s:option(ListValue, "proto", "Protokoll")
+proto:value("tcp", "TCP")
+proto:value("udp", "UDP")
+proto:value("tcpudp", "TCP + UDP")
+
+dport = s:option(Value, "dport", "Externer Port", "Port[:Endport]")
+
+to = s:option(Value, "to", "Interne Adresse", "IP-Adresse[:Zielport[-Zielendport]]")
+
+return m
--- /dev/null
+sel("admin", "network")
+act("portfw", "Portweiterleitung")
+act("firewall", "Firewall")
\ No newline at end of file
--- /dev/null
+include ../../build/config.mk
+include ../../build/module.mk
\ No newline at end of file
--- /dev/null
+config core general
+ option leasetime 1
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+[ "$(date +%M | cut -c2)" == "5" ] && luci-splash sync
\ No newline at end of file
--- /dev/null
+#!/bin/sh /etc/rc.common
+START=70
+
+iface_add() {
+ local cfg="$1"
+
+ config_get net "$cfg" network
+ [ -n "$net" ] || return 0
+
+ config_get iface "$net" ifname
+ [ -n "$iface" ] || return 0
+ iface="${iface%%:*}"
+
+ config_get ipaddr "$net" ipaddr
+ [ -n "$ipaddr" ] || return 0
+
+ config_get netmask "$net" netmask
+ [ -n "$netmask" ] || return 0
+
+ eval "$(ipcalc.sh $ipaddr $netmask)"
+
+ iptables -t nat -A luci_splash -i "$iface" -s "$NETWORK/$PREFIX" -j luci_splash_portal
+ iptables -t nat -A luci_splash_portal -i "$iface" -s "$NETWORK/$PREFIX" -d "$ipaddr" -p tcp -m multiport --dports 22,80,443 -j RETURN
+}
+
+blacklist_add() {
+ local cfg="$1"
+
+ config_get mac "$cfg" mac
+ [ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j DROP
+}
+
+whitelist_add() {
+ local cfg="$1"
+
+ config_get mac "$cfg" mac
+ [ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j RETURN
+}
+
+start() {
+ ### Read chains from config
+ include /lib/network
+ scan_interfaces
+ config_load luci_splash
+
+ ### Create subchains
+ iptables -t nat -N luci_splash
+ iptables -t nat -N luci_splash_portal
+ iptables -t nat -N luci_splash_leases
+
+ ### Build the main and portal rule
+ config_foreach blacklist_add blacklist
+ config_foreach whitelist_add whitelist
+ config_foreach iface_add iface
+
+ ### Build the portal rule
+ iptables -t nat -A luci_splash_portal -p udp --dport 53 -j RETURN
+ iptables -t nat -A luci_splash_portal -j luci_splash_leases
+
+ ### Build the leases rule
+ iptables -t nat -A luci_splash_leases -p tcp --dport 80 -j REDIRECT --to-ports 8082
+ iptables -t nat -A luci_splash_leases -j DROP
+
+ ### Start the splash httpd
+ httpd -c /etc/luci_splash_httpd.conf -p 8082 -h /usr/lib/luci-splash/htdocs
+
+ ### Hook in the chain
+ iptables -t nat -A prerouting_rule -j luci_splash
+}
+
+stop() {
+ ### Hook out the chain
+ iptables -t nat -D prerouting_rule -j luci_splash
+
+ ### Clear subchains
+ iptables -t nat -F luci_splash_leases
+ iptables -t nat -F luci_splash_portal
+ iptables -t nat -F luci_splash
+
+ ### Delete subchains
+ iptables -t nat -X luci_splash_leases
+ iptables -t nat -X luci_splash_portal
+ iptables -t nat -X luci_splash
+}
+
--- /dev/null
+E404:index.html
\ No newline at end of file
--- /dev/null
+#!/usr/bin/haserl --shell=luac
+package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
+package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
+
+require("ffluci.http")
+require("ffluci.sys")
+require("ffluci.model.uci")
+
+local srv
+local net
+local ip = ffluci.http.remote_addr()
+for k, v in pairs(ffluci.model.uci.sections("network")) do
+ if v[".type"] == "interface" and v.ipaddr then
+ local p = ffluci.sys.net.mask4prefix(v.netmask)
+ if ffluci.sys.net.belongs(ip, v.ipaddr, p) then
+ net = k
+ srv = v.ipaddr
+ break
+ end
+ end
+end
+
+local stat = false
+for k, v in pairs(ffluci.model.uci.sections("luci_splash")) do
+ if v[".type"] == "iface" and v.network == net then
+ stat = true
+ end
+end
+
+if not srv then
+ ffluci.http.textheader()
+ return print("Unable to detect network settings!")
+end
+
+if not stat then
+ ffluci.http.redirect("http://" .. srv)
+end
+
+local action = "splash"
+
+local mac = ffluci.sys.net.ip4mac(ip)
+if not mac then
+ action = "unknown"
+end
+
+local status = ffluci.sys.execl("luci-splash status "..mac)[1]
+
+if status == "whitelisted" or status == "lease" then
+ action = "allowed"
+end
+
+ffluci.http.redirect("http://" .. srv .. "/cgi-bin/luci-splash/" .. action)
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="refresh" content="0; URL=/cgi-bin/index.cgi" />
+</head>
+<body style="background-color: black">
+<a style="color: white; text-decoration: none" href="/cgi-bin/index.cgi">FFLuCI - Freifunk Lua Configuration Interface</a>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+echo "Status: 302 Found"
+echo "Location: /cgi-bin/ffluci/splash/splash$PATH_INFO"
+echo
\ No newline at end of file
--- /dev/null
+module("ffluci.controller.splash.splash", package.seeall)
+
+function action_activate()
+ local mac = ffluci.sys.net.ip4mac(ffluci.http.env.REMOTE_ADDR)
+ if mac and ffluci.http.formvalue("accept") then
+ os.execute("luci-splash add "..mac.." >/dev/null 2>&1")
+ ffluci.http.redirect(ffluci.model.uci.get("freifunk", "community", "homepage"))
+ else
+ ffluci.http.redirect(ffluci.dispatcher.build_url())
+ end
+end
+
+function action_accepted()
+ ffluci.http.redirect(ffluci.dispatcher.build_url())
+end
+
+function action_unknown()
+ ffluci.http.redirect(ffluci.dispatcher.build_url())
+end
\ No newline at end of file
--- /dev/null
+-- ToDo: Translate, Add descriptions and help texts
+require("ffluci.model.uci")
+
+m = Map("luci_splash", "Client-Splash", [[Client-Splash ist das Freifunk Hotspot-Authentifizierungs-System.]])
+
+s = m:section(NamedSection, "general", "core", "Allgemein")
+s:option(Value, "leasetime", "Freigabezeit", "h")
+
+s = m:section(TypedSection, "iface", "Schnittstellen")
+s.addremove = true
+s.anonymous = true
+
+iface = s:option(ListValue, "network", "Schnittstelle")
+for k, v in pairs(ffluci.model.uci.sections("network")) do
+ if v[".type"] == "interface" and k ~= "loopback" then
+ iface:value(k)
+ end
+end
+
+s = m:section(TypedSection, "whitelist", "Automatische Freigabe")
+s.addremove = true
+s.anonymous = true
+s:option(Value, "mac", "MAC-Adresse")
+
+s = m:section(TypedSection, "blacklist", "Automatische Sperrung")
+s.addremove = true
+s.anonymous = true
+s:option(Value, "mac", "MAC-Adresse")
+
+return m
\ No newline at end of file
--- /dev/null
+sel("admin", "services")
+act("splash", "Client-Splash")
\ No newline at end of file
--- /dev/null
+<h1><%:welcome Willkommen%>!</h1>
+<p>
+Du bist jetzt mit dem freien Funknetz
+<a href="<%~freifunk.community.homepage%>"><%~freifunk.community.name%></a> verbunden.<br />
+Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter.
+</p>
+
+<p>
+Ein Zugang <strong>ins Internet</strong> ist trotzdem möglich,
+da einige Freifunker ihre privaten Internetzugänge zur Verfügung stellen.
+Diese Zugänge müssen sich hier alle teilen.
+Bitte sei Dir dessen bewusst und verhalte Dich dementsprechend:
+<ul>
+<li>bitte <strong>keine Filesharing-Programme</strong> betreiben!</li>
+<li>bitte <strong>keine unnötigen Downloads oder Streams</strong> starten!</li>
+<li>bitte <strong>keine illegalen Aktivitäten</strong>!</li>
+</ul>
+</p>
+
+<p>
+Wenn Du unsere Idee gut findest, kannst Du uns unterstützen:
+<ul>
+<li><a href="<%~freifunk.community.homepage%>">Werde selbst Freifunker oder teile deinen Internetzugang!</a></li>
+<li>Betreibe deine anderen WLAN-Geräte <em>NICHT</em> auf den Kanälen 1-5, diese stören oft unser Netz.</li>
+</ul>
+</p>
+
+<p>
+Mit einem Klick auf <em><%:accept Annehmen%></em> kannst du für <%~luci_splash.general.leasetime%> Stunden
+über unser Netz das Internet verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren.
+</p>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<%+splash/splash%>
+<form method="get" action="<%=controller%>/splash/splash/activate">
+ <input type="submit" value="<%:decline Ablehnen%>" />
+ <input type="submit" name="accept" value="<%:accept Annehmen%>" />
+</form>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+include ../../build/config.mk
+include ../../build/module.mk
\ No newline at end of file
--- /dev/null
+#!/usr/bin/haserl --shell=luac
+package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
+package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
+require("ffluci.dispatcher").httpdispatch()
\ No newline at end of file
--- /dev/null
+#!/usr/bin/haserl --shell=luac --upload-limit=6144
+-- This is a bit hacky: remove -upload from SCRIPT_NAME
+ENV.SCRIPT_NAME = ENV.SCRIPT_NAME:sub(1, #ENV.SCRIPT_NAME - 7)
+dofile("ffluci")
\ No newline at end of file
--- /dev/null
+#!/usr/bin/haserl --shell=luac
+print("Status: 302 Found")
+print("Location: ffluci\n")
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="refresh" content="0; URL=/cgi-bin/index.cgi" />
+</head>
+<body style="background-color: black">
+<a style="color: white; text-decoration: none" href="/cgi-bin/index.cgi">FFLuCI - Freifunk Lua Configuration Interface</a>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - SGI-Module for Haserl
+
+Description:
+Server Gateway Interface for Haserl
+
+FileId:
+$Id: haserl.lua 2027 2008-05-07 21:16:35Z Cyrus $
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+module("ffluci.sgi.haserl", package.seeall)
+
+-- Environment Table
+ffluci.http.env = ENV
+
+
+-- Returns a table of all COOKIE, GET and POST Parameters
+function ffluci.http.formvalues()
+ return FORM
+end
+
+-- Gets form value from key
+function ffluci.http.formvalue(key, default)
+ local c = ffluci.http.formvalues()
+
+ for match in key:gmatch("[%w-_]+") do
+ c = c[match]
+ if c == nil then
+ return default
+ end
+ end
+
+ return c
+end
+
+-- Gets a table of values with a certain prefix
+function ffluci.http.formvaluetable(prefix)
+ return ffluci.http.formvalue(prefix, {})
+end
+
+-- Sends a custom HTTP-Header
+function ffluci.http.header(key, value)
+ print(key .. ": " .. value)
+end
+
+-- Set Content-Type
+function ffluci.http.prepare_content(type)
+ print("Content-Type: "..type.."\n")
+end
+
+-- Asks the browser to redirect to "url"
+function ffluci.http.redirect(url)
+ ffluci.http.status(302, "Found")
+ ffluci.http.header("Location", url)
+ print()
+end
+
+-- Sets HTTP-Status-Header
+function ffluci.http.status(code, message)
+ print("Status: " .. tostring(code) .. " " .. message)
+end
--- /dev/null
+include ../../build/config.mk
+include ../../build/module.mk
\ No newline at end of file
--- /dev/null
+package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
+package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
+module("webuci", package.seeall)
+
+function prepare_req(uri)
+ env = {}
+ env.REQUEST_URI = uri
+ require("ffluci.menu").get()
+end
+
+function init_req(context)
+ env.SERVER_PROTOCOL = context.server_proto
+ env.REMOTE_ADDR = context.remote_addr
+ env.REQUEST_METHOD = context.request_method
+ env.PATH_INFO = "/" .. context.uri
+ env.REMOTE_PORT = context.remote_port
+ env.SERVER_ADDR = context.server_addr
+ env.SCRIPT_NAME = env.REQUEST_URI:sub(1, #env.REQUEST_URI - #env.PATH_INFO)
+end
+
+function handle_req(context)
+ require("ffluci.dispatcher").httpdispatch()
+end
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - SGI-Module for Haserl
+
+Description:
+Server Gateway Interface for Haserl
+
+FileId:
+$Id: webuci.lua 2027 2008-05-07 21:16:35Z Cyrus $
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+module("ffluci.sgi.webuci", package.seeall)
+
+-- Environment Table
+ffluci.http.env = webuci.env
+
+
+local status_set = false
+
+-- Returns a table of all COOKIE, GET and POST Parameters
+function ffluci.http.formvalues()
+ return webuci.vars
+end
+
+-- Gets form value from key
+function ffluci.http.formvalue(key, default)
+ return ffluci.http.formvalues()[key] or default
+end
+
+-- Gets a table of values with a certain prefix
+function ffluci.http.formvaluetable(prefix)
+ local vals = {}
+ prefix = prefix and prefix .. "." or "."
+
+ for k, v in pairs(ffluci.http.formvalues()) do
+ if k:find(prefix, 1, true) == 1 then
+ vals[k:sub(#prefix + 1)] = v
+ end
+ end
+
+ return vals
+end
+
+-- Sends a custom HTTP-Header
+function ffluci.http.header(key, value)
+ print(key .. ": " .. value)
+end
+
+-- Set Content-Type
+function ffluci.http.prepare_content(type)
+ if not status_set then
+ ffluci.http.status(200, "OK")
+ end
+
+ print("Content-Type: "..type.."\n")
+end
+
+-- Asks the browser to redirect to "url"
+function ffluci.http.redirect(url)
+ ffluci.http.status(302, "Found")
+ ffluci.http.header("Location", url)
+ print()
+end
+
+-- Sets HTTP-Status-Header
+function ffluci.http.status(code, message)
+ print(webuci.env.SERVER_PROTOCOL .. " " .. tostring(code) .. " " .. message)
+ status_set = true
+end
--- /dev/null
+LUAC = luac
+LUAC_OPTIONS = -s
+LUCI_INSTALLDIR = /usr/lib/lua/ffluci
\ No newline at end of file
--- /dev/null
+.PHONY: all compile source clean
+
+all: compile
+
+source:
+ mkdir -p dist$(LUCI_INSTALLDIR)
+ cp root dist -R
+ cp src dist$(LUCI_INSTALLDIR) -R
+ for i in $$(find dist -name .svn); do rm $$i -rf; done
+
+compile: source
+ for i in $$(find dist -name *.lua); do $(LUAC) $(LUAC_OPTIONS) -o $$i $$i; done
+
+clean:
+ rm dist -rf
\ No newline at end of file
+++ /dev/null
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=ffluci-splash
-PKG_VERSION:=0.1
-PKG_RELEASE:=1
-
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
-PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
-PKG_BUILD_DEPENDS:=lua-luci
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/ffluci-splash
- SECTION:=admin
- CATEGORY:=Administration
- SUBMENU:=FFLuCI
- DEPENDS:=+ffluci +iptables-mod-nat +lua-luci
- TITLE:=FFLuCI DHCP-Splash
-endef
-
-define Build/Compile
-endef
-
-define Package/ffluci-splash/install
- $(INSTALL_DIR) $(1)/usr/lib/luci-splash/htdocs/cgi-bin
- $(INSTALL_DIR) $(1)/etc/config
- $(INSTALL_DIR) $(1)/etc/cron.minutely
- $(INSTALL_DIR) $(1)/etc/init.d
- $(INSTALL_DIR) $(1)/usr/sbin
-
- $(CP) -a ./src/luci-splash/* $(1)/usr/lib/luci-splash/ -R
- $(INSTALL_BIN) ./src/luci-splash/htdocs/cgi-bin/index.cgi $(1)/usr/lib/luci-splash/htdocs/cgi-bin
- $(INSTALL_BIN) ./src/luci_splash.init $(1)/etc/init.d/luci_splash
- $(INSTALL_BIN) ./src/luci-splash.lua $(1)/usr/sbin/luci-splash
-
- $(INSTALL_BIN) ./src/luci_splash.cron $(1)/etc/cron.minutely/luci-splash
- $(CP) -a ./src/luci_splash.uci $(1)/etc/config/luci_splash
- $(CP) -a ./src/luci_splash_httpd.conf $(1)/etc/
-
- $(CP) -a ./ipkg/conffiles $(1)/CONTROL/conffiles
-endef
-
-$(eval $(call BuildPackage,ffluci-splash))
+++ /dev/null
-/etc/config/luci_splash
\ No newline at end of file
+++ /dev/null
-#!/usr/bin/lua
-package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
-package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
-
-require("ffluci.http")
-require("ffluci.sys")
-require("ffluci.model.uci")
-
--- Init state session
-uci = ffluci.model.uci.StateSession()
-
-
-function main(argv)
- local cmd = argv[1]
- local arg = argv[2]
-
- if cmd == "status" then
- if not arg then
- os.exit(1)
- end
-
- if iswhitelisted(arg) then
- print("whitelisted")
- os.exit(0)
- end
-
- if haslease(arg) then
- print("lease")
- os.exit(0)
- end
-
- print("unknown")
- os.exit(0)
- elseif cmd == "add" then
- if not arg then
- os.exit(1)
- end
-
- if not haslease(arg) then
- add_lease(arg)
- else
- print("already leased!")
- os.exit(2)
- end
- os.exit(0)
- elseif cmd == "remove" then
- if not arg then
- os.exit(1)
- end
-
- remove_lease(arg)
- os.exit(0)
- elseif cmd == "sync" then
- sync()
- os.exit(0)
- else
- print("Usage: " .. argv[0] .. " <status|add|remove|sync> [MAC]")
- os.exit(1)
- end
-end
-
--- Add a lease to state and invoke add_rule
-function add_lease(mac)
- local key = uci:add("luci_splash", "lease")
- uci:set("luci_splash", key, "mac", mac)
- uci:set("luci_splash", key, "start", os.time())
- add_rule(mac)
-end
-
-
--- Remove a lease from state and invoke remove_rule
-function remove_lease(mac)
- mac = mac:lower()
-
- for k, v in pairs(uci:sections("luci_splash")) do
- if v[".type"] == "lease" and v.mac:lower() == mac then
- remove_rule(mac)
- uci:del("luci_splash", k)
- end
- end
-end
-
-
--- Add an iptables rule
-function add_rule(mac)
- return os.execute("iptables -t nat -I luci_splash_leases -m mac --mac-source '"..mac.."' -j RETURN")
-end
-
-
--- Remove an iptables rule
-function remove_rule(mac)
- return os.execute("iptables -t nat -D luci_splash_leases -m mac --mac-source '"..mac.."' -j RETURN")
-end
-
-
--- Check whether a MAC-Address is listed in the lease state list
-function haslease(mac)
- mac = mac:lower()
-
- for k, v in pairs(uci:sections("luci_splash")) do
- if v[".type"] == "lease" and v.mac and v.mac:lower() == mac then
- return true
- end
- end
-
- return false
-end
-
-
--- Check whether a MAC-Address is whitelisted
-function iswhitelisted(mac)
- mac = mac:lower()
-
- for k, v in pairs(uci:sections("luci_splash")) do
- if v[".type"] == "whitelist" and v.mac and v.mac:lower() == mac then
- return true
- end
- end
-
- return false
-end
-
-
--- Returns a list of MAC-Addresses for which a rule is existing
-function listrules()
- local cmd = "iptables -t nat -L luci_splash_leases | grep RETURN |"
- cmd = cmd .. "egrep -io [0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+"
- return ffluci.util.split(ffluci.sys.exec(cmd))
-end
-
-
--- Synchronise leases, remove abandoned rules
-function sync()
- local written = {}
- local time = os.time()
-
- uci:t_load("luci_splash")
-
- -- Current leases in state files
- local leases = uci:t_sections("luci_splash")
-
- -- Convert leasetime to seconds
- local leasetime = tonumber(uci:t_get("luci_splash", "general", "leasetime")) * 3600
-
- -- Clean state file
- uci:t_revert("luci_splash")
-
-
- -- For all leases
- for k, v in pairs(leases) do
- if v[".type"] == "lease" then
- if os.difftime(time, tonumber(v.start)) > leasetime then
- -- Remove expired
- remove_rule(v.mac)
- else
- -- Rewrite state
- local n = uci:t_add("luci_splash", "lease")
- uci:t_set("luci_splash", n, "mac", v.mac)
- uci:t_set("luci_splash", n, "start", v.start)
- written[v.mac:lower()] = 1
- end
- end
- end
-
-
- -- Delete rules without state
- for i, r in ipairs(listrules()) do
- if #r > 0 and not written[r:lower()] then
- remove_rule(r)
- end
- end
-
- uci:t_save("luci_splash")
-end
-
-main(arg)
\ No newline at end of file
+++ /dev/null
-#!/usr/bin/haserl --shell=luac
-package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
-package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
-
-require("ffluci.http")
-require("ffluci.sys")
-require("ffluci.model.uci")
-
-local srv
-local net
-local ip = ffluci.http.remote_addr()
-for k, v in pairs(ffluci.model.uci.sections("network")) do
- if v[".type"] == "interface" and v.ipaddr then
- local p = ffluci.sys.net.mask4prefix(v.netmask)
- if ffluci.sys.net.belongs(ip, v.ipaddr, p) then
- net = k
- srv = v.ipaddr
- break
- end
- end
-end
-
-local stat = false
-for k, v in pairs(ffluci.model.uci.sections("luci_splash")) do
- if v[".type"] == "iface" and v.network == net then
- stat = true
- end
-end
-
-if not srv then
- ffluci.http.textheader()
- return print("Unable to detect network settings!")
-end
-
-if not stat then
- ffluci.http.redirect("http://" .. srv)
-end
-
-local action = "splash"
-
-local mac = ffluci.sys.net.ip4mac(ip)
-if not mac then
- action = "unknown"
-end
-
-local status = ffluci.sys.execl("luci-splash status "..mac)[1]
-
-if status == "whitelisted" or status == "lease" then
- action = "allowed"
-end
-
-ffluci.http.redirect("http://" .. srv .. "/cgi-bin/luci-splash/" .. action)
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="refresh" content="0; URL=/cgi-bin/index.cgi" />
-</head>
-<body style="background-color: black">
-<a style="color: white; text-decoration: none" href="/cgi-bin/index.cgi">FFLuCI - Freifunk Lua Configuration Interface</a>
-</body>
-</html>
\ No newline at end of file
+++ /dev/null
-#!/bin/sh
-[ "$(date +%M | cut -c2)" == "5" ] && luci-splash sync
\ No newline at end of file
+++ /dev/null
-#!/bin/sh /etc/rc.common
-START=70
-
-iface_add() {
- local cfg="$1"
-
- config_get net "$cfg" network
- [ -n "$net" ] || return 0
-
- config_get iface "$net" ifname
- [ -n "$iface" ] || return 0
- iface="${iface%%:*}"
-
- config_get ipaddr "$net" ipaddr
- [ -n "$ipaddr" ] || return 0
-
- config_get netmask "$net" netmask
- [ -n "$netmask" ] || return 0
-
- eval "$(ipcalc.sh $ipaddr $netmask)"
-
- iptables -t nat -A luci_splash -i "$iface" -s "$NETWORK/$PREFIX" -j luci_splash_portal
- iptables -t nat -A luci_splash_portal -i "$iface" -s "$NETWORK/$PREFIX" -d "$ipaddr" -p tcp -m multiport --dports 22,80,443 -j RETURN
-}
-
-blacklist_add() {
- local cfg="$1"
-
- config_get mac "$cfg" mac
- [ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j DROP
-}
-
-whitelist_add() {
- local cfg="$1"
-
- config_get mac "$cfg" mac
- [ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j RETURN
-}
-
-start() {
- ### Read chains from config
- include /lib/network
- scan_interfaces
- config_load luci_splash
-
- ### Create subchains
- iptables -t nat -N luci_splash
- iptables -t nat -N luci_splash_portal
- iptables -t nat -N luci_splash_leases
-
- ### Build the main and portal rule
- config_foreach blacklist_add blacklist
- config_foreach whitelist_add whitelist
- config_foreach iface_add iface
-
- ### Build the portal rule
- iptables -t nat -A luci_splash_portal -p udp --dport 53 -j RETURN
- iptables -t nat -A luci_splash_portal -j luci_splash_leases
-
- ### Build the leases rule
- iptables -t nat -A luci_splash_leases -p tcp --dport 80 -j REDIRECT --to-ports 8082
- iptables -t nat -A luci_splash_leases -j DROP
-
- ### Start the splash httpd
- httpd -c /etc/luci_splash_httpd.conf -p 8082 -h /usr/lib/luci-splash/htdocs
-
- ### Hook in the chain
- iptables -t nat -A prerouting_rule -j luci_splash
-}
-
-stop() {
- ### Hook out the chain
- iptables -t nat -D prerouting_rule -j luci_splash
-
- ### Clear subchains
- iptables -t nat -F luci_splash_leases
- iptables -t nat -F luci_splash_portal
- iptables -t nat -F luci_splash
-
- ### Delete subchains
- iptables -t nat -X luci_splash_leases
- iptables -t nat -X luci_splash_portal
- iptables -t nat -X luci_splash
-}
-
+++ /dev/null
-config core general
- option leasetime 1
\ No newline at end of file
+++ /dev/null
-E404:index.html
\ No newline at end of file
+++ /dev/null
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=ffluci-system-addons
-PKG_VERSION:=0.1
-PKG_RELEASE:=1
-
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
-PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/ffluci-system-addons
- SECTION:=admin
- CATEGORY:=Administration
- SUBMENU:=FFLuCI
- TITLE:=FFLuCI System Addons for Kamikaze
-endef
-
-define Build/Compile
-endef
-
-define Package/ffluci-system-addons/install
- $(INSTALL_DIR) $(1)/usr/bin
- $(INSTALL_DIR) $(1)/etc/crontabs
- $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
-
- $(INSTALL_BIN) ./src/run-parts $(1)/usr/bin
- $(CP) ./src/root.crontab $(1)/etc/crontabs/root
- $(CP) ./src/hotplug.d-20-aliases $(1)/etc/hotplug.d/iface/20-aliases
-endef
-
-$(eval $(call BuildPackage,ffluci-system-addons))
+++ /dev/null
-add_aliases() {
- local config="$1"
-
- config_get base "$INTERFACE" ifname
- config_get iface "$config" ifname
- config_get ipaddr "$config" ipaddr
- config_get auto "$config" auto
-
- [ "${iface%%:*}" == "$base" -a "$iface" != "$base" ] && {
- case "$auto" in
- 1|on|enabled) setup_interface "$iface" "$config";;
- *) return 1;;
- esac
- }
-}
-
-
-case "$ACTION" in
- ifup)
- include /lib/network
- scan_interfaces
- config_foreach "add_aliases" interface
- ;;
-esac
+++ /dev/null
-0-59/1 * * * * /usr/bin/run-parts /etc/cron.minutely
-0 * * * * /usr/bin/run-parts /etc/cron.hourly
-0 0 * * * /usr/bin/run-parts /etc/cron.daily
+++ /dev/null
-#!/bin/sh
-set +e
-
-if [ $# -lt 1 ]; then
- echo "Usage: run-parts <dir>"
- exit 1
-fi
-
-if [ ! -d $1 ]; then
- echo "Not a directory: $1"
- exit 1
-fi
-
-for i in $1/*; do
- [ -x $i ] && $i
-done
-
-exit 0
\ No newline at end of file
include $(TOPDIR)/rules.mk
+PKG_BRANCH:=trunk
+PKG_SOURCE_URL:=https://dev.leipzig.freifunk.net/svn/ff-luci/$(PKG_BRANCH)
+PKG_REV:=$(shell LC_ALL=C svn info ${PKG_SOURCE_URL} | sed -ne's/^Last Changed Rev: //p')
+
PKG_NAME:=ffluci
-PKG_REV:=HEAD
-PKG_VERSION:=0.3+svn$(PKG_REV)
+PKG_VERSION:=0.4+svn$(PKG_REV)
PKG_RELEASE:=1
-PKG_BRANCH:=trunk
+PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
PKG_SOURCE_PROTO:=svn
PKG_SOURCE_VERSION:=$(PKG_REV)
-PKG_SOURCE_URL:=https://dev.leipzig.freifunk.net/svn/ff-luci/$(PKG_BRANCH)
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
-PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
+
+PKG_BUILD_DEPENDS:=lua-luci
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
-PKG_BUILD_DEPENDS:=lua-luci
+# LUA_TARGET:=compile LUAC=$(BUILD_DIR_HOST)/lua-luci/luac
+LUA_TARGET:=source
-# MAKE_ACTION:=compile LUAC=$(BUILD_DIR_HOST)/lua-luci/luac
-MAKE_ACTION:=source
include $(INCLUDE_DIR)/package.mk
-define Package/ffluci
+define Build/Configure
+endef
+
+define Build/Compile
+ $(MAKE) -C$(PKG_BUILD_DIR) build LUA_TARGET=$(LUA_TARGET)
+endef
+
+
+define Package/ffluci/template
SECTION:=admin
CATEGORY:=Administration
- TITLE:=FFLuCI
- SUBMENU:=FFLuCI
- DEPENDS:=+luaposix +haserl-lua +ffluci-system-addons
+ TITLE:=FFLuCI - Freifunk Lua Configuration Interface
+ URL:=http://luci.freifunk-halle.net/
MAINTAINER:=Steven Barth <steven-at-midlink-dot-org>
endef
-define Build/Configure
+define Package/ffluci/install/template
+ $(CP) $(PKG_BUILD_DIR)/$(2)/dist/* $(1)/ -R
+
+ for i in $(PKG_BUILD_DIR)/$(2)/dist/usr/bin/*; do $(INSTALL_BIN) $$i $(1)/usr/bin/; done
+ for i in $(PKG_BUILD_DIR)/$(2)/dist/usr/sbin/*; do $(INSTALL_BIN) $$i $(1)/usr/sbin/; done
+ for i in $(PKG_BUILD_DIR)/$(2)/dist/bin/*; do $(INSTALL_BIN) $$i $(1)/bin/; done
+ for i in $(PKG_BUILD_DIR)/$(2)/dist/sbin/*; do $(INSTALL_BIN) $$i $(1)/sbin/; done
endef
-define Build/Compile
- $(MAKE) -C $(PKG_BUILD_DIR)/core $(MAKE_ACTION)
- $(MAKE) -C $(PKG_BUILD_DIR)/module/admin-core $(MAKE_ACTION)
- $(MAKE) -C $(PKG_BUILD_DIR)/module/public-core $(MAKE_ACTION)
- $(MAKE) -C $(PKG_BUILD_DIR)/module/rpc-core $(MAKE_ACTION)
+
+define Package/ffluci
+ $(call Package/ffluci/template)
+ MENU:=1
+ DEPENDS:=+lua-luci +luaposix +luci-addons
+endef
+
+define Package/ffluci/conffiles
+/etc/config/luci
endef
define Package/ffluci/install
- $(INSTALL_DIR) $(1)/usr/lib/lua/ffluci
- $(INSTALL_DIR) $(1)/www/cgi-bin
- $(INSTALL_DIR) $(1)/www/ffluci
- $(INSTALL_DIR) $(1)/etc/config
- $(INSTALL_DIR) $(1)/etc/init.d
- $(INSTALL_DIR) $(1)/sbin
- $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
-
- $(CP) $(PKG_BUILD_DIR)/core/dist/* $(1)/usr/lib/lua/ -R
- $(CP) $(PKG_BUILD_DIR)/core/contrib/uci/* $(1)/etc/config/
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/core/contrib/ffluci $(1)/www/cgi-bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/core/contrib/ffluci-upload $(1)/www/cgi-bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/core/contrib/index.cgi $(1)/www/cgi-bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/core/contrib/index.html $(1)/www
-
- $(CP) $(PKG_BUILD_DIR)/themes/fledermaus/contrib/media $(1)/www/ffluci/ -R
-
- $(CP) $(PKG_BUILD_DIR)/module/admin-core/dist/* $(1)/usr/lib/lua/ffluci/ -R
- $(CP) $(PKG_BUILD_DIR)/module/admin-core/contrib/uci/luci_fw $(1)/etc/config/luci_fw
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/module/admin-core/contrib/init.d/luci_fw $(1)/etc/init.d/luci_fw
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/module/admin-core/contrib/init.d/luci_freifunk $(1)/etc/init.d/luci_freifunk
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/module/admin-core/contrib/ffluci-flash $(1)/sbin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/module/admin-core/contrib/luci-splash $(1)/www/cgi-bin
-
- $(CP) $(PKG_BUILD_DIR)/module/public-core/dist/* $(1)/usr/lib/lua/ffluci/ -R
- $(CP) $(PKG_BUILD_DIR)/module/public-core/contrib/media $(1)/www/ffluci/ -R
-
- $(CP) $(PKG_BUILD_DIR)/module/rpc-core/dist/* $(1)/usr/lib/lua/ffluci/ -R
-
- $(CP) -a ./ipkg/ffluci.postinst $(1)/CONTROL/postinst
- $(CP) -a ./ipkg/conffiles $(1)/CONTROL/conffiles
- rm $(DL_DIR)/$(PKG_SOURCE)
-endef
-
-$(eval $(call BuildPackage,ffluci))
\ No newline at end of file
+ $(call Package/ffluci/install/template,$(1),core)
+ $(call Package/ffluci/install/template,$(1),themes/fledermaus)
+endef
+
+
+
+### Meta Packages ###
+
+define Package/ffluci-freifunk-meta
+ $(call Package/ffluci/template)
+ DEPENDS:=+ffluci +ffluci-sgi-haserl +ffluci-freifunk +ffluci-firewall +ffluci-splash
+ TITLE:=Freifunk Meta-Package
+endef
+
+define Package/ffluci-meta/install
+endef
+
+
+define Package/ffluci-freifunk-halle
+ $(call Package/ffluci/template)
+ DEPENDS:=+ffluci-freifunk-meta +kmod-tun
+ TITLE:=Community Meta-Package Halle
+endef
+
+define Package/ffluci-freifunk-halle/install
+endef
+
+
+define Package/ffluci-freifunk-leipzig
+ $(call Package/ffluci/template)
+ DEPENDS:=+ffluci-freifunk-meta +kmod-tun
+ TITLE:=Community Meta-Package Leipzig
+endef
+
+define Package/ffluci-freifunk-leipzig/install
+ $(call Package/ffluci/install/template,$(1),applications/community-leipzig)
+endef
+
+
+
+### Modules ###
+
+define Package/ffluci-module-admin-core
+ $(call Package/ffluci/template)
+ DEPENDS:=+ffluci
+ TITLE:=Core Administrative pages for FFLuCI
+endef
+
+define Package/ffluci-module-admin-core/install
+ $(call Package/ffluci/install/template,$(1),modules/admin-core)
+endef
+
+
+define Package/ffluci-module-freifunk
+ $(call Package/ffluci/template)
+ DEPENDS:=+ffluci +ffluci-module-admin-core
+ TITLE:=Freifunk public and configuration pages
+endef
+
+define Package/ffluci-module-freifunk/conffiles
+/etc/config/freifunk
+endef
+
+define Package/ffluci-module-freifunk/install
+ $(call Package/ffluci/install/template,$(1),modules/freifunk)
+endef
+
+
+
+### Applications ###
+
+define Package/ffluci-firewall
+ $(call Package/ffluci/template)
+ DEPENDS:=+ffluci +ffluci-module-admin-core
+ TITLE:=Firewall and Portforwarding module
+endef
+
+define Package/ffluci-firewall/conffiles
+/etc/config/luci_fw
+endef
+
+define Package/ffluci-firewall/install
+ $(call Package/ffluci/install/template,$(1),applications/luci-fw)
+endef
+
+
+define Package/ffluci-splash
+ $(call Package/ffluci/template)
+ DEPENDS:=+ffluci +ffluci-freifunk +ffluci-sgi-haserl +iptables-mod-nat
+ TITLE:=Freifunk DHCP-Splash
+endef
+
+define Package/ffluci-splash/conffiles
+/etc/config/luci_splash
+endef
+
+define Package/ffluci-splash/install
+ $(call Package/ffluci/install/template,$(1),applications/luci-splash)
+endef
+
+
+
+### Server Gateway Interfaces ###
+
+define Package/ffluci-sgi-haserl
+ $(call Package/ffluci/template)
+ DEPENDS:=+ffluci +haserl-lua
+ TITLE:=SGI for Haserl on top of Busybox httpd
+endef
+
+define Package/ffluci-sgi-haserl/install
+ $(call Package/ffluci/install/template,$(1),applications/sgi-haserl)
+endef
+
+
+define Package/ffluci-sgi-webuci
+ $(call Package/ffluci/template)
+ DEPENDS:=+ffluci
+ TITLE:=SGI for Webuci
+endef
+
+define Package/ffluci-sgi-webuci/install
+ $(call Package/ffluci/install/template,$(1),applications/sgi-webuci)
+endef
+
+
+
+
+$(eval $(call BuildPackage,ffluci))
+
+$(eval $(call BuildPackage,ffluci-freifunk-meta))
+$(eval $(call BuildPackage,ffluci-freifunk-halle))
+$(eval $(call BuildPackage,ffluci-freifunk-leipzig))
+
+$(eval $(call BuildPackage,ffluci-module-admin-core))
+$(eval $(call BuildPackage,ffluci-module-freifunk))
+
+$(eval $(call BuildPackage,ffluci-firewall))
+$(eval $(call BuildPackage,ffluci-splash))
+
+$(eval $(call BuildPackage,ffluci-sgi-haserl))
+$(eval $(call BuildPackage,ffluci-sgi-webuci))
\ No newline at end of file
+++ /dev/null
-/etc/config/luci
-/etc/config/luci_fw
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+[ -n "${IPKG_INSTROOT}" ] || {
+ ( . /etc/uci-defaults/ffluci-community-leipzig ) && rm -f /etc/uci-defaults/ffluci-community-leipzig
+}
--- /dev/null
+#!/bin/sh
+PATTERNS='/cgi-bin/ffluci/admin:root:$p$root /cgi-bin/ffluci-upload:root:$p$root'
+
+for i in $PATTERNS
+do
+ grep "$i" ${IPKG_INSTROOT}/etc/httpd.conf >/dev/null 2>/dev/null || echo "$i" >> ${IPKG_INSTROOT}/etc/httpd.conf
+done
+
+[ -n ${IPKG_INSTROOT} ] || /etc/init.d/httpd restart
+++ /dev/null
-#!/bin/sh
-PATTERNS='/cgi-bin/ffluci/admin:root:$p$root /cgi-bin/ffluci-upload:root:$p$root'
-
-for i in $PATTERNS
-do
- grep "$i" ${IPKG_INSTROOT}/etc/httpd.conf >/dev/null 2>/dev/null || echo "$i" >> ${IPKG_INSTROOT}/etc/httpd.conf
-done
-
-[ -n ${IPKG_INSTROOT} ] || /etc/init.d/httpd restart
--- /dev/null
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=luci-addons
+PKG_VERSION:=0.2
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
+
+include $(INCLUDE_DIR)/package.mk
+
+
+define Build/Compile
+endef
+
+
+define Package/luci-addons
+ SECTION:=utils
+ CATEGORY:=Utilities
+ TITLE:=FFLuCI System Addons for Kamikaze
+ URL:=http://luci.freifunk-halle.net
+endef
+
+define Package/luci-addons/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_DIR) $(1)/etc/crontabs
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+
+ $(INSTALL_BIN) ./dist/usr/bin/run-parts $(1)/usr/bin
+ $(INSTALL_BIN) ./dist/sbin/ffluci-flash $(1)/sbin
+
+ $(CP) ./dist/etc/crontabs/root $(1)/etc/crontabs/root
+ $(CP) ./dist/etc/hotplug.d/iface/20-aliases $(1)/etc/hotplug.d/iface/20-aliases
+endef
+
+$(eval $(call BuildPackage,luci-addons))
\ No newline at end of file
--- /dev/null
+0-59/1 * * * * /usr/bin/run-parts /etc/cron.minutely
+0 * * * * /usr/bin/run-parts /etc/cron.hourly
+0 0 * * * /usr/bin/run-parts /etc/cron.daily
--- /dev/null
+add_aliases() {
+ local config="$1"
+
+ config_get base "$INTERFACE" ifname
+ config_get iface "$config" ifname
+ config_get ipaddr "$config" ipaddr
+ config_get auto "$config" auto
+
+ [ "${iface%%:*}" == "$base" -a "$iface" != "$base" ] && {
+ case "$auto" in
+ 1|on|enabled) setup_interface "$iface" "$config";;
+ *) return 1;;
+ esac
+ }
+}
+
+
+case "$ACTION" in
+ ifup)
+ include /lib/network
+ scan_interfaces
+ config_foreach "add_aliases" interface
+ ;;
+esac
--- /dev/null
+#!/bin/sh
+. /etc/functions.sh
+
+# initialize defaults
+RAMFS_COPY_BIN="" # extra programs for temporary ramfs root
+RAMFS_COPY_DATA="" # extra data files
+export KEEP_PATTERN=""
+export VERBOSE=1
+
+# parse options
+while [ -n "$1" ]; do
+ case "$1" in
+ -k)
+ shift
+ export KEEP_PATTERN="$1"
+ ;;
+ -*)
+ echo "Invalid option: $1"
+ exit 1
+ ;;
+ *) break;;
+ esac
+ shift;
+done
+
+export CONFFILES=/tmp/sysupgrade.conffiles
+export CONF_TAR=/tmp/sysupgrade.tgz
+
+[ -f $CONFFILES ] && rm $CONFFILES
+[ -f $CONF_TAR ] && rm $CONF_TAR
+
+export ARGV="$*"
+export ARGC="$#"
+
+[ -z "$ARGV" ] && {
+ cat <<EOF
+Usage: $0 [options] <image file or URL>
+
+Options:
+ -k <"file 1, file 2, ..."> Files to be kept
+EOF
+ exit 1
+}
+
+add_pattern_conffiles() {
+ local file="$1"
+ find $KEEP_PATTERN >> "$file" 2>/dev/null
+ return 0
+}
+
+# hooks
+sysupgrade_image_check="platform_check_image"
+sysupgrade_init_conffiles=""
+
+[ -n "$KEEP_PATTERN" ] && append sysupgrade_init_conffiles "add_pattern_conffiles"
+
+include /lib/upgrade
+
+do_save_conffiles() {
+ [ -z "$(rootfs_type)" ] && {
+ echo "Cannot save config while running from ramdisk."
+ exit 3
+ return 0
+ }
+ run_hooks "$CONFFILES" $sysupgrade_init_conffiles
+
+ v "Saving config files..."
+ [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
+ tar c${TAR_V}zf "$CONF_TAR" -T "$CONFFILES" 2>/dev/null
+}
+
+type platform_check_image >/dev/null 2>/dev/null || {
+ echo "Firmware upgrade is not implemented for this platform."
+ exit 1
+}
+
+for check in $sysupgrade_image_check; do
+ ( eval "$check \"\$ARGV\"" ) || {
+ echo "Image check '$check' failed."
+ exit 2
+ }
+done
+
+[ -n "$sysupgrade_init_conffiles" ] && do_save_conffiles
+run_hooks "" $sysupgrade_pre_upgrade
+
+v "Switching to ramdisk..."
+run_ramfs '. /etc/functions.sh; include /lib/upgrade; do_upgrade'
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+set +e
+
+if [ $# -lt 1 ]; then
+ echo "Usage: run-parts <dir>"
+ exit 1
+fi
+
+if [ ! -d $1 ]; then
+ echo "Not a directory: $1"
+ exit 1
+fi
+
+for i in $1/*; do
+ [ -x $i ] && $i
+done
+
+exit 0
\ No newline at end of file
-LUAC = luac
-LUAC_OPTIONS = -s
-
-FILES = ffluci/debug.lua ffluci/view/*.htm ffluci/view/cbi/*.htm ffluci/i18n/*
-
-CFILES = ffluci/bits.lua ffluci/util.lua \
-ffluci/sgi/haserl.lua ffluci/sgi/webuci.lua \
-ffluci/http.lua ffluci/fs.lua ffluci/sys.lua \
-ffluci/model/uci/wrapper.lua ffluci/model/uci/libuci.lua ffluci/model/uci.lua \
-ffluci/model/ipkg.lua ffluci/config.lua ffluci/i18n.lua ffluci/template.lua \
-ffluci/cbi.lua ffluci/dispatcher.lua ffluci/menu.lua ffluci/init.lua
-
-DIRECTORIES = ffluci/model/cbi ffluci/model/menu ffluci/controller ffluci/i18n ffluci/view/cbi ffluci/model/uci ffluci/sgi
-
-OUTDIRS = $(DIRECTORIES:%=dist/%)
-INFILES = $(CFILES:%=src/%)
-OUTFILE = ffluci/init.lua
-CPFILES = $(FILES:%=src/%)
-
-.PHONY: all compile source depends clean
-
-all: compile
-
-depends:
- mkdir -p $(OUTDIRS)
- for i in $(CPFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
- mkdir -p dist/$$(dirname $$i); cp src/$$i dist/$$i; fi; done
-
-compile: depends
- $(LUAC) $(LUAC_OPTIONS) -o dist/$(OUTFILE) $(INFILES)
- for i in $(CFILES); do [ -f dist/$$i ] || ln -s `dirname $$i | cut -s -d / -f 2- | sed -e 's/[^/]*\/*/..\//g'``basename $(OUTFILE)` dist/$$i; done
-
-
-source: depends
- for i in $(CFILES); do cp src/$$i dist/$$i; done
-
-
-clean:
- rm dist -rf
+include ../build/config.mk
+include ../build/module.mk
\ No newline at end of file
+++ /dev/null
-#!/usr/bin/haserl --shell=luac
-package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
-package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
-require("ffluci.dispatcher").httpdispatch()
\ No newline at end of file
+++ /dev/null
-#!/usr/bin/haserl --shell=luac --upload-limit=6144
--- This is a bit hacky: remove -upload from SCRIPT_NAME
-ENV.SCRIPT_NAME = ENV.SCRIPT_NAME:sub(1, #ENV.SCRIPT_NAME - 7)
-dofile("ffluci")
\ No newline at end of file
+++ /dev/null
-#!/usr/bin/haserl --shell=luac
-print("Status: 302 Found")
-print("Location: ffluci\n")
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="refresh" content="0; URL=/cgi-bin/index.cgi" />
-</head>
-<body style="background-color: black">
-<a style="color: white; text-decoration: none" href="/cgi-bin/index.cgi">FFLuCI - Freifunk Lua Configuration Interface</a>
-</body>
-</html>
\ No newline at end of file
+++ /dev/null
-config public contact
- option nickname
- option name
- option mail
- option phone
- option location
- option geo
- option note
-
-config public community
- option name "Freifunk Halle"
- option homepage http://halle.freifunk.net
- option essid halle.freifunk.net
- option bssid 02:CA:FF:EE:BA:BE
- option realm netz.freifunk-halle.net
- option channel 1
- option net 104.0.0.0
- option mask 255.0.0.0
- option dhcp 10.0.0.0
- option dhcpmask 255.255.255.0
- option dns "88.198.178.18 141.54.1.1 212.204.49.83 208.67.220.220 208.67.222.222"
-
-config settings routing
- option internal 0
- option internet 0
-
\ No newline at end of file
+++ /dev/null
-config core main
- option lang de
- option mediaurlbase /ffluci/media
-
-config core category_privileges
- option public nobody:nogroup
-
-config extern flash_keep
- option uci "/etc/config"
- option dropbear "/etc/dropbear"
- option openvpn "/etc/openvpn"
- option passwd "/etc/passwd"
- option ipkg "/etc/ipkg.conf"
- option httpd "/etc/httpd.conf"
- option firewall "/etc/firewall.user"
-
-config event uci_oncommit
- option network "/etc/init.d/network restart"
- option wireless "/etc/init.d/network restart"
- option olsr "/sbin/reboot"
- option dhcp "/etc/init.d/dnsmasq restart"
- option luci_fw "/etc/init.d/luci_fw restart"
- option dropbear "/etc/init.d/dropbear restart"
- option httpd "/etc/init.d/httpd restart"
- option fstab "/etc/init.d/fstab restart"
- option qos "/etc/init.d/qos restart"
- option luci_splash "/etc/init.d/luci_splash restart"
- option freifunk "/etc/init.d/luci_freifunk restart"
-
-config internal languages
- option de "Deutsch"
- option en "English"
-
-config internal themes
- option Fledermaus "/ffluci/media"
\ No newline at end of file
+++ /dev/null
-package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
-package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
-module("webuci", package.seeall)
-
-function prepare_req(uri)
- env = {}
- env.REQUEST_URI = uri
- require("ffluci.menu").get()
-end
-
-function init_req(context)
- env.SERVER_PROTOCOL = context.server_proto
- env.REMOTE_ADDR = context.remote_addr
- env.REQUEST_METHOD = context.request_method
- env.PATH_INFO = "/" .. context.uri
- env.REMOTE_PORT = context.remote_port
- env.SERVER_ADDR = context.server_addr
- env.SCRIPT_NAME = env.REQUEST_URI:sub(1, #env.REQUEST_URI - #env.PATH_INFO)
-end
-
-function handle_req(context)
- require("ffluci.dispatcher").httpdispatch()
-end
\ No newline at end of file
--- /dev/null
+config core main
+ option lang de
+ option mediaurlbase /ffluci/media
+
+config core category_privileges
+ option public nobody:nogroup
+
+config extern flash_keep
+ option uci "/etc/config"
+ option dropbear "/etc/dropbear"
+ option openvpn "/etc/openvpn"
+ option passwd "/etc/passwd"
+ option ipkg "/etc/ipkg.conf"
+ option httpd "/etc/httpd.conf"
+ option firewall "/etc/firewall.user"
+
+config event uci_oncommit
+ option network "/etc/init.d/network restart"
+ option wireless "/etc/init.d/network restart"
+ option olsr "/sbin/reboot"
+ option dhcp "/etc/init.d/dnsmasq restart"
+ option luci_fw "/etc/init.d/luci_fw restart"
+ option dropbear "/etc/init.d/dropbear restart"
+ option httpd "/etc/init.d/httpd restart"
+ option fstab "/etc/init.d/fstab restart"
+ option qos "/etc/init.d/qos restart"
+ option luci_splash "/etc/init.d/luci_splash restart"
+ option freifunk "/etc/init.d/luci_freifunk restart"
+
+config internal languages
+ option de "Deutsch"
+ option en "English"
+
+config internal themes
+ option Fledermaus "/ffluci/media"
\ No newline at end of file
--- /dev/null
+--[[
+/*
+ * Copyright (c) 2007 Tim Kelly/Dialectronics
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do so, subject to the
+ * following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+--]]
+
+--[[
+/*
+ * Copyright (c) 2007 Tim Kelly/Dialectronics
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to permit
+ * persons to whom the Software is furnished to do so, subject to the
+ * following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+--]]
+
+module("ffluci.bits", package.seeall);
+
+local hex2bin = {
+ ["0"] = "0000",
+ ["1"] = "0001",
+ ["2"] = "0010",
+ ["3"] = "0011",
+ ["4"] = "0100",
+ ["5"] = "0101",
+ ["6"] = "0110",
+ ["7"] = "0111",
+ ["8"] = "1000",
+ ["9"] = "1001",
+ ["a"] = "1010",
+ ["b"] = "1011",
+ ["c"] = "1100",
+ ["d"] = "1101",
+ ["e"] = "1110",
+ ["f"] = "1111"
+ }
+
+
+
+local bin2hex = {
+ ["0000"] = "0",
+ ["0001"] = "1",
+ ["0010"] = "2",
+ ["0011"] = "3",
+ ["0100"] = "4",
+ ["0101"] = "5",
+ ["0110"] = "6",
+ ["0111"] = "7",
+ ["1000"] = "8",
+ ["1001"] = "9",
+ ["1010"] = "A",
+ ["1011"] = "B",
+ ["1100"] = "C",
+ ["1101"] = "D",
+ ["1110"] = "E",
+ ["1111"] = "F"
+ }
+
+--[[
+local dec2hex = {
+ ["0"] = "0",
+ ["1"] = "1",
+ ["2"] = "2",
+ ["3"] = "3",
+ ["4"] = "4",
+ ["5"] = "5",
+ ["6"] = "6",
+ ["7"] = "7",
+ ["8"] = "8",
+ ["9"] = "9",
+ ["10"] = "A",
+ ["11"] = "B",
+ ["12"] = "C",
+ ["13"] = "D",
+ ["14"] = "E",
+ ["15"] = "F"
+ }
+--]]
+
+
+-- These functions are big-endian and take up to 32 bits
+
+-- Hex2Bin
+-- Bin2Hex
+-- Hex2Dec
+-- Dec2Hex
+-- Bin2Dec
+-- Dec2Bin
+
+
+function Hex2Bin(s)
+
+-- s -> hexadecimal string
+
+local ret = ""
+local i = 0
+
+
+ for i in string.gfind(s, ".") do
+ i = string.lower(i)
+
+ ret = ret..hex2bin[i]
+
+ end
+
+ return ret
+end
+
+
+function Bin2Hex(s)
+
+-- s -> binary string
+
+local l = 0
+local h = ""
+local b = ""
+local rem
+
+l = string.len(s)
+rem = l % 4
+l = l-1
+h = ""
+
+ -- need to prepend zeros to eliminate mod 4
+ if (rem > 0) then
+ s = string.rep("0", 4 - rem)..s
+ end
+
+ for i = 1, l, 4 do
+ b = string.sub(s, i, i+3)
+ h = h..bin2hex[b]
+ end
+
+ return h
+
+end
+
+
+function Bin2Dec(s)
+
+-- s -> binary string
+
+local num = 0
+local ex = string.len(s) - 1
+local l = 0
+
+ l = ex + 1
+ for i = 1, l do
+ b = string.sub(s, i, i)
+ if b == "1" then
+ num = num + 2^ex
+ end
+ ex = ex - 1
+ end
+
+ return string.format("%u", num)
+
+end
+
+
+
+function Dec2Bin(s, num)
+
+-- s -> Base10 string
+-- num -> string length to extend to
+
+local n
+
+ if (num == nil) then
+ n = 0
+ else
+ n = num
+ end
+
+ s = string.format("%x", s)
+
+ s = Hex2Bin(s)
+
+ while string.len(s) < n do
+ s = "0"..s
+ end
+
+ return s
+
+end
+
+
+
+
+function Hex2Dec(s)
+
+-- s -> hexadecimal string
+
+local s = Hex2Bin(s)
+
+ return Bin2Dec(s)
+
+end
+
+
+
+function Dec2Hex(s)
+
+-- s -> Base10 string
+
+ s = string.format("%x", s)
+
+ return s
+
+end
+
+
+
+
+-- These functions are big-endian and will extend to 32 bits
+
+-- BMAnd
+-- BMNAnd
+-- BMOr
+-- BMXOr
+-- BMNot
+
+
+function BMAnd(v, m)
+
+-- v -> hex string to be masked
+-- m -> hex string mask
+
+-- s -> hex string as masked
+
+-- bv -> binary string of v
+-- bm -> binary string mask
+
+local bv = Hex2Bin(v)
+local bm = Hex2Bin(m)
+
+local i = 0
+local s = ""
+
+ while (string.len(bv) < 32) do
+ bv = "0000"..bv
+ end
+
+ while (string.len(bm) < 32) do
+ bm = "0000"..bm
+ end
+
+
+ for i = 1, 32 do
+ cv = string.sub(bv, i, i)
+ cm = string.sub(bm, i, i)
+ if cv == cm then
+ if cv == "1" then
+ s = s.."1"
+ else
+ s = s.."0"
+ end
+ else
+ s = s.."0"
+
+ end
+ end
+
+ return Bin2Hex(s)
+
+end
+
+
+function BMNAnd(v, m)
+
+-- v -> hex string to be masked
+-- m -> hex string mask
+
+-- s -> hex string as masked
+
+-- bv -> binary string of v
+-- bm -> binary string mask
+
+local bv = Hex2Bin(v)
+local bm = Hex2Bin(m)
+
+local i = 0
+local s = ""
+
+ while (string.len(bv) < 32) do
+ bv = "0000"..bv
+ end
+
+ while (string.len(bm) < 32) do
+ bm = "0000"..bm
+ end
+
+
+ for i = 1, 32 do
+ cv = string.sub(bv, i, i)
+ cm = string.sub(bm, i, i)
+ if cv == cm then
+ if cv == "1" then
+ s = s.."0"
+ else
+ s = s.."1"
+ end
+ else
+ s = s.."1"
+
+ end
+ end
+
+ return Bin2Hex(s)
+
+end
+
+
+
+function BMOr(v, m)
+
+-- v -> hex string to be masked
+-- m -> hex string mask
+
+-- s -> hex string as masked
+
+-- bv -> binary string of v
+-- bm -> binary string mask
+
+local bv = Hex2Bin(v)
+local bm = Hex2Bin(m)
+
+local i = 0
+local s = ""
+
+ while (string.len(bv) < 32) do
+ bv = "0000"..bv
+ end
+
+ while (string.len(bm) < 32) do
+ bm = "0000"..bm
+ end
+
+
+ for i = 1, 32 do
+ cv = string.sub(bv, i, i)
+ cm = string.sub(bm, i, i)
+ if cv == "1" then
+ s = s.."1"
+ elseif cm == "1" then
+ s = s.."1"
+ else
+ s = s.."0"
+ end
+ end
+
+ return Bin2Hex(s)
+
+end
+
+function BMXOr(v, m)
+
+-- v -> hex string to be masked
+-- m -> hex string mask
+
+-- s -> hex string as masked
+
+-- bv -> binary string of v
+-- bm -> binary string mask
+
+local bv = Hex2Bin(v)
+local bm = Hex2Bin(m)
+
+local i = 0
+local s = ""
+
+ while (string.len(bv) < 32) do
+ bv = "0000"..bv
+ end
+
+ while (string.len(bm) < 32) do
+ bm = "0000"..bm
+ end
+
+
+ for i = 1, 32 do
+ cv = string.sub(bv, i, i)
+ cm = string.sub(bm, i, i)
+ if cv == "1" then
+ if cm == "0" then
+ s = s.."1"
+ else
+ s = s.."0"
+ end
+ elseif cm == "1" then
+ if cv == "0" then
+ s = s.."1"
+ else
+ s = s.."0"
+ end
+ else
+ -- cv and cm == "0"
+ s = s.."0"
+ end
+ end
+
+ return Bin2Hex(s)
+
+end
+
+
+function BMNot(v, m)
+
+-- v -> hex string to be masked
+-- m -> hex string mask
+
+-- s -> hex string as masked
+
+-- bv -> binary string of v
+-- bm -> binary string mask
+
+local bv = Hex2Bin(v)
+local bm = Hex2Bin(m)
+
+local i = 0
+local s = ""
+
+ while (string.len(bv) < 32) do
+ bv = "0000"..bv
+ end
+
+ while (string.len(bm) < 32) do
+ bm = "0000"..bm
+ end
+
+
+ for i = 1, 32 do
+ cv = string.sub(bv, i, i)
+ cm = string.sub(bm, i, i)
+ if cm == "1" then
+ if cv == "1" then
+ -- turn off
+ s = s.."0"
+ else
+ -- turn on
+ s = s.."1"
+ end
+ else
+ -- leave untouched
+ s = s..cv
+
+ end
+ end
+
+ return Bin2Hex(s)
+
+end
+
+
+-- these functions shift right and left, adding zeros to lost or gained bits
+-- returned values are 32 bits long
+
+-- BShRight(v, nb)
+-- BShLeft(v, nb)
+
+
+function BShRight(v, nb)
+
+-- v -> hexstring value to be shifted
+-- nb -> number of bits to shift to the right
+
+-- s -> binary string of v
+
+local s = Hex2Bin(v)
+
+ while (string.len(s) < 32) do
+ s = "0000"..s
+ end
+
+ s = string.sub(s, 1, 32 - nb)
+
+ while (string.len(s) < 32) do
+ s = "0"..s
+ end
+
+ return Bin2Hex(s)
+
+end
+
+function BShLeft(v, nb)
+
+-- v -> hexstring value to be shifted
+-- nb -> number of bits to shift to the right
+
+-- s -> binary string of v
+
+local s = Hex2Bin(v)
+
+ while (string.len(s) < 32) do
+ s = "0000"..s
+ end
+
+ s = string.sub(s, nb + 1, 32)
+
+ while (string.len(s) < 32) do
+ s = s.."0"
+ end
+
+ return Bin2Hex(s)
+
+end
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - Configuration Bind Interface
+
+Description:
+Offers an interface for binding confiugration values to certain
+data types. Supports value and range validation and basic dependencies.
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+module("ffluci.cbi", package.seeall)
+
+require("ffluci.template")
+require("ffluci.util")
+require("ffluci.http")
+require("ffluci.model.uci")
+
+local class = ffluci.util.class
+local instanceof = ffluci.util.instanceof
+
+-- Loads a CBI map from given file, creating an environment and returns it
+function load(cbimap)
+ require("ffluci.fs")
+ require("ffluci.i18n")
+ require("ffluci.config")
+ require("ffluci.sys")
+
+ local cbidir = ffluci.sys.libpath() .. "/model/cbi/"
+ local func, err = loadfile(cbidir..cbimap..".lua")
+
+ if not func then
+ return nil
+ end
+
+ ffluci.i18n.loadc("cbi")
+
+ ffluci.util.resfenv(func)
+ ffluci.util.updfenv(func, ffluci.cbi)
+ ffluci.util.extfenv(func, "translate", ffluci.i18n.translate)
+
+ local map = func()
+
+ if not instanceof(map, Map) then
+ error("CBI map returns no valid map object!")
+ return nil
+ end
+
+ return map
+end
+
+-- Node pseudo abstract class
+Node = class()
+
+function Node.__init__(self, title, description)
+ self.children = {}
+ self.title = title or ""
+ self.description = description or ""
+ self.template = "cbi/node"
+end
+
+-- Append child nodes
+function Node.append(self, obj)
+ table.insert(self.children, obj)
+end
+
+-- Parse this node and its children
+function Node.parse(self, ...)
+ for k, child in ipairs(self.children) do
+ child:parse(...)
+ end
+end
+
+-- Render this node
+function Node.render(self)
+ ffluci.template.render(self.template, {self=self})
+end
+
+-- Render the children
+function Node.render_children(self, ...)
+ for k, node in ipairs(self.children) do
+ node:render(...)
+ end
+end
+
+
+--[[
+A simple template element
+]]--
+Template = class(Node)
+
+function Template.__init__(self, template)
+ Node.__init__(self)
+ self.template = template
+end
+
+
+--[[
+Map - A map describing a configuration file
+]]--
+Map = class(Node)
+
+function Map.__init__(self, config, ...)
+ Node.__init__(self, ...)
+ self.config = config
+ self.template = "cbi/map"
+ self.uci = ffluci.model.uci.Session()
+ self.ucidata, self.uciorder = self.uci:sections(self.config)
+ if not self.ucidata or not self.uciorder then
+ error("Unable to read UCI data: " .. self.config)
+ end
+end
+
+-- Use optimized UCI writing
+function Map.parse(self, ...)
+ self.uci:t_load(self.config)
+ Node.parse(self, ...)
+ self.uci:t_save(self.config)
+end
+
+-- Creates a child section
+function Map.section(self, class, ...)
+ if instanceof(class, AbstractSection) then
+ local obj = class(self, ...)
+ self:append(obj)
+ return obj
+ else
+ error("class must be a descendent of AbstractSection")
+ end
+end
+
+-- UCI add
+function Map.add(self, sectiontype)
+ local name = self.uci:t_add(self.config, sectiontype)
+ if name then
+ self.ucidata[name] = {}
+ self.ucidata[name][".type"] = sectiontype
+ table.insert(self.uciorder, name)
+ end
+ return name
+end
+
+-- UCI set
+function Map.set(self, section, option, value)
+ local stat = self.uci:t_set(self.config, section, option, value)
+ if stat then
+ local val = self.uci:t_get(self.config, section, option)
+ if option then
+ self.ucidata[section][option] = val
+ else
+ if not self.ucidata[section] then
+ self.ucidata[section] = {}
+ end
+ self.ucidata[section][".type"] = val
+ table.insert(self.uciorder, section)
+ end
+ end
+ return stat
+end
+
+-- UCI del
+function Map.del(self, section, option)
+ local stat = self.uci:t_del(self.config, section, option)
+ if stat then
+ if option then
+ self.ucidata[section][option] = nil
+ else
+ self.ucidata[section] = nil
+ for i, k in ipairs(self.uciorder) do
+ if section == k then
+ table.remove(self.uciorder, i)
+ end
+ end
+ end
+ end
+ return stat
+end
+
+-- UCI get (cached)
+function Map.get(self, section, option)
+ if not section then
+ return self.ucidata, self.uciorder
+ elseif option and self.ucidata[section] then
+ return self.ucidata[section][option]
+ else
+ return self.ucidata[section]
+ end
+end
+
+
+--[[
+AbstractSection
+]]--
+AbstractSection = class(Node)
+
+function AbstractSection.__init__(self, map, sectiontype, ...)
+ Node.__init__(self, ...)
+ self.sectiontype = sectiontype
+ self.map = map
+ self.config = map.config
+ self.optionals = {}
+
+ self.optional = true
+ self.addremove = false
+ self.dynamic = false
+end
+
+-- Appends a new option
+function AbstractSection.option(self, class, ...)
+ if instanceof(class, AbstractValue) then
+ local obj = class(self.map, ...)
+ self:append(obj)
+ return obj
+ else
+ error("class must be a descendent of AbstractValue")
+ end
+end
+
+-- Parse optional options
+function AbstractSection.parse_optionals(self, section)
+ if not self.optional then
+ return
+ end
+
+ self.optionals[section] = {}
+
+ local field = ffluci.http.formvalue("cbi.opt."..self.config.."."..section)
+ for k,v in ipairs(self.children) do
+ if v.optional and not v:cfgvalue(section) then
+ if field == v.option then
+ field = nil
+ else
+ table.insert(self.optionals[section], v)
+ end
+ end
+ end
+
+ if field and #field > 0 and self.dynamic then
+ self:add_dynamic(field)
+ end
+end
+
+-- Add a dynamic option
+function AbstractSection.add_dynamic(self, field, optional)
+ local o = self:option(Value, field, field)
+ o.optional = optional
+end
+
+-- Parse all dynamic options
+function AbstractSection.parse_dynamic(self, section)
+ if not self.dynamic then
+ return
+ end
+
+ local arr = ffluci.util.clone(self:cfgvalue(section))
+ local form = ffluci.http.formvaluetable("cbid."..self.config.."."..section)
+ for k, v in pairs(form) do
+ arr[k] = v
+ end
+
+ for key,val in pairs(arr) do
+ local create = true
+
+ for i,c in ipairs(self.children) do
+ if c.option == key then
+ create = false
+ end
+ end
+
+ if create and key:sub(1, 1) ~= "." then
+ self:add_dynamic(key, true)
+ end
+ end
+end
+
+-- Returns the section's UCI table
+function AbstractSection.cfgvalue(self, section)
+ return self.map:get(section)
+end
+
+-- Removes the section
+function AbstractSection.remove(self, section)
+ return self.map:del(section)
+end
+
+-- Creates the section
+function AbstractSection.create(self, section)
+ return self.map:set(section, nil, self.sectiontype)
+end
+
+
+
+--[[
+NamedSection - A fixed configuration section defined by its name
+]]--
+NamedSection = class(AbstractSection)
+
+function NamedSection.__init__(self, map, section, ...)
+ AbstractSection.__init__(self, map, ...)
+ self.template = "cbi/nsection"
+
+ self.section = section
+ self.addremove = false
+end
+
+function NamedSection.parse(self)
+ local s = self.section
+ local active = self:cfgvalue(s)
+
+
+ if self.addremove then
+ local path = self.config.."."..s
+ if active then -- Remove the section
+ if ffluci.http.formvalue("cbi.rns."..path) and self:remove(s) then
+ return
+ end
+ else -- Create and apply default values
+ if ffluci.http.formvalue("cbi.cns."..path) and self:create(s) then
+ for k,v in pairs(self.children) do
+ v:write(s, v.default)
+ end
+ end
+ end
+ end
+
+ if active then
+ AbstractSection.parse_dynamic(self, s)
+ if ffluci.http.formvalue("cbi.submit") then
+ Node.parse(self, s)
+ end
+ AbstractSection.parse_optionals(self, s)
+ end
+end
+
+
+--[[
+TypedSection - A (set of) configuration section(s) defined by the type
+ addremove: Defines whether the user can add/remove sections of this type
+ anonymous: Allow creating anonymous sections
+ validate: a validation function returning nil if the section is invalid
+]]--
+TypedSection = class(AbstractSection)
+
+function TypedSection.__init__(self, ...)
+ AbstractSection.__init__(self, ...)
+ self.template = "cbi/tsection"
+ self.deps = {}
+ self.excludes = {}
+
+ self.anonymous = false
+end
+
+-- Return all matching UCI sections for this TypedSection
+function TypedSection.cfgsections(self)
+ local sections = {}
+ local map, order = self.map:get()
+
+ for i, k in ipairs(order) do
+ if map[k][".type"] == self.sectiontype then
+ if self:checkscope(k) then
+ table.insert(sections, k)
+ end
+ end
+ end
+
+ return sections
+end
+
+-- Creates a new section of this type with the given name (or anonymous)
+function TypedSection.create(self, name)
+ if name then
+ self.map:set(name, nil, self.sectiontype)
+ else
+ name = self.map:add(self.sectiontype)
+ end
+
+ for k,v in pairs(self.children) do
+ if v.default then
+ self.map:set(name, v.option, v.default)
+ end
+ end
+end
+
+-- Limits scope to sections that have certain option => value pairs
+function TypedSection.depends(self, option, value)
+ table.insert(self.deps, {option=option, value=value})
+end
+
+-- Excludes several sections by name
+function TypedSection.exclude(self, field)
+ self.excludes[field] = true
+end
+
+function TypedSection.parse(self)
+ if self.addremove then
+ -- Create
+ local crval = "cbi.cts." .. self.config .. "." .. self.sectiontype
+ local name = ffluci.http.formvalue(crval)
+ if self.anonymous then
+ if name then
+ self:create()
+ end
+ else
+ if name then
+ -- Ignore if it already exists
+ if self:cfgvalue(name) then
+ name = nil;
+ end
+
+ name = self:checkscope(name)
+
+ if not name then
+ self.err_invalid = true
+ end
+
+ if name and name:len() > 0 then
+ self:create(name)
+ end
+ end
+ end
+
+ -- Remove
+ crval = "cbi.rts." .. self.config
+ name = ffluci.http.formvaluetable(crval)
+ for k,v in pairs(name) do
+ if self:cfgvalue(k) and self:checkscope(k) then
+ self:remove(k)
+ end
+ end
+ end
+
+ for i, k in ipairs(self:cfgsections()) do
+ AbstractSection.parse_dynamic(self, k)
+ if ffluci.http.formvalue("cbi.submit") then
+ Node.parse(self, k)
+ end
+ AbstractSection.parse_optionals(self, k)
+ end
+end
+
+-- Render the children
+function TypedSection.render_children(self, section)
+ for k, node in ipairs(self.children) do
+ node:render(section)
+ end
+end
+
+-- Verifies scope of sections
+function TypedSection.checkscope(self, section)
+ -- Check if we are not excluded
+ if self.excludes[section] then
+ return nil
+ end
+
+ -- Check if at least one dependency is met
+ if #self.deps > 0 and self:cfgvalue(section) then
+ local stat = false
+
+ for k, v in ipairs(self.deps) do
+ if self:cfgvalue(section)[v.option] == v.value then
+ stat = true
+ end
+ end
+
+ if not stat then
+ return nil
+ end
+ end
+
+ return self:validate(section)
+end
+
+
+-- Dummy validate function
+function TypedSection.validate(self, section)
+ return section
+end
+
+
+--[[
+AbstractValue - An abstract Value Type
+ null: Value can be empty
+ valid: A function returning the value if it is valid otherwise nil
+ depends: A table of option => value pairs of which one must be true
+ default: The default value
+ size: The size of the input fields
+ rmempty: Unset value if empty
+ optional: This value is optional (see AbstractSection.optionals)
+]]--
+AbstractValue = class(Node)
+
+function AbstractValue.__init__(self, map, option, ...)
+ Node.__init__(self, ...)
+ self.option = option
+ self.map = map
+ self.config = map.config
+ self.tag_invalid = {}
+ self.deps = {}
+
+ self.rmempty = false
+ self.default = nil
+ self.size = nil
+ self.optional = false
+end
+
+-- Add a dependencie to another section field
+function AbstractValue.depends(self, field, value)
+ table.insert(self.deps, {field=field, value=value})
+end
+
+-- Return whether this object should be created
+function AbstractValue.formcreated(self, section)
+ local key = "cbi.opt."..self.config.."."..section
+ return (ffluci.http.formvalue(key) == self.option)
+end
+
+-- Returns the formvalue for this object
+function AbstractValue.formvalue(self, section)
+ local key = "cbid."..self.map.config.."."..section.."."..self.option
+ return ffluci.http.formvalue(key)
+end
+
+function AbstractValue.parse(self, section)
+ local fvalue = self:formvalue(section)
+
+ if fvalue and fvalue ~= "" then -- If we have a form value, write it to UCI
+ fvalue = self:validate(fvalue)
+ if not fvalue then
+ self.tag_invalid[section] = true
+ end
+ if fvalue and not (fvalue == self:cfgvalue(section)) then
+ self:write(section, fvalue)
+ end
+ else -- Unset the UCI or error
+ if self.rmempty or self.optional then
+ self:remove(section)
+ end
+ end
+end
+
+-- Render if this value exists or if it is mandatory
+function AbstractValue.render(self, s)
+ if not self.optional or self:cfgvalue(s) or self:formcreated(s) then
+ ffluci.template.render(self.template, {self=self, section=s})
+ end
+end
+
+-- Return the UCI value of this object
+function AbstractValue.cfgvalue(self, section)
+ return self.map:get(section, self.option)
+end
+
+-- Validate the form value
+function AbstractValue.validate(self, value)
+ return value
+end
+
+-- Write to UCI
+function AbstractValue.write(self, section, value)
+ return self.map:set(section, self.option, value)
+end
+
+-- Remove from UCI
+function AbstractValue.remove(self, section)
+ return self.map:del(section, self.option)
+end
+
+
+
+
+--[[
+Value - A one-line value
+ maxlength: The maximum length
+ isnumber: The value must be a valid (floating point) number
+ isinteger: The value must be a valid integer
+ ispositive: The value must be positive (and a number)
+]]--
+Value = class(AbstractValue)
+
+function Value.__init__(self, ...)
+ AbstractValue.__init__(self, ...)
+ self.template = "cbi/value"
+
+ self.maxlength = nil
+ self.isnumber = false
+ self.isinteger = false
+end
+
+-- This validation is a bit more complex
+function Value.validate(self, val)
+ if self.maxlength and tostring(val):len() > self.maxlength then
+ val = nil
+ end
+
+ return ffluci.util.validate(val, self.isnumber, self.isinteger)
+end
+
+
+-- DummyValue - This does nothing except being there
+DummyValue = class(AbstractValue)
+
+function DummyValue.__init__(self, map, ...)
+ AbstractValue.__init__(self, map, ...)
+ self.template = "cbi/dvalue"
+ self.value = nil
+end
+
+function DummyValue.parse(self)
+
+end
+
+function DummyValue.render(self, s)
+ ffluci.template.render(self.template, {self=self, section=s})
+end
+
+
+--[[
+Flag - A flag being enabled or disabled
+]]--
+Flag = class(AbstractValue)
+
+function Flag.__init__(self, ...)
+ AbstractValue.__init__(self, ...)
+ self.template = "cbi/fvalue"
+
+ self.enabled = "1"
+ self.disabled = "0"
+end
+
+-- A flag can only have two states: set or unset
+function Flag.parse(self, section)
+ local fvalue = self:formvalue(section)
+
+ if fvalue then
+ fvalue = self.enabled
+ else
+ fvalue = self.disabled
+ end
+
+ if fvalue == self.enabled or (not self.optional and not self.rmempty) then
+ if not(fvalue == self:cfgvalue(section)) then
+ self:write(section, fvalue)
+ end
+ else
+ self:remove(section)
+ end
+end
+
+
+
+--[[
+ListValue - A one-line value predefined in a list
+ widget: The widget that will be used (select, radio)
+]]--
+ListValue = class(AbstractValue)
+
+function ListValue.__init__(self, ...)
+ AbstractValue.__init__(self, ...)
+ self.template = "cbi/lvalue"
+ self.keylist = {}
+ self.vallist = {}
+
+ self.size = 1
+ self.widget = "select"
+end
+
+function ListValue.value(self, key, val)
+ val = val or key
+ table.insert(self.keylist, tostring(key))
+ table.insert(self.vallist, tostring(val))
+end
+
+function ListValue.validate(self, val)
+ if ffluci.util.contains(self.keylist, val) then
+ return val
+ else
+ return nil
+ end
+end
+
+
+
+--[[
+MultiValue - Multiple delimited values
+ widget: The widget that will be used (select, checkbox)
+ delimiter: The delimiter that will separate the values (default: " ")
+]]--
+MultiValue = class(AbstractValue)
+
+function MultiValue.__init__(self, ...)
+ AbstractValue.__init__(self, ...)
+ self.template = "cbi/mvalue"
+ self.keylist = {}
+ self.vallist = {}
+
+ self.widget = "checkbox"
+ self.delimiter = " "
+end
+
+function MultiValue.value(self, key, val)
+ val = val or key
+ table.insert(self.keylist, tostring(key))
+ table.insert(self.vallist, tostring(val))
+end
+
+function MultiValue.valuelist(self, section)
+ local val = self:cfgvalue(section)
+
+ if not(type(val) == "string") then
+ return {}
+ end
+
+ return ffluci.util.split(val, self.delimiter)
+end
+
+function MultiValue.validate(self, val)
+ if not(type(val) == "string") then
+ return nil
+ end
+
+ local result = ""
+
+ for value in val:gmatch("[^\n]+") do
+ if ffluci.util.contains(self.keylist, value) then
+ result = result .. self.delimiter .. value
+ end
+ end
+
+ if result:len() > 0 then
+ return result:sub(self.delimiter:len() + 1)
+ else
+ return nil
+ end
+end
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - Configuration
+
+Description:
+Some FFLuCI configuration values read from uci file "luci"
+
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+
+module("ffluci.config", package.seeall)
+require("ffluci.model.uci")
+require("ffluci.util")
+require("ffluci.sys")
+
+-- Warning! This is only for fallback and compatibility purporses! --
+main = {}
+
+-- This is where stylesheets and images go
+main.mediaurlbase = "/ffluci/media"
+
+-- Does anybody think about browser autodetect here?
+-- Too bad busybox doesn't populate HTTP_ACCEPT_LANGUAGE
+main.lang = "de"
+
+
+-- Now overwrite with UCI values
+local ucidata = ffluci.model.uci.sections("luci")
+if ucidata then
+ ffluci.util.update(ffluci.config, ucidata)
+end
\ No newline at end of file
--- /dev/null
+module("ffluci.debug", package.seeall)
+__file__ = debug.getinfo(1, 'S').source:sub(2)
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - Dispatcher
+
+Description:
+The request dispatcher and module dispatcher generators
+
+
+The dispatching process:
+ For a detailed explanation of the dispatching process we assume:
+ You have installed the FFLuCI CGI-Dispatcher in /cgi-bin/ffluci
+
+ To enforce a higher level of security only the CGI-Dispatcher
+ resides inside the web server's document root, everything else
+ stays inside an external directory, we assume this is /lua/ffluci
+ for this explanation.
+
+ All controllers and action are reachable as sub-objects of /cgi-bin/ffluci
+ as if they were virtual folders and files
+ e.g.: /cgi-bin/ffluci/public/info/about
+ /cgi-bin/ffluci/admin/network/interfaces
+ and so on.
+
+ The PATH_INFO variable holds the dispatch path and
+ will be split into three parts: /category/module/action
+
+ Category: This is the category in which modules are stored in
+ By default there are two categories:
+ "public" - which is the default public category
+ "admin" - which is the default protected category
+
+ As FFLuCI itself does not implement authentication
+ you should make sure that "admin" and other sensitive
+ categories are protected by the webserver.
+
+ E.g. for busybox add a line like:
+ /cgi-bin/ffluci/admin:root:$p$root
+ to /etc/httpd.conf to protect the "admin" category
+
+
+ Module: This is the controller which will handle the request further
+ It is always a submodule of ffluci.controller, so a module
+ called "helloworld" will be stored in
+ /lua/ffluci/controller/helloworld.lua
+ You are free to submodule your controllers any further.
+
+ Action: This is action that will be invoked after loading the module.
+ The kind of how the action will be dispatched depends on
+ the module dispatcher that is defined in the controller.
+ See the description of the default module dispatcher down
+ on this page for some examples.
+
+
+ The main dispatcher at first searches for the module by trying to
+ include ffluci.controller.category.module
+ (where "category" is the category name and "module" is the module name)
+ If this fails a 404 status code will be send to the client and FFLuCI exits
+
+ Then the main dispatcher calls the module dispatcher
+ ffluci.controller.category.module.dispatcher with the request object
+ as the only argument. The module dispatcher is then responsible
+ for the further dispatching process.
+
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+
+module("ffluci.dispatcher", package.seeall)
+require("ffluci.http")
+require("ffluci.template")
+require("ffluci.config")
+require("ffluci.sys")
+
+-- Sets privilege for given category
+function assign_privileges(category)
+ local cp = ffluci.config.category_privileges
+ if cp and cp[category] then
+ local u, g = cp[category]:match("([^:]+):([^:]+)")
+ ffluci.sys.process.setuser(u)
+ ffluci.sys.process.setgroup(g)
+ end
+end
+
+
+-- Builds a URL from a triple of category, module and action
+function build_url(category, module, action)
+ category = category or "public"
+ module = module or "index"
+ action = action or "index"
+
+ local pattern = ffluci.http.env.SCRIPT_NAME .. "/%s/%s/%s"
+ return pattern:format(category, module, action)
+end
+
+
+-- Dispatches the "request"
+function dispatch(req)
+ request = req
+ local m = "ffluci.controller." .. request.category .. "." .. request.module
+ local stat, module = pcall(require, m)
+ if not stat then
+ return error404()
+ else
+ module.request = request
+ module.dispatcher = module.dispatcher or dynamic
+ setfenv(module.dispatcher, module)
+ return module.dispatcher(request)
+ end
+end
+
+-- Sends a 404 error code and renders the "error404" template if available
+function error404(message)
+ ffluci.http.status(404, "Not Found")
+ message = message or "Not Found"
+
+ if not pcall(ffluci.template.render, "error404") then
+ ffluci.http.prepare_content("text/plain")
+ print(message)
+ end
+ return false
+end
+
+-- Sends a 500 error code and renders the "error500" template if available
+function error500(message)
+ ffluci.http.status(500, "Internal Server Error")
+
+ if not pcall(ffluci.template.render, "error500", {message=message}) then
+ ffluci.http.prepare_content("text/plain")
+ print(message)
+ end
+ return false
+end
+
+
+-- Dispatches a request depending on the PATH_INFO variable
+function httpdispatch()
+ local pathinfo = ffluci.http.env.PATH_INFO or ""
+ local parts = pathinfo:gmatch("/[%w-]+")
+
+ local sanitize = function(s, default)
+ return s and s:sub(2) or default
+ end
+
+ local cat = sanitize(parts(), "public")
+ local mod = sanitize(parts(), "index")
+ local act = sanitize(parts(), "index")
+
+ assign_privileges(cat)
+ dispatch({category=cat, module=mod, action=act})
+end
+
+
+-- Dispatchers --
+
+
+-- The Action Dispatcher searches the module for any function called
+-- action_"request.action" and calls it
+function action(...)
+ local disp = require("ffluci.dispatcher")
+ if not disp._action(...) then
+ disp.error404()
+ end
+end
+
+-- The CBI dispatcher directly parses and renders the CBI map which is
+-- placed in ffluci/modles/cbi/"request.module"/"request.action"
+function cbi(...)
+ local disp = require("ffluci.dispatcher")
+ if not disp._cbi(...) then
+ disp.error404()
+ end
+end
+
+-- The dynamic dispatcher chains the action, submodule, simpleview and CBI dispatcher
+-- in this particular order. It is the default dispatcher.
+function dynamic(...)
+ local disp = require("ffluci.dispatcher")
+ if not disp._action(...)
+ and not disp._submodule(...)
+ and not disp._simpleview(...)
+ and not disp._cbi(...) then
+ disp.error404()
+ end
+end
+
+-- The Simple View Dispatcher directly renders the template
+-- which is placed in ffluci/views/"request.module"/"request.action"
+function simpleview(...)
+ local disp = require("ffluci.dispatcher")
+ if not disp._simpleview(...) then
+ disp.error404()
+ end
+end
+
+
+-- The submodule dispatcher tries to load a submodule of the controller
+-- and calls its "action"-function
+function submodule(...)
+ local disp = require("ffluci.dispatcher")
+ if not disp._submodule(...) then
+ disp.error404()
+ end
+end
+
+
+-- Internal Dispatcher Functions --
+
+function _action(request)
+ local action = getfenv(2)["action_" .. request.action:gsub("-", "_")]
+ local i18n = require("ffluci.i18n")
+
+ if action then
+ i18n.loadc(request.category .. "_" .. request.module)
+ i18n.loadc(request.category .. "_" .. request.module .. "_" .. request.action)
+ action()
+ return true
+ else
+ return false
+ end
+end
+
+
+function _cbi(request)
+ local disp = require("ffluci.dispatcher")
+ local tmpl = require("ffluci.template")
+ local cbi = require("ffluci.cbi")
+ local i18n = require("ffluci.i18n")
+
+ local path = request.category.."_"..request.module.."/"..request.action
+
+ local stat, map = pcall(cbi.load, path)
+ if stat and map then
+ local stat, err = pcall(map.parse, map)
+ if not stat then
+ disp.error500(err)
+ return true
+ end
+ i18n.loadc(request.category .. "_" .. request.module)
+ i18n.loadc(request.category .. "_" .. request.module .. "_" .. request.action)
+ tmpl.render("cbi/header")
+ map:render()
+ tmpl.render("cbi/footer")
+ return true
+ elseif not stat then
+ disp.error500(map)
+ return true
+ else
+ return false
+ end
+end
+
+
+function _simpleview(request)
+ local i18n = require("ffluci.i18n")
+ local tmpl = require("ffluci.template")
+
+ local path = request.category.."_"..request.module.."/"..request.action
+
+ local stat, t = pcall(tmpl.Template, path)
+ if stat then
+ i18n.loadc(request.category .. "_" .. request.module)
+ i18n.loadc(request.category .. "_" .. request.module .. "_" .. request.action)
+ t:render()
+ return true
+ else
+ return false
+ end
+end
+
+
+function _submodule(request)
+ local i18n = require("ffluci.i18n")
+ local m = "ffluci.controller." .. request.category .. "." ..
+ request.module .. "." .. request.action
+ local stat, module = pcall(require, m)
+
+ if stat and module.action then
+ i18n.loadc(request.category .. "_" .. request.module)
+ i18n.loadc(request.category .. "_" .. request.module .. "_" .. request.action)
+ return pcall(module.action)
+ end
+
+ return false
+end
\ No newline at end of file
+++ /dev/null
---[[
-/*
- * Copyright (c) 2007 Tim Kelly/Dialectronics
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to permit
- * persons to whom the Software is furnished to do so, subject to the
- * following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
- * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
---]]
-
---[[
-/*
- * Copyright (c) 2007 Tim Kelly/Dialectronics
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to permit
- * persons to whom the Software is furnished to do so, subject to the
- * following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
- * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
---]]
-
-module("ffluci.bits", package.seeall);
-
-local hex2bin = {
- ["0"] = "0000",
- ["1"] = "0001",
- ["2"] = "0010",
- ["3"] = "0011",
- ["4"] = "0100",
- ["5"] = "0101",
- ["6"] = "0110",
- ["7"] = "0111",
- ["8"] = "1000",
- ["9"] = "1001",
- ["a"] = "1010",
- ["b"] = "1011",
- ["c"] = "1100",
- ["d"] = "1101",
- ["e"] = "1110",
- ["f"] = "1111"
- }
-
-
-
-local bin2hex = {
- ["0000"] = "0",
- ["0001"] = "1",
- ["0010"] = "2",
- ["0011"] = "3",
- ["0100"] = "4",
- ["0101"] = "5",
- ["0110"] = "6",
- ["0111"] = "7",
- ["1000"] = "8",
- ["1001"] = "9",
- ["1010"] = "A",
- ["1011"] = "B",
- ["1100"] = "C",
- ["1101"] = "D",
- ["1110"] = "E",
- ["1111"] = "F"
- }
-
---[[
-local dec2hex = {
- ["0"] = "0",
- ["1"] = "1",
- ["2"] = "2",
- ["3"] = "3",
- ["4"] = "4",
- ["5"] = "5",
- ["6"] = "6",
- ["7"] = "7",
- ["8"] = "8",
- ["9"] = "9",
- ["10"] = "A",
- ["11"] = "B",
- ["12"] = "C",
- ["13"] = "D",
- ["14"] = "E",
- ["15"] = "F"
- }
---]]
-
-
--- These functions are big-endian and take up to 32 bits
-
--- Hex2Bin
--- Bin2Hex
--- Hex2Dec
--- Dec2Hex
--- Bin2Dec
--- Dec2Bin
-
-
-function Hex2Bin(s)
-
--- s -> hexadecimal string
-
-local ret = ""
-local i = 0
-
-
- for i in string.gfind(s, ".") do
- i = string.lower(i)
-
- ret = ret..hex2bin[i]
-
- end
-
- return ret
-end
-
-
-function Bin2Hex(s)
-
--- s -> binary string
-
-local l = 0
-local h = ""
-local b = ""
-local rem
-
-l = string.len(s)
-rem = l % 4
-l = l-1
-h = ""
-
- -- need to prepend zeros to eliminate mod 4
- if (rem > 0) then
- s = string.rep("0", 4 - rem)..s
- end
-
- for i = 1, l, 4 do
- b = string.sub(s, i, i+3)
- h = h..bin2hex[b]
- end
-
- return h
-
-end
-
-
-function Bin2Dec(s)
-
--- s -> binary string
-
-local num = 0
-local ex = string.len(s) - 1
-local l = 0
-
- l = ex + 1
- for i = 1, l do
- b = string.sub(s, i, i)
- if b == "1" then
- num = num + 2^ex
- end
- ex = ex - 1
- end
-
- return string.format("%u", num)
-
-end
-
-
-
-function Dec2Bin(s, num)
-
--- s -> Base10 string
--- num -> string length to extend to
-
-local n
-
- if (num == nil) then
- n = 0
- else
- n = num
- end
-
- s = string.format("%x", s)
-
- s = Hex2Bin(s)
-
- while string.len(s) < n do
- s = "0"..s
- end
-
- return s
-
-end
-
-
-
-
-function Hex2Dec(s)
-
--- s -> hexadecimal string
-
-local s = Hex2Bin(s)
-
- return Bin2Dec(s)
-
-end
-
-
-
-function Dec2Hex(s)
-
--- s -> Base10 string
-
- s = string.format("%x", s)
-
- return s
-
-end
-
-
-
-
--- These functions are big-endian and will extend to 32 bits
-
--- BMAnd
--- BMNAnd
--- BMOr
--- BMXOr
--- BMNot
-
-
-function BMAnd(v, m)
-
--- v -> hex string to be masked
--- m -> hex string mask
-
--- s -> hex string as masked
-
--- bv -> binary string of v
--- bm -> binary string mask
-
-local bv = Hex2Bin(v)
-local bm = Hex2Bin(m)
-
-local i = 0
-local s = ""
-
- while (string.len(bv) < 32) do
- bv = "0000"..bv
- end
-
- while (string.len(bm) < 32) do
- bm = "0000"..bm
- end
-
-
- for i = 1, 32 do
- cv = string.sub(bv, i, i)
- cm = string.sub(bm, i, i)
- if cv == cm then
- if cv == "1" then
- s = s.."1"
- else
- s = s.."0"
- end
- else
- s = s.."0"
-
- end
- end
-
- return Bin2Hex(s)
-
-end
-
-
-function BMNAnd(v, m)
-
--- v -> hex string to be masked
--- m -> hex string mask
-
--- s -> hex string as masked
-
--- bv -> binary string of v
--- bm -> binary string mask
-
-local bv = Hex2Bin(v)
-local bm = Hex2Bin(m)
-
-local i = 0
-local s = ""
-
- while (string.len(bv) < 32) do
- bv = "0000"..bv
- end
-
- while (string.len(bm) < 32) do
- bm = "0000"..bm
- end
-
-
- for i = 1, 32 do
- cv = string.sub(bv, i, i)
- cm = string.sub(bm, i, i)
- if cv == cm then
- if cv == "1" then
- s = s.."0"
- else
- s = s.."1"
- end
- else
- s = s.."1"
-
- end
- end
-
- return Bin2Hex(s)
-
-end
-
-
-
-function BMOr(v, m)
-
--- v -> hex string to be masked
--- m -> hex string mask
-
--- s -> hex string as masked
-
--- bv -> binary string of v
--- bm -> binary string mask
-
-local bv = Hex2Bin(v)
-local bm = Hex2Bin(m)
-
-local i = 0
-local s = ""
-
- while (string.len(bv) < 32) do
- bv = "0000"..bv
- end
-
- while (string.len(bm) < 32) do
- bm = "0000"..bm
- end
-
-
- for i = 1, 32 do
- cv = string.sub(bv, i, i)
- cm = string.sub(bm, i, i)
- if cv == "1" then
- s = s.."1"
- elseif cm == "1" then
- s = s.."1"
- else
- s = s.."0"
- end
- end
-
- return Bin2Hex(s)
-
-end
-
-function BMXOr(v, m)
-
--- v -> hex string to be masked
--- m -> hex string mask
-
--- s -> hex string as masked
-
--- bv -> binary string of v
--- bm -> binary string mask
-
-local bv = Hex2Bin(v)
-local bm = Hex2Bin(m)
-
-local i = 0
-local s = ""
-
- while (string.len(bv) < 32) do
- bv = "0000"..bv
- end
-
- while (string.len(bm) < 32) do
- bm = "0000"..bm
- end
-
-
- for i = 1, 32 do
- cv = string.sub(bv, i, i)
- cm = string.sub(bm, i, i)
- if cv == "1" then
- if cm == "0" then
- s = s.."1"
- else
- s = s.."0"
- end
- elseif cm == "1" then
- if cv == "0" then
- s = s.."1"
- else
- s = s.."0"
- end
- else
- -- cv and cm == "0"
- s = s.."0"
- end
- end
-
- return Bin2Hex(s)
-
-end
-
-
-function BMNot(v, m)
-
--- v -> hex string to be masked
--- m -> hex string mask
-
--- s -> hex string as masked
-
--- bv -> binary string of v
--- bm -> binary string mask
-
-local bv = Hex2Bin(v)
-local bm = Hex2Bin(m)
-
-local i = 0
-local s = ""
-
- while (string.len(bv) < 32) do
- bv = "0000"..bv
- end
-
- while (string.len(bm) < 32) do
- bm = "0000"..bm
- end
-
-
- for i = 1, 32 do
- cv = string.sub(bv, i, i)
- cm = string.sub(bm, i, i)
- if cm == "1" then
- if cv == "1" then
- -- turn off
- s = s.."0"
- else
- -- turn on
- s = s.."1"
- end
- else
- -- leave untouched
- s = s..cv
-
- end
- end
-
- return Bin2Hex(s)
-
-end
-
-
--- these functions shift right and left, adding zeros to lost or gained bits
--- returned values are 32 bits long
-
--- BShRight(v, nb)
--- BShLeft(v, nb)
-
-
-function BShRight(v, nb)
-
--- v -> hexstring value to be shifted
--- nb -> number of bits to shift to the right
-
--- s -> binary string of v
-
-local s = Hex2Bin(v)
-
- while (string.len(s) < 32) do
- s = "0000"..s
- end
-
- s = string.sub(s, 1, 32 - nb)
-
- while (string.len(s) < 32) do
- s = "0"..s
- end
-
- return Bin2Hex(s)
-
-end
-
-function BShLeft(v, nb)
-
--- v -> hexstring value to be shifted
--- nb -> number of bits to shift to the right
-
--- s -> binary string of v
-
-local s = Hex2Bin(v)
-
- while (string.len(s) < 32) do
- s = "0000"..s
- end
-
- s = string.sub(s, nb + 1, 32)
-
- while (string.len(s) < 32) do
- s = s.."0"
- end
-
- return Bin2Hex(s)
-
-end
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - Configuration Bind Interface
-
-Description:
-Offers an interface for binding confiugration values to certain
-data types. Supports value and range validation and basic dependencies.
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-module("ffluci.cbi", package.seeall)
-
-require("ffluci.template")
-require("ffluci.util")
-require("ffluci.http")
-require("ffluci.model.uci")
-
-local class = ffluci.util.class
-local instanceof = ffluci.util.instanceof
-
--- Loads a CBI map from given file, creating an environment and returns it
-function load(cbimap)
- require("ffluci.fs")
- require("ffluci.i18n")
- require("ffluci.config")
- require("ffluci.sys")
-
- local cbidir = ffluci.sys.libpath() .. "/model/cbi/"
- local func, err = loadfile(cbidir..cbimap..".lua")
-
- if not func then
- return nil
- end
-
- ffluci.i18n.loadc("cbi")
-
- ffluci.util.resfenv(func)
- ffluci.util.updfenv(func, ffluci.cbi)
- ffluci.util.extfenv(func, "translate", ffluci.i18n.translate)
-
- local map = func()
-
- if not instanceof(map, Map) then
- error("CBI map returns no valid map object!")
- return nil
- end
-
- return map
-end
-
--- Node pseudo abstract class
-Node = class()
-
-function Node.__init__(self, title, description)
- self.children = {}
- self.title = title or ""
- self.description = description or ""
- self.template = "cbi/node"
-end
-
--- Append child nodes
-function Node.append(self, obj)
- table.insert(self.children, obj)
-end
-
--- Parse this node and its children
-function Node.parse(self, ...)
- for k, child in ipairs(self.children) do
- child:parse(...)
- end
-end
-
--- Render this node
-function Node.render(self)
- ffluci.template.render(self.template, {self=self})
-end
-
--- Render the children
-function Node.render_children(self, ...)
- for k, node in ipairs(self.children) do
- node:render(...)
- end
-end
-
-
---[[
-A simple template element
-]]--
-Template = class(Node)
-
-function Template.__init__(self, template)
- Node.__init__(self)
- self.template = template
-end
-
-
---[[
-Map - A map describing a configuration file
-]]--
-Map = class(Node)
-
-function Map.__init__(self, config, ...)
- Node.__init__(self, ...)
- self.config = config
- self.template = "cbi/map"
- self.uci = ffluci.model.uci.Session()
- self.ucidata, self.uciorder = self.uci:sections(self.config)
- if not self.ucidata or not self.uciorder then
- error("Unable to read UCI data: " .. self.config)
- end
-end
-
--- Use optimized UCI writing
-function Map.parse(self, ...)
- self.uci:t_load(self.config)
- Node.parse(self, ...)
- self.uci:t_save(self.config)
-end
-
--- Creates a child section
-function Map.section(self, class, ...)
- if instanceof(class, AbstractSection) then
- local obj = class(self, ...)
- self:append(obj)
- return obj
- else
- error("class must be a descendent of AbstractSection")
- end
-end
-
--- UCI add
-function Map.add(self, sectiontype)
- local name = self.uci:t_add(self.config, sectiontype)
- if name then
- self.ucidata[name] = {}
- self.ucidata[name][".type"] = sectiontype
- table.insert(self.uciorder, name)
- end
- return name
-end
-
--- UCI set
-function Map.set(self, section, option, value)
- local stat = self.uci:t_set(self.config, section, option, value)
- if stat then
- local val = self.uci:t_get(self.config, section, option)
- if option then
- self.ucidata[section][option] = val
- else
- if not self.ucidata[section] then
- self.ucidata[section] = {}
- end
- self.ucidata[section][".type"] = val
- table.insert(self.uciorder, section)
- end
- end
- return stat
-end
-
--- UCI del
-function Map.del(self, section, option)
- local stat = self.uci:t_del(self.config, section, option)
- if stat then
- if option then
- self.ucidata[section][option] = nil
- else
- self.ucidata[section] = nil
- for i, k in ipairs(self.uciorder) do
- if section == k then
- table.remove(self.uciorder, i)
- end
- end
- end
- end
- return stat
-end
-
--- UCI get (cached)
-function Map.get(self, section, option)
- if not section then
- return self.ucidata, self.uciorder
- elseif option and self.ucidata[section] then
- return self.ucidata[section][option]
- else
- return self.ucidata[section]
- end
-end
-
-
---[[
-AbstractSection
-]]--
-AbstractSection = class(Node)
-
-function AbstractSection.__init__(self, map, sectiontype, ...)
- Node.__init__(self, ...)
- self.sectiontype = sectiontype
- self.map = map
- self.config = map.config
- self.optionals = {}
-
- self.optional = true
- self.addremove = false
- self.dynamic = false
-end
-
--- Appends a new option
-function AbstractSection.option(self, class, ...)
- if instanceof(class, AbstractValue) then
- local obj = class(self.map, ...)
- self:append(obj)
- return obj
- else
- error("class must be a descendent of AbstractValue")
- end
-end
-
--- Parse optional options
-function AbstractSection.parse_optionals(self, section)
- if not self.optional then
- return
- end
-
- self.optionals[section] = {}
-
- local field = ffluci.http.formvalue("cbi.opt."..self.config.."."..section)
- for k,v in ipairs(self.children) do
- if v.optional and not v:cfgvalue(section) then
- if field == v.option then
- field = nil
- else
- table.insert(self.optionals[section], v)
- end
- end
- end
-
- if field and #field > 0 and self.dynamic then
- self:add_dynamic(field)
- end
-end
-
--- Add a dynamic option
-function AbstractSection.add_dynamic(self, field, optional)
- local o = self:option(Value, field, field)
- o.optional = optional
-end
-
--- Parse all dynamic options
-function AbstractSection.parse_dynamic(self, section)
- if not self.dynamic then
- return
- end
-
- local arr = ffluci.util.clone(self:cfgvalue(section))
- local form = ffluci.http.formvaluetable("cbid."..self.config.."."..section)
- for k, v in pairs(form) do
- arr[k] = v
- end
-
- for key,val in pairs(arr) do
- local create = true
-
- for i,c in ipairs(self.children) do
- if c.option == key then
- create = false
- end
- end
-
- if create and key:sub(1, 1) ~= "." then
- self:add_dynamic(key, true)
- end
- end
-end
-
--- Returns the section's UCI table
-function AbstractSection.cfgvalue(self, section)
- return self.map:get(section)
-end
-
--- Removes the section
-function AbstractSection.remove(self, section)
- return self.map:del(section)
-end
-
--- Creates the section
-function AbstractSection.create(self, section)
- return self.map:set(section, nil, self.sectiontype)
-end
-
-
-
---[[
-NamedSection - A fixed configuration section defined by its name
-]]--
-NamedSection = class(AbstractSection)
-
-function NamedSection.__init__(self, map, section, ...)
- AbstractSection.__init__(self, map, ...)
- self.template = "cbi/nsection"
-
- self.section = section
- self.addremove = false
-end
-
-function NamedSection.parse(self)
- local s = self.section
- local active = self:cfgvalue(s)
-
-
- if self.addremove then
- local path = self.config.."."..s
- if active then -- Remove the section
- if ffluci.http.formvalue("cbi.rns."..path) and self:remove(s) then
- return
- end
- else -- Create and apply default values
- if ffluci.http.formvalue("cbi.cns."..path) and self:create(s) then
- for k,v in pairs(self.children) do
- v:write(s, v.default)
- end
- end
- end
- end
-
- if active then
- AbstractSection.parse_dynamic(self, s)
- if ffluci.http.formvalue("cbi.submit") then
- Node.parse(self, s)
- end
- AbstractSection.parse_optionals(self, s)
- end
-end
-
-
---[[
-TypedSection - A (set of) configuration section(s) defined by the type
- addremove: Defines whether the user can add/remove sections of this type
- anonymous: Allow creating anonymous sections
- validate: a validation function returning nil if the section is invalid
-]]--
-TypedSection = class(AbstractSection)
-
-function TypedSection.__init__(self, ...)
- AbstractSection.__init__(self, ...)
- self.template = "cbi/tsection"
- self.deps = {}
- self.excludes = {}
-
- self.anonymous = false
-end
-
--- Return all matching UCI sections for this TypedSection
-function TypedSection.cfgsections(self)
- local sections = {}
- local map, order = self.map:get()
-
- for i, k in ipairs(order) do
- if map[k][".type"] == self.sectiontype then
- if self:checkscope(k) then
- table.insert(sections, k)
- end
- end
- end
-
- return sections
-end
-
--- Creates a new section of this type with the given name (or anonymous)
-function TypedSection.create(self, name)
- if name then
- self.map:set(name, nil, self.sectiontype)
- else
- name = self.map:add(self.sectiontype)
- end
-
- for k,v in pairs(self.children) do
- if v.default then
- self.map:set(name, v.option, v.default)
- end
- end
-end
-
--- Limits scope to sections that have certain option => value pairs
-function TypedSection.depends(self, option, value)
- table.insert(self.deps, {option=option, value=value})
-end
-
--- Excludes several sections by name
-function TypedSection.exclude(self, field)
- self.excludes[field] = true
-end
-
-function TypedSection.parse(self)
- if self.addremove then
- -- Create
- local crval = "cbi.cts." .. self.config .. "." .. self.sectiontype
- local name = ffluci.http.formvalue(crval)
- if self.anonymous then
- if name then
- self:create()
- end
- else
- if name then
- -- Ignore if it already exists
- if self:cfgvalue(name) then
- name = nil;
- end
-
- name = self:checkscope(name)
-
- if not name then
- self.err_invalid = true
- end
-
- if name and name:len() > 0 then
- self:create(name)
- end
- end
- end
-
- -- Remove
- crval = "cbi.rts." .. self.config
- name = ffluci.http.formvaluetable(crval)
- for k,v in pairs(name) do
- if self:cfgvalue(k) and self:checkscope(k) then
- self:remove(k)
- end
- end
- end
-
- for i, k in ipairs(self:cfgsections()) do
- AbstractSection.parse_dynamic(self, k)
- if ffluci.http.formvalue("cbi.submit") then
- Node.parse(self, k)
- end
- AbstractSection.parse_optionals(self, k)
- end
-end
-
--- Render the children
-function TypedSection.render_children(self, section)
- for k, node in ipairs(self.children) do
- node:render(section)
- end
-end
-
--- Verifies scope of sections
-function TypedSection.checkscope(self, section)
- -- Check if we are not excluded
- if self.excludes[section] then
- return nil
- end
-
- -- Check if at least one dependency is met
- if #self.deps > 0 and self:cfgvalue(section) then
- local stat = false
-
- for k, v in ipairs(self.deps) do
- if self:cfgvalue(section)[v.option] == v.value then
- stat = true
- end
- end
-
- if not stat then
- return nil
- end
- end
-
- return self:validate(section)
-end
-
-
--- Dummy validate function
-function TypedSection.validate(self, section)
- return section
-end
-
-
---[[
-AbstractValue - An abstract Value Type
- null: Value can be empty
- valid: A function returning the value if it is valid otherwise nil
- depends: A table of option => value pairs of which one must be true
- default: The default value
- size: The size of the input fields
- rmempty: Unset value if empty
- optional: This value is optional (see AbstractSection.optionals)
-]]--
-AbstractValue = class(Node)
-
-function AbstractValue.__init__(self, map, option, ...)
- Node.__init__(self, ...)
- self.option = option
- self.map = map
- self.config = map.config
- self.tag_invalid = {}
- self.deps = {}
-
- self.rmempty = false
- self.default = nil
- self.size = nil
- self.optional = false
-end
-
--- Add a dependencie to another section field
-function AbstractValue.depends(self, field, value)
- table.insert(self.deps, {field=field, value=value})
-end
-
--- Return whether this object should be created
-function AbstractValue.formcreated(self, section)
- local key = "cbi.opt."..self.config.."."..section
- return (ffluci.http.formvalue(key) == self.option)
-end
-
--- Returns the formvalue for this object
-function AbstractValue.formvalue(self, section)
- local key = "cbid."..self.map.config.."."..section.."."..self.option
- return ffluci.http.formvalue(key)
-end
-
-function AbstractValue.parse(self, section)
- local fvalue = self:formvalue(section)
-
- if fvalue and fvalue ~= "" then -- If we have a form value, write it to UCI
- fvalue = self:validate(fvalue)
- if not fvalue then
- self.tag_invalid[section] = true
- end
- if fvalue and not (fvalue == self:cfgvalue(section)) then
- self:write(section, fvalue)
- end
- else -- Unset the UCI or error
- if self.rmempty or self.optional then
- self:remove(section)
- end
- end
-end
-
--- Render if this value exists or if it is mandatory
-function AbstractValue.render(self, s)
- if not self.optional or self:cfgvalue(s) or self:formcreated(s) then
- ffluci.template.render(self.template, {self=self, section=s})
- end
-end
-
--- Return the UCI value of this object
-function AbstractValue.cfgvalue(self, section)
- return self.map:get(section, self.option)
-end
-
--- Validate the form value
-function AbstractValue.validate(self, value)
- return value
-end
-
--- Write to UCI
-function AbstractValue.write(self, section, value)
- return self.map:set(section, self.option, value)
-end
-
--- Remove from UCI
-function AbstractValue.remove(self, section)
- return self.map:del(section, self.option)
-end
-
-
-
-
---[[
-Value - A one-line value
- maxlength: The maximum length
- isnumber: The value must be a valid (floating point) number
- isinteger: The value must be a valid integer
- ispositive: The value must be positive (and a number)
-]]--
-Value = class(AbstractValue)
-
-function Value.__init__(self, ...)
- AbstractValue.__init__(self, ...)
- self.template = "cbi/value"
-
- self.maxlength = nil
- self.isnumber = false
- self.isinteger = false
-end
-
--- This validation is a bit more complex
-function Value.validate(self, val)
- if self.maxlength and tostring(val):len() > self.maxlength then
- val = nil
- end
-
- return ffluci.util.validate(val, self.isnumber, self.isinteger)
-end
-
-
--- DummyValue - This does nothing except being there
-DummyValue = class(AbstractValue)
-
-function DummyValue.__init__(self, map, ...)
- AbstractValue.__init__(self, map, ...)
- self.template = "cbi/dvalue"
- self.value = nil
-end
-
-function DummyValue.parse(self)
-
-end
-
-function DummyValue.render(self, s)
- ffluci.template.render(self.template, {self=self, section=s})
-end
-
-
---[[
-Flag - A flag being enabled or disabled
-]]--
-Flag = class(AbstractValue)
-
-function Flag.__init__(self, ...)
- AbstractValue.__init__(self, ...)
- self.template = "cbi/fvalue"
-
- self.enabled = "1"
- self.disabled = "0"
-end
-
--- A flag can only have two states: set or unset
-function Flag.parse(self, section)
- local fvalue = self:formvalue(section)
-
- if fvalue then
- fvalue = self.enabled
- else
- fvalue = self.disabled
- end
-
- if fvalue == self.enabled or (not self.optional and not self.rmempty) then
- if not(fvalue == self:cfgvalue(section)) then
- self:write(section, fvalue)
- end
- else
- self:remove(section)
- end
-end
-
-
-
---[[
-ListValue - A one-line value predefined in a list
- widget: The widget that will be used (select, radio)
-]]--
-ListValue = class(AbstractValue)
-
-function ListValue.__init__(self, ...)
- AbstractValue.__init__(self, ...)
- self.template = "cbi/lvalue"
- self.keylist = {}
- self.vallist = {}
-
- self.size = 1
- self.widget = "select"
-end
-
-function ListValue.value(self, key, val)
- val = val or key
- table.insert(self.keylist, tostring(key))
- table.insert(self.vallist, tostring(val))
-end
-
-function ListValue.validate(self, val)
- if ffluci.util.contains(self.keylist, val) then
- return val
- else
- return nil
- end
-end
-
-
-
---[[
-MultiValue - Multiple delimited values
- widget: The widget that will be used (select, checkbox)
- delimiter: The delimiter that will separate the values (default: " ")
-]]--
-MultiValue = class(AbstractValue)
-
-function MultiValue.__init__(self, ...)
- AbstractValue.__init__(self, ...)
- self.template = "cbi/mvalue"
- self.keylist = {}
- self.vallist = {}
-
- self.widget = "checkbox"
- self.delimiter = " "
-end
-
-function MultiValue.value(self, key, val)
- val = val or key
- table.insert(self.keylist, tostring(key))
- table.insert(self.vallist, tostring(val))
-end
-
-function MultiValue.valuelist(self, section)
- local val = self:cfgvalue(section)
-
- if not(type(val) == "string") then
- return {}
- end
-
- return ffluci.util.split(val, self.delimiter)
-end
-
-function MultiValue.validate(self, val)
- if not(type(val) == "string") then
- return nil
- end
-
- local result = ""
-
- for value in val:gmatch("[^\n]+") do
- if ffluci.util.contains(self.keylist, value) then
- result = result .. self.delimiter .. value
- end
- end
-
- if result:len() > 0 then
- return result:sub(self.delimiter:len() + 1)
- else
- return nil
- end
-end
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - Configuration
-
-Description:
-Some FFLuCI configuration values read from uci file "luci"
-
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-
-module("ffluci.config", package.seeall)
-require("ffluci.model.uci")
-require("ffluci.util")
-require("ffluci.sys")
-
--- Warning! This is only for fallback and compatibility purporses! --
-main = {}
-
--- This is where stylesheets and images go
-main.mediaurlbase = "/ffluci/media"
-
--- Does anybody think about browser autodetect here?
--- Too bad busybox doesn't populate HTTP_ACCEPT_LANGUAGE
-main.lang = "de"
-
-
--- Now overwrite with UCI values
-local ucidata = ffluci.model.uci.sections("luci")
-if ucidata then
- ffluci.util.update(ffluci.config, ucidata)
-end
\ No newline at end of file
+++ /dev/null
-module("ffluci.debug", package.seeall)
-__file__ = debug.getinfo(1, 'S').source:sub(2)
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - Dispatcher
-
-Description:
-The request dispatcher and module dispatcher generators
-
-
-The dispatching process:
- For a detailed explanation of the dispatching process we assume:
- You have installed the FFLuCI CGI-Dispatcher in /cgi-bin/ffluci
-
- To enforce a higher level of security only the CGI-Dispatcher
- resides inside the web server's document root, everything else
- stays inside an external directory, we assume this is /lua/ffluci
- for this explanation.
-
- All controllers and action are reachable as sub-objects of /cgi-bin/ffluci
- as if they were virtual folders and files
- e.g.: /cgi-bin/ffluci/public/info/about
- /cgi-bin/ffluci/admin/network/interfaces
- and so on.
-
- The PATH_INFO variable holds the dispatch path and
- will be split into three parts: /category/module/action
-
- Category: This is the category in which modules are stored in
- By default there are two categories:
- "public" - which is the default public category
- "admin" - which is the default protected category
-
- As FFLuCI itself does not implement authentication
- you should make sure that "admin" and other sensitive
- categories are protected by the webserver.
-
- E.g. for busybox add a line like:
- /cgi-bin/ffluci/admin:root:$p$root
- to /etc/httpd.conf to protect the "admin" category
-
-
- Module: This is the controller which will handle the request further
- It is always a submodule of ffluci.controller, so a module
- called "helloworld" will be stored in
- /lua/ffluci/controller/helloworld.lua
- You are free to submodule your controllers any further.
-
- Action: This is action that will be invoked after loading the module.
- The kind of how the action will be dispatched depends on
- the module dispatcher that is defined in the controller.
- See the description of the default module dispatcher down
- on this page for some examples.
-
-
- The main dispatcher at first searches for the module by trying to
- include ffluci.controller.category.module
- (where "category" is the category name and "module" is the module name)
- If this fails a 404 status code will be send to the client and FFLuCI exits
-
- Then the main dispatcher calls the module dispatcher
- ffluci.controller.category.module.dispatcher with the request object
- as the only argument. The module dispatcher is then responsible
- for the further dispatching process.
-
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-
-module("ffluci.dispatcher", package.seeall)
-require("ffluci.http")
-require("ffluci.template")
-require("ffluci.config")
-require("ffluci.sys")
-
--- Sets privilege for given category
-function assign_privileges(category)
- local cp = ffluci.config.category_privileges
- if cp and cp[category] then
- local u, g = cp[category]:match("([^:]+):([^:]+)")
- ffluci.sys.process.setuser(u)
- ffluci.sys.process.setgroup(g)
- end
-end
-
-
--- Builds a URL from a triple of category, module and action
-function build_url(category, module, action)
- category = category or "public"
- module = module or "index"
- action = action or "index"
-
- local pattern = ffluci.http.env.SCRIPT_NAME .. "/%s/%s/%s"
- return pattern:format(category, module, action)
-end
-
-
--- Dispatches the "request"
-function dispatch(req)
- request = req
- local m = "ffluci.controller." .. request.category .. "." .. request.module
- local stat, module = pcall(require, m)
- if not stat then
- return error404()
- else
- module.request = request
- module.dispatcher = module.dispatcher or dynamic
- setfenv(module.dispatcher, module)
- return module.dispatcher(request)
- end
-end
-
--- Sends a 404 error code and renders the "error404" template if available
-function error404(message)
- ffluci.http.status(404, "Not Found")
- message = message or "Not Found"
-
- if not pcall(ffluci.template.render, "error404") then
- ffluci.http.prepare_content("text/plain")
- print(message)
- end
- return false
-end
-
--- Sends a 500 error code and renders the "error500" template if available
-function error500(message)
- ffluci.http.status(500, "Internal Server Error")
-
- if not pcall(ffluci.template.render, "error500", {message=message}) then
- ffluci.http.prepare_content("text/plain")
- print(message)
- end
- return false
-end
-
-
--- Dispatches a request depending on the PATH_INFO variable
-function httpdispatch()
- local pathinfo = ffluci.http.env.PATH_INFO or ""
- local parts = pathinfo:gmatch("/[%w-]+")
-
- local sanitize = function(s, default)
- return s and s:sub(2) or default
- end
-
- local cat = sanitize(parts(), "public")
- local mod = sanitize(parts(), "index")
- local act = sanitize(parts(), "index")
-
- assign_privileges(cat)
- dispatch({category=cat, module=mod, action=act})
-end
-
-
--- Dispatchers --
-
-
--- The Action Dispatcher searches the module for any function called
--- action_"request.action" and calls it
-function action(...)
- local disp = require("ffluci.dispatcher")
- if not disp._action(...) then
- disp.error404()
- end
-end
-
--- The CBI dispatcher directly parses and renders the CBI map which is
--- placed in ffluci/modles/cbi/"request.module"/"request.action"
-function cbi(...)
- local disp = require("ffluci.dispatcher")
- if not disp._cbi(...) then
- disp.error404()
- end
-end
-
--- The dynamic dispatcher chains the action, submodule, simpleview and CBI dispatcher
--- in this particular order. It is the default dispatcher.
-function dynamic(...)
- local disp = require("ffluci.dispatcher")
- if not disp._action(...)
- and not disp._submodule(...)
- and not disp._simpleview(...)
- and not disp._cbi(...) then
- disp.error404()
- end
-end
-
--- The Simple View Dispatcher directly renders the template
--- which is placed in ffluci/views/"request.module"/"request.action"
-function simpleview(...)
- local disp = require("ffluci.dispatcher")
- if not disp._simpleview(...) then
- disp.error404()
- end
-end
-
-
--- The submodule dispatcher tries to load a submodule of the controller
--- and calls its "action"-function
-function submodule(...)
- local disp = require("ffluci.dispatcher")
- if not disp._submodule(...) then
- disp.error404()
- end
-end
-
-
--- Internal Dispatcher Functions --
-
-function _action(request)
- local action = getfenv(2)["action_" .. request.action:gsub("-", "_")]
- local i18n = require("ffluci.i18n")
-
- if action then
- i18n.loadc(request.category .. "_" .. request.module)
- i18n.loadc(request.category .. "_" .. request.module .. "_" .. request.action)
- action()
- return true
- else
- return false
- end
-end
-
-
-function _cbi(request)
- local disp = require("ffluci.dispatcher")
- local tmpl = require("ffluci.template")
- local cbi = require("ffluci.cbi")
- local i18n = require("ffluci.i18n")
-
- local path = request.category.."_"..request.module.."/"..request.action
-
- local stat, map = pcall(cbi.load, path)
- if stat and map then
- local stat, err = pcall(map.parse, map)
- if not stat then
- disp.error500(err)
- return true
- end
- i18n.loadc(request.category .. "_" .. request.module)
- i18n.loadc(request.category .. "_" .. request.module .. "_" .. request.action)
- tmpl.render("cbi/header")
- map:render()
- tmpl.render("cbi/footer")
- return true
- elseif not stat then
- disp.error500(map)
- return true
- else
- return false
- end
-end
-
-
-function _simpleview(request)
- local i18n = require("ffluci.i18n")
- local tmpl = require("ffluci.template")
-
- local path = request.category.."_"..request.module.."/"..request.action
-
- local stat, t = pcall(tmpl.Template, path)
- if stat then
- i18n.loadc(request.category .. "_" .. request.module)
- i18n.loadc(request.category .. "_" .. request.module .. "_" .. request.action)
- t:render()
- return true
- else
- return false
- end
-end
-
-
-function _submodule(request)
- local i18n = require("ffluci.i18n")
- local m = "ffluci.controller." .. request.category .. "." ..
- request.module .. "." .. request.action
- local stat, module = pcall(require, m)
-
- if stat and module.action then
- i18n.loadc(request.category .. "_" .. request.module)
- i18n.loadc(request.category .. "_" .. request.module .. "_" .. request.action)
- return pcall(module.action)
- end
-
- return false
-end
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - Filesystem tools
-
-Description:
-A module offering often needed filesystem manipulation functions
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-
-module("ffluci.fs", package.seeall)
-
-require("posix")
-
--- Glob
-function glob(pattern)
- return posix.glob(pattern)
-end
-
--- Checks whether a file exists
-function isfile(filename)
- local fp = io.open(filename, "r")
- if fp then fp:close() end
- return fp ~= nil
-end
-
--- Returns the content of file
-function readfile(filename)
- local fp, err = io.open(filename)
-
- if fp == nil then
- return nil, err
- end
-
- local data = fp:read("*a")
- fp:close()
- return data
-end
-
--- Writes given data to a file
-function writefile(filename, data)
- local fp, err = io.open(filename, "w")
-
- if fp == nil then
- return nil, err
- end
-
- fp:write(data)
- fp:close()
-
- return true
-end
-
--- Returns the file modification date/time of "path"
-function mtime(path)
- return posix.stat(path, "mtime")
-end
-
--- basename wrapper
-basename = posix.basename
-
--- dirname wrapper
-dirname = posix.dirname
-
--- dir wrapper
-function dir(path)
- local dir = {}
- for node in posix.files(path) do
- table.insert(dir, 1, node)
- end
- return dir
-end
-
--- Alias for posix.mkdir
-mkdir = posix.mkdir
-
--- Alias for posix.rmdir
-rmdir = posix.rmdir
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - HTTP-Interaction
-
-Description:
-HTTP-Header manipulator and form variable preprocessor
-
-FileId:
-$Id$
-
-ToDo:
-- Cookie handling
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-
-module("ffluci.http", package.seeall)
-
-if ENV and ENV.HASERLVER then
- require("ffluci.sgi.haserl")
-elseif webuci then
- require("ffluci.sgi.webuci")
-end
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - Internationalisation
-
-Description:
-A very minimalistic but yet effective internationalisation module
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-
-module("ffluci.i18n", package.seeall)
-require("ffluci.sys")
-
-table = {}
-i18ndir = ffluci.sys.libpath() .. "/i18n/"
-
--- Clears the translation table
-function clear()
- table = {}
-end
-
--- Loads a translation and copies its data into the global translation table
-function load(file)
- local f = loadfile(i18ndir .. file)
- if f then
- setfenv(f, table)
- f()
- return true
- else
- return false
- end
-end
-
--- Same as load but autocompletes the filename with .LANG from config.lang
-function loadc(file)
- return load(file .. "." .. require("ffluci.config").main.lang)
-end
-
--- Returns the i18n-value defined by "key" or if there is no such: "default"
-function translate(key, default)
- return table[key] or default
-end
\ No newline at end of file
+++ /dev/null
-cbi_add = "Add entry"
-cbi_del = "Remove entry"
-cbi_invalid = "Error: Invalid input value"
-cbi_addopt = "-- Field --"
\ No newline at end of file
+++ /dev/null
-add = "Add"
-save = "Save"
-reset = "Reset"
-
-load = "Load"
-webif = "Webinterface"
-public = "Public"
-admin = "Administration"
-apply = "Apply"
-changes = "Changes"
-revert = "Revert"
-
-index = "Overview"
-system = "System"
-services = "Services"
-network = "Network"
-wifi = "Wifi"
-status = "Status"
-statistic = "Statistic"
-
-config = "Configuration"
-path = "Path"
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - Freifunk Lua Configuration Interface
-
-Description:
-This is the init file
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-module("ffluci", package.seeall)
-
-__version__ = "0.4"
-__appname__ = "FFLuCI"
+++ /dev/null
---[[
-FFLuCI - Menu Builder
-
-Description:
-Collects menu building information from controllers
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-module("ffluci.menu", package.seeall)
-
-require("ffluci.fs")
-require("ffluci.util")
-require("ffluci.sys")
-
--- Default modelpath
-modelpath = ffluci.sys.libpath() .. "/model/menu/"
-
--- Menu definition extra scope
-scope = {
- translate = function(...) return require("ffluci.i18n").translate(...) end,
- loadtrans = function(...) return require("ffluci.i18n").loadc(...) end,
- isfile = ffluci.fs.isfile
-}
-
--- Local menu database
-local menu = nil
-
--- The current pointer
-local menuc = {}
-
--- Adds a menu category to the current menu and selects it
-function add(cat, controller, title, order)
- order = order or 100
- if not menu[cat] then
- menu[cat] = {}
- end
-
- local entry = {}
- entry[".descr"] = title
- entry[".order"] = order
- entry[".contr"] = controller
-
- menuc = entry
-
- local i = 0
- for k,v in ipairs(menu[cat]) do
- if v[".order"] > entry[".order"] then
- break
- end
- i = k
- end
- table.insert(menu[cat], i+1, entry)
-
- return true
-end
-
--- Adds an action to the current menu
-function act(action, title)
- table.insert(menuc, {action = action, descr = title})
- return true
-end
-
--- Selects a menu category
-function sel(cat, controller)
- if not menu[cat] then
- return nil
- end
- menuc = menu[cat]
-
- local stat = nil
- for k,v in ipairs(menuc) do
- if v[".contr"] == controller then
- menuc = v
- stat = true
- end
- end
-
- return stat
-end
-
-
--- Collect all menu information provided in the model dir
-function collect()
- local generators = {}
-
- for k, menu in pairs(ffluci.fs.dir(modelpath)) do
- if menu:sub(1, 1) ~= "." then
- local f = loadfile(modelpath.."/"..menu)
- if f then
- table.insert(generators, f)
- end
- end
- end
-
- return generators
-end
-
--- Parse the collected information
-function parse(generators)
- menu = {}
- for i, f in pairs(generators) do
- local env = ffluci.util.clone(scope)
-
- env.add = add
- env.sel = sel
- env.act = act
-
- setfenv(f, env)
- f()
- end
- return menu
-end
-
--- Returns the menu information
-function get()
- if not menu then
- menu = parse(collect())
- end
- return menu
-end
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - IPKG wrapper library
-
-Description:
-Wrapper for the ipkg Package manager
-
-Any return value of false or nil can be interpreted as an error
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-module("ffluci.model.ipkg", package.seeall)
-require("ffluci.sys")
-require("ffluci.util")
-
-ipkg = "ipkg"
-
--- Returns repository information
-function info(pkg)
- return _lookup("info", pkg)
-end
-
--- Returns a table with status information
-function status(pkg)
- return _lookup("status", pkg)
-end
-
--- Installs packages
-function install(...)
- return _action("install", ...)
-end
-
--- Returns whether a package is installed
-function installed(pkg, ...)
- local p = status(...)[pkg]
- return (p and p.Status and p.Status.installed)
-end
-
--- Removes packages
-function remove(...)
- return _action("remove", ...)
-end
-
--- Updates package lists
-function update()
- return _action("update")
-end
-
--- Upgrades installed packages
-function upgrade()
- return _action("upgrade")
-end
-
-
--- Internal action function
-function _action(cmd, ...)
- local pkg = ""
- arg.n = nil
- for k, v in pairs(arg) do
- pkg = pkg .. " '" .. v:gsub("'", "") .. "'"
- end
-
- local c = ipkg.." "..cmd.." "..pkg.." >/dev/null 2>&1"
- local r = os.execute(c)
- return (r == 0), r
-end
-
--- Internal lookup function
-function _lookup(act, pkg)
- local cmd = ipkg .. " " .. act
- if pkg then
- cmd = cmd .. " '" .. pkg:gsub("'", "") .. "'"
- end
-
- return _parselist(ffluci.sys.exec(cmd .. " 2>/dev/null"))
-end
-
--- Internal parser function
-function _parselist(rawdata)
- if type(rawdata) ~= "string" then
- error("IPKG: Invalid rawdata given")
- end
-
- rawdata = ffluci.util.split(rawdata)
- local data = {}
- local c = {}
- local l = nil
-
- for k, line in pairs(rawdata) do
- if line:sub(1, 1) ~= " " then
- local split = ffluci.util.split(line, ":", 1)
- local key = nil
- local val = nil
-
- if split[1] then
- key = ffluci.util.trim(split[1])
- end
-
- if split[2] then
- val = ffluci.util.trim(split[2])
- end
-
- if key and val then
- if key == "Package" then
- c = {Package = val}
- data[val] = c
- elseif key == "Status" then
- c.Status = {}
- for i, j in pairs(ffluci.util.split(val, " ")) do
- c.Status[j] = true
- end
- else
- c[key] = val
- end
- l = key
- end
- else
- -- Multi-line field
- c[l] = c[l] .. "\n" .. line:sub(2)
- end
- end
-
- return data
-end
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - UCI mpdel
-
-Description:
-Generalized UCI model
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-module("ffluci.model.uci", package.seeall)
-
--- Default savedir
-savedir = "/tmp/.uci"
-
--- Test whether to load libuci-Wrapper or /sbin/uci-Wrapper
-if pcall(require, "uci") then
- Session = require("ffluci.model.uci.libuci").Session
-else
- Session = require("ffluci.model.uci.wrapper").Session
-end
-
--- The default Session
-local default = Session()
-local state = Session("/var/state")
-
--- The state Session
-function StateSession()
- return state
-end
-
-
--- Wrapper for "uci add"
-function add(...)
- return default:add(...)
-end
-
-
--- Wrapper for "uci changes"
-function changes(...)
- return default:changes(...)
-end
-
--- Wrapper for "uci commit"
-function commit(...)
- return default:commit(...)
-end
-
-
--- Wrapper for "uci del"
-function del(...)
- return default:del(...)
-end
-
-
--- Wrapper for "uci get"
-function get(...)
- return default:get(...)
-end
-
-
--- Wrapper for "uci revert"
-function revert(...)
- return default:revert(...)
-end
-
-
--- Wrapper for "uci show"
-function sections(...)
- return default:sections(...)
-end
-
-
--- Wrapper for "uci set"
-function set(...)
- return default:set(...)
-end
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - UCI libuci wrapper
-
-Description:
-Wrapper for the libuci Lua bindings
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-
-module("ffluci.model.uci.libuci", package.seeall)
-
-require("uci")
-require("ffluci.util")
-require("ffluci.sys")
-
--- Session class
-Session = ffluci.util.class()
-
--- Session constructor
-function Session.__init__(self, savedir)
- self.ucicmd = savedir and "uci -P " .. savedir or "uci"
- self.savedir = savedir or ffluci.model.uci.savedir
-end
-
-function Session.add(self, config, section_type)
- return self:_uci("add " .. _path(config) .. " " .. _path(section_type))
-end
-
-function Session.changes(self, config)
- return self:_uci("changes " .. _path(config))
-end
-
-function Session.commit(self, config)
- self:t_load(config)
- return self:t_commit(config)
-end
-
-function Session.del(self, config, section, option)
- return self:_uci2("del " .. _path(config, section, option))
-end
-
-function Session.get(self, config, section, option)
- self:t_load(config)
- return self:t_get(config, section, option)
-end
-
-function Session.revert(self, config)
- self:t_load(config)
- return self:t_revert(config)
-end
-
-function Session.sections(self, config)
- self:t_load(config)
- return self:t_sections(config)
-end
-
-function Session.set(self, config, section, option, value)
- self:t_load(config)
- return self:t_set(config, section, option, value) and self:t_save(config)
-end
-
-function Session.synchronize(self)
- return uci.set_savedir(self.savedir)
-end
-
-
--- UCI-Transactions
-
-function Session.t_load(self, config)
- return self:synchronize() and uci.load(config)
-end
-
-function Session.t_save(self, config)
- return uci.save(config)
-end
-
-function Session.t_add(self, config, type)
- self:t_save(config)
- local r = self:add(config, type)
- self:t_load(config)
- return r
-end
-
-function Session.t_commit(self, config)
- return uci.commit(config)
-end
-
-function Session.t_del(self, config, section, option)
- self:t_save(config)
- local r = self:del(config, section, option)
- self:t_load(config)
- return r
-end
-
-function Session.t_get(self, config, section, option)
- if option then
- return uci.get(config, section, option)
- else
- return uci.get(config, section)
- end
-end
-
-function Session.t_revert(self, config)
- return uci.revert(config)
-end
-
-function Session.t_sections(self, config)
- local raw = uci.get_all(config)
- if not raw then
- return nil
- end
-
- local s = {}
- local o = {}
-
- for i, sec in ipairs(raw) do
- table.insert(o, sec.name)
-
- s[sec.name] = sec.options
- s[sec.name][".type"] = sec.type
- end
-
- return s, o
-end
-
-function Session.t_set(self, config, section, option, value)
- if option then
- return uci.set(config.."."..section.."."..option.."="..value)
- else
- return uci.set(config.."."..section.."="..value)
- end
-end
-
--- Internal functions --
-
-
-function Session._uci(self, cmd)
- local res = ffluci.sys.exec(self.ucicmd .. " 2>/dev/null " .. cmd)
-
- if res:len() == 0 then
- return nil
- else
- return res:sub(1, res:len()-1)
- end
-end
-
-function Session._uci2(self, cmd)
- local res = ffluci.sys.exec(self.ucicmd .. " 2>&1 " .. cmd)
-
- if res:len() > 0 then
- return false, res
- else
- return true
- end
-end
-
--- Build path (config.section.option=value) and prevent command injection
-function _path(...)
- local result = ""
-
- -- Not using ipairs because it is not reliable in case of nil arguments
- arg.n = nil
- for k,v in pairs(arg) do
- if v then
- v = tostring(v)
- if k == 1 then
- result = "'" .. v:gsub("['.]", "") .. "'"
- elseif k < 4 then
- result = result .. ".'" .. v:gsub("['.]", "") .. "'"
- elseif k == 4 then
- result = result .. "='" .. v:gsub("'", "") .. "'"
- end
- end
- end
- return result
-end
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - UCI wrapper library
-
-Description:
-Wrapper for the /sbin/uci application, syntax of implemented functions
-is comparable to the syntax of the uci application
-
-Any return value of false or nil can be interpreted as an error
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-
-module("ffluci.model.uci.wrapper", package.seeall)
-
-require("ffluci.util")
-require("ffluci.sys")
-
--- Session class
-Session = ffluci.util.class()
-
--- Session constructor
-function Session.__init__(self, savedir)
- self.ucicmd = savedir and "uci -P " .. savedir or "uci"
-end
-
-function Session.add(self, config, section_type)
- return self:_uci("add " .. _path(config) .. " " .. _path(section_type))
-end
-
-function Session.changes(self, config)
- return self:_uci("changes " .. _path(config))
-end
-
-function Session.commit(self, config)
- return self:_uci2("commit " .. _path(config))
-end
-
-function Session.del(self, config, section, option)
- return self:_uci2("del " .. _path(config, section, option))
-end
-
-function Session.get(self, config, section, option)
- return self:_uci("get " .. _path(config, section, option))
-end
-
-function Session.revert(self, config)
- return self:_uci2("revert " .. _path(config))
-end
-
-function Session.sections(self, config)
- if not config then
- return nil
- end
-
- local r1, r2 = self:_uci3("show " .. _path(config))
- if type(r1) == "table" then
- return r1, r2
- else
- return nil, r2
- end
-end
-
-function Session.set(self, config, section, option, value)
- return self:_uci2("set " .. _path(config, section, option, value))
-end
-
-function Session.synchronize(self) end
-
--- Dummy transaction functions
-
-function Session.t_load(self) end
-function Session.t_save(self) end
-
-Session.t_add = Session.add
-Session.t_commit = Session.commit
-Session.t_del = Session.del
-Session.t_get = Session.get
-Session.t_revert = Session.revert
-Session.t_sections = Session.sections
-Session.t_set = Session.set
-
-
-
-
-
--- Internal functions --
-
-
-function Session._uci(self, cmd)
- local res = ffluci.sys.exec(self.ucicmd .. " 2>/dev/null " .. cmd)
-
- if res:len() == 0 then
- return nil
- else
- return res:sub(1, res:len()-1)
- end
-end
-
-function Session._uci2(self, cmd)
- local res = ffluci.sys.exec(self.ucicmd .. " 2>&1 " .. cmd)
-
- if res:len() > 0 then
- return false, res
- else
- return true
- end
-end
-
-function Session._uci3(self, cmd)
- local res = ffluci.sys.execl(self.ucicmd .. " 2>&1 " .. cmd)
- if res[1] and res[1]:sub(1, self.ucicmd:len()+1) == self.ucicmd..":" then
- return nil, res[1]
- end
-
- local tbl = {}
- local ord = {}
-
- for k,line in pairs(res) do
- c, s, t = line:match("^([^.]-)%.([^.]-)=(.-)$")
- if c then
- tbl[s] = {}
- table.insert(ord, s)
- tbl[s][".type"] = t
- end
-
- c, s, o, v = line:match("^([^.]-)%.([^.]-)%.([^.]-)=(.-)$")
- if c then
- tbl[s][o] = v
- end
- end
-
- return tbl, ord
-end
-
--- Build path (config.section.option=value) and prevent command injection
-function _path(...)
- local result = ""
-
- -- Not using ipairs because it is not reliable in case of nil arguments
- arg.n = nil
- for k,v in pairs(arg) do
- if v then
- v = tostring(v)
- if k == 1 then
- result = "'" .. v:gsub("['.]", "") .. "'"
- elseif k < 4 then
- result = result .. ".'" .. v:gsub("['.]", "") .. "'"
- elseif k == 4 then
- result = result .. "='" .. v:gsub("'", "") .. "'"
- end
- end
- end
- return result
-end
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - SGI-Module for Haserl
-
-Description:
-Server Gateway Interface for Haserl
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-module("ffluci.sgi.haserl", package.seeall)
-
--- Environment Table
-ffluci.http.env = ENV
-
-
--- Returns a table of all COOKIE, GET and POST Parameters
-function ffluci.http.formvalues()
- return FORM
-end
-
--- Gets form value from key
-function ffluci.http.formvalue(key, default)
- local c = ffluci.http.formvalues()
-
- for match in key:gmatch("[%w-_]+") do
- c = c[match]
- if c == nil then
- return default
- end
- end
-
- return c
-end
-
--- Gets a table of values with a certain prefix
-function ffluci.http.formvaluetable(prefix)
- return ffluci.http.formvalue(prefix, {})
-end
-
--- Sends a custom HTTP-Header
-function ffluci.http.header(key, value)
- print(key .. ": " .. value)
-end
-
--- Set Content-Type
-function ffluci.http.prepare_content(type)
- print("Content-Type: "..type.."\n")
-end
-
--- Asks the browser to redirect to "url"
-function ffluci.http.redirect(url)
- ffluci.http.status(302, "Found")
- ffluci.http.header("Location", url)
- print()
-end
-
--- Sets HTTP-Status-Header
-function ffluci.http.status(code, message)
- print("Status: " .. tostring(code) .. " " .. message)
-end
+++ /dev/null
---[[
-FFLuCI - SGI-Module for Haserl
-
-Description:
-Server Gateway Interface for Haserl
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-module("ffluci.sgi.webuci", package.seeall)
-
--- Environment Table
-ffluci.http.env = webuci.env
-
-
-local status_set = false
-
--- Returns a table of all COOKIE, GET and POST Parameters
-function ffluci.http.formvalues()
- return webuci.vars
-end
-
--- Gets form value from key
-function ffluci.http.formvalue(key, default)
- return ffluci.http.formvalues()[key] or default
-end
-
--- Gets a table of values with a certain prefix
-function ffluci.http.formvaluetable(prefix)
- local vals = {}
- prefix = prefix and prefix .. "." or "."
-
- for k, v in pairs(ffluci.http.formvalues()) do
- if k:find(prefix, 1, true) == 1 then
- vals[k:sub(#prefix + 1)] = v
- end
- end
-
- return vals
-end
-
--- Sends a custom HTTP-Header
-function ffluci.http.header(key, value)
- print(key .. ": " .. value)
-end
-
--- Set Content-Type
-function ffluci.http.prepare_content(type)
- if not status_set then
- ffluci.http.status(200, "OK")
- end
-
- print("Content-Type: "..type.."\n")
-end
-
--- Asks the browser to redirect to "url"
-function ffluci.http.redirect(url)
- ffluci.http.status(302, "Found")
- ffluci.http.header("Location", url)
- print()
-end
-
--- Sets HTTP-Status-Header
-function ffluci.http.status(code, message)
- print(webuci.env.SERVER_PROTOCOL .. " " .. tostring(code) .. " " .. message)
- status_set = true
-end
+++ /dev/null
---[[
-FFLuCI - System library
-
-Description:
-Utilities for interaction with the Linux system
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-
-module("ffluci.sys", package.seeall)
-require("posix")
-require("ffluci.bits")
-require("ffluci.util")
-
--- Returns whether a system is bigendian
-function bigendian()
- local fp = io.open("/bin/sh")
- fp:seek("set", 5)
- return (fp:read(1):byte() ~= 1)
-end
-
--- Runs "command" and returns its output
-function exec(command)
- local pp = io.popen(command)
- local data = pp:read("*a")
- pp:close()
-
- return data
-end
-
--- Runs "command" and returns its output as a array of lines
-function execl(command)
- local pp = io.popen(command)
- local line = ""
- local data = {}
-
- while true do
- line = pp:read()
- if (line == nil) then break end
- table.insert(data, line)
- end
- pp:close()
-
- return data
-end
-
--- Uses "ffluci-flash" to flash a new image file to the system
-function flash(image, kpattern)
- local cmd = "ffluci-flash "
- if kpattern then
- cmd = cmd .. "-k '" .. kpattern:gsub("'", "") .. "' "
- end
- cmd = cmd .. "'" .. image:gsub("'", "") .. "' >/dev/null 2>&1"
-
- return os.execute(cmd)
-end
-
--- Returns the hostname
-function hostname()
- return io.lines("/proc/sys/kernel/hostname")()
-end
-
--- Returns the contents of a documented referred by an URL
-function httpget(url)
- return exec("wget -qO- '"..url:gsub("'", "").."'")
-end
-
--- Returns the FFLuci-Basedir
-function libpath()
- return ffluci.fs.dirname(require("ffluci.debug").__file__)
-end
-
--- Returns the load average
-function loadavg()
- local loadavg = io.lines("/proc/loadavg")()
- return loadavg:match("^(.-) (.-) (.-) (.-) (.-)$")
-end
-
--- Reboots the system
-function reboot()
- return os.execute("reboot >/dev/null 2>&1")
-end
-
--- Returns the system type, cpu name, and installed physical memory
-function sysinfo()
- local c1 = "cat /proc/cpuinfo|grep system\\ typ|cut -d: -f2 2>/dev/null"
- local c2 = "uname -m 2>/dev/null"
- local c3 = "cat /proc/cpuinfo|grep model\\ name|cut -d: -f2 2>/dev/null"
- local c4 = "cat /proc/cpuinfo|grep cpu\\ model|cut -d: -f2 2>/dev/null"
- local c5 = "cat /proc/meminfo|grep MemTotal|cut -d: -f2 2>/dev/null"
-
- local s = ffluci.util.trim(exec(c1))
- local m = ""
- local r = ""
-
- if s == "" then
- s = ffluci.util.trim(exec(c2))
- m = ffluci.util.trim(exec(c3))
- else
- m = ffluci.util.trim(exec(c4))
- end
-
- r = ffluci.util.trim(exec(c5))
-
- return s, m, r
-end
-
-
-group = {}
-group.getgroup = posix.getgroup
-
-net = {}
--- Returns the ARP-Table
-function net.arptable()
- return _parse_delimited_table(io.lines("/proc/net/arp"), "%s%s+")
-end
-
--- Returns whether an IP-Adress belongs to a certain net
-function net.belongs(ip, ipnet, prefix)
- return (net.ip4bin(ip):sub(1, prefix) == net.ip4bin(ipnet):sub(1, prefix))
-end
-
--- Detect the default route
-function net.defaultroute()
- local routes = net.routes()
- local route = nil
-
- for i, r in pairs(ffluci.sys.net.routes()) do
- if r.Destination == "00000000" and (not route or route.Metric > r.Metric) then
- route = r
- end
- end
-
- return route
-end
-
--- Returns all available network interfaces
-function net.devices()
- local devices = {}
- for line in io.lines("/proc/net/dev") do
- table.insert(devices, line:match(" *(.-):"))
- end
- return devices
-end
-
--- Returns the MAC-Address belonging to the given IP-Address
-function net.ip4mac(ip)
- local mac = nil
-
- for i, l in ipairs(net.arptable()) do
- if l["IP address"] == ip then
- mac = l["HW address"]
- end
- end
-
- return mac
-end
-
--- Returns the prefix to a given netmask
-function net.mask4prefix(mask)
- local bin = net.ip4bin(mask)
-
- if not bin then
- return nil
- end
-
- return #ffluci.util.split(bin, "1")-1
-end
-
--- Returns the kernel routing table
-function net.routes()
- return _parse_delimited_table(io.lines("/proc/net/route"))
-end
-
--- Returns the numeric IP to a given hexstring
-function net.hexip4(hex, be)
- if #hex ~= 8 then
- return nil
- end
-
- be = be or bigendian()
-
- local hexdec = ffluci.bits.Hex2Dec
-
- local ip = ""
- if be then
- ip = ip .. tostring(hexdec(hex:sub(1,2))) .. "."
- ip = ip .. tostring(hexdec(hex:sub(3,4))) .. "."
- ip = ip .. tostring(hexdec(hex:sub(5,6))) .. "."
- ip = ip .. tostring(hexdec(hex:sub(7,8)))
- else
- ip = ip .. tostring(hexdec(hex:sub(7,8))) .. "."
- ip = ip .. tostring(hexdec(hex:sub(5,6))) .. "."
- ip = ip .. tostring(hexdec(hex:sub(3,4))) .. "."
- ip = ip .. tostring(hexdec(hex:sub(1,2)))
- end
-
- return ip
-end
-
--- Returns the binary IP to a given IP
-function net.ip4bin(ip)
- local parts = ffluci.util.split(ip, '.')
- if #parts ~= 4 then
- return nil
- end
-
- local decbin = ffluci.bits.Dec2Bin
-
- local bin = ""
- bin = bin .. decbin(parts[1], 8)
- bin = bin .. decbin(parts[2], 8)
- bin = bin .. decbin(parts[3], 8)
- bin = bin .. decbin(parts[4], 8)
-
- return bin
-end
-
--- Tests whether a host is pingable
-function net.pingtest(host)
- return os.execute("ping -c1 '"..host:gsub("'", '').."' >/dev/null 2>&1")
-end
-
-
-process = {}
-process.info = posix.getpid
-
--- Sets the gid of a process
-function process.setgroup(pid, gid)
- return posix.setpid("g", pid, gid)
-end
-
--- Sets the uid of a process
-function process.setuser(pid, uid)
- return posix.setpid("u", pid, uid)
-end
-
-user = {}
--- returns user information to a given uid
-user.getuser = posix.getpasswd
-
--- Changes the user password of given user
-function user.setpasswd(user, pwd)
- if pwd then
- pwd = pwd:gsub("'", "")
- end
-
- if user then
- user = user:gsub("'", "")
- end
-
- local cmd = "(echo '"..pwd.."';sleep 1;echo '"..pwd.."')|"
- cmd = cmd .. "passwd '"..user.."' >/dev/null 2>&1"
- return os.execute(cmd)
-end
-
-
-wifi = {}
-
-function wifi.getiwconfig()
- local cnt = exec("/usr/sbin/iwconfig 2>/dev/null")
- local iwc = {}
-
- for i, l in pairs(ffluci.util.split(ffluci.util.trim(cnt), "\n\n")) do
- local k = l:match("^(.-) ")
- l = l:gsub("^(.-) +", "", 1)
- if k then
- iwc[k] = _parse_mixed_record(l)
- end
- end
-
- return iwc
-end
-
-function wifi.iwscan()
- local cnt = exec("iwlist scan 2>/dev/null")
- local iws = {}
-
- for i, l in pairs(ffluci.util.split(ffluci.util.trim(cnt), "\n\n")) do
- local k = l:match("^(.-) ")
- l = l:gsub("^[^\n]+", "", 1)
- l = ffluci.util.trim(l)
- if k then
- iws[k] = {}
- for j, c in pairs(ffluci.util.split(l, "\n Cell")) do
- c = c:gsub("^(.-)- ", "", 1)
- c = ffluci.util.split(c, "\n", 7)
- c = table.concat(c, "\n", 1)
- table.insert(iws[k], _parse_mixed_record(c))
- end
- end
- end
-
- return iws
-end
-
-
--- Internal functions
-
-function _parse_delimited_table(iter, delimiter)
- delimiter = delimiter or "%s+"
-
- local data = {}
- local trim = ffluci.util.trim
- local split = ffluci.util.split
-
- local keys = split(trim(iter()), delimiter, nil, true)
- for i, j in pairs(keys) do
- keys[i] = trim(keys[i])
- end
-
- for line in iter do
- local row = {}
- line = trim(line)
- if #line > 0 then
- for i, j in pairs(split(line, delimiter, nil, true)) do
- if keys[i] then
- row[keys[i]] = j
- end
- end
- end
- table.insert(data, row)
- end
-
- return data
-end
-
-function _parse_mixed_record(cnt)
- local data = {}
-
- for i, l in pairs(ffluci.util.split(ffluci.util.trim(cnt), "\n")) do
- for j, f in pairs(ffluci.util.split(ffluci.util.trim(l), " ")) do
- local k, x, v = f:match('([^%s][^:=]+) *([:=]*) *"*([^\n"]*)"*')
-
- if k then
- if x == "" then
- table.insert(data, k)
- else
- data[k] = v
- end
- end
- end
- end
-
- return data
-end
\ No newline at end of file
+++ /dev/null
---[[
-FFLuCI - Template Parser
-
-Description:
-A template parser supporting includes, translations, Lua code blocks
-and more. It can be used either as a compiler or as an interpreter.
-
-FileId: $Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-module("ffluci.template", package.seeall)
-
-require("ffluci.config")
-require("ffluci.util")
-require("ffluci.fs")
-require("ffluci.http")
-
-viewdir = ffluci.sys.libpath() .. "/view/"
-
-
--- Compile modes:
--- none: Never compile, only use precompiled data from files
--- memory: Always compile, do not save compiled files, ignore precompiled
--- file: Compile on demand, save compiled files, update precompiled
-compiler_mode = "memory"
-
-
--- This applies to compiler modes "always" and "smart"
---
--- Produce compiled lua code rather than lua sourcecode
--- WARNING: Increases template size heavily!!!
--- This produces the same bytecode as luac but does not have a strip option
-compiler_enable_bytecode = false
-
-
--- Define the namespace for template modules
-viewns = {
- translate = function(...) return require("ffluci.i18n").translate(...) end,
- config = function(...) return require("ffluci.model.uci").get(...) or "" end,
- controller = ffluci.http.env.SCRIPT_NAME,
- media = ffluci.config.main.mediaurlbase,
- write = io.write,
- include = function(name) Template(name):render(getfenv(2)) end,
-}
-
--- Compiles a given template into an executable Lua module
-function compile(template)
- -- Search all <% %> expressions (remember: Lua table indexes begin with #1)
- local function expr_add(command)
- table.insert(expr, command)
- return "<%" .. tostring(#expr) .. "%>"
- end
-
- -- As "expr" should be local, we have to assign it to the "expr_add" scope
- local expr = {}
- ffluci.util.extfenv(expr_add, "expr", expr)
-
- -- Save all expressiosn to table "expr"
- template = template:gsub("<%%(.-)%%>", expr_add)
-
- local function sanitize(s)
- s = ffluci.util.escape(s)
- s = ffluci.util.escape(s, "'")
- s = ffluci.util.escape(s, "\n")
- return s
- end
-
- -- Escape and sanitize all the template (all non-expressions)
- template = sanitize(template)
-
- -- Template module header/footer declaration
- local header = "write('"
- local footer = "')"
-
- template = header .. template .. footer
-
- -- Replacements
- local r_include = "')\ninclude('%s')\nwrite('"
- local r_i18n = "'..translate('%1','%2')..'"
- local r_uci = "'..config('%1','%2','%3')..'"
- local r_pexec = "'..(%s or '')..'"
- local r_exec = "')\n%s\nwrite('"
-
- -- Parse the expressions
- for k,v in pairs(expr) do
- local p = v:sub(1, 1)
- local re = nil
- if p == "+" then
- re = r_include:format(sanitize(string.sub(v, 2)))
- elseif p == ":" then
- re = sanitize(v):gsub(":(.-) (.+)", r_i18n)
- elseif p == "~" then
- re = sanitize(v):gsub("~(.-)%.(.-)%.(.+)", r_uci)
- elseif p == "=" then
- re = r_pexec:format(v:sub(2))
- else
- re = r_exec:format(v)
- end
- template = template:gsub("<%%"..tostring(k).."%%>", re)
- end
-
- if compiler_enable_bytecode then
- tf = loadstring(template)
- template = string.dump(tf)
- end
-
- return template
-end
-
--- Oldstyle render shortcut
-function render(name, scope, ...)
- scope = scope or getfenv(2)
- local s, t = pcall(Template, name)
- if not s then
- error(t)
- else
- t:render(scope, ...)
- end
-end
-
-
--- Template class
-Template = ffluci.util.class()
-
--- Shared template cache to store templates in to avoid unnecessary reloading
-Template.cache = {}
-
-
--- Constructor - Reads and compiles the template on-demand
-function Template.__init__(self, name)
- if self.cache[name] then
- self.template = self.cache[name]
- else
- self.template = nil
- end
-
- -- Create a new namespace for this template
- self.viewns = {}
-
- -- Copy over from general namespace
- for k, v in pairs(viewns) do
- self.viewns[k] = v
- end
-
- -- If we have a cached template, skip compiling and loading
- if self.template then
- return
- end
-
- -- Compile and build
- local sourcefile = viewdir .. name .. ".htm"
- local compiledfile = viewdir .. name .. ".lua"
- local err
-
- if compiler_mode == "file" then
- local tplmt = ffluci.fs.mtime(sourcefile)
- local commt = ffluci.fs.mtime(compiledfile)
-
- -- Build if there is no compiled file or if compiled file is outdated
- if ((commt == nil) and not (tplmt == nil))
- or (not (commt == nil) and not (tplmt == nil) and commt < tplmt) then
- local source
- source, err = ffluci.fs.readfile(sourcefile)
-
- if source then
- local compiled = compile(source)
- ffluci.fs.writefile(compiledfile, compiled)
- self.template, err = loadstring(compiled)
- end
- else
- self.template, err = loadfile(compiledfile)
- end
-
- elseif compiler_mode == "none" then
- self.template, err = loadfile(self.compiledfile)
-
- elseif compiler_mode == "memory" then
- local source
- source, err = ffluci.fs.readfile(sourcefile)
- if source then
- self.template, err = loadstring(compile(source))
- end
-
- end
-
- -- If we have no valid template throw error, otherwise cache the template
- if not self.template then
- error(err)
- else
- self.cache[name] = self.template
- end
-end
-
-
--- Renders a template
-function Template.render(self, scope)
- scope = scope or getfenv(2)
-
- -- Save old environment
- local oldfenv = getfenv(self.template)
-
- -- Put our predefined objects in the scope of the template
- ffluci.util.resfenv(self.template)
- ffluci.util.updfenv(self.template, scope)
- ffluci.util.updfenv(self.template, self.viewns)
-
- -- Now finally render the thing
- self.template()
-
- -- Reset environment
- setfenv(self.template, oldfenv)
-end
+++ /dev/null
---[[
-FFLuCI - Utility library
-
-Description:
-Several common useful Lua functions
-
-FileId:
-$Id$
-
-License:
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-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
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-]]--
-
-module("ffluci.util", package.seeall)
-
-
--- Lua simplified Python-style OO class support emulation
-function class(base)
- local class = {}
-
- local create = function(class, ...)
- local inst = {}
- setmetatable(inst, {__index = class})
-
- if inst.__init__ then
- local stat, err = pcall(inst.__init__, inst, ...)
- if not stat then
- error(err)
- end
- end
-
- return inst
- end
-
- local classmeta = {__call = create}
-
- if base then
- classmeta.__index = base
- end
-
- setmetatable(class, classmeta)
- return class
-end
-
-
--- Clones an object (deep on-demand)
-function clone(object, deep)
- local copy = {}
-
- for k, v in pairs(object) do
- if deep and type(v) == "table" then
- v = clone(v, deep)
- end
- copy[k] = v
- end
-
- setmetatable(copy, getmetatable(object))
-
- return copy
-end
-
-
--- Checks whether a table has an object "value" in it
-function contains(table, value)
- for k,v in pairs(table) do
- if value == v then
- return true
- end
- end
- return false
-end
-
-
--- Dumps a table to stdout (useful for testing and debugging)
-function dumptable(t, i)
- i = i or 0
- for k,v in pairs(t) do
- print(string.rep("\t", i) .. k, v)
- if type(v) == "table" then
- dumptable(v, i+1)
- end
- end
-end
-
-
--- Escapes all occurences of c in s
-function escape(s, c)
- c = c or "\\"
- return s:gsub(c, "\\" .. c)
-end
-
-
--- Populate obj in the scope of f as key
-function extfenv(f, key, obj)
- local scope = getfenv(f)
- scope[key] = obj
-end
-
-
--- Checks whether an object is an instanceof class
-function instanceof(object, class)
- local meta = getmetatable(object)
- while meta and meta.__index do
- if meta.__index == class then
- return true
- end
- meta = getmetatable(meta.__index)
- end
- return false
-end
-
-
--- Creates valid XML PCDATA from a string
-function pcdata(value)
- value = value:gsub("&", "&")
- value = value:gsub('"', """)
- value = value:gsub("'", "'")
- value = value:gsub("<", "<")
- return value:gsub(">", ">")
-end
-
-
--- Resets the scope of f doing a shallow copy of its scope into a new table
-function resfenv(f)
- setfenv(f, clone(getfenv(f)))
-end
-
-
--- Splits a string into an array
-function split(str, pat, max, regex)
- pat = pat or "\n"
- max = max or #str
-
- local t = {}
- local c = 1
-
- if #str == 0 then
- return {""}
- end
-
- if #pat == 0 then
- return nil
- end
-
- if max == 0 then
- return str
- end
-
- repeat
- local s, e = str:find(pat, c, not regex)
- table.insert(t, str:sub(c, s and s - 1))
- max = max - 1
- c = e and e + 1 or #str + 1
- until not s or max < 0
-
- return t
-end
-
--- Removes whitespace from beginning and end of a string
-function trim(str)
- local s = str:gsub("^%s*(.-)%s*$", "%1")
- return s
-end
-
--- Updates given table with new values
-function update(t, updates)
- for k, v in pairs(updates) do
- t[k] = v
- end
-end
-
-
--- Updates the scope of f with "extscope"
-function updfenv(f, extscope)
- update(getfenv(f), extscope)
-end
-
-
--- Validates a variable
-function validate(value, cast_number, cast_int)
- if cast_number or cast_int then
- value = tonumber(value)
- end
-
- if cast_int and value and not(value % 1 == 0) then
- value = nil
- end
-
- return value
-end
\ No newline at end of file
+++ /dev/null
-<%+cbi/valueheader%>
-<% if self.value then
- if type(self.value) == "function" then %>
- <%=self:value(section)%>
-<% else %>
- <%=self.value%>
-<% end
-else %>
- <%=self:cfgvalue(section)%>
-<% end %>
-
-<%+cbi/valuefooter%>
+++ /dev/null
- <div>
- <input type="submit" value="<%:save Speichern%>" />
- <input type="reset" value="<%:reset Zurücksetzen%>" />
- <script type="text/javascript">cbi_d_init();</script>
- </div>
- </form>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+cbi/valueheader%>
- <input onchange="cbi_d_update(this.id)" type="checkbox" id="cbid.<%=self.config.."."..section.."."..self.option%>" name="cbid.<%=self.config.."."..section.."."..self.option%>"<% if self:cfgvalue(section) == self.enabled then %> checked="checked"<% end %> value="1" />
-<%+cbi/valuefooter%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
- <form method="post" action="<%=ffluci.http.env.REQUEST_URI%>">
- <div>
- <script type="text/javascript" src="<%=media%>/cbi.js"></script>
- <input type="hidden" name="cbi.submit" value="1" />
- <input type="submit" value="<%:save Speichern%>" class="hidden" />
- </div>
+++ /dev/null
-<%+cbi/valueheader%>
-<% if self.widget == "select" then %>
- <select onchange="cbi_d_update(this.id)" id="cbid.<%=self.config.."."..section.."."..self.option%>" name="cbid.<%=self.config.."."..section.."."..self.option%>"<% if self.size then %> size="<%=self.size%>"<% end %>>
-<%for i, key in pairs(self.keylist) do%>
- <option<% if self:cfgvalue(section) == key then %> selected="selected"<% end %> value="<%=key%>"><%=self.vallist[i]%></option>
-<% end %>
- </select>
-<% elseif self.widget == "radio" then
- local c = 0;
- for i, key in pairs(self.keylist) do
- c = c + 1%>
- <%=self.vallist[i]%><input type="radio" name="cbid.<%=self.config.."."..section.."."..self.option%>"<% if self:cfgvalue(section) == key then %> checked="checked"<% end %> value="<%=key%>" />
-<% if c == self.size then c = 0 %><br />
-<% end end %>
-<% end %>
-<%+cbi/valuefooter%>
\ No newline at end of file
+++ /dev/null
- <div class="cbi-map" id="cbi-<%=self.config%>">
- <h1><%=self.title%></h1>
- <div class="cbi-map-descr"><%=self.description%></div>
-<% self:render_children() %>
- <br />
- </div>
+++ /dev/null
-<%
-local v = self:valuelist(section)
-%>
-<%+cbi/valueheader%>
-<% if self.widget == "select" then %>
- <select multiple="multiple" name="cbid.<%=self.config.."."..section.."."..self.option%>[]"<% if self.size then %> size="<%=self.size%>"<% end %>>
-<%for i, key in pairs(self.keylist) do %>
- <option<% if ffluci.util.contains(v, key) then %> selected="selected"<% end %> value="<%=key%>"><%=self.vallist[i]%></option>
-<% end %>
- </select>
-<% elseif self.widget == "checkbox" then
- local c = 0;
- for i, key in pairs(self.keylist) do
- c = c + 1%>
- <%=self.vallist[i]%><input type="checkbox" name="cbid.<%=self.config.."."..section.."."..self.option%>[]"<% if ffluci.util.contains(v, key) then %> checked="checked"<% end %> value="<%=key%>" />
-<% if c == self.size then c = 0 %><br />
-<% end end %>
-<% end %>
-<%+cbi/valuefooter%>
\ No newline at end of file
+++ /dev/null
-<% if self:cfgvalue(self.section) then
-section = self.section %>
- <div class="cbi-section" id="cbi-<%=self.config%>-<%=section%>">
- <h2><%=self.title%></h2>
- <div class="cbi-section-descr"><%=self.description%></div>
- <% if self.addremove then %><div class="cbi-section-remove right">
- <input type="submit" name="cbi.rns.<%=self.config%>.<%=section%>" value="<%:cbi_del Eintrag entfernen%>" />
- </div><% end %>
-<%+cbi/ucisection%>
- </div>
-<% elseif self.addremove then %>
- <div class="cbi-section" id="cbi-<%=self.config%>-<%=self.section%>">
- <h2><%=self.title%></h2>
- <div class="cbi-section-descr"><%=self.description%></div>
- <input type="submit" name="cbi.cns.<%=self.config%>.<%=self.section%>" value="<%:cbi_add Eintrag anlegen%>" />
- </div>
-<% end %>
+++ /dev/null
- <div class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
- <h2><%=self.title%></h2>
- <div class="cbi-section-descr"><%=self.description%></div>
-<% for i, k in ipairs(self:cfgsections()) do%>
- <% if self.addremove then %><div class="cbi-section-remove right">
- <input type="submit" name="cbi.rts.<%=self.config%>.<%=k%>" value="<%:cbi_del Eintrag entfernen%>" />
- </div><% end %>
- <% if not self.anonymous then %><h3><%=k%></h3><% end %>
-<% section = k %>
-<%+cbi/ucisection%>
-<% end %>
-<% if self.addremove then %>
- <div class="cbi-section-create">
- <% if self.anonymous then %>
- <input type="submit" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" value="<%:cbi_add Eintrag hinzufügen%>" />
- <% else %>
- <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
- <input type="submit" value="<%:cbi_add Eintrag hinzufügen%>" />
- <% end %><% if self.err_invalid then %><div class="cbi-error"><%:cbi_invalid Fehler: Ungültige Eingabe%></div><% end %>
- </div>
-<% end %>
- </div>
+++ /dev/null
- <div class="cbi-section-node" id="cbi-<%=self.config%>-<%=section%>">
-<% self:render_children(section) %>
- <% if #self.optionals[section] > 0 or self.dynamic then %>
- <div class="cbi-optionals">
- <% if self.dynamic then %>
- <input type="text" name="cbi.opt.<%=self.config%>.<%=section%>" />
- <% else %>
- <select name="cbi.opt.<%=self.config%>.<%=section%>">
- <option><%:cbi_addopt -- Feld --%></option>
- <% for key, val in pairs(self.optionals[section]) do %>
- <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=val.title%></option>
- <% end %>
- </select>
- <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
- <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>");
- <% end %><% end %>
- <% end %></script>
- <% end %>
- <input type="submit" value="<%:add hinzufügen%>" />
- </div>
- <% end %>
- </div>
- <br />
\ No newline at end of file
+++ /dev/null
-<%+cbi/valueheader%>
- <input type="text" onchange="cbi_d_update(this.id)" <% if self.size then %>size="<%=self.size%>" <% end %><% if self.maxlength then %>maxlength="<%=self.maxlength%>" <% end %>name="cbid.<%=self.config.."."..section.."."..self.option%>" id="cbid.<%=self.config.."."..section.."."..self.option%>" value="<%=self:cfgvalue(section)%>" />
-<%+cbi/valuefooter%>
+++ /dev/null
- <div class="cbi-value-description"><%=self.description%> </div>
- </div>
- <% if self.tag_invalid[section] then %><div class="cbi-error"><%:cbi_invalid Fehler: Ungültige Eingabe%></div><% end %>
- </div>
- <% if #self.deps > 0 then %><script type="text/javascript">
- <% for j, d in ipairs(self.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>");
- <% end %>
- </script><% end %>
\ No newline at end of file
+++ /dev/null
- <div class="cbi-value" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
- <div class="cbi-value-title"><%=self.title%></div>
- <div class="cbi-value-field">
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1>404 Not Found</h1>
-<p>Sorry, the object you requested was not found.</p>
-<tt>Unable to dispatch: <%=ffluci.http.env.PATH_INFO%></tt>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1>500 Internal Server Error</h1>
-<p>Sorry, the server encountered an unexpected error.</p>
-<tt><%=message%></tt>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
- </div>
- <div class="clear"></div>
-</div></div>
-
-<div class="separator magenta bold"><a href="http://luci.freifunk-halle.net">FFLuCI 0.3 - Freifunk Lua Configuration Interface</a></div>
-</body>
-</html>
\ No newline at end of file
+++ /dev/null
-<%
-require("ffluci.sys")
-local load1, load5, load15 = ffluci.sys.loadavg()
-local req = require("ffluci.dispatcher").request
-local menu = require("ffluci.menu").get()[req.category]
-menu = menu or {}
-require("ffluci.i18n").loadc("default")
-require("ffluci.http").prepare_content("text/html")
-%><?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" />
- <link rel="stylesheet" type="text/css" href="<%=media%>/css/<%=req.category%>_<%=req.module%>.css" />
- <meta http-equiv="content-type" content="text/xhtml+xml; charset=utf-8" />
- <meta http-equiv="content-script-type" content="text/javascript" />
- <title>FFLuCI</title>
-</head>
-<body>
-<div id="header">
- <div class="headerlogo left"><img src="<%=media%>/logo.png" alt="Freifunk" /></div>
- <div class="whitetext smalltext right">
- OpenWRT Kamikaze<br />
- Freifunk Firmware 2.0-dev<br />
- <%:load Last%>: <%=load1%> <%=load5%> <%=load15%><br />
- <%:hostname Hostname%>: <%=ffluci.sys.hostname()%>
- </div>
- <div>
- <span class="headertitle">Freifunk Kamikaze</span><br />
- <span class="whitetext bold"><%:batmanedition Fledermausedition%></span>
- </div>
-</div>
-
-<div class="separator yellow bold">
-<%:path Pfad%>: <a href="<%=controller .. "/" .. req.category%>"><%=translate(req.category, req.category)%></a>
-» <a href="<%=controller .. "/" .. req.category .. "/" .. req.module %>"><%=translate(req.module, req.module)%></a>
-» <a href="<%=controller .. "/" .. req.category .. "/" .. req.module .. "/" .. req.action %>"><%=translate(req.action, req.action)%></a>
-</div>
-
-<div id="columns"><div id="columnswrapper">
- <div class="sidebar left">
- <% for k,v in pairs(menu) do %>
- <div<% if v[".contr"] == req.module then %> class="yellowtext"<% end %>><a href="<%=controller.."/"..req.category.."/"..v[".contr"]%>"><%=translate(v[".contr"], v[".descr"])%></a><%
- if v[".contr"] == req.module then %>
- <ul><% for key,val in ipairs(v) do %>
- <li<% if val.action == req.action then %> class="yellowtext"<% end %>><a href="<%=controller.."/"..req.category.."/"..req.module.."/"..val.action%>"><%=translate(val.action, val.descr)%></a></li>
- <% end %></ul>
- <% end %></div>
- <% end %>
- </div>
- <div class="sidebar right">
- <div><%:webif Weboberfläche%>
- <ul>
- <li<% if "public" == req.category then %> class="yellowtext"<% end %>><a href="<%=controller%>/public"><%:public Öffentlich%></a></li>
- <li<% if "admin" == req.category then %> class="yellowtext"<% end %>><a href="<%=controller%>/admin"><%:admin Verwaltung%></a></li>
- </ul>
- </div>
- <%
- if "admin" == req.category then
- require("ffluci.model.uci")
- local ucic = ffluci.model.uci.changes()
- if ucic then
- ucic = #ffluci.util.split(ucic)
- end
- %>
- <div><%:config Konfiguration%>
- <ul>
- <% if ucic then %>
- <li><a href="<%=controller%>/admin/uci/changes"><%:changes Änderungen%>: <%=ucic%></a></li>
- <li><a href="<%=controller%>/admin/uci/apply"><%:apply Anwenden%></a></li>
- <li><a href="<%=controller%>/admin/uci/revert"><%:revert Verwerfen%></a></li>
- <% else %>
- <li><%:changes Änderungen%>: 0</li>
- <% end %>
- </ul>
- </div>
- <% end %>
- </div>
- <div id="content">
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - Filesystem tools
+
+Description:
+A module offering often needed filesystem manipulation functions
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+
+module("ffluci.fs", package.seeall)
+
+require("posix")
+
+-- Glob
+function glob(pattern)
+ return posix.glob(pattern)
+end
+
+-- Checks whether a file exists
+function isfile(filename)
+ local fp = io.open(filename, "r")
+ if fp then fp:close() end
+ return fp ~= nil
+end
+
+-- Returns the content of file
+function readfile(filename)
+ local fp, err = io.open(filename)
+
+ if fp == nil then
+ return nil, err
+ end
+
+ local data = fp:read("*a")
+ fp:close()
+ return data
+end
+
+-- Writes given data to a file
+function writefile(filename, data)
+ local fp, err = io.open(filename, "w")
+
+ if fp == nil then
+ return nil, err
+ end
+
+ fp:write(data)
+ fp:close()
+
+ return true
+end
+
+-- Returns the file modification date/time of "path"
+function mtime(path)
+ return posix.stat(path, "mtime")
+end
+
+-- basename wrapper
+basename = posix.basename
+
+-- dirname wrapper
+dirname = posix.dirname
+
+-- dir wrapper
+function dir(path)
+ local dir = {}
+ for node in posix.files(path) do
+ table.insert(dir, 1, node)
+ end
+ return dir
+end
+
+-- Alias for posix.mkdir
+mkdir = posix.mkdir
+
+-- Alias for posix.rmdir
+rmdir = posix.rmdir
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - HTTP-Interaction
+
+Description:
+HTTP-Header manipulator and form variable preprocessor
+
+FileId:
+$Id$
+
+ToDo:
+- Cookie handling
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+
+module("ffluci.http", package.seeall)
+
+if ENV and ENV.HASERLVER then
+ require("ffluci.sgi.haserl")
+elseif webuci then
+ require("ffluci.sgi.webuci")
+end
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - Internationalisation
+
+Description:
+A very minimalistic but yet effective internationalisation module
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+
+module("ffluci.i18n", package.seeall)
+require("ffluci.sys")
+
+table = {}
+i18ndir = ffluci.sys.libpath() .. "/i18n/"
+
+-- Clears the translation table
+function clear()
+ table = {}
+end
+
+-- Loads a translation and copies its data into the global translation table
+function load(file)
+ local f = loadfile(i18ndir .. file)
+ if f then
+ setfenv(f, table)
+ f()
+ return true
+ else
+ return false
+ end
+end
+
+-- Same as load but autocompletes the filename with .LANG from config.lang
+function loadc(file)
+ return load(file .. "." .. require("ffluci.config").main.lang)
+end
+
+-- Returns the i18n-value defined by "key" or if there is no such: "default"
+function translate(key, default)
+ return table[key] or default
+end
\ No newline at end of file
--- /dev/null
+cbi_add = "Add entry"
+cbi_del = "Remove entry"
+cbi_invalid = "Error: Invalid input value"
+cbi_addopt = "-- Field --"
\ No newline at end of file
--- /dev/null
+add = "Add"
+save = "Save"
+reset = "Reset"
+
+load = "Load"
+webif = "Webinterface"
+public = "Public"
+admin = "Administration"
+apply = "Apply"
+changes = "Changes"
+revert = "Revert"
+
+index = "Overview"
+system = "System"
+services = "Services"
+network = "Network"
+wifi = "Wifi"
+status = "Status"
+statistic = "Statistic"
+
+config = "Configuration"
+path = "Path"
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - Freifunk Lua Configuration Interface
+
+Description:
+This is the init file
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+module("ffluci", package.seeall)
+
+__version__ = "0.4"
+__appname__ = "FFLuCI"
--- /dev/null
+--[[
+FFLuCI - Menu Builder
+
+Description:
+Collects menu building information from controllers
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+module("ffluci.menu", package.seeall)
+
+require("ffluci.fs")
+require("ffluci.util")
+require("ffluci.sys")
+
+-- Default modelpath
+modelpath = ffluci.sys.libpath() .. "/model/menu/"
+
+-- Menu definition extra scope
+scope = {
+ translate = function(...) return require("ffluci.i18n").translate(...) end,
+ loadtrans = function(...) return require("ffluci.i18n").loadc(...) end,
+ isfile = ffluci.fs.isfile
+}
+
+-- Local menu database
+local menu = nil
+
+-- The current pointer
+local menuc = {}
+
+-- Adds a menu category to the current menu and selects it
+function add(cat, controller, title, order)
+ order = order or 100
+ if not menu[cat] then
+ menu[cat] = {}
+ end
+
+ local entry = {}
+ entry[".descr"] = title
+ entry[".order"] = order
+ entry[".contr"] = controller
+
+ menuc = entry
+
+ local i = 0
+ for k,v in ipairs(menu[cat]) do
+ if v[".order"] > entry[".order"] then
+ break
+ end
+ i = k
+ end
+ table.insert(menu[cat], i+1, entry)
+
+ return true
+end
+
+-- Adds an action to the current menu
+function act(action, title)
+ table.insert(menuc, {action = action, descr = title})
+ return true
+end
+
+-- Selects a menu category
+function sel(cat, controller)
+ if not menu[cat] then
+ return nil
+ end
+ menuc = menu[cat]
+
+ local stat = nil
+ for k,v in ipairs(menuc) do
+ if v[".contr"] == controller then
+ menuc = v
+ stat = true
+ end
+ end
+
+ return stat
+end
+
+
+-- Collect all menu information provided in the model dir
+function collect()
+ local generators = {}
+
+ for k, menu in pairs(ffluci.fs.dir(modelpath)) do
+ if menu:sub(1, 1) ~= "." then
+ local f = loadfile(modelpath.."/"..menu)
+ if f then
+ table.insert(generators, f)
+ end
+ end
+ end
+
+ return generators
+end
+
+-- Parse the collected information
+function parse(generators)
+ menu = {}
+ for i, f in pairs(generators) do
+ local env = ffluci.util.clone(scope)
+
+ env.add = add
+ env.sel = sel
+ env.act = act
+
+ setfenv(f, env)
+ f()
+ end
+ return menu
+end
+
+-- Returns the menu information
+function get()
+ if not menu then
+ menu = parse(collect())
+ end
+ return menu
+end
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - IPKG wrapper library
+
+Description:
+Wrapper for the ipkg Package manager
+
+Any return value of false or nil can be interpreted as an error
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+module("ffluci.model.ipkg", package.seeall)
+require("ffluci.sys")
+require("ffluci.util")
+
+ipkg = "ipkg"
+
+-- Returns repository information
+function info(pkg)
+ return _lookup("info", pkg)
+end
+
+-- Returns a table with status information
+function status(pkg)
+ return _lookup("status", pkg)
+end
+
+-- Installs packages
+function install(...)
+ return _action("install", ...)
+end
+
+-- Returns whether a package is installed
+function installed(pkg, ...)
+ local p = status(...)[pkg]
+ return (p and p.Status and p.Status.installed)
+end
+
+-- Removes packages
+function remove(...)
+ return _action("remove", ...)
+end
+
+-- Updates package lists
+function update()
+ return _action("update")
+end
+
+-- Upgrades installed packages
+function upgrade()
+ return _action("upgrade")
+end
+
+
+-- Internal action function
+function _action(cmd, ...)
+ local pkg = ""
+ arg.n = nil
+ for k, v in pairs(arg) do
+ pkg = pkg .. " '" .. v:gsub("'", "") .. "'"
+ end
+
+ local c = ipkg.." "..cmd.." "..pkg.." >/dev/null 2>&1"
+ local r = os.execute(c)
+ return (r == 0), r
+end
+
+-- Internal lookup function
+function _lookup(act, pkg)
+ local cmd = ipkg .. " " .. act
+ if pkg then
+ cmd = cmd .. " '" .. pkg:gsub("'", "") .. "'"
+ end
+
+ return _parselist(ffluci.sys.exec(cmd .. " 2>/dev/null"))
+end
+
+-- Internal parser function
+function _parselist(rawdata)
+ if type(rawdata) ~= "string" then
+ error("IPKG: Invalid rawdata given")
+ end
+
+ rawdata = ffluci.util.split(rawdata)
+ local data = {}
+ local c = {}
+ local l = nil
+
+ for k, line in pairs(rawdata) do
+ if line:sub(1, 1) ~= " " then
+ local split = ffluci.util.split(line, ":", 1)
+ local key = nil
+ local val = nil
+
+ if split[1] then
+ key = ffluci.util.trim(split[1])
+ end
+
+ if split[2] then
+ val = ffluci.util.trim(split[2])
+ end
+
+ if key and val then
+ if key == "Package" then
+ c = {Package = val}
+ data[val] = c
+ elseif key == "Status" then
+ c.Status = {}
+ for i, j in pairs(ffluci.util.split(val, " ")) do
+ c.Status[j] = true
+ end
+ else
+ c[key] = val
+ end
+ l = key
+ end
+ else
+ -- Multi-line field
+ c[l] = c[l] .. "\n" .. line:sub(2)
+ end
+ end
+
+ return data
+end
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - UCI mpdel
+
+Description:
+Generalized UCI model
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+module("ffluci.model.uci", package.seeall)
+
+-- Default savedir
+savedir = "/tmp/.uci"
+
+-- Test whether to load libuci-Wrapper or /sbin/uci-Wrapper
+if pcall(require, "uci") then
+ Session = require("ffluci.model.uci.libuci").Session
+else
+ Session = require("ffluci.model.uci.wrapper").Session
+end
+
+-- The default Session
+local default = Session()
+local state = Session("/var/state")
+
+-- The state Session
+function StateSession()
+ return state
+end
+
+
+-- Wrapper for "uci add"
+function add(...)
+ return default:add(...)
+end
+
+
+-- Wrapper for "uci changes"
+function changes(...)
+ return default:changes(...)
+end
+
+-- Wrapper for "uci commit"
+function commit(...)
+ return default:commit(...)
+end
+
+
+-- Wrapper for "uci del"
+function del(...)
+ return default:del(...)
+end
+
+
+-- Wrapper for "uci get"
+function get(...)
+ return default:get(...)
+end
+
+
+-- Wrapper for "uci revert"
+function revert(...)
+ return default:revert(...)
+end
+
+
+-- Wrapper for "uci show"
+function sections(...)
+ return default:sections(...)
+end
+
+
+-- Wrapper for "uci set"
+function set(...)
+ return default:set(...)
+end
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - UCI libuci wrapper
+
+Description:
+Wrapper for the libuci Lua bindings
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+
+module("ffluci.model.uci.libuci", package.seeall)
+
+require("uci")
+require("ffluci.util")
+require("ffluci.sys")
+
+-- Session class
+Session = ffluci.util.class()
+
+-- Session constructor
+function Session.__init__(self, savedir)
+ self.ucicmd = savedir and "uci -P " .. savedir or "uci"
+ self.savedir = savedir or ffluci.model.uci.savedir
+end
+
+function Session.add(self, config, section_type)
+ return self:_uci("add " .. _path(config) .. " " .. _path(section_type))
+end
+
+function Session.changes(self, config)
+ return self:_uci("changes " .. _path(config))
+end
+
+function Session.commit(self, config)
+ self:t_load(config)
+ return self:t_commit(config)
+end
+
+function Session.del(self, config, section, option)
+ return self:_uci2("del " .. _path(config, section, option))
+end
+
+function Session.get(self, config, section, option)
+ self:t_load(config)
+ return self:t_get(config, section, option)
+end
+
+function Session.revert(self, config)
+ self:t_load(config)
+ return self:t_revert(config)
+end
+
+function Session.sections(self, config)
+ self:t_load(config)
+ return self:t_sections(config)
+end
+
+function Session.set(self, config, section, option, value)
+ self:t_load(config)
+ return self:t_set(config, section, option, value) and self:t_save(config)
+end
+
+function Session.synchronize(self)
+ return uci.set_savedir(self.savedir)
+end
+
+
+-- UCI-Transactions
+
+function Session.t_load(self, config)
+ return self:synchronize() and uci.load(config)
+end
+
+function Session.t_save(self, config)
+ return uci.save(config)
+end
+
+function Session.t_add(self, config, type)
+ self:t_save(config)
+ local r = self:add(config, type)
+ self:t_load(config)
+ return r
+end
+
+function Session.t_commit(self, config)
+ return uci.commit(config)
+end
+
+function Session.t_del(self, config, section, option)
+ self:t_save(config)
+ local r = self:del(config, section, option)
+ self:t_load(config)
+ return r
+end
+
+function Session.t_get(self, config, section, option)
+ if option then
+ return uci.get(config, section, option)
+ else
+ return uci.get(config, section)
+ end
+end
+
+function Session.t_revert(self, config)
+ return uci.revert(config)
+end
+
+function Session.t_sections(self, config)
+ local raw = uci.get_all(config)
+ if not raw then
+ return nil
+ end
+
+ local s = {}
+ local o = {}
+
+ for i, sec in ipairs(raw) do
+ table.insert(o, sec.name)
+
+ s[sec.name] = sec.options
+ s[sec.name][".type"] = sec.type
+ end
+
+ return s, o
+end
+
+function Session.t_set(self, config, section, option, value)
+ if option then
+ return uci.set(config.."."..section.."."..option.."="..value)
+ else
+ return uci.set(config.."."..section.."="..value)
+ end
+end
+
+-- Internal functions --
+
+
+function Session._uci(self, cmd)
+ local res = ffluci.sys.exec(self.ucicmd .. " 2>/dev/null " .. cmd)
+
+ if res:len() == 0 then
+ return nil
+ else
+ return res:sub(1, res:len()-1)
+ end
+end
+
+function Session._uci2(self, cmd)
+ local res = ffluci.sys.exec(self.ucicmd .. " 2>&1 " .. cmd)
+
+ if res:len() > 0 then
+ return false, res
+ else
+ return true
+ end
+end
+
+-- Build path (config.section.option=value) and prevent command injection
+function _path(...)
+ local result = ""
+
+ -- Not using ipairs because it is not reliable in case of nil arguments
+ arg.n = nil
+ for k,v in pairs(arg) do
+ if v then
+ v = tostring(v)
+ if k == 1 then
+ result = "'" .. v:gsub("['.]", "") .. "'"
+ elseif k < 4 then
+ result = result .. ".'" .. v:gsub("['.]", "") .. "'"
+ elseif k == 4 then
+ result = result .. "='" .. v:gsub("'", "") .. "'"
+ end
+ end
+ end
+ return result
+end
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - UCI wrapper library
+
+Description:
+Wrapper for the /sbin/uci application, syntax of implemented functions
+is comparable to the syntax of the uci application
+
+Any return value of false or nil can be interpreted as an error
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+
+module("ffluci.model.uci.wrapper", package.seeall)
+
+require("ffluci.util")
+require("ffluci.sys")
+
+-- Session class
+Session = ffluci.util.class()
+
+-- Session constructor
+function Session.__init__(self, savedir)
+ self.ucicmd = savedir and "uci -P " .. savedir or "uci"
+end
+
+function Session.add(self, config, section_type)
+ return self:_uci("add " .. _path(config) .. " " .. _path(section_type))
+end
+
+function Session.changes(self, config)
+ return self:_uci("changes " .. _path(config))
+end
+
+function Session.commit(self, config)
+ return self:_uci2("commit " .. _path(config))
+end
+
+function Session.del(self, config, section, option)
+ return self:_uci2("del " .. _path(config, section, option))
+end
+
+function Session.get(self, config, section, option)
+ return self:_uci("get " .. _path(config, section, option))
+end
+
+function Session.revert(self, config)
+ return self:_uci2("revert " .. _path(config))
+end
+
+function Session.sections(self, config)
+ if not config then
+ return nil
+ end
+
+ local r1, r2 = self:_uci3("show " .. _path(config))
+ if type(r1) == "table" then
+ return r1, r2
+ else
+ return nil, r2
+ end
+end
+
+function Session.set(self, config, section, option, value)
+ return self:_uci2("set " .. _path(config, section, option, value))
+end
+
+function Session.synchronize(self) end
+
+-- Dummy transaction functions
+
+function Session.t_load(self) end
+function Session.t_save(self) end
+
+Session.t_add = Session.add
+Session.t_commit = Session.commit
+Session.t_del = Session.del
+Session.t_get = Session.get
+Session.t_revert = Session.revert
+Session.t_sections = Session.sections
+Session.t_set = Session.set
+
+
+
+
+
+-- Internal functions --
+
+
+function Session._uci(self, cmd)
+ local res = ffluci.sys.exec(self.ucicmd .. " 2>/dev/null " .. cmd)
+
+ if res:len() == 0 then
+ return nil
+ else
+ return res:sub(1, res:len()-1)
+ end
+end
+
+function Session._uci2(self, cmd)
+ local res = ffluci.sys.exec(self.ucicmd .. " 2>&1 " .. cmd)
+
+ if res:len() > 0 then
+ return false, res
+ else
+ return true
+ end
+end
+
+function Session._uci3(self, cmd)
+ local res = ffluci.sys.execl(self.ucicmd .. " 2>&1 " .. cmd)
+ if res[1] and res[1]:sub(1, self.ucicmd:len()+1) == self.ucicmd..":" then
+ return nil, res[1]
+ end
+
+ local tbl = {}
+ local ord = {}
+
+ for k,line in pairs(res) do
+ c, s, t = line:match("^([^.]-)%.([^.]-)=(.-)$")
+ if c then
+ tbl[s] = {}
+ table.insert(ord, s)
+ tbl[s][".type"] = t
+ end
+
+ c, s, o, v = line:match("^([^.]-)%.([^.]-)%.([^.]-)=(.-)$")
+ if c then
+ tbl[s][o] = v
+ end
+ end
+
+ return tbl, ord
+end
+
+-- Build path (config.section.option=value) and prevent command injection
+function _path(...)
+ local result = ""
+
+ -- Not using ipairs because it is not reliable in case of nil arguments
+ arg.n = nil
+ for k,v in pairs(arg) do
+ if v then
+ v = tostring(v)
+ if k == 1 then
+ result = "'" .. v:gsub("['.]", "") .. "'"
+ elseif k < 4 then
+ result = result .. ".'" .. v:gsub("['.]", "") .. "'"
+ elseif k == 4 then
+ result = result .. "='" .. v:gsub("'", "") .. "'"
+ end
+ end
+ end
+ return result
+end
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - System library
+
+Description:
+Utilities for interaction with the Linux system
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+
+module("ffluci.sys", package.seeall)
+require("posix")
+require("ffluci.bits")
+require("ffluci.util")
+
+-- Returns whether a system is bigendian
+function bigendian()
+ local fp = io.open("/bin/sh")
+ fp:seek("set", 5)
+ return (fp:read(1):byte() ~= 1)
+end
+
+-- Runs "command" and returns its output
+function exec(command)
+ local pp = io.popen(command)
+ local data = pp:read("*a")
+ pp:close()
+
+ return data
+end
+
+-- Runs "command" and returns its output as a array of lines
+function execl(command)
+ local pp = io.popen(command)
+ local line = ""
+ local data = {}
+
+ while true do
+ line = pp:read()
+ if (line == nil) then break end
+ table.insert(data, line)
+ end
+ pp:close()
+
+ return data
+end
+
+-- Uses "ffluci-flash" to flash a new image file to the system
+function flash(image, kpattern)
+ local cmd = "ffluci-flash "
+ if kpattern then
+ cmd = cmd .. "-k '" .. kpattern:gsub("'", "") .. "' "
+ end
+ cmd = cmd .. "'" .. image:gsub("'", "") .. "' >/dev/null 2>&1"
+
+ return os.execute(cmd)
+end
+
+-- Returns the hostname
+function hostname()
+ return io.lines("/proc/sys/kernel/hostname")()
+end
+
+-- Returns the contents of a documented referred by an URL
+function httpget(url)
+ return exec("wget -qO- '"..url:gsub("'", "").."'")
+end
+
+-- Returns the FFLuci-Basedir
+function libpath()
+ return ffluci.fs.dirname(require("ffluci.debug").__file__)
+end
+
+-- Returns the load average
+function loadavg()
+ local loadavg = io.lines("/proc/loadavg")()
+ return loadavg:match("^(.-) (.-) (.-) (.-) (.-)$")
+end
+
+-- Reboots the system
+function reboot()
+ return os.execute("reboot >/dev/null 2>&1")
+end
+
+-- Returns the system type, cpu name, and installed physical memory
+function sysinfo()
+ local c1 = "cat /proc/cpuinfo|grep system\\ typ|cut -d: -f2 2>/dev/null"
+ local c2 = "uname -m 2>/dev/null"
+ local c3 = "cat /proc/cpuinfo|grep model\\ name|cut -d: -f2 2>/dev/null"
+ local c4 = "cat /proc/cpuinfo|grep cpu\\ model|cut -d: -f2 2>/dev/null"
+ local c5 = "cat /proc/meminfo|grep MemTotal|cut -d: -f2 2>/dev/null"
+
+ local s = ffluci.util.trim(exec(c1))
+ local m = ""
+ local r = ""
+
+ if s == "" then
+ s = ffluci.util.trim(exec(c2))
+ m = ffluci.util.trim(exec(c3))
+ else
+ m = ffluci.util.trim(exec(c4))
+ end
+
+ r = ffluci.util.trim(exec(c5))
+
+ return s, m, r
+end
+
+
+group = {}
+group.getgroup = posix.getgroup
+
+net = {}
+-- Returns the ARP-Table
+function net.arptable()
+ return _parse_delimited_table(io.lines("/proc/net/arp"), "%s%s+")
+end
+
+-- Returns whether an IP-Adress belongs to a certain net
+function net.belongs(ip, ipnet, prefix)
+ return (net.ip4bin(ip):sub(1, prefix) == net.ip4bin(ipnet):sub(1, prefix))
+end
+
+-- Detect the default route
+function net.defaultroute()
+ local routes = net.routes()
+ local route = nil
+
+ for i, r in pairs(ffluci.sys.net.routes()) do
+ if r.Destination == "00000000" and (not route or route.Metric > r.Metric) then
+ route = r
+ end
+ end
+
+ return route
+end
+
+-- Returns all available network interfaces
+function net.devices()
+ local devices = {}
+ for line in io.lines("/proc/net/dev") do
+ table.insert(devices, line:match(" *(.-):"))
+ end
+ return devices
+end
+
+-- Returns the MAC-Address belonging to the given IP-Address
+function net.ip4mac(ip)
+ local mac = nil
+
+ for i, l in ipairs(net.arptable()) do
+ if l["IP address"] == ip then
+ mac = l["HW address"]
+ end
+ end
+
+ return mac
+end
+
+-- Returns the prefix to a given netmask
+function net.mask4prefix(mask)
+ local bin = net.ip4bin(mask)
+
+ if not bin then
+ return nil
+ end
+
+ return #ffluci.util.split(bin, "1")-1
+end
+
+-- Returns the kernel routing table
+function net.routes()
+ return _parse_delimited_table(io.lines("/proc/net/route"))
+end
+
+-- Returns the numeric IP to a given hexstring
+function net.hexip4(hex, be)
+ if #hex ~= 8 then
+ return nil
+ end
+
+ be = be or bigendian()
+
+ local hexdec = ffluci.bits.Hex2Dec
+
+ local ip = ""
+ if be then
+ ip = ip .. tostring(hexdec(hex:sub(1,2))) .. "."
+ ip = ip .. tostring(hexdec(hex:sub(3,4))) .. "."
+ ip = ip .. tostring(hexdec(hex:sub(5,6))) .. "."
+ ip = ip .. tostring(hexdec(hex:sub(7,8)))
+ else
+ ip = ip .. tostring(hexdec(hex:sub(7,8))) .. "."
+ ip = ip .. tostring(hexdec(hex:sub(5,6))) .. "."
+ ip = ip .. tostring(hexdec(hex:sub(3,4))) .. "."
+ ip = ip .. tostring(hexdec(hex:sub(1,2)))
+ end
+
+ return ip
+end
+
+-- Returns the binary IP to a given IP
+function net.ip4bin(ip)
+ local parts = ffluci.util.split(ip, '.')
+ if #parts ~= 4 then
+ return nil
+ end
+
+ local decbin = ffluci.bits.Dec2Bin
+
+ local bin = ""
+ bin = bin .. decbin(parts[1], 8)
+ bin = bin .. decbin(parts[2], 8)
+ bin = bin .. decbin(parts[3], 8)
+ bin = bin .. decbin(parts[4], 8)
+
+ return bin
+end
+
+-- Tests whether a host is pingable
+function net.pingtest(host)
+ return os.execute("ping -c1 '"..host:gsub("'", '').."' >/dev/null 2>&1")
+end
+
+
+process = {}
+process.info = posix.getpid
+
+-- Sets the gid of a process
+function process.setgroup(pid, gid)
+ return posix.setpid("g", pid, gid)
+end
+
+-- Sets the uid of a process
+function process.setuser(pid, uid)
+ return posix.setpid("u", pid, uid)
+end
+
+user = {}
+-- returns user information to a given uid
+user.getuser = posix.getpasswd
+
+-- Changes the user password of given user
+function user.setpasswd(user, pwd)
+ if pwd then
+ pwd = pwd:gsub("'", "")
+ end
+
+ if user then
+ user = user:gsub("'", "")
+ end
+
+ local cmd = "(echo '"..pwd.."';sleep 1;echo '"..pwd.."')|"
+ cmd = cmd .. "passwd '"..user.."' >/dev/null 2>&1"
+ return os.execute(cmd)
+end
+
+
+wifi = {}
+
+function wifi.getiwconfig()
+ local cnt = exec("/usr/sbin/iwconfig 2>/dev/null")
+ local iwc = {}
+
+ for i, l in pairs(ffluci.util.split(ffluci.util.trim(cnt), "\n\n")) do
+ local k = l:match("^(.-) ")
+ l = l:gsub("^(.-) +", "", 1)
+ if k then
+ iwc[k] = _parse_mixed_record(l)
+ end
+ end
+
+ return iwc
+end
+
+function wifi.iwscan()
+ local cnt = exec("iwlist scan 2>/dev/null")
+ local iws = {}
+
+ for i, l in pairs(ffluci.util.split(ffluci.util.trim(cnt), "\n\n")) do
+ local k = l:match("^(.-) ")
+ l = l:gsub("^[^\n]+", "", 1)
+ l = ffluci.util.trim(l)
+ if k then
+ iws[k] = {}
+ for j, c in pairs(ffluci.util.split(l, "\n Cell")) do
+ c = c:gsub("^(.-)- ", "", 1)
+ c = ffluci.util.split(c, "\n", 7)
+ c = table.concat(c, "\n", 1)
+ table.insert(iws[k], _parse_mixed_record(c))
+ end
+ end
+ end
+
+ return iws
+end
+
+
+-- Internal functions
+
+function _parse_delimited_table(iter, delimiter)
+ delimiter = delimiter or "%s+"
+
+ local data = {}
+ local trim = ffluci.util.trim
+ local split = ffluci.util.split
+
+ local keys = split(trim(iter()), delimiter, nil, true)
+ for i, j in pairs(keys) do
+ keys[i] = trim(keys[i])
+ end
+
+ for line in iter do
+ local row = {}
+ line = trim(line)
+ if #line > 0 then
+ for i, j in pairs(split(line, delimiter, nil, true)) do
+ if keys[i] then
+ row[keys[i]] = j
+ end
+ end
+ end
+ table.insert(data, row)
+ end
+
+ return data
+end
+
+function _parse_mixed_record(cnt)
+ local data = {}
+
+ for i, l in pairs(ffluci.util.split(ffluci.util.trim(cnt), "\n")) do
+ for j, f in pairs(ffluci.util.split(ffluci.util.trim(l), " ")) do
+ local k, x, v = f:match('([^%s][^:=]+) *([:=]*) *"*([^\n"]*)"*')
+
+ if k then
+ if x == "" then
+ table.insert(data, k)
+ else
+ data[k] = v
+ end
+ end
+ end
+ end
+
+ return data
+end
\ No newline at end of file
--- /dev/null
+--[[
+FFLuCI - Template Parser
+
+Description:
+A template parser supporting includes, translations, Lua code blocks
+and more. It can be used either as a compiler or as an interpreter.
+
+FileId: $Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+module("ffluci.template", package.seeall)
+
+require("ffluci.config")
+require("ffluci.util")
+require("ffluci.fs")
+require("ffluci.http")
+
+viewdir = ffluci.sys.libpath() .. "/view/"
+
+
+-- Compile modes:
+-- none: Never compile, only use precompiled data from files
+-- memory: Always compile, do not save compiled files, ignore precompiled
+-- file: Compile on demand, save compiled files, update precompiled
+compiler_mode = "memory"
+
+
+-- This applies to compiler modes "always" and "smart"
+--
+-- Produce compiled lua code rather than lua sourcecode
+-- WARNING: Increases template size heavily!!!
+-- This produces the same bytecode as luac but does not have a strip option
+compiler_enable_bytecode = false
+
+
+-- Define the namespace for template modules
+viewns = {
+ translate = function(...) return require("ffluci.i18n").translate(...) end,
+ config = function(...) return require("ffluci.model.uci").get(...) or "" end,
+ controller = ffluci.http.env.SCRIPT_NAME,
+ media = ffluci.config.main.mediaurlbase,
+ write = io.write,
+ include = function(name) Template(name):render(getfenv(2)) end,
+}
+
+-- Compiles a given template into an executable Lua module
+function compile(template)
+ -- Search all <% %> expressions (remember: Lua table indexes begin with #1)
+ local function expr_add(command)
+ table.insert(expr, command)
+ return "<%" .. tostring(#expr) .. "%>"
+ end
+
+ -- As "expr" should be local, we have to assign it to the "expr_add" scope
+ local expr = {}
+ ffluci.util.extfenv(expr_add, "expr", expr)
+
+ -- Save all expressiosn to table "expr"
+ template = template:gsub("<%%(.-)%%>", expr_add)
+
+ local function sanitize(s)
+ s = ffluci.util.escape(s)
+ s = ffluci.util.escape(s, "'")
+ s = ffluci.util.escape(s, "\n")
+ return s
+ end
+
+ -- Escape and sanitize all the template (all non-expressions)
+ template = sanitize(template)
+
+ -- Template module header/footer declaration
+ local header = "write('"
+ local footer = "')"
+
+ template = header .. template .. footer
+
+ -- Replacements
+ local r_include = "')\ninclude('%s')\nwrite('"
+ local r_i18n = "'..translate('%1','%2')..'"
+ local r_uci = "'..config('%1','%2','%3')..'"
+ local r_pexec = "'..(%s or '')..'"
+ local r_exec = "')\n%s\nwrite('"
+
+ -- Parse the expressions
+ for k,v in pairs(expr) do
+ local p = v:sub(1, 1)
+ local re = nil
+ if p == "+" then
+ re = r_include:format(sanitize(string.sub(v, 2)))
+ elseif p == ":" then
+ re = sanitize(v):gsub(":(.-) (.+)", r_i18n)
+ elseif p == "~" then
+ re = sanitize(v):gsub("~(.-)%.(.-)%.(.+)", r_uci)
+ elseif p == "=" then
+ re = r_pexec:format(v:sub(2))
+ else
+ re = r_exec:format(v)
+ end
+ template = template:gsub("<%%"..tostring(k).."%%>", re)
+ end
+
+ if compiler_enable_bytecode then
+ tf = loadstring(template)
+ template = string.dump(tf)
+ end
+
+ return template
+end
+
+-- Oldstyle render shortcut
+function render(name, scope, ...)
+ scope = scope or getfenv(2)
+ local s, t = pcall(Template, name)
+ if not s then
+ error(t)
+ else
+ t:render(scope, ...)
+ end
+end
+
+
+-- Template class
+Template = ffluci.util.class()
+
+-- Shared template cache to store templates in to avoid unnecessary reloading
+Template.cache = {}
+
+
+-- Constructor - Reads and compiles the template on-demand
+function Template.__init__(self, name)
+ if self.cache[name] then
+ self.template = self.cache[name]
+ else
+ self.template = nil
+ end
+
+ -- Create a new namespace for this template
+ self.viewns = {}
+
+ -- Copy over from general namespace
+ for k, v in pairs(viewns) do
+ self.viewns[k] = v
+ end
+
+ -- If we have a cached template, skip compiling and loading
+ if self.template then
+ return
+ end
+
+ -- Compile and build
+ local sourcefile = viewdir .. name .. ".htm"
+ local compiledfile = viewdir .. name .. ".lua"
+ local err
+
+ if compiler_mode == "file" then
+ local tplmt = ffluci.fs.mtime(sourcefile)
+ local commt = ffluci.fs.mtime(compiledfile)
+
+ -- Build if there is no compiled file or if compiled file is outdated
+ if ((commt == nil) and not (tplmt == nil))
+ or (not (commt == nil) and not (tplmt == nil) and commt < tplmt) then
+ local source
+ source, err = ffluci.fs.readfile(sourcefile)
+
+ if source then
+ local compiled = compile(source)
+ ffluci.fs.writefile(compiledfile, compiled)
+ self.template, err = loadstring(compiled)
+ end
+ else
+ self.template, err = loadfile(compiledfile)
+ end
+
+ elseif compiler_mode == "none" then
+ self.template, err = loadfile(self.compiledfile)
+
+ elseif compiler_mode == "memory" then
+ local source
+ source, err = ffluci.fs.readfile(sourcefile)
+ if source then
+ self.template, err = loadstring(compile(source))
+ end
+
+ end
+
+ -- If we have no valid template throw error, otherwise cache the template
+ if not self.template then
+ error(err)
+ else
+ self.cache[name] = self.template
+ end
+end
+
+
+-- Renders a template
+function Template.render(self, scope)
+ scope = scope or getfenv(2)
+
+ -- Save old environment
+ local oldfenv = getfenv(self.template)
+
+ -- Put our predefined objects in the scope of the template
+ ffluci.util.resfenv(self.template)
+ ffluci.util.updfenv(self.template, scope)
+ ffluci.util.updfenv(self.template, self.viewns)
+
+ -- Now finally render the thing
+ self.template()
+
+ -- Reset environment
+ setfenv(self.template, oldfenv)
+end
--- /dev/null
+--[[
+FFLuCI - Utility library
+
+Description:
+Several common useful Lua functions
+
+FileId:
+$Id$
+
+License:
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+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
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+]]--
+
+module("ffluci.util", package.seeall)
+
+
+-- Lua simplified Python-style OO class support emulation
+function class(base)
+ local class = {}
+
+ local create = function(class, ...)
+ local inst = {}
+ setmetatable(inst, {__index = class})
+
+ if inst.__init__ then
+ local stat, err = pcall(inst.__init__, inst, ...)
+ if not stat then
+ error(err)
+ end
+ end
+
+ return inst
+ end
+
+ local classmeta = {__call = create}
+
+ if base then
+ classmeta.__index = base
+ end
+
+ setmetatable(class, classmeta)
+ return class
+end
+
+
+-- Clones an object (deep on-demand)
+function clone(object, deep)
+ local copy = {}
+
+ for k, v in pairs(object) do
+ if deep and type(v) == "table" then
+ v = clone(v, deep)
+ end
+ copy[k] = v
+ end
+
+ setmetatable(copy, getmetatable(object))
+
+ return copy
+end
+
+
+-- Checks whether a table has an object "value" in it
+function contains(table, value)
+ for k,v in pairs(table) do
+ if value == v then
+ return true
+ end
+ end
+ return false
+end
+
+
+-- Dumps a table to stdout (useful for testing and debugging)
+function dumptable(t, i)
+ i = i or 0
+ for k,v in pairs(t) do
+ print(string.rep("\t", i) .. k, v)
+ if type(v) == "table" then
+ dumptable(v, i+1)
+ end
+ end
+end
+
+
+-- Escapes all occurences of c in s
+function escape(s, c)
+ c = c or "\\"
+ return s:gsub(c, "\\" .. c)
+end
+
+
+-- Populate obj in the scope of f as key
+function extfenv(f, key, obj)
+ local scope = getfenv(f)
+ scope[key] = obj
+end
+
+
+-- Checks whether an object is an instanceof class
+function instanceof(object, class)
+ local meta = getmetatable(object)
+ while meta and meta.__index do
+ if meta.__index == class then
+ return true
+ end
+ meta = getmetatable(meta.__index)
+ end
+ return false
+end
+
+
+-- Creates valid XML PCDATA from a string
+function pcdata(value)
+ value = value:gsub("&", "&")
+ value = value:gsub('"', """)
+ value = value:gsub("'", "'")
+ value = value:gsub("<", "<")
+ return value:gsub(">", ">")
+end
+
+
+-- Resets the scope of f doing a shallow copy of its scope into a new table
+function resfenv(f)
+ setfenv(f, clone(getfenv(f)))
+end
+
+
+-- Splits a string into an array
+function split(str, pat, max, regex)
+ pat = pat or "\n"
+ max = max or #str
+
+ local t = {}
+ local c = 1
+
+ if #str == 0 then
+ return {""}
+ end
+
+ if #pat == 0 then
+ return nil
+ end
+
+ if max == 0 then
+ return str
+ end
+
+ repeat
+ local s, e = str:find(pat, c, not regex)
+ table.insert(t, str:sub(c, s and s - 1))
+ max = max - 1
+ c = e and e + 1 or #str + 1
+ until not s or max < 0
+
+ return t
+end
+
+-- Removes whitespace from beginning and end of a string
+function trim(str)
+ local s = str:gsub("^%s*(.-)%s*$", "%1")
+ return s
+end
+
+-- Updates given table with new values
+function update(t, updates)
+ for k, v in pairs(updates) do
+ t[k] = v
+ end
+end
+
+
+-- Updates the scope of f with "extscope"
+function updfenv(f, extscope)
+ update(getfenv(f), extscope)
+end
+
+
+-- Validates a variable
+function validate(value, cast_number, cast_int)
+ if cast_number or cast_int then
+ value = tonumber(value)
+ end
+
+ if cast_int and value and not(value % 1 == 0) then
+ value = nil
+ end
+
+ return value
+end
\ No newline at end of file
--- /dev/null
+<%+cbi/valueheader%>
+<% if self.value then
+ if type(self.value) == "function" then %>
+ <%=self:value(section)%>
+<% else %>
+ <%=self.value%>
+<% end
+else %>
+ <%=self:cfgvalue(section)%>
+<% end %>
+
+<%+cbi/valuefooter%>
--- /dev/null
+ <div>
+ <input type="submit" value="<%:save Speichern%>" />
+ <input type="reset" value="<%:reset Zurücksetzen%>" />
+ <script type="text/javascript">cbi_d_init();</script>
+ </div>
+ </form>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+cbi/valueheader%>
+ <input onchange="cbi_d_update(this.id)" type="checkbox" id="cbid.<%=self.config.."."..section.."."..self.option%>" name="cbid.<%=self.config.."."..section.."."..self.option%>"<% if self:cfgvalue(section) == self.enabled then %> checked="checked"<% end %> value="1" />
+<%+cbi/valuefooter%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+ <form method="post" action="<%=ffluci.http.env.REQUEST_URI%>">
+ <div>
+ <script type="text/javascript" src="<%=media%>/cbi.js"></script>
+ <input type="hidden" name="cbi.submit" value="1" />
+ <input type="submit" value="<%:save Speichern%>" class="hidden" />
+ </div>
--- /dev/null
+<%+cbi/valueheader%>
+<% if self.widget == "select" then %>
+ <select onchange="cbi_d_update(this.id)" id="cbid.<%=self.config.."."..section.."."..self.option%>" name="cbid.<%=self.config.."."..section.."."..self.option%>"<% if self.size then %> size="<%=self.size%>"<% end %>>
+<%for i, key in pairs(self.keylist) do%>
+ <option<% if self:cfgvalue(section) == key then %> selected="selected"<% end %> value="<%=key%>"><%=self.vallist[i]%></option>
+<% end %>
+ </select>
+<% elseif self.widget == "radio" then
+ local c = 0;
+ for i, key in pairs(self.keylist) do
+ c = c + 1%>
+ <%=self.vallist[i]%><input type="radio" name="cbid.<%=self.config.."."..section.."."..self.option%>"<% if self:cfgvalue(section) == key then %> checked="checked"<% end %> value="<%=key%>" />
+<% if c == self.size then c = 0 %><br />
+<% end end %>
+<% end %>
+<%+cbi/valuefooter%>
\ No newline at end of file
--- /dev/null
+ <div class="cbi-map" id="cbi-<%=self.config%>">
+ <h1><%=self.title%></h1>
+ <div class="cbi-map-descr"><%=self.description%></div>
+<% self:render_children() %>
+ <br />
+ </div>
--- /dev/null
+<%
+local v = self:valuelist(section)
+%>
+<%+cbi/valueheader%>
+<% if self.widget == "select" then %>
+ <select multiple="multiple" name="cbid.<%=self.config.."."..section.."."..self.option%>[]"<% if self.size then %> size="<%=self.size%>"<% end %>>
+<%for i, key in pairs(self.keylist) do %>
+ <option<% if ffluci.util.contains(v, key) then %> selected="selected"<% end %> value="<%=key%>"><%=self.vallist[i]%></option>
+<% end %>
+ </select>
+<% elseif self.widget == "checkbox" then
+ local c = 0;
+ for i, key in pairs(self.keylist) do
+ c = c + 1%>
+ <%=self.vallist[i]%><input type="checkbox" name="cbid.<%=self.config.."."..section.."."..self.option%>[]"<% if ffluci.util.contains(v, key) then %> checked="checked"<% end %> value="<%=key%>" />
+<% if c == self.size then c = 0 %><br />
+<% end end %>
+<% end %>
+<%+cbi/valuefooter%>
\ No newline at end of file
--- /dev/null
+<% if self:cfgvalue(self.section) then
+section = self.section %>
+ <div class="cbi-section" id="cbi-<%=self.config%>-<%=section%>">
+ <h2><%=self.title%></h2>
+ <div class="cbi-section-descr"><%=self.description%></div>
+ <% if self.addremove then %><div class="cbi-section-remove right">
+ <input type="submit" name="cbi.rns.<%=self.config%>.<%=section%>" value="<%:cbi_del Eintrag entfernen%>" />
+ </div><% end %>
+<%+cbi/ucisection%>
+ </div>
+<% elseif self.addremove then %>
+ <div class="cbi-section" id="cbi-<%=self.config%>-<%=self.section%>">
+ <h2><%=self.title%></h2>
+ <div class="cbi-section-descr"><%=self.description%></div>
+ <input type="submit" name="cbi.cns.<%=self.config%>.<%=self.section%>" value="<%:cbi_add Eintrag anlegen%>" />
+ </div>
+<% end %>
--- /dev/null
+ <div class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
+ <h2><%=self.title%></h2>
+ <div class="cbi-section-descr"><%=self.description%></div>
+<% for i, k in ipairs(self:cfgsections()) do%>
+ <% if self.addremove then %><div class="cbi-section-remove right">
+ <input type="submit" name="cbi.rts.<%=self.config%>.<%=k%>" value="<%:cbi_del Eintrag entfernen%>" />
+ </div><% end %>
+ <% if not self.anonymous then %><h3><%=k%></h3><% end %>
+<% section = k %>
+<%+cbi/ucisection%>
+<% end %>
+<% if self.addremove then %>
+ <div class="cbi-section-create">
+ <% if self.anonymous then %>
+ <input type="submit" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" value="<%:cbi_add Eintrag hinzufügen%>" />
+ <% else %>
+ <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
+ <input type="submit" value="<%:cbi_add Eintrag hinzufügen%>" />
+ <% end %><% if self.err_invalid then %><div class="cbi-error"><%:cbi_invalid Fehler: Ungültige Eingabe%></div><% end %>
+ </div>
+<% end %>
+ </div>
--- /dev/null
+ <div class="cbi-section-node" id="cbi-<%=self.config%>-<%=section%>">
+<% self:render_children(section) %>
+ <% if #self.optionals[section] > 0 or self.dynamic then %>
+ <div class="cbi-optionals">
+ <% if self.dynamic then %>
+ <input type="text" name="cbi.opt.<%=self.config%>.<%=section%>" />
+ <% else %>
+ <select name="cbi.opt.<%=self.config%>.<%=section%>">
+ <option><%:cbi_addopt -- Feld --%></option>
+ <% for key, val in pairs(self.optionals[section]) do %>
+ <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=val.title%></option>
+ <% end %>
+ </select>
+ <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
+ <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>");
+ <% end %><% end %>
+ <% end %></script>
+ <% end %>
+ <input type="submit" value="<%:add hinzufügen%>" />
+ </div>
+ <% end %>
+ </div>
+ <br />
\ No newline at end of file
--- /dev/null
+<%+cbi/valueheader%>
+ <input type="text" onchange="cbi_d_update(this.id)" <% if self.size then %>size="<%=self.size%>" <% end %><% if self.maxlength then %>maxlength="<%=self.maxlength%>" <% end %>name="cbid.<%=self.config.."."..section.."."..self.option%>" id="cbid.<%=self.config.."."..section.."."..self.option%>" value="<%=self:cfgvalue(section)%>" />
+<%+cbi/valuefooter%>
--- /dev/null
+ <div class="cbi-value-description"><%=self.description%> </div>
+ </div>
+ <% if self.tag_invalid[section] then %><div class="cbi-error"><%:cbi_invalid Fehler: Ungültige Eingabe%></div><% end %>
+ </div>
+ <% if #self.deps > 0 then %><script type="text/javascript">
+ <% for j, d in ipairs(self.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>");
+ <% end %>
+ </script><% end %>
\ No newline at end of file
--- /dev/null
+ <div class="cbi-value" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
+ <div class="cbi-value-title"><%=self.title%></div>
+ <div class="cbi-value-field">
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1>404 Not Found</h1>
+<p>Sorry, the object you requested was not found.</p>
+<tt>Unable to dispatch: <%=ffluci.http.env.PATH_INFO%></tt>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1>500 Internal Server Error</h1>
+<p>Sorry, the server encountered an unexpected error.</p>
+<tt><%=message%></tt>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+ </div>
+ <div class="clear"></div>
+</div></div>
+
+<div class="separator magenta bold"><a href="http://luci.freifunk-halle.net">FFLuCI 0.3 - Freifunk Lua Configuration Interface</a></div>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+<%
+require("ffluci.sys")
+local load1, load5, load15 = ffluci.sys.loadavg()
+local req = require("ffluci.dispatcher").request
+local menu = require("ffluci.menu").get()[req.category]
+menu = menu or {}
+require("ffluci.i18n").loadc("default")
+require("ffluci.http").prepare_content("text/html")
+%><?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" />
+ <link rel="stylesheet" type="text/css" href="<%=media%>/css/<%=req.category%>_<%=req.module%>.css" />
+ <meta http-equiv="content-type" content="text/xhtml+xml; charset=utf-8" />
+ <meta http-equiv="content-script-type" content="text/javascript" />
+ <title>FFLuCI</title>
+</head>
+<body>
+<div id="header">
+ <div class="headerlogo left"><img src="<%=media%>/logo.png" alt="Freifunk" /></div>
+ <div class="whitetext smalltext right">
+ OpenWRT Kamikaze<br />
+ Freifunk Firmware 2.0-dev<br />
+ <%:load Last%>: <%=load1%> <%=load5%> <%=load15%><br />
+ <%:hostname Hostname%>: <%=ffluci.sys.hostname()%>
+ </div>
+ <div>
+ <span class="headertitle">Freifunk Kamikaze</span><br />
+ <span class="whitetext bold"><%:batmanedition Fledermausedition%></span>
+ </div>
+</div>
+
+<div class="separator yellow bold">
+<%:path Pfad%>: <a href="<%=controller .. "/" .. req.category%>"><%=translate(req.category, req.category)%></a>
+» <a href="<%=controller .. "/" .. req.category .. "/" .. req.module %>"><%=translate(req.module, req.module)%></a>
+» <a href="<%=controller .. "/" .. req.category .. "/" .. req.module .. "/" .. req.action %>"><%=translate(req.action, req.action)%></a>
+</div>
+
+<div id="columns"><div id="columnswrapper">
+ <div class="sidebar left">
+ <% for k,v in pairs(menu) do %>
+ <div<% if v[".contr"] == req.module then %> class="yellowtext"<% end %>><a href="<%=controller.."/"..req.category.."/"..v[".contr"]%>"><%=translate(v[".contr"], v[".descr"])%></a><%
+ if v[".contr"] == req.module then %>
+ <ul><% for key,val in ipairs(v) do %>
+ <li<% if val.action == req.action then %> class="yellowtext"<% end %>><a href="<%=controller.."/"..req.category.."/"..req.module.."/"..val.action%>"><%=translate(val.action, val.descr)%></a></li>
+ <% end %></ul>
+ <% end %></div>
+ <% end %>
+ </div>
+ <div class="sidebar right">
+ <div><%:webif Weboberfläche%>
+ <ul>
+ <li<% if "public" == req.category then %> class="yellowtext"<% end %>><a href="<%=controller%>/public"><%:public Öffentlich%></a></li>
+ <li<% if "admin" == req.category then %> class="yellowtext"<% end %>><a href="<%=controller%>/admin"><%:admin Verwaltung%></a></li>
+ </ul>
+ </div>
+ <%
+ if "admin" == req.category then
+ require("ffluci.model.uci")
+ local ucic = ffluci.model.uci.changes()
+ if ucic then
+ ucic = #ffluci.util.split(ucic)
+ end
+ %>
+ <div><%:config Konfiguration%>
+ <ul>
+ <% if ucic then %>
+ <li><a href="<%=controller%>/admin/uci/changes"><%:changes Änderungen%>: <%=ucic%></a></li>
+ <li><a href="<%=controller%>/admin/uci/apply"><%:apply Anwenden%></a></li>
+ <li><a href="<%=controller%>/admin/uci/revert"><%:revert Verwerfen%></a></li>
+ <% else %>
+ <li><%:changes Änderungen%>: 0</li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+ </div>
+ <div id="content">
\ No newline at end of file
+++ /dev/null
-LUAC = luac
-LUAC_OPTIONS = -s
-
-FILES = i18n/* view/*/*.htm
-
-CFILES = controller/*/*.lua model/cbi/*/*.lua model/menu/*.lua
-
-DIRECTORIES = model/cbi model/menu controller i18n view
-
-
-INFILES = $(CFILES:%=src/%)
-OUTDIRS = $(DIRECTORIES:%=dist/%)
-CPFILES = $(FILES:%=src/%)
-
-.PHONY: all compile source clean depends
-
-all: compile
-
-depends:
- mkdir -p $(OUTDIRS)
- for i in $(CPFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
- mkdir -p dist/$$(dirname $$i); cp src/$$i dist/$$i; fi; done
-
-compile: depends
- for i in $(INFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
- mkdir -p dist/$$(dirname $$i); $(LUAC) $(LUAC_OPTIONS) -o dist/$$i src/$$i; fi; done
-
-source: depends
- for i in $(INFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
- mkdir -p dist/$$(dirname $$i); cp src/$$i dist/$$i; fi; done
-
-
-clean:
- rm dist -rf
+++ /dev/null
-#!/bin/sh
-. /etc/functions.sh
-
-# initialize defaults
-RAMFS_COPY_BIN="" # extra programs for temporary ramfs root
-RAMFS_COPY_DATA="" # extra data files
-export KEEP_PATTERN=""
-export VERBOSE=1
-
-# parse options
-while [ -n "$1" ]; do
- case "$1" in
- -k)
- shift
- export KEEP_PATTERN="$1"
- ;;
- -*)
- echo "Invalid option: $1"
- exit 1
- ;;
- *) break;;
- esac
- shift;
-done
-
-export CONFFILES=/tmp/sysupgrade.conffiles
-export CONF_TAR=/tmp/sysupgrade.tgz
-
-[ -f $CONFFILES ] && rm $CONFFILES
-[ -f $CONF_TAR ] && rm $CONF_TAR
-
-export ARGV="$*"
-export ARGC="$#"
-
-[ -z "$ARGV" ] && {
- cat <<EOF
-Usage: $0 [options] <image file or URL>
-
-Options:
- -k <"file 1, file 2, ..."> Files to be kept
-EOF
- exit 1
-}
-
-add_pattern_conffiles() {
- local file="$1"
- find $KEEP_PATTERN >> "$file" 2>/dev/null
- return 0
-}
-
-# hooks
-sysupgrade_image_check="platform_check_image"
-sysupgrade_init_conffiles=""
-
-[ -n "$KEEP_PATTERN" ] && append sysupgrade_init_conffiles "add_pattern_conffiles"
-
-include /lib/upgrade
-
-do_save_conffiles() {
- [ -z "$(rootfs_type)" ] && {
- echo "Cannot save config while running from ramdisk."
- exit 3
- return 0
- }
- run_hooks "$CONFFILES" $sysupgrade_init_conffiles
-
- v "Saving config files..."
- [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V=""
- tar c${TAR_V}zf "$CONF_TAR" -T "$CONFFILES" 2>/dev/null
-}
-
-type platform_check_image >/dev/null 2>/dev/null || {
- echo "Firmware upgrade is not implemented for this platform."
- exit 1
-}
-
-for check in $sysupgrade_image_check; do
- ( eval "$check \"\$ARGV\"" ) || {
- echo "Image check '$check' failed."
- exit 2
- }
-done
-
-[ -n "$sysupgrade_init_conffiles" ] && do_save_conffiles
-run_hooks "" $sysupgrade_pre_upgrade
-
-v "Switching to ramdisk..."
-run_ramfs '. /etc/functions.sh; include /lib/upgrade; do_upgrade'
\ No newline at end of file
+++ /dev/null
-#!/bin/sh /etc/rc.common
-START=70
-
-start() {
- include /lib/network
- scan_interfaces
-
-
- ### Read interface names
- config_get wanif wan ifname
- config_get lanif lan ifname
- config_get ffif ff ifname
- config_get ffdif ffdhcp ifname
-
- config_get lanip lan ipaddr
- config_get lanmask lan netmask
-
- config_get ffip ff ipaddr
- config_get ffmask ff netmask
-
- config_get ffdip ffdhcp ipaddr
- config_get ffdmask ffdhcp netmask
-
- [ -n "$ffif" ] || return 0
-
-
- ### Creating chains
- iptables -N luci_freifunk_forwarding
- iptables -t nat -N luci_freifunk_postrouting
-
-
- ### Read from config
- config_load freifunk
-
- config_get_bool internal routing internal
- [ -n "$wanif" ] && config_get_bool internet routing internet
-
-
- ### Freifunk to Freifunk
- [ "$internal" -gt 0 ] && {
- iptables -A luci_freifunk_forwarding -i "$ffif" -o "$ffif" -j ACCEPT
- }
-
- ### Freifunk DHCP to Freifunk
- [ "$internal" -gt 0 -a -n "$ffdif" ] && {
- eval "$(ipcalc.sh $ffdip $ffdmask)"
-
- iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$ffif" -j MASQUERADE
- }
-
- ### Lan to Freifunk
- [ -n "$lanif" ] && {
- eval "$(ipcalc.sh $lanip $lanmask)"
-
- iptables -A luci_freifunk_forwarding -i "$lanif" -o "$ffif" -j ACCEPT
- iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$ffif" -j MASQUERADE
- }
-
- ### Freifunk to Wan
- [ "$internet" -gt 0 ] && {
- eval "$(ipcalc.sh $ffip $ffmask)"
-
- iptables -A luci_freifunk_forwarding -i "$ffif" -o "$wanif" -j ACCEPT
- iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$wanif" -j MASQUERADE
- }
-
- ### Freifunk DHCP to Wan
- [ "$internet" -gt 0 -a -n "$ffdif" ] && {
- eval "$(ipcalc.sh $ffdip $ffdmask)"
-
- iptables -t nat -A luci_freifunk_postrouting -s "$NETWORK/$PREFIX" -o "$wanif" -j MASQUERADE
- }
-
- ### Hook in the chains
- iptables -A forwarding_rule -j luci_freifunk_forwarding
- iptables -t nat -A postrouting_rule -j luci_freifunk_postrouting
-}
-
-stop() {
- ### Hook out the chains
- iptables -D forwarding_rule -j luci_freifunk_forwarding
- iptables -t nat -D postrouting_rule -j luci_freifunk_postrouting
-
- ### Clear the chains
- iptables -F luci_freifunk_forwarding
- iptables -t nat -F luci_freifunk_postrouting
-
- ### Delete chains
- iptables -X luci_freifunk_forwarding
- iptables -t nat -X luci_freifunk_postrouting
-}
+++ /dev/null
-#!/bin/sh /etc/rc.common
-START=46
-
-apply_portfw() {
- local cfg="$1"
- config_get proto "$cfg" proto
- config_get dport "$cfg" dport
- config_get iface "$cfg" iface
- config_get to "$cfg" to
-
- ports=$(echo $to | cut -sd: -f2)
- if [ -n "$ports" ]; then
- ports="--dport $(echo $ports | sed -e 's/-/:/')"
- else
- ports="--dport $dport"
- fi
-
- ip=$(echo $to | cut -d: -f1)
-
- if ([ "$proto" == "tcpudp" ] || [ "$proto" == "tcp" ]); then
- iptables -t nat -A luci_fw_prerouting -i "$iface" -p tcp --dport "$dport" -j DNAT --to "$to"
- iptables -A luci_fw_forward -i "$iface" -p tcp -d "$ip" $ports -j ACCEPT
- fi
-
- if ([ "$proto" == "tcpudp" ] || [ "$proto" == "udp" ]); then
- iptables -t nat -A luci_fw_prerouting -i "$iface" -p udp --dport "$dport" -j DNAT --to "$to"
- iptables -A luci_fw_forward -i "$iface" -p udp -d "$ip" $ports -j ACCEPT
- fi
-}
-
-apply_rule() {
- local cfg="$1"
- local cmd=""
-
- config_get chain "$cfg" chain
- [ -n "$chain" ] || return 0
- [ "$chain" == "forward" ] && cmd="$cmd -A luci_fw_forward"
- [ "$chain" == "input" ] && cmd="$cmd -A luci_fw_input"
- [ "$chain" == "output" ] && cmd="$cmd -A luci_fw_output"
- [ "$chain" == "prerouting" ] && cmd="$cmd -t nat -A luci_fw_prerouting"
- [ "$chain" == "postrouting" ] && cmd="$cmd -t nat -A luci_fw_postrouting"
-
- config_get iface "$cfg" iface
- [ -n "$iface" ] && cmd="$cmd -i $iface"
-
- config_get oface "$cfg" oface
- [ -n "$oface" ] && cmd="$cmd -o $oface"
-
- config_get proto "$cfg" proto
- [ -n "$proto" ] && cmd="$cmd -p $proto"
-
- config_get source "$cfg" source
- [ -n "$source" ] && cmd="$cmd -s $source"
-
- config_get destination "$cfg" destination
- [ -n "$destination" ] && cmd="$cmd -d $destination"
-
- config_get sport "$cfg" sport
- [ -n "$sport" ] && cmd="$cmd --sport $sport"
-
- config_get dport "$cfg" dport
- [ -n "$dport" ] && cmd="$cmd --dport $dport"
-
- config_get todest "$cfg" todest
- [ -n "$todest" ] && cmd="$cmd --to-destination $todest"
-
- config_get tosrc "$cfg" tosrc
- [ -n "$tosrc" ] && cmd="$cmd --to-source $tosrc"
-
- config_get mac "$cfg" mac
- [ -n "$mac" ] && cmd="$cmd -m mac --mac-source $mac"
-
- config_get jump "$cfg" jump
- [ -n "$jump" ] && cmd="$cmd -j $jump"
-
- config_get command "$cfg" command
- [ -n "$command" ] && cmd="$cmd $command"
-
- iptables $cmd
-}
-
-start() {
- ### Create subchains
- iptables -N luci_fw_input
- iptables -N luci_fw_output
- iptables -N luci_fw_forward
- iptables -t nat -N luci_fw_prerouting
- iptables -t nat -N luci_fw_postrouting
-
- ### Hook in the chains
- iptables -A input_rule -j luci_fw_input
- iptables -A output_rule -j luci_fw_output
- iptables -A forwarding_rule -j luci_fw_forward
- iptables -t nat -A prerouting_rule -j luci_fw_prerouting
- iptables -t nat -A postrouting_rule -j luci_fw_postrouting
-
- ### Read chains from config
- config_load luci_fw
- config_foreach apply_portfw portfw
- config_foreach apply_rule rule
-}
-
-stop() {
- ### Hook out the chains
- iptables -D input_rule -j luci_fw_input
- iptables -D output_rule -j luci_fw_output
- iptables -D forwarding_rule -j luci_fw_forward
- iptables -t nat -D prerouting_rule -j luci_fw_prerouting
- iptables -t nat -D postrouting_rule -j luci_fw_postrouting
-
- ### Clear subchains
- iptables -F luci_fw_input
- iptables -F luci_fw_output
- iptables -F luci_fw_forward
- iptables -t nat -F luci_fw_prerouting
- iptables -t nat -F luci_fw_postrouting
-
- ### Delete subchains
- iptables -X luci_fw_input
- iptables -X luci_fw_output
- iptables -X luci_fw_forward
- iptables -t nat -X luci_fw_prerouting
- iptables -t nat -X luci_fw_postrouting
-}
+++ /dev/null
-#!/bin/sh
-echo "Status: 302 Found"
-echo "Location: /cgi-bin/ffluci/splash/splash$PATH_INFO"
-echo
\ No newline at end of file
+++ /dev/null
-
-
\ No newline at end of file
+++ /dev/null
-module("ffluci.controller.admin.index", package.seeall)
-
-function action_wizard()
- if ffluci.http.formvalue("ip") then
- return configure_freifunk()
- end
-
- local ifaces = {}
- local wldevs = ffluci.model.uci.sections("wireless")
-
- if wldevs then
- for k, v in pairs(wldevs) do
- if v[".type"] == "wifi-device" then
- table.insert(ifaces, k)
- end
- end
- end
-
- ffluci.template.render("admin_index/wizard", {ifaces=ifaces})
-end
-
-function configure_freifunk()
- local ip = ffluci.http.formvalue("ip")
- local uci = ffluci.model.uci.Session()
-
- -- Load UCI
- uci:t_load("network")
- uci:t_load("dhcp")
- uci:t_load("freifunk")
- uci:t_load("luci_splash")
- uci:t_load("olsr")
- uci:t_load("wireless")
-
-
- -- Configure FF-Interface
- uci:t_del("network", "ff")
- uci:t_del("network", "ffdhcp")
-
- uci:t_set("network", "ff", nil, "interface")
- uci:t_set("network", "ff", "type", "bridge")
- uci:t_set("network", "ff", "proto", "static")
- uci:t_set("network", "ff", "ipaddr", ip)
- uci:t_set("network", "ff", "netmask", uci:t_get("freifunk", "community", "mask"))
- uci:t_set("network", "ff", "dns", uci:t_get("freifunk", "community", "dns"))
-
- -- Enable internal routing
- uci:t_set("freifunk", "routing", "internal", "1")
-
- -- Enable internet routing
- if ffluci.http.formvalue("shareinet") then
- uci:t_set("freifunk", "routing", "internet", "1")
- else
- uci:t_set("freifunk", "routing", "internet", "0")
- end
-
- -- Configure DHCP
- if ffluci.http.formvalue("dhcp") then
- local dhcpnet = uci:t_get("freifunk", "community", "dhcp"):match("^([0-9]+)")
- local dhcpip = ip:gsub("^[0-9]+", dhcpnet)
-
- uci:t_set("network", "ffdhcp", nil, "interface")
- uci:t_set("network", "ffdhcp", "proto", "static")
- uci:t_set("network", "ffdhcp", "ifname", "br-ff:dhcp")
- uci:t_set("network", "ffdhcp", "ipaddr", dhcpip)
- uci:t_set("network", "ffdhcp", "netmask", uci:t_get("freifunk", "community", "dhcpmask"))
-
- local dhcp = uci:t_sections("dhcp")
- if dhcp then
- for k, v in pairs(dhcp) do
- if v[".type"] == "dhcp" and v.interface == "ffdhcp" then
- uci:t_del("dhcp", k)
- end
- end
-
- local dhcpbeg = 48 + tonumber(ip:match("[0-9]+$")) * 4
-
- local sk = uci:t_add("dhcp", "dhcp")
- uci:t_set("dhcp", sk, "interface", "ffdhcp")
- uci:t_set("dhcp", sk, "start", dhcpbeg)
- uci:t_set("dhcp", sk, "limit", (dhcpbeg < 252) and 3 or 2)
- uci:t_set("dhcp", sk, "leasetime", "30m")
- end
-
- local splash = uci:t_sections("luci_splash")
- if splash then
- for k, v in pairs(splash) do
- if v[".type"] == "iface" then
- uci:t_del("luci_splash", k)
- end
- end
-
- local sk = uci:t_add("luci_splash", "iface")
- uci:t_set("luci_splash", sk, "network", "ffdhcp")
- end
- end
-
- -- Configure OLSR
- if ffluci.http.formvalue("olsr") and uci:t_sections("olsr") then
- for k, v in pairs(uci:t_sections("olsr")) do
- if v[".type"] == "Interface" or v[".type"] == "LoadPlugin" then
- uci:t_del("olsr", k)
- end
- end
-
- if ffluci.http.formvalue("shareinet") then
- uci:t_set("olsr", "dyn_gw", nil, "LoadPlugin")
- uci:t_set("olsr", "dyn_gw", "Library", "olsrd_dyn_gw.so.0.4")
- end
-
- uci:t_set("olsr", "nameservice", nil, "LoadPlugin")
- uci:t_set("olsr", "nameservice", "Library", "olsrd_nameservice.so.0.3")
- uci:t_set("olsr", "nameservice", "name", ip:gsub("%.", "-"))
- uci:t_set("olsr", "nameservice", "hosts_file", "/var/etc/hosts")
- uci:t_set("olsr", "nameservice", "suffix", ".olsr")
- uci:t_set("olsr", "nameservice", "latlon_infile", "/tmp/latlon.txt")
-
- uci:t_set("olsr", "txtinfo", nil, "LoadPlugin")
- uci:t_set("olsr", "txtinfo", "Library", "olsrd_txtinfo.so.0.1")
- uci:t_set("olsr", "txtinfo", "Accept", "127.0.0.1")
-
- local oif = uci:t_add("olsr", "Interface")
- uci:t_set("olsr", oif, "Interface", "ff")
- uci:t_set("olsr", oif, "HelloInterval", "6.0")
- uci:t_set("olsr", oif, "HelloValidityTime", "108.0")
- uci:t_set("olsr", oif, "TcInterval", "4.0")
- uci:t_set("olsr", oif, "TcValidityTime", "324.0")
- uci:t_set("olsr", oif, "MidInterval", "18.0")
- uci:t_set("olsr", oif, "MidValidityTime", "324.0")
- uci:t_set("olsr", oif, "HnaInterval", "18.0")
- uci:t_set("olsr", oif, "HnaValidityTime", "108.0")
- end
-
- -- Configure Wifi
- local wcfg = uci:t_sections("wireless")
- if wcfg then
- for iface, v in pairs(wcfg) do
- if v[".type"] == "wifi-device" and ffluci.http.formvalue("wifi."..iface) then
- -- Cleanup
- for k, j in pairs(wcfg) do
- if j[".type"] == "wifi-iface" and j.device == iface then
- uci:t_del("wireless", k)
- end
- end
-
- uci:t_set("wireless", iface, "disabled", "0")
- uci:t_set("wireless", iface, "mode", "11g")
- uci:t_set("wireless", iface, "txantenna", 1)
- uci:t_set("wireless", iface, "rxantenna", 1)
- uci:t_set("wireless", iface, "channel", uci:t_get("freifunk", "community", "channel"))
-
- local wif = uci:t_add("wireless", "wifi-iface")
- uci:t_set("wireless", wif, "device", iface)
- uci:t_set("wireless", wif, "network", "ff")
- uci:t_set("wireless", wif, "mode", "adhoc")
- uci:t_set("wireless", wif, "ssid", uci:t_get("freifunk", "community", "essid"))
- uci:t_set("wireless", wif, "bssid", uci:t_get("freifunk", "community", "bssid"))
- uci:t_set("wireless", wif, "txpower", 13)
- end
- end
- end
-
- -- Save UCI
- uci:t_save("network")
- uci:t_save("dhcp")
- uci:t_save("freifunk")
- uci:t_save("luci_splash")
- uci:t_save("olsr")
- uci:t_save("wireless")
-
- ffluci.http.redirect(ffluci.dispatcher.build_url("admin", "uci", "changes"))
-end
\ No newline at end of file
+++ /dev/null
-module("ffluci.controller.admin.network", package.seeall)
\ No newline at end of file
+++ /dev/null
-module("ffluci.controller.admin.services", package.seeall)
\ No newline at end of file
+++ /dev/null
-module("ffluci.controller.admin.system", package.seeall)
-
-require("ffluci.sys")
-require("ffluci.http")
-require("ffluci.util")
-require("ffluci.fs")
-require("ffluci.model.ipkg")
-require("ffluci.model.uci")
-
-function action_editor()
- local file = ffluci.http.formvalue("file", "")
- local data = ffluci.http.formvalue("data")
- local err = nil
- local msg = nil
- local stat = true
-
- if file and data then
- stat, err = ffluci.fs.writefile(file, data)
- end
-
- if not stat then
- err = ffluci.util.split(err, " ")
- table.remove(err, 1)
- msg = table.concat(err, " ")
- end
-
- local cnt, err = ffluci.fs.readfile(file)
- if cnt then
- cnt = ffluci.util.pcdata(cnt)
- end
- ffluci.template.render("admin_system/editor", {fn=file, cnt=cnt, msg=msg})
-end
-
-function action_ipkg()
- local file = "/etc/ipkg.conf"
- local data = ffluci.http.formvalue("data")
- local stat = nil
- local err = nil
-
- if data then
- stat, err = ffluci.fs.writefile(file, data)
- end
-
- local cnt = ffluci.fs.readfile(file)
- if cnt then
- cnt = ffluci.util.pcdata(cnt)
- end
-
- ffluci.template.render("admin_system/ipkg", {cnt=cnt, msg=err})
-end
-
-function action_packages()
- local ipkg = ffluci.model.ipkg
- local void = nil
- local submit = ffluci.http.formvalue("submit")
-
-
- -- Search query
- local query = ffluci.http.formvalue("query")
- query = (query ~= '') and query or nil
-
-
- -- Packets to be installed
- local install = submit and ffluci.http.formvaluetable("install")
-
- -- Install from URL
- local url = ffluci.http.formvalue("url")
- if url and url ~= '' and submit then
- if not install then
- install = {}
- end
- install[url] = 1
- end
-
- -- Do install
- if install then
- for k, v in pairs(install) do
- void, install[k] = ipkg.install(k)
- end
- end
-
-
- -- Remove packets
- local remove = submit and ffluci.http.formvaluetable("remove")
- if remove then
- for k, v in pairs(remove) do
- void, remove[k] = ipkg.remove(k)
- end
- end
-
-
- -- Update all packets
- local update = ffluci.http.formvalue("update")
- if update then
- void, update = ipkg.update()
- end
-
-
- -- Upgrade all packets
- local upgrade = ffluci.http.formvalue("upgrade")
- if upgrade then
- void, upgrade = ipkg.upgrade()
- end
-
-
- -- Package info
- local info = ffluci.model.ipkg.info(query)
- info = info or {}
- local pkgs = {}
-
- -- Sort after status and name
- for k, v in pairs(info) do
- local x = 0
- for i, j in pairs(pkgs) do
- local vins = (v.Status and v.Status.installed)
- local jins = (j.Status and j.Status.installed)
- if vins ~= jins then
- if vins then
- break
- end
- else
- if j.Package > v.Package then
- break
- end
- end
- x = i
- end
- table.insert(pkgs, x+1, v)
- end
-
- ffluci.template.render("admin_system/packages", {pkgs=pkgs, query=query,
- install=install, remove=remove, update=update, upgrade=upgrade})
-end
-
-function action_passwd()
- local p1 = ffluci.http.formvalue("pwd1")
- local p2 = ffluci.http.formvalue("pwd2")
- local stat = nil
-
- if p1 or p2 then
- if p1 == p2 then
- stat = ffluci.sys.user.setpasswd("root", p1)
- else
- stat = 10
- end
- end
-
- ffluci.template.render("admin_system/passwd", {stat=stat})
-end
-
-function action_reboot()
- local reboot = ffluci.http.formvalue("reboot")
- ffluci.template.render("admin_system/reboot", {reboot=reboot})
- if reboot then
- ffluci.sys.reboot()
- end
-end
-
-function action_sshkeys()
- local file = "/etc/dropbear/authorized_keys"
- local data = ffluci.http.formvalue("data")
- local stat = nil
- local err = nil
-
- if data then
- stat, err = ffluci.fs.writefile(file, data)
- end
-
- local cnt = ffluci.fs.readfile(file)
- if cnt then
- cnt = ffluci.util.pcdata(cnt)
- end
-
- ffluci.template.render("admin_system/sshkeys", {cnt=cnt, msg=err})
-end
-
-function action_upgrade()
- local ret = nil
- local plat = ffluci.fs.mtime("/lib/upgrade/platform.sh")
-
- local image = ffluci.http.formvalue("image")
- local imgname = ffluci.http.formvalue("image_name")
- local keepcfg = ffluci.http.formvalue("keepcfg")
-
- if plat and imgname then
- local kpattern = nil
- if keepcfg then
- local files = ffluci.model.uci.sections("luci").flash_keep
- if files.luci and files.luci.flash_keep then
- kpattern = ""
- for k,v in pairs(files.luci.flash_keep) do
- kpattern = kpattern .. " " .. v
- end
- end
- end
- ret = ffluci.sys.flash(image, kpattern)
- end
-
- ffluci.template.render("admin_system/upgrade", {sysupgrade=plat, ret=ret})
-end
\ No newline at end of file
+++ /dev/null
-module("ffluci.controller.admin.uci", package.seeall)
-require("ffluci.util")
-require("ffluci.sys")
-
--- This function has a higher priority than the admin_uci/apply template
-function action_apply()
- local changes = ffluci.model.uci.changes()
- local output = ""
-
- if changes then
- local com = {}
- local run = {}
-
- -- Collect files to be applied and commit changes
- for i, line in ipairs(ffluci.util.split(changes)) do
- local r = line:match("^-?([^.]+)")
- if r then
- com[r] = true
-
- if ffluci.config.uci_oncommit and ffluci.config.uci_oncommit[r] then
- run[ffluci.config.uci_oncommit[r]] = true
- end
- end
- end
-
- -- Apply
- for config, i in pairs(com) do
- ffluci.model.uci.commit(config)
- end
-
- -- Search for post-commit commands
- for cmd, i in pairs(run) do
- output = output .. cmd .. ":" .. ffluci.sys.exec(cmd) .. "\n"
- end
- end
-
- ffluci.template.render("admin_uci/apply", {changes=changes, output=output})
-end
-
-
-function action_revert()
- local changes = ffluci.model.uci.changes()
- if changes then
- local revert = {}
-
- -- Collect files to be reverted
- for i, line in ipairs(ffluci.util.split(changes)) do
- local r = line:match("^-?([^.]+)")
- if r then
- revert[r] = true
- end
- end
-
- -- Revert them
- for k, v in pairs(revert) do
- ffluci.model.uci.revert(k)
- end
- end
-
- ffluci.template.render("admin_uci/revert", {changes=changes})
-end
\ No newline at end of file
+++ /dev/null
-module("ffluci.controller.admin.wifi", package.seeall)
\ No newline at end of file
+++ /dev/null
-module("ffluci.controller.splash.splash", package.seeall)
-
-function action_activate()
- local mac = ffluci.sys.net.ip4mac(ffluci.http.env.REMOTE_ADDR)
- if mac and ffluci.http.formvalue("accept") then
- os.execute("luci-splash add "..mac.." >/dev/null 2>&1")
- ffluci.http.redirect(ffluci.model.uci.get("freifunk", "community", "homepage"))
- else
- ffluci.http.redirect(ffluci.dispatcher.build_url())
- end
-end
-
-function action_accepted()
- ffluci.http.redirect(ffluci.dispatcher.build_url())
-end
-
-function action_unknown()
- ffluci.http.redirect(ffluci.dispatcher.build_url())
-end
\ No newline at end of file
+++ /dev/null
-contact = "Contact"
-luci = "User Interface"
-
-hello = "Hello!"
-admin1 = "This is the administration area of FFLuCI."
-admin2 = "FFLuCI is a free, flexible, and user friendly graphical interface for configuring OpenWRT Kamikaze."
-admin3 = "On the following pages you can adjust all important settings of your router."
-admin4 = "You will find a navigation leading to the different configuration pages on the left side."
-admin5 = [[As we are always want to improve this interface we are looking forward
-to your feedback and suggestions.]]
-admin6 = "And now have fun with your router!"
-team = "The FFLuCI Team"
-
-contact1 = [[This information will be available on the public contact page.
-As stated in the Picopeering Agreement you should at least enter your e-mail address.
-To display your router on any topography map, please enter your geographical coordinates or at least
-your street and house number in the location field.]]
-nickname = "Nickname"
-mail1 = "This field is essential!"
-phone = "Phone"
-location = "Location"
-coord = "Coordinates"
-coord1 = "Latitude;Longitude (e.g. 51.5;12.9)"
-note = "Note"
-
-luci1 = "Here you can customize the settings and the functionality of FFLuCI."
-language = "Language"
-general = "General"
-catpriv = "Category Privileges"
-catpriv1 = [[To secure FFLuCI even further the user and group privileges of
-each category can be decreased. Therefore an attacker cannot takeover the whole system
-when a security exploit for any publicly available page is found.]]
-ucicommit = "Post-commit actions"
-ucicommit1 = [[These commands will be executed automatically when a given UCI configuration is committed allowing
-changes to be applied instantly.]]
-keepflash = "Files to be kept when flashing a new firmware"
-keepflash1 = "When flashing a new firmware with FFLuCI these files will be added to the new firmware installation."
\ No newline at end of file
+++ /dev/null
-uci_applied = "The following changes were applied"
-uci_reverted = "The following changes were reverted"
\ No newline at end of file
+++ /dev/null
--- Todo: Translate
-m = Map("freifunk", translate("contact", "Kontakt"), translate("contact1", [[Diese Daten sind
-auf der öffentlichen Kontaktseite sichtbar. Bitte gib an, wie man dich am besten kontaktieren kann.
-Diese Informationen sollten nach der Picopeering Vereinbarung mindestens deine E-Mail-Adresse enthalten.
-Damit dein Knoten durch Topographieprogramme erfasst werden kann, gib bitte deine Geokoordinaten oder
-zumindest deine Straße und Hausnummer unter Standort an.]]))
-
-c = m:section(NamedSection, "contact", "public")
-
-c:option(Value, "nickname", translate("nickname", "Pseudonym"))
-c:option(Value, "name", translate("name", "Name"))
-c:option(Value, "mail", translate("mail", "E-Mail"), translate("mail1", "Bitte unbedingt angeben!"))
-c:option(Value, "phone", translate("phone", "Telefon"))
-c:option(Value, "location", translate("location", "Standort"))
-c:option(Value, "geo", translate("coord", "Koordinaten"), translate("coord1", "Bitte als Breite;Länge (z.B: 51.5;12.9) angeben"))
-c:option(Value, "note", translate("note", "Notiz"))
-
-return m
\ No newline at end of file
+++ /dev/null
--- Todo: Translate
-m = Map("freifunk", "Freifunk")
-
-s = m:section(NamedSection, "routing", "settings", "Netzverkehr")
-s:option(Flag, "internal", "Freifunk zulassen", "immer aktivieren!")
-s:option(Flag, "internet", "Internet zulassen")
-
-c = m:section(NamedSection, "community", "public", "Gemeinschaft", [[Dies sind die Grundeinstellungen
-für die lokale Freifunkgemeinschaft. Diese Werte wirken sich NICHT auf die Konfiguration
-des Routers aus, sondern definieren nur die Vorgaben für den Freifunkassistenten.]])
-c:option(Value, "name", "Gemeinschaft")
-c:option(Value, "homepage", "Webseite")
-c:option(Value, "essid", "ESSID")
-c:option(Value, "bssid", "BSSID")
-c:option(Value, "channel", "Funkkanal")
-c:option(Value, "realm", "Realm")
-c:option(Value, "net", "Adressbereich")
-c:option(Value, "mask", "Netzmaske")
-c:option(Value, "dns", "DNS-Server")
-c:option(Value, "dhcp", "DHCP-Bereich")
-c:option(Value, "dhcpmask", "DHCP-Maske")
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Translate
-require("ffluci.config")
-m = Map("luci", translate("luci", "Oberfläche"), translate("luci1",
- "Hier können Eigenschaften und die Funktionalität der Oberfläche angepasst werden."))
-
-c = m:section(NamedSection, "main", "core", translate("general", "Allgemein"))
-
-l = c:option(ListValue, "lang", translate("language", "Sprache"))
-for k, v in pairs(ffluci.config.languages) do
- if k:sub(1, 1) ~= "." then
- l:value(k, v)
- end
-end
-
-t = c:option(ListValue, "mediaurlbase", translate("design", "Design"))
-for k, v in pairs(ffluci.config.themes) do
- if k:sub(1, 1) ~= "." then
- t:value(v, k)
- end
-end
-
-p = m:section(NamedSection, "category_privileges", "core", translate("catpriv", "Kategorieprivilegien"),
- translate("catpriv1", [[Zur zusätzlichen Sicherung der Oberfläche gegen Angreifer, können hier die
-Ausführungsrechte der Seiten für einzelne Kategorien reduziert werden. So können z.B. Sicherheitslücken im
-ungeschützten Bereich der Oberfläche nicht mehr zur Übernahme des Routers genutzt werden.]]))
-p.dynamic = true
-
-u = m:section(NamedSection, "uci_oncommit", "event", translate("ucicommit", "UCI-Befehle beim Anwenden"),
- translate("ucicommit1", [[Beim Anwenden
-der Konfiguration aus der Oberflächliche heraus können automatisch die relevanten Dienste neugestart werden,
-sodass Änderungen sofort nach dem Anwenden aktiv werden und der Router nicht erst neugestartet werden muss.]]))
-u.dynamic = true
-
-f = m:section(NamedSection, "flash_keep", "extern", translate("keepflash", "Zu übernehmende Dateien bei Firmwareupgrade"),
- translate("keepflash1", [[Die folgenden Dateien und Verzeichnisse werden beim Aktualisieren der Firmware
-über die Oberfläche automatisch in die neue Firmware übernommen.]]))
-f.dynamic = true
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Translate, Add descriptions and help texts
-require("ffluci.model.uci")
-require("ffluci.sys")
-
-m = Map("dhcp", "DHCP", [[Mit Hilfe von DHCP können Netzteilnehmer automatisch
-ihre Netzwerkkonfiguration (IP-Adresse, Netzmaske, DNS-Server, DHCP, ...) beziehen.]])
-
-s = m:section(TypedSection, "dhcp")
-s.addremove = true
-s.anonymous = true
-
-iface = s:option(ListValue, "interface", "Schnittstelle")
-for k, v in pairs(ffluci.model.uci.sections("network")) do
- if v[".type"] == "interface" and k ~= "loopback" then
- iface:value(k)
- s:depends("interface", k) -- Only change sections with existing interfaces
- end
-end
-
-s:option(Value, "start", "Start", "Erste vergebene Adresse (letztes Oktett)").rmempty = true
-
-s:option(Value, "limit", "Limit", "Anzahl zu vergebender Adressen -1").rmempty = true
-
-s:option(Value, "leasetime", "Laufzeit").rmempty = true
-
-s:option(Flag, "dynamicdhcp", "Dynamisches DHCP").rmempty = true
-
-s:option(Value, "name", "Name").optional = true
-
-s:option(Flag, "ignore", "Schnittstelle ignorieren", "DHCP für dieses Netzwerk deaktivieren").optional = true
-
-s:option(Value, "netmask", "Netzmaske").optional = true
-
-s:option(Flag, "force", "Start erzwingen").optional = true
-
-for i, line in pairs(ffluci.sys.execl("dnsmasq --help dhcp")) do
- k, v = line:match("([^ ]+) +([^ ]+)")
- s:option(Value, "dhcp"..k, v).optional = true
-end
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Translate, Add descriptions and help texts
-m = Map("luci_fw", "Firewall", [[Mit Hilfe der Firewall können Zugriffe auf das Netzwerk
-erlaubt, verboten oder umgeleitet werden.]])
-
-s = m:section(TypedSection, "rule")
-s.addremove = true
-s.anonymous = true
-
-chain = s:option(ListValue, "chain", "Kette")
-chain:value("forward", "Forward")
-chain:value("input", "Input")
-chain:value("output", "Output")
-chain:value("prerouting", "Prerouting")
-chain:value("postrouting", "Postrouting")
-
-s:option(Value, "iface", "Eingangsschnittstelle").optional = true
-s:option(Value, "oface", "Ausgangsschnittstelle").optional = true
-
-proto = s:option(ListValue, "proto", "Protokoll")
-proto.optional = true
-proto:value("")
-proto:value("tcp", "TCP")
-proto:value("udp", "UDP")
-
-s:option(Value, "source", "Quelladresse").optional = true
-s:option(Value, "destination", "Zieladresse").optional = true
-s:option(Value, "mac", "MAC-Adresse").optional = true
-
-sport = s:option(Value, "sport", "Quellport")
-sport.optional = true
-sport:depends("proto", "tcp")
-sport:depends("proto", "udp")
-
-dport = s:option(Value, "dport", "Zielport")
-dport.optional = true
-dport:depends("proto", "tcp")
-dport:depends("proto", "udp")
-
-tosrc = s:option(Value, "tosrc", "Neue Quelladresse [SNAT]")
-tosrc.optional = true
-tosrc:depends("jump", "SNAT")
-
-tosrc = s:option(Value, "todest", "Neue Zieladresse [DNAT]")
-tosrc.optional = true
-tosrc:depends("jump", "DNAT")
-
-jump = s:option(ListValue, "jump", "Aktion")
-jump.rmempty = true
-jump:value("", "")
-jump:value("ACCEPT", "annehmen (ACCEPT)")
-jump:value("REJECT", "zurückweisen (REJECT)")
-jump:value("DROP", "verwerfen (DROP)")
-jump:value("LOG", "protokollieren (LOG)")
-jump:value("DNAT", "Ziel umschreiben (DNAT) [nur Prerouting]")
-jump:value("MASQUERADE", "maskieren (MASQUERADE) [nur Postrouting]")
-jump:value("SNAT", "Quelle umschreiben (SNAT) [nur Postrouting]")
-
-
-add = s:option(Value, "command", "Eigener Befehl")
-add.size = 50
-add.rmempty = true
-
-return m
+++ /dev/null
--- ToDo: Translate, Add descriptions and help texts
-m = Map("network", "Schnittstellen", [[An dieser Stelle können die einzelnen Schnittstellen
-des Netzwerkes konfiguriert werden. Es können mehrere Schnittstellen zu einer Brücke zusammengefasst werden,
-indem diese durch Leerzeichen getrennt aufgezählt werden und ein entsprechender Haken im Feld Netzwerkbrücke
-gesetzt wird. Es können VLANs in der Notation SCHNITTSTELLE.VLANNR (z.B.: eth0.1) verwendet werden.]])
-
-s = m:section(TypedSection, "interface")
-s.addremove = true
-s:exclude("loopback")
-s:depends("proto", "static")
-s:depends("proto", "dhcp")
-
-p = s:option(ListValue, "proto", "Protokoll")
-p:value("static", "statisch")
-p:value("dhcp", "DHCP")
-p.default = "static"
-
-br = s:option(Flag, "type", "Netzwerkbrücke", "überbrückt angegebene Schnittstelle(n)")
-br.enabled = "bridge"
-br.rmempty = true
-
-s:option(Value, "ifname", "Schnittstelle")
-
-s:option(Value, "ipaddr", "IP-Adresse")
-
-s:option(Value, "netmask", "Netzmaske"):depends("proto", "static")
-
-gw = s:option(Value, "gateway", "Gateway")
-gw:depends("proto", "static")
-gw.rmempty = true
-
-dns = s:option(Value, "dns", "DNS-Server")
-dns:depends("proto", "static")
-dns.optional = true
-
-mtu = s:option(Value, "mtu", "MTU")
-mtu.optional = true
-mtu.isinteger = true
-
-mac = s:option(Value, "macaddr", "MAC-Adresse")
-mac.optional = true
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Translate, Add descriptions and help texts
-require("ffluci.sys")
-m = Map("luci_fw", "Portweiterleitung", [[Portweiterleitungen ermöglichen es interne
-Netzwerkdienste von einem anderen externen Netzwerk aus erreichbar zu machen.]])
-
-s = m:section(TypedSection, "portfw")
-s.addremove = true
-s.anonymous = true
-
-iface = s:option(ListValue, "iface", "Externes Interface")
-iface:value("")
-for k,v in pairs(ffluci.sys.net.devices()) do
- iface:value(v)
-end
-
-proto = s:option(ListValue, "proto", "Protokoll")
-proto:value("tcp", "TCP")
-proto:value("udp", "UDP")
-proto:value("tcpudp", "TCP + UDP")
-
-dport = s:option(Value, "dport", "Externer Port", "Port[:Endport]")
-
-to = s:option(Value, "to", "Interne Adresse", "IP-Adresse[:Zielport[-Zielendport]]")
-
-return m
+++ /dev/null
--- ToDo: Translate, Add descriptions and help texts
-m = Map("network", "Punkt-zu-Punkt Verbindungen", [[Punkt-zu-Punkt Verbindungen
-über PPPoE oder PPTP werden häufig dazu verwendet, um über DSL o.ä. Techniken eine
-Verbindung zum Internetgateway eines Internetzugangsanbieters aufzubauen.]])
-
-s = m:section(TypedSection, "interface")
-s.addremove = true
-s:depends("proto", "pppoe")
-s:depends("proto", "pptp")
-
-p = s:option(ListValue, "proto", "Protokoll")
-p:value("pppoe", "PPPoE")
-p:value("pptp", "PPTP")
-p.default = "pppoe"
-
-s:option(Value, "ifname", "Schnittstelle")
-
-s:option(Value, "username", "Benutzername")
-s:option(Value, "password", "Passwort")
-
-s:option(Value, "keepalive", "Keep-Alive", "Bei einer Verbindungstrennung automatisch neu verbinden").optional = true
-
-s:option(Value, "demand", "Dial on Demand (idle time)", "Zeit nach der die Verbindung bei Inaktivität getrennt wird").optional = true
-
-srv = s:option(Value, "server", "PPTP-Server")
-srv:depends("proto", "pptp")
-srv.optional = true
-
-mtu = s:option(Value, "mtu", "MTU")
-mtu.optional = true
-mtu.isinteger = true
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Translate, Add descriptions and help texts
-m = Map("qos", "Quality of Service", [[Mit Hilfe von QoS kann einzelnen Rechnern oder Netzwerkdiensten
-eine höhere oder niedrigere Priorität zugewiesen werden.]])
-
-s = m:section(TypedSection, "interface", "Schnittstellen")
-s.addremove = true
-
-s:option(Flag, "enabled", "aktiviert")
-
-c = s:option(ListValue, "classgroup", "Klassifizierung")
-c:value("Default", "standard")
-c.default = "Default"
-
-s:option(Flag, "overhead", "Overheadberechnung")
-
-s:option(Value, "download", "Downlink", "kb/s")
-
-s:option(Value, "upload", "Uplink", "kb/s")
-
-s = m:section(TypedSection, "classify", "Klassifizierung")
-
-s.anonymous = true
-s.addremove = true
-
-t = s:option(ListValue, "target", "Klasse")
-t:value("Priority")
-t:value("Express")
-t:value("Normal")
-t:value("Bulk")
-t.default = "Normal"
-
-s:option(Value, "srchost", "Quelladresse", "Quellhost / Quellnetz").optional = true
-s:option(Value, "dsthost", "Zieladresse", "Zielhost / Zielnetz").optional = true
-s:option(Value, "layer7", "Layer 7").optional = true
-
-p2p = s:option(ListValue, "ipp2p", "P2P")
-p2p:value("")
-p2p:value("all", "Alle")
-p2p:value("bit", "Bittorrent")
-p2p:value("dc", "DirectConnect")
-p2p:value("edk", "eDonkey")
-p2p:value("gnu", "Gnutella")
-p2p:value("kazaa", "Kazaa")
-p2p.optional = true
-
-p = s:option(ListValue, "proto", "Protokoll")
-p:value("")
-p:value("tcp", "TCP")
-p:value("udp", "UDP")
-p:value("icmp", "ICMP")
-p.optional = true
-
-s:option(Value, "ports", "Port").optional = true
-s:option(Value, "portrange", "Portbereich").optional = true
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Translate, Add descriptions and help texts
-m = Map("network", "Statische Routen", [[Statische Routen geben an,
-über welche Schnittstelle und welches Gateway ein bestimmter Host
-oder ein bestimmtes Netzwerk erreicht werden kann.]])
-
-s = m:section(TypedSection, "route")
-s.addremove = true
-s.anonymous = true
-
-iface = s:option(ListValue, "interface", "Schnittstelle")
-for k, v in pairs(ffluci.model.uci.sections("network")) do
- if v[".type"] == "interface" and k ~= "loopback" then
- iface:value(k)
- end
-end
-
-s:option(Value, "target", "Ziel", "Host-IP oder Netzwerk")
-
-s:option(Value, "netmask", "Netzmaske", "falls Ziel ein Netzwerk ist").rmemepty = true
-
-s:option(Value, "gateway", "Gateway")
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Autodetect things, maybe use MultiValue instead, Translate, Add descriptions
-m = Map("network", "VLAN", [[Die Netzwerkschnittstellen am Router
-können zu verschienden VLANs zusammengefasst werden, in denen Geräte miteinander direkt
-kommunizieren können. VLANs werden auch häufig dazu genutzt, um Netzwerke voneiander zu trennen.
-So ist oftmals eine Schnittstelle als Uplink zu einem größerem Netz, wie dem Internet vorkonfiguriert
-und die anderen Schnittstellen bilden ein VLAN für das lokale Netzwerk.]])
-
-s = m:section(TypedSection, "switch", nil, [[Die zu einem VLAN gehörenden Schnittstellen
-werden durch Leerzeichen getrennt. Die Schnittstelle mit der höchsten Nummer (meistens 5) bildet
-in der Regel die Verbindung zur internen Netzschnittstelle des Routers. Bei Geräten mit 5 Schnittstellen
-ist in der Regel die Schnittstelle mit der niedrigsten Nummer (0) die standardmäßige Uplinkschnittstelle des Routers.]])
-
-for i = 0, 15 do
- s:option(Value, "vlan"..i, "vlan"..i).optional = true
-end
-
-return m
\ No newline at end of file
+++ /dev/null
-m = Map("dhcp", "Dnsmasq", "Dnsmasq ist ein kombinierter DHCP-Server und DNS-Forwarder für NAT-Firewalls.")
-
-s = m:section(TypedSection, "dnsmasq", "Einstellungen")
-s.anonymous = true
-
-s:option(Flag, "domainneeded", "Anfragen nur mit Domain", "Anfragen ohne Domainnamen nicht weiterleiten")
-s:option(Flag, "authoritative", "Authoritativ", "Dies ist der einzige DHCP im lokalen Netz")
-s:option(Flag, "boguspriv", "Private Anfragen filtern", "Reverse DNS-Anfragen für lokalen Netze nicht weiterleiten")
-s:option(Flag, "filterwin2k", "Windowsanfragen filtern", "nutzlose DNS-Anfragen aktueller Windowssysteme filtern")
-s:option(Flag, "localise_queries", "Lokalisiere Anfragen", "Gibt die Adresse eines Hostnamen entsprechend seines Subnetzes zurück")
-s:option(Value, "local", "Lokale Server")
-s:option(Value, "domain", "Lokale Domain")
-s:option(Flag, "expandhosts", "Erweitere Hosts", "Fügt Domainnamen zu einfachen Hosteinträgen in der Resolvdatei hinzu")
-s:option(Flag, "nonegcache", "Unbekannte nicht cachen", "Negative DNS-Antworten nicht zwischenspeichern")
-s:option(Flag, "readethers", "Verwende /etc/ethers", "Lese Informationen aus /etc/ethers um den DHCP-Server zu konfigurieren")
-s:option(Value, "leasefile", "Leasedatei", "Speicherort für vergebenen DHCP-Adressen")
-s:option(Value, "resolvfile", "Resolvdatei", "Lokale DNS-Datei")
-s:option(Flag, "nohosts", "Ignoriere /etc/hosts").optional = true
-s:option(Flag, "strictorder", "Strikte Reihenfolge", "DNS-Server werden strikt der Reihenfolge in der Resolvdatei nach abgefragt").optional = true
-s:option(Flag, "logqueries", "Schreibe Abfragelog").optional = true
-s:option(Flag, "noresolv", "Ignoriere Resolvdatei").optional = true
-s:option(Value, "dnsforwardmax", "gleichzeitige Abfragen").optional = true
-s:option(Value, "port", "DNS-Port").optional = true
-s:option(Value, "ednspacket_max", "max. EDNS.0 Paketgröße").optional = true
-s:option(Value, "dhcpleasemax", "max. DHCP-Leases").optional = true
-s:option(Value, "addnhosts", "Zusätzliche Hostdatei").optional = true
-s:option(Value, "queryport", "Abfrageport").optional = true
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Translate, Add descriptions
-m = Map("dropbear", "SSH-Server", [[Der SSH-Server ermöglicht Shell-Zugriff
-über das Netzwerk und bietet einen integrierten SCP-Dienst.]])
-
-s = m:section(TypedSection, "dropbear")
-s.anonymous = true
-
-port = s:option(Value, "Port", "Port")
-port.isinteger = true
-
-pwauth = s:option(Flag, "PasswordAuth", "Passwortanmeldung", "Erlaube Anmeldung per Passwort")
-pwauth.enabled = 'on'
-pwauth.disabled = 'off'
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Translate, Add descriptions
-m = Map("httpd", "HTTP-Server", "Der HTTP-Server ist u.a. für die Bereitstellung dieser Obefläche zuständig.")
-
-s = m:section(TypedSection, "httpd")
-s.anonymous = true
-
-port = s:option(Value, "port", "Port")
-port.isinteger = true
-
-s:option(Value, "home", "Wurzelverzeichnis")
-
-config = s:option(Value, "c_file", "Konfigurationsdatei", "/etc/httpd.conf wenn leer")
-config.rmempty = true
-
-realm = s:option(Value, "realm", "Anmeldeaufforderung", "Aufforderungstext zum Anmelden im Administrationsbereich")
-realm.rmempty = true
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Autodetect things, Translate, Add descriptions
-require("ffluci.fs")
-
-m = Map("olsr", "OLSR", [[OLSR ist ein flexibles Routingprotokoll,
-dass den Aufbau von mobilen Ad-Hoc Netzen unterstützt.]])
-
-s = m:section(NamedSection, "general", "olsr", "Allgemeine Einstellungen")
-
-debug = s:option(ListValue, "DebugLevel", "Debugmodus")
-for i=0, 9 do
- debug:value(i)
-end
-
-ipv = s:option(ListValue, "IpVersion", "Internet Protokoll")
-ipv:value("4", "IPv4")
-ipv:value("6", "IPv6")
-
-noint = s:option(Flag, "AllowNoInt", "Start ohne Netzwerk")
-noint.enabled = "yes"
-noint.disabled = "no"
-
-s:option(Value, "Pollrate", "Abfragerate (Pollrate)", "s")
-
-tcr = s:option(ListValue, "TcRedundancy", "TC-Redundanz")
-tcr:value("0", "MPR-Selektoren")
-tcr:value("1", "MPR-Selektoren und MPR")
-tcr:value("2", "Alle Nachbarn")
-
-s:option(Value, "MprCoverage", "MPR-Erfassung")
-
-lql = s:option(ListValue, "LinkQualityLevel", "VQ-Level")
-lql:value("0", "deaktiviert")
-lql:value("1", "MPR-Auswahl")
-lql:value("2", "MPR-Auswahl und Routing")
-
-lqfish = s:option(Flag, "LinkQualityFishEye", "VQ-Fisheye")
-
-s:option(Value, "LinkQualityWinSize", "VQ-Fenstergröße")
-
-s:option(Value, "LinkQualityDijkstraLimit", "VQ-Dijkstralimit")
-
-hyst = s:option(Flag, "UseHysteresis", "Hysterese aktivieren")
-hyst.enabled = "yes"
-hyst.disabled = "no"
-
-
-i = m:section(TypedSection, "Interface", "Schnittstellen")
-i.anonymous = true
-i.addremove = true
-i.dynamic = true
-
-network = i:option(ListValue, "Interface", "Netzwerkschnittstellen")
-network:value("")
-for k, v in pairs(ffluci.model.uci.sections("network")) do
- if v[".type"] == "interface" and k ~= "loopback" then
- network:value(k)
- end
-end
-
-i:option(Value, "HelloInterval", "Hello-Intervall")
-
-i:option(Value, "HelloValidityTime", "Hello-Gültigkeit")
-
-i:option(Value, "TcInterval", "TC-Intervall")
-
-i:option(Value, "TcValidityTime", "TC-Gültigkeit")
-
-i:option(Value, "MidInterval", "MID-Intervall")
-
-i:option(Value, "MidValidityTime", "MID-Gültigkeit")
-
-i:option(Value, "HnaInterval", "HNA-Intervall")
-
-i:option(Value, "HnaValidityTime", "HNA-Gültigkeit")
-
-
-p = m:section(TypedSection, "LoadPlugin", "Plugins")
-p.addremove = true
-p.dynamic = true
-
-lib = p:option(ListValue, "Library", "Bibliothek")
-lib:value("")
-for k, v in pairs(ffluci.fs.dir("/usr/lib")) do
- if v:sub(1, 6) == "olsrd_" then
- lib:value(v)
- end
-end
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Translate, Add descriptions and help texts
-require("ffluci.model.uci")
-
-m = Map("luci_splash", "Client-Splash", [[Client-Splash ist das Freifunk Hotspot-Authentifizierungs-System.]])
-
-s = m:section(NamedSection, "general", "core", "Allgemein")
-s:option(Value, "leasetime", "Freigabezeit", "h")
-
-s = m:section(TypedSection, "iface", "Schnittstellen")
-s.addremove = true
-s.anonymous = true
-
-iface = s:option(ListValue, "network", "Schnittstelle")
-for k, v in pairs(ffluci.model.uci.sections("network")) do
- if v[".type"] == "interface" and k ~= "loopback" then
- iface:value(k)
- end
-end
-
-s = m:section(TypedSection, "whitelist", "Automatische Freigabe")
-s.addremove = true
-s.anonymous = true
-s:option(Value, "mac", "MAC-Adresse")
-
-s = m:section(TypedSection, "blacklist", "Automatische Sperrung")
-s.addremove = true
-s.anonymous = true
-s:option(Value, "mac", "MAC-Adresse")
-
-return m
\ No newline at end of file
+++ /dev/null
-m = Map("fstab", "Einhängepunkte")
-
-mount = m:section(TypedSection, "mount", "Einhängepunkte", [[Einhängepunkte bestimmen, an welcher Stelle des Dateisystems
-bestimmte Laufwerke und Speicher zur Verwendung eingebunden werden.]])
-mount.anonymous = true
-mount.addremove = true
-
-mount:option(Flag, "enabled", "aktivieren")
-mount:option(Value, "device", "Gerät", "Die Gerätedatei des Speichers oder der Partition (z.B.: /dev/sda)")
-mount:option(Value, "target", "Einhängepunkt", "Die Stelle an der der Speicher in das Dateisystem eingehängt wird.")
-mount:option(Value, "fstype", "Dateisystem", "Das Dateisystem mit dem der Speicher formatiert ist (z.B.: ext3)")
-mount:option(Value, "options", "Optionen", "Weitere Optionen (siehe das Handbuch des Befehls 'mount')")
-
-
-swap = m:section(TypedSection, "swap", "SWAP", [[Falls der Arbeitsspeicher des Routers nicht ausreicht,
-kann dieser nicht benutzte Daten zeitweise auf einem SWAP-Laufwerk auslagern um so die
-effektive Größe des Arbeitsspeichers zu erhöhen. Die Auslagerung der Daten ist natürlich bedeutend langsamer
-als direkte Arbeitsspeicherzugriffe.]])
-swap.anonymous = true
-swap.addremove = true
-
-swap:option(Flag, "enabled", "aktivieren")
-swap:option(Value, "device", "Gerät", "Die Gerätedatei des Speichers oder der Partition (z.B.: /dev/sda)")
-
-return m
+++ /dev/null
-m = Map("system", "Hostname", [[Definiert den Hostnamen des Routers.
-Der Hostname ist eine im Netzwerk eindeutige Kennung, die dieses Gerät identifiziert.]])
-
-s = m:section(TypedSection, "system")
-s.anonymous = true
-
-s:option(Value, "hostname", "Hostname")
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Translate, Add descriptions and help texts
-
-m = Map("wireless", "Geräte", [[An dieser Stelle können eingebaute WLAN-Geräte konfiguriert werden.]])
-
-s = m:section(TypedSection, "wifi-device")
---s.addremove = true
-
-en = s:option(Flag, "disabled", "Aktivieren")
-en.enabled = "0"
-en.disabled = "1"
-
-t = s:option(ListValue, "type", "Typ")
-t:value("broadcom")
-t:value("atheros")
-t:value("mac80211")
-t:value("prism2")
---[[
-require("ffluci.sys")
-local c = ". /etc/functions.sh;for i in /lib/wifi/*;do . $i;done;echo $DRIVERS"
-for driver in ffluci.sys.execl(c)[1]:gmatch("[^ ]+") do
- t:value(driver)
-end
-]]--
-
-mode = s:option(ListValue, "mode", "Modus")
-mode:value("", "standard")
-mode:value("11b", "802.11b")
-mode:value("11g", "802.11g")
-mode:value("11a", "802.11a")
-mode:value("11bg", "802.11b+g")
-mode.rmempty = true
-
-s:option(Value, "channel", "Funkkanal")
-
-s:option(Value, "txantenna", "Sendeantenne").rmempty = true
-
-s:option(Value, "rxantenna", "Empfangsantenne").rmempty = true
-
-s:option(Value, "distance", "Distanz",
- "Distanz zum am weitesten entfernten Funkpartner (m)").rmempty = true
-
-s:option(Value, "diversity", "Diversität"):depends("type", "atheros")
-
-country = s:option(Value, "country", "Ländercode")
-country.optional = true
-country:depends("type", "broadcom")
-
-maxassoc = s:option(Value, "maxassoc", "Verbindungslimit")
-maxassoc:depends("type", "broadcom")
-maxassoc.optional = true
-
-return m
\ No newline at end of file
+++ /dev/null
--- ToDo: Translate, Add descriptions and help texts
-m = Map("wireless", "Netze", [[Pro WLAN-Gerät können mehrere Netze bereitgestellt werden.
-Es sollte beachtet werden, dass es hardware- / treiberspezifische Einschränkungen gibt.
-So kann pro WLAN-Gerät in der Regel entweder 1 Ad-Hoc-Zugang ODER bis zu 3 Access-Point und 1 Client-Zugang
-gleichzeitig erstellt werden.]])
-
-s = m:section(TypedSection, "wifi-iface")
-s.addremove = true
-s.anonymous = true
-
-s:option(Value, "ssid", "Netzkennung (ESSID)").maxlength = 32
-
-device = s:option(ListValue, "device", "Gerät")
-local d = ffluci.model.uci.sections("wireless")
-if d then
- for k, v in pairs(d) do
- if v[".type"] == "wifi-device" then
- device:value(k)
- end
- end
-end
-
-network = s:option(ListValue, "network", "Netzwerk", "WLAN-Netz zu Netzwerk hinzufügen")
-network:value("")
-for k, v in pairs(ffluci.model.uci.sections("network")) do
- if v[".type"] == "interface" and k ~= "loopback" then
- network:value(k)
- end
-end
-
-mode = s:option(ListValue, "mode", "Modus")
-mode:value("ap", "Access Point")
-mode:value("adhoc", "Ad-Hoc")
-mode:value("sta", "Client")
-mode:value("wds", "WDS")
-
-s:option(Value, "bssid", "BSSID").optional = true
-
-s:option(Value, "txpower", "Sendeleistung", "dbm").rmempty = true
-
-s:option(Flag, "frameburst", "Broadcom-Frameburst").optional = true
-s:option(Flag, "bursting", "Atheros-Frameburst").optional = true
-
-
-encr = s:option(ListValue, "encryption", "Verschlüsselung")
-encr:value("none", "keine")
-encr:value("wep", "WEP")
-encr:value("psk", "WPA-PSK")
-encr:value("wpa", "WPA-Radius")
-encr:value("psk2", "WPA2-PSK")
-encr:value("wpa2", "WPA2-Radius")
-
-key = s:option(Value, "key", "Schlüssel")
-key:depends("encryption", "wep")
-key:depends("encryption", "psk")
-key:depends("encryption", "wpa")
-key:depends("encryption", "psk2")
-key:depends("encryption", "wpa2")
-key.rmempty = true
-
-server = s:option(Value, "server", "Radius-Server")
-server:depends("encryption", "wpa")
-server:depends("encryption", "wpa2")
-server.rmempty = true
-
-port = s:option(Value, "port", "Radius-Port")
-port:depends("encryption", "wpa")
-port:depends("encryption", "wpa2")
-port.rmempty = true
-
-s:option(Flag, "isolate", "AP-Isolation", "Unterbindet Client-Client-Verkehr").optional = true
-
-s:option(Flag, "hidden", "ESSID verstecken").optional = true
-
-
-
-return m
\ No newline at end of file
+++ /dev/null
-add("admin", "index", "Übersicht", 10)
-act("wizard", "Freifunkassistent")
-act("contact", "Kontakt")
-act("luci", "Oberfläche")
-act("freifunk", "Freifunk")
-
-add("admin", "system", "System", 30)
-act("packages", "Paketverwaltung")
-act("passwd", "Passwort ändern")
-act("sshkeys", "SSH-Schlüssel")
-act("hostname", "Hostname")
-act("fstab", "Einhängepunkte")
-act("upgrade", "Firmwareupgrade")
-act("reboot", "Neu starten")
-
-add("admin", "services", "Dienste", 40)
-if isfile("/etc/config/olsr") then
- act("olsrd", "OLSR")
-end
-act("httpd", "HTTP-Server")
-act("dropbear", "SSH-Server")
-act("dnsmasq", "Dnsmasq")
-if isfile("/etc/config/luci_splash") then
- act("splash", "Client-Splash")
-end
-
-add("admin", "network", "Netzwerk", 50)
-act("vlan", "Switch")
-act("ifaces", "Schnittstellen")
-act("dhcp", "DHCP-Server")
-act("ptp", "PPPoE / PPTP")
-act("routes", "Statische Routen")
-act("portfw", "Portweiterleitung")
-act("firewall", "Firewall")
-if isfile("/etc/config/qos") then
- act("qos", "Quality of Service")
-end
-
-add("admin", "wifi", "Drahtlos", 60)
-act("devices", "Geräte")
-act("networks", "Netze")
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:hello Hallo!%></h1>
-<p><%:admin1 Dies ist der Administrationsbereich von FFLuCI.%></p>
-<p><%:admin2 FFLuCI ist eine freie, flexible und benutzerfreundliche grafische Oberfläche zur Konfiguration von OpenWRT Kamikaze.%><br />
-<%:admin3 Auf den folgenden Seiten können alle wichtigen Einstellungen des Routers vorgenommen werden.%></p>
-<p><%:admin4 Auf der linken Seite befindet sich eine Navigation, die zu den einzelnen Konfigurationsseiten führt.%></p>
-<p><%:admin5 Wir sind natürlich stets darum bemüht, diese Oberfläche
-noch besser und intuitiver zu Gestalten und freuen uns über jegliche Art von Feedback oder Verbesserungsvorschlägen.%></p>
-<p><%:admin6 Und nun wünschen wir viel Spaß mit dem Router!%></p>
-<p><em><strong><a href="http://luci.freifunk-halle.net"><%:team Das FFLuCI-Team%></a></strong></em></p>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:ffwizard Freifunkassistent%></h1>
-<p><%:ffwizard1 Dieser Assistent konfiguriert den Router für die Benutzung im Freifunknetz%></p>
-<br />
-<form method="post" action="<%=controller%>/admin/index/wizard">
- <div class="cbi-section-node">
- <div class="cbi-value">
- <div class="cbi-value-title"><%:ip IP-Adresse%>:
- <input type="text" size="20" name="ip" /></div>
- </div>
- <% for i, k in ipairs(ifaces) do %>
- <div class="cbi-value">
- <div class="cbi-value-title"><%:wificfg Drahtlosgerät einrichten%>: <%=k%></div>
- <div class="cbi-value-field"><input type="checkbox" name="wifi.<%=k%>" value="1" checked="checked" /></div>
- </div>
- <% end %>
- <div class="cbi-value">
- <div class="cbi-value-title"><%:cfgolsr OLSR konfigurieren%></div>
- <div class="cbi-value-field"><input type="checkbox" name="olsr" value="1" checked="checked" /></div>
- </div>
- <div class="cbi-value">
- <div class="cbi-value-title"><%:cfgdhcp Drahtlos DHCP konfigurieren%></div>
- <div class="cbi-value-field"><input type="checkbox" name="dhcp" value="1" checked="checked" /></div>
- </div>
- <div class="cbi-value">
- <div class="cbi-value-title"><%:shareinet Internet teilen%></div>
- <div class="cbi-value-field"><input type="checkbox" name="shareinet" value="1" checked="checked" /></div>
- </div>
- </div>
- <br />
- <div>
- <input type="submit" value="<%:configure Konfigurieren%>" />
- <input type="reset" value="<%:reset Zurücksetzen%>" />
- </div>
-</form>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:network Netzwerk%></h1>
-<p><%:network1 In diesem Bereich finden sich alle netzwerkbezogenen Einstellungen.%></p>
-<p><%:network2 Der Netzwerkswitch kann bei den meisten Routern frei konfiguriert
-und in mehrere VLANs aufgeteilt werden. %></p>
-<p><%:network3 Schnittstellen und PPPoE/PPTP-Einstellungen ermöglichen
-die freie Organisation des Netzwerks und die Anbindung an ein WAN.%></p>
-<p><%:network4 DHCP ermöglichst die automatische Netzwerkkonfiguration von Rechnern im (W)LAN.%></p>
-<p><%:network5 Portweiterleitung und Firewall erlauben eine effektive Absicherung des Netzes, bei gleichzeitiger
-Bereitstellung von externen Diensten.%></p>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:services Dienste%></h1>
-<p><%:services1 Dienste und Dämonen stellen bestimmte Funktionalitäten auf dem Router zur Verfügung.%></p>
-<p><%:services2 Es handelt sich hierbei meist um Netzwerkserver, die verschiedene Aufgaben auf dem Router erfüllen,
-beispielsweise Shell-Zugang ermöglichen oder diese Weboberfläche per HTTP anbieten.%></p>
-<p><%:servcies3 In diesen Bereich fallen auch die Meshnetzwerkdienste wie OLSR und BATMAN, die dabei helfen,
-ein autarkes Ad-Hoc Netzwerk aufzubauen.%></p>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:texteditor Texteditor%></h1>
-<form method="post" action="<%=controller%>/admin/system/editor">
-<div><%:file Datei%>: <input type="text" name="file" size="30" value="<%=fn%>" />
-<% if msg then %><span class="error"><%:error Fehler%>: <%=msg%></span><% end %></div>
-<br />
-<div><textarea style="width: 100%" rows="20" name="data"><%=cnt%></textarea></div>
-<br />
-<div>
- <input type="submit" value="<%:save Speichern%>" />
- <input type="reset" value="<%:reset Zurücksetzen%>" />
-</div>
-</form>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:system System%></h1>
-<p><%:system1 Hier finden sich Einstellungen, die das System selbst, dessen Kennung,
-installierte Software und Hardware, Authentifizierung oder eingehängte Speicher betreffen.%></p>
-<p><%:system2 Diese Einstellungen definieren die Grundlage des Systems, auf dem die
-installierte Software aufbaut.%></p>
-<p><%:system3 Beachte bitte, dass eine fehlerhafte Konfiguration den Start
-des Routers verhindern oder dich vom Zugriff auf diesen ausschließen kann.%></p>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:system System%></h1>
-<h2><%:ipkg IPKG-Konfiguration%></h2>
-
-<br />
-
-<div><strong><%:ipkg_pkglists Paketlisten%>:</strong><code>src <em>Name</em> <em>URL</em></code></div>
-<div><strong><%:ipkg_targets Installationsziele%>:</strong><code>dest <em>Name</em> <em>Pfad</em></code></div>
-
-<br />
-
-<form method="post" action="<%=controller%>/admin/system/ipkg">
- <div class="cbi-section-node" style="width: 100%">
- <div class="cbi-value">
- <div class="cbi-value-field">
- <textarea style="width: 100%" rows="10" name="data"><%=cnt%></textarea>
- </div>
- </div>
- </div>
- <div>
- <input type="submit" value="<%:save Speichern%>" />
- <input type="reset" value="<%:reset Zurücksetzen%>" />
- </div>
- <% if msg then %><br /><div class="error"><%:error Fehler%>: <%=msg%></div><% end %>
-</form>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:system System%></h1>
-<h2><%:packages Paketverwaltung%></h2>
-
-<br />
-
-<% if install or remove or update or upgrade then %>
-<div class="code"><strong><%:status Status%>:</strong><br />
-<% if update then %>
- <%:packages_update Paketlisten aktualisieren%>: <% if update == 0 then %><span class="ok"><%:ok OK%></span><% else %><span class="error"><%:error Fehler%> (<%:code Code%> <%=update%>)</span><% end %><br />
-<% end %>
-<% if upgrade then%>
- <%:packages_upgrade Installierte Pakete aktualisieren%>: <% if upgrade == 0 then %><span class="ok"><%:ok OK%></span><% else %><span class="error"><%:error Fehler%> (<%:code Code%> <%=upgrade%>)</span><% end %><br />
-<% end %>
-<% if install then for k,v in pairs(install) do %>
- <%:packages_install Installation von%> '<%=k%>': <% if v == 0 then %><span class="ok"><%:ok OK%></span><% else %><span class="error"><%:error Fehler%> (<%:code Code%> <%=v%>)</span><% end %><br />
-<% end end %>
-<% if remove then for k,v in pairs(remove) do %>
- <%:packages_remove Deinstallation von%> '<%=k%>': <% if v == 0 then %><span class="ok"><%:ok OK%></span><% else %><span class="error"><%:error Fehler%> (<%:code Code%> <%=v%>)</span><% end %><br />
-<% end end %>
-</div>
-<br />
-<% end %>
-
-<div>
-<a href="<%=controller%>/admin/system/ipkg"><%:packages_ipkg Paketlisten und Installationsziele bearbeiten%></a><br />
-<a href="<%=controller%>/admin/system/packages?update=1"><%:packages_updatelist Paketlisten aktualisieren%></a><br />
-<a href="<%=controller%>/admin/system/packages?upgrade=1"><%:packages_upgrade Installierte Pakete aktualisieren%></a>
-</div>
-
-<br />
-<br />
-
-<form method="post" action="<%=controller%>/admin/system/packages">
- <div>
- <span class="bold"><%:packages_installurl Paket herunterladen und installieren%>:</span><br />
- <input type="text" name="url" size="30" value="" />
- <input type="submit" name="submit" value="<%:ok OK%>" />
- </div>
-
- <br />
- <br />
-
- <div>
- <span class="bold"><%:filter Filter%>:</span>
- <input type="text" name="query" size="20" value="<%=query%>" />
- <input type="submit" name="search" value="<%:packages_search Paket suchen%>" />
- <input type="submit" name="submit" value="<%:packages_do Aktionen ausführen%>" />
- </div>
-
- <br />
- <br />
-
- <div>
- <table style="font-size: 0.8em">
- <tr>
- <th><%:packages_name Paketname%></th>
- <th><%:version Version%></th>
- <th><%:install Installieren%></th>
- <th><%:delete Löschen%></th>
- <th><%:descr Beschreibung%></th>
- </tr>
- <% for k, pkg in pairs(pkgs) do %>
- <tr>
- <td><%=pkg.Package%></td>
- <td><%=pkg.Version%></td>
- <td><% if not pkg.Status or not pkg.Status.installed then %><input type="checkbox" name="install.<%=pkg.Package%>" value="1" /><% else %><%:installed installiert%><% end %></td>
- <td><% if pkg.Status and pkg.Status.installed then %><input type="checkbox" name="remove.<%=pkg.Package%>" value="1" /><% else %><%:notinstalled nicht installiert%><% end %></td>
- <td><%=pkg.Description%></td>
- </tr>
- <% end %>
- </table>
- </div>
- <br />
- <input type="submit" name="submit" value="<%:packages_do Aktionen ausführen%>" />
-</form>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:system System%></h1>
-<h2><%:passwd Passwort ändern%></h2>
-<p><%:passwd1 Ändert das Passwort des Systemverwalters (Benutzer "root")%></p>
-<div><br />
-<% if stat then %>
- <% if stat == 0 then %>
- <code><%:password_changed Passwort erfolgreich geändert!%></code>
- <% elseif stat == 10 then %>
- <code class="error"><%:password_nomatch Passwörter stimmen nicht überein! %></code>
- <% else %>
- <code class="error"><%:unknown_error Unbekannter Fehler!%></code>
- <% end %>
-<% end %>
-<% if not stat or stat == 10 then %>
- <form method="post" action="<%=controller%>/admin/system/passwd">
- <div class="cbi-section-node">
- <div class="cbi-value">
- <div class="cbi-value-title"><%:password Passwort%></div>
- <div class="cbi-value-field"><input type="password" name="pwd1" /></div>
- </div>
- <div class="cbi-value">
- <div class="cbi-value-title"><%:confirmation Bestätigung%></div>
- <div class="cbi-value-field"><input type="password" name="pwd2" /></div>
- </div>
- <br />
- <div>
- <input type="submit" value="<%:save Speichern%>" />
- <input type="reset" value="<%:reset Zurücksetzen%>" />
- </div>
- </div>
- </form>
-<% end %>
-</div>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:system System%></h1>
-<h2><%:reboot Neu starten%></h2>
-<p><%:reboot1 Startet das Betriebssystem des Routers neu.%></p>
-<% if not reboot then %>
-<p><a href="<%=controller%>/admin/system/reboot?reboot=1"><%:reboot_do Neustart durchführen%></a></p>
-<% else %>
-<p><%:reboot_running Bitte warten: Neustart wird durchgeführt...%></p>
-<script type="text/javascript">setTimeout("location='<%=controller%>/admin'", 60000)</script>
-<% end %>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:system System%></h1>
-<h2><%:sshkeys SSH-Schlüssel%></h2>
-
-<br />
-
-<div><%:sshkeys_descr Hier können öffentliche SSH-Schlüssel (einer pro Zeile)
- zur Authentifizierung abgelegt werden.%></div>
-
-<br />
-
-<form method="post" action="<%=controller%>/admin/system/sshkeys">
- <div class="cbi-section-node" style="width: 100%">
- <div class="cbi-value">
- <div class="cbi-value-field">
- <textarea style="width: 100%" rows="10" name="data"><%=cnt%></textarea>
- </div>
- </div>
- </div>
- <div>
- <input type="submit" value="<%:save Speichern%>" />
- <input type="reset" value="<%:reset Zurücksetzen%>" />
- </div>
- <% if msg then %><br /><div class="error"><%:error Fehler%>: <%=msg%></div><% end %>
-</form>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:system System%></h1>
-<h2><%:upgrade Upgrade%></h2>
-<p><%:upgrade1 Ersetzt die installierte Firmware (das Betriebssystem des Routers) durch ein neues.
-Das Format der Firmware ist plattformabhängig.%></p>
-<br />
-<% if sysupgrade and not ret then %>
-<form method="post" action="<%=controller%>-upload/admin/system/upgrade" enctype="multipart/form-data">
- <div class="cbi-section-node">
- <div class="cbi-value clear">
- <div class="cbi-value-title left"><%:fwimage Firmwareimage%></div>
- <div class="cbi-value-field"><input type="file" size="30" name="image" /></div>
- </div>
- <br />
- <div class="cbi-value clear">
- <input type="checkbox" name="keepcfg" value="1" checked="checked" />
- <span class="bold"><%:keepcfg Konfigurationsdateien übernehmen%></span>
- </div>
- <br />
- <div>
- <input type="submit" value="<%:fwupgrade Firmware aktualisieren%>" />
- </div>
- </div>
-</form>
-<% elseif ret then %>
- <% if ret == 0 then %>
-<div class="ok"><%:flashed Flashvorgang erfolgreich. Router startet neu...%></div>
- <% else %>
-<div class="error"><%:flasherr Flashvorgang fehlgeschlagen!%> (<%:code Code%> <%=ret%>)</div>
- <% end %>
-<% else %>
-<div class="error"><%:notimplemented Diese Funktion steht leider (noch) nicht zur Verfügung.%></div>
-<% end %>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:config Konfiguration%></h1>
-<p><%:uci_applied Die folgenden Änderungen wurden übernommen%>:</p>
-<code><%=(changes or "-")%>
-<%=output%></code>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:config Konfiguration%></h1>
-<h2><%:changes Änderungen%></h2>
-<code><%=(ffluci.model.uci.changes() or "-")%></code>
-<form class="inline" method="get" action="<%=controller%>/admin/uci/apply">
- <input type="submit" value="<%:apply Anwenden%>" />
-</form>
-<form class="inline" method="get" action="<%=controller%>/admin/uci/revert">
- <input type="submit" value="<%:revert Verwerfen%>" />
-</form>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:config Konfiguration%></h1>
-<p><%:uci_reverted Die folgenden Änderungen wurden verworfen%>:</p>
-<code><%=(changes or "-")%></code>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:wifi Drahtlos%></h1>
-<p><%:wifi1 Hier finden sich Konfiugrationsmöglichkeiten für Drahtlos-Netzwerke nach dem WLAN-Standard.%></p>
-<p><%:wifi2 802.11b/g/a/n-Geräte können so einfach in das bestehende physische Netzwerk integriert werden.
-Die Unterstützung von virtuellen Adaptern ermöglicht auch den Einsatz als Wireless-Repeater oder von
-mehreren Netzwerken gleichzeitig auf einem Gerät.%></p>
-<p><%:wifi3 Es werden Managed, Client, Ad-Hoc und WDS-Modus unterstützt sowie WPA und WPA2-Verschlüsselung zur gesicherten
-Kommunikation.%></p>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<h1><%:welcome Willkommen%>!</h1>
-<p>
-Du bist jetzt mit dem freien Funknetz
-<a href="<%~freifunk.community.homepage%>"><%~freifunk.community.name%></a> verbunden.<br />
-Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter.
-</p>
-
-<p>
-Ein Zugang <strong>ins Internet</strong> ist trotzdem möglich,
-da einige Freifunker ihre privaten Internetzugänge zur Verfügung stellen.
-Diese Zugänge müssen sich hier alle teilen.
-Bitte sei Dir dessen bewusst und verhalte Dich dementsprechend:
-<ul>
-<li>bitte <strong>keine Filesharing-Programme</strong> betreiben!</li>
-<li>bitte <strong>keine unnötigen Downloads oder Streams</strong> starten!</li>
-<li>bitte <strong>keine illegalen Aktivitäten</strong>!</li>
-</ul>
-</p>
-
-<p>
-Wenn Du unsere Idee gut findest, kannst Du uns unterstützen:
-<ul>
-<li><a href="<%~freifunk.community.homepage%>">Werde selbst Freifunker oder teile deinen Internetzugang!</a></li>
-<li>Betreibe deine anderen WLAN-Geräte <em>NICHT</em> auf den Kanälen 1-5, diese stören oft unser Netz.</li>
-</ul>
-</p>
-
-<p>
-Mit einem Klick auf <em><%:accept Annehmen%></em> kannst du für <%~luci_splash.general.leasetime%> Stunden
-über unser Netz das Internet verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren.
-</p>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<%+splash/splash%>
-<form method="get" action="<%=controller%>/splash/splash/activate">
- <input type="submit" value="<%:decline Ablehnen%>" />
- <input type="submit" name="accept" value="<%:accept Annehmen%>" />
-</form>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-LUAC = luac
-LUAC_OPTIONS = -s
-
-FILES = i18n/* view/*/*.htm
-
-CFILES = controller/*/*.lua model/cbi/*/*.lua model/menu/*.lua
-
-DIRECTORIES = model/cbi model/menu controller i18n view
-
-
-INFILES = $(CFILES:%=src/%)
-OUTDIRS = $(DIRECTORIES:%=dist/%)
-CPFILES = $(FILES:%=src/%)
-
-.PHONY: all compile source clean depends
-
-all: compile
-
-
-depends:
- mkdir -p $(OUTDIRS)
- for i in $(CPFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
- mkdir -p dist/$$(dirname $$i); cp src/$$i dist/$$i; fi; done
-
-compile: depends
- for i in $(INFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
- mkdir -p dist/$$(dirname $$i); $(LUAC) $(LUAC_OPTIONS) -o dist/$$i src/$$i; fi; done
-
-source: depends
- for i in $(INFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
- mkdir -p dist/$$(dirname $$i); cp src/$$i dist/$$i; fi; done
-
-
-clean:
- rm dist -rf
+++ /dev/null
-module("ffluci.controller.public.index", package.seeall)
\ No newline at end of file
+++ /dev/null
-module("ffluci.controller.public.olsr", package.seeall)
-require("ffluci.sys")
-
-function action_index()
- local data = fetch_txtinfo("links")
-
- if not data or not data.Links then
- ffluci.template.render("public_olsr/error_olsr")
- return nil
- end
-
- local function compare(a, b)
- if tonumber(a.ETX) == 0 then
- return false
- end
-
- if tonumber(b.ETX) == 0 then
- return true
- end
-
- return tonumber(a.ETX) < tonumber(b.ETX)
- end
-
- table.sort(data.Links, compare)
-
- ffluci.template.render("public_olsr/index", {links=data.Links})
-end
-
-function action_routes()
- local data = fetch_txtinfo("routes")
-
- if not data or not data.Routes then
- ffluci.template.render("public_olsr/error_olsr")
- return nil
- end
-
- local function compare(a, b)
- if tonumber(a.ETX) == 0 then
- return false
- end
-
- if tonumber(b.ETX) == 0 then
- return true
- end
-
- return tonumber(a.ETX) < tonumber(b.ETX)
- end
-
- table.sort(data.Routes, compare)
-
- ffluci.template.render("public_olsr/routes", {routes=data.Routes})
-end
-
-function action_topology()
- local data = fetch_txtinfo("topology")
-
- if not data or not data.Topology then
- ffluci.template.render("public_olsr/error_olsr")
- return nil
- end
-
- local function compare(a, b)
- return a["Destination IP"] < b["Destination IP"]
- end
-
- table.sort(data.Topology, compare)
-
- ffluci.template.render("public_olsr/topology", {routes=data.Topology})
-end
-
-function action_hna()
- local data = fetch_txtinfo("hna")
-
- if not data or not data.HNA then
- ffluci.template.render("public_olsr/error_olsr")
- return nil
- end
-
- local function compare(a, b)
- return a.Network < b.Network
- end
-
- table.sort(data.HNA, compare)
-
- ffluci.template.render("public_olsr/hna", {routes=data.HNA})
-end
-
-function action_mid()
- local data = fetch_txtinfo("mid")
-
- if not data or not data.MID then
- ffluci.template.render("public_olsr/error_olsr")
- return nil
- end
-
- local function compare(a, b)
- return a.IP < b.IP
- end
-
- table.sort(data.MID, compare)
-
- ffluci.template.render("public_olsr/mid", {mids=data.MID})
-end
-
-
--- Internal
-function fetch_txtinfo(otable)
- otable = otable or ""
- local rawdata = ffluci.sys.httpget("http://127.0.0.1:2006/"..otable)
-
- if #rawdata == 0 then
- return nil
- end
-
- local data = {}
-
- local tables = ffluci.util.split(ffluci.util.trim(rawdata), "\n\n")
-
-
- for i, tbl in ipairs(tables) do
- local lines = ffluci.util.split(tbl, "\n")
- local name = table.remove(lines, 1):sub(8)
- local keys = ffluci.util.split(table.remove(lines, 1), "\t")
-
- data[name] = {}
-
- for j, line in ipairs(lines) do
- local fields = ffluci.util.split(line, "\t")
- data[name][j] = {}
- for k, key in pairs(keys) do
- data[name][j][key] = fields[k]
- end
- end
- end
-
- return data
-end
\ No newline at end of file
+++ /dev/null
-module("ffluci.controller.public.status", package.seeall)
-
-function action_index()
- local data = {}
-
- data.s, data.m, data.r = ffluci.sys.sysinfo()
-
- data.wifi = ffluci.sys.wifi.getiwconfig()
-
- data.routes = {}
- for i, r in pairs(ffluci.sys.net.routes()) do
- if r.Destination == "00000000" then
- table.insert(data.routes, r)
- end
- end
-
-
- ffluci.template.render("public_status/index", data)
-end
-
-
+++ /dev/null
-module("ffluci.controller.sudo.status", package.seeall)
\ No newline at end of file
+++ /dev/null
-add("public", "index", "Übersicht", 10)
-act("contact", "Kontakt")
-
-add("public", "status", "Status", 20)
-act("routes", "Routingtabelle")
-act("iwscan", "WLAN-Scan")
-
-add("public", "olsr", "OLSR", 30)
-act("routes", "Routen")
-act("topology", "Topologie")
-act("hna", "HNA")
-act("mid", "MID")
+++ /dev/null
-<%+header%>
-<% local contact = ffluci.model.uci.sections("freifunk").contact %>
-<h1><%:contact Kontakt%></h1>
-<table cellspacing="0" cellpadding="6">
- <tr><th><%:nickname Pseudonym%>:</th><td><%=contact.nickname%></td></tr>
- <tr><th><%:name Name%>:</th><td><%=contact.name%></td></tr>
- <tr><th><%:mail E-Mail%>:</th><td><%=contact.mail%></td></tr>
- <tr><th><%:phone Telefon%>:</th><td><%=contact.phone%></td></tr>
- <tr><th><%:location Standort%>:</th><td><%=contact.location%></td></tr>
- <tr><th><%:geocoord Geokoordinaten%>:</th><td><%=contact.geo%></td></tr>
- <tr><th><%:note Notiz%>:</th><td><%=contact.note%></td></tr>
-</table>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<% local ff = ffluci.model.uci.sections("freifunk") %>
-<h1><%:hellonet Hallo und willkommen im Netz von%> <%=ff.community.name%>!</h1>
-<p><%:public1 Wir sind eine Initiative zur Schaffung eines freien, offenen und unabhängigen Funknetzwerks auf WLAN-Basis.%><br />
-<%:public2 Dies ist der Zugangspunkt %><%=ffluci.sys.hostname()%>. <%:public3 Er wird betrieben von %>
-<a href="<%=controller%>/public/index/contact"><%=ff.contact.nickname%></a>.</p>
-<p><%:public4 Weitere Informationen zur globalen Freifunkinitiative findest du unter%> <a href="http://freifunk.net">Freifunk.net</a>.<br />
-<%:public5 Hast du Interesse an diesem Projekt, dann wende dich an deine lokale Gemeinschaft%> <a href="<%=ff.community.homepage%>"><%=ff.community.name%></a>.</p>
-<p><strong><%:note Hinweis%></strong>: <%:public6 Der Internetzugang über das experimentelle Freifunknetz ist an technische und organisatorische Bedingungen geknüpft und deshalb möglicherweise
-nicht (immer) gewährleistet.%></p>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:olsr OLSR%></h1>
-<p class="error"><%:olsrerror1 Es konnte keine Verbindung zum OLSR-Daemon hergestellt werden!%></p>
-<p><%:olsrerror2 Um die Statusinformationen abfragen zu können muss der OLSR-Daemon gestartet
-und das Plugin "txtinfo" geladen sein.%></p>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:olsrhna OLSR-HNA%></h1>
-<br />
-<table cellspacing="0" cellpadding="6">
-<tr>
-<th><%:destination Ziel%></th>
-<th><%:gateway Gateway%></th>
-</tr>
-<% for k, route in ipairs(routes) do %>
-<tr>
-<td><%=route.Network%>/<%=route.Netmask%></td>
-<td><a href="http://<%=route.Gateway%>"><%=route.Gateway%></a></td>
-</tr>
-<% end %>
-</table>
-<br />
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:olsrlinks OLSR-Verbindungen%></h1>
-<p><%:olsrlinks1 Übersicht über aktuell bestehende OLSR-Verbindungen%></p>
-<br />
-<table cellspacing="0" cellpadding="6">
-<tr>
-<th><%:destination Ziel%></th>
-<th><%:local Lokal%></th>
-<th>LQ</th>
-<th>NLQ</th>
-<th>ETX</th>
-</tr>
-<% for k, link in ipairs(links) do
- local color = "#bb3333"
-
- link.ETX = tonumber(link.ETX)
- if link.ETX == 0 then
- color = "#bb3333"
- elseif link.ETX < 4 then
- color = "#00cc00"
- elseif link.ETX < 10 then
- color = "#ffcb05"
- elseif link.ETX < 100 then
- color = "#ff6600"
- end
-%>
-<tr>
-<td><a href="http://<%=link["remote IP"]%>"><%=link["remote IP"]%></a></td>
-<td><%=link["Local IP"]%></td>
-<td><%=link.LinkQuality%></td>
-<td><%=link.NLQ%></td>
-<td style="background-color:<%=color%>"><%=link.ETX%></td>
-</tr>
-<% end %>
-</table>
-<br />
-<h3><%:legend Legende%>:</h3>
-<ul>
-<li><strong>LQ: </strong><%:lq1 Erfolgsquote gesendeter Pakete%></li>
-<li><strong>NLQ: </strong><%:nlq1 Erfolgsquote empfangener Pakete%></li>
-<li><strong>ETX: </strong><%:etx1 Zu erwartende Sendeversuche pro Paket%></li>
-</ul>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:olsrmid OLSR-MID%></h1>
-<br />
-<table cellspacing="0" cellpadding="6">
-<tr>
-<th><%:node Knoten%></th>
-<th><%:aliases Aliasse%></th>
-</tr>
-<% for k, mid in ipairs(mids) do %>
-<tr>
-<td><a href="http://<%=mid.IP%>"><%=mid.IP%></a></td>
-<td><%=mid.Aliases%></td>
-</tr>
-<% end %>
-</table>
-<br />
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:olsrlinks OLSR-Routen%></h1>
-<br />
-<table cellspacing="0" cellpadding="6">
-<tr>
-<th><%:destination Ziel%></th>
-<th><%:gateway Gateway%></th>
-<th><%:interface Schnittstelle%></th>
-<th><%:metric Metrik%></th>
-<th>ETX</th>
-</tr>
-<% for k, route in ipairs(routes) do
- local color = "#bb3333"
-
- route.ETX = tonumber(route.ETX)
- if route.ETX == 0 then
- color = "#bb3333"
- elseif route.ETX < 4 then
- color = "#00cc00"
- elseif route.ETX < 10 then
- color = "#ffcb05"
- elseif route.ETX < 100 then
- color = "#ff6600"
- end
-%>
-<tr>
-<td><%=route.Destination%></td>
-<td><%=route.Gateway%></td>
-<td><%=route.Interface%></td>
-<td><%=route.Metric%></td>
-<td style="background-color:<%=color%>"><%=route.ETX%></td>
-</tr>
-<% end %>
-</table>
-<br />
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:olsrtopo OLSR-Topologie%></h1>
-<br />
-<table cellspacing="0" cellpadding="6">
-<tr>
-<th><%:destination Ziel%></th>
-<th><%:lasthop Letzter Router%></th>
-<th>LQ</th>
-<th>ILQ</th>
-<th>ETX</th>
-</tr>
-<% for k, route in ipairs(routes) do %>
-<tr>
-<td><a href="http://<%=route["Destination IP"]%>"><%=route["Destination IP"]%></a></td>
-<td><a href="http://<%=route["Last hop IP"]%>"><%=route["Last hop IP"]%></a></td>
-<td><%=route.LQ%></td>
-<td><%=route.ILQ%></td>
-<td><%=route.ETX%></td>
-</tr>
-<% end %>
-</table>
-<br />
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:status Status%></h1>
-<h2><%:system System%></h2>
-
-<br />
-<table cellspacing="0" cellpadding="6" class="smalltext">
-<tr>
-<th><%:system_type Systemtyp%>:</th>
-<td><%=s%></td>
-</tr>
-<tr>
-<th><%:cpu Prozessor%>:</th>
-<td><%=m%></td>
-</tr>
-<tr>
-<th><%:ram Hauptspeicher%>:</th>
-<td><%=r%></td>
-</tr>
-</table>
-<br /><br />
-
-<h2><%:wifi Drahtlos%></h2>
-<br />
-<table cellspacing="0" cellpadding="6" class="smalltext">
-<tr>
-<th><%:name Name%></th>
-<th><%:protocol Protokoll%></th>
-<th><%:frequency Frequenz%></th>
-<th><%:power Leistung%></th>
-<th><%:bitrate Bitrate%></th>
-<th><%:rts RTS%></th>
-<th><%:frag Frag.%></th>
-<th><%:link Verb.%></th>
-<th><%:signal Signal%></th>
-<th><%:noise Rausch%></th>
-</tr>
-<%=ffluci.sys.httpget("http://127.0.0.1" .. controller .. "/sudo/status/iwconfig")%>
-</table>
-<br />
-<br />
-<h2><%:defroutes Standardrouten%></h2>
-<br />
-<table cellspacing="0" cellpadding="6" class="smalltext">
-<tr>
-<th><%:gateway Gateway%></th>
-<th><%:metric Metrik%></th>
-<th><%:iface Schnittstelle%></th>
-</tr>
-<%
-for i, rt in pairs(routes) do
-%>
-<tr>
-<td><%=ffluci.sys.net.hexip4(rt.Gateway)%></th>
-<td><%=rt.Metric%></th>
-<td><%=rt.Iface%></th>
-</tr>
-<% end %>
-</table>
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:iwscan WLAN-Scan%></h1>
-<p><%:iwscan1 Drahtlosnetzwerke in der lokalen Umgebung des Routers:%></p>
-
-<br />
-<table cellspacing="0" cellpadding="6" class="smalltext">
-<tr>
-<th><%:interface Schnittstelle%></th>
-<th><%:essid ESSID%></th>
-<th><%:bssid BSSID%></th>
-<th><%:mode Modus%></th>
-<th><%:channel Kanal%></th>
-<th><%:encr Vers.%></th>
-<th><%:link Verb.%></th>
-<th><%:signal Signal%></th>
-<th><%:noise Rausch%></th>
-</tr>
-<%=ffluci.sys.httpget("http://127.0.0.1" .. controller .. "/sudo/status/iwscan")%>
-</table>
-<br />
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%+header%>
-<h1><%:routes Routen%></h1>
-
-<br />
-<table cellspacing="0" cellpadding="6" class="smalltext">
-<tr>
-<th><%:target Ziel%></th>
-<th><%:netmask Netzmaske%></th>
-<th><%:gateway Gateway%></th>
-<th><%:metric Metrik%></th>
-<th><%:iface Schnittstelle%></th>
-</tr>
-<%
-local routes = ffluci.sys.net.routes()
-
-for i, r in pairs(routes) do
-%>
-<tr>
-<td><%=ffluci.sys.net.hexip4(r.Destination)%></td>
-<td><%=ffluci.sys.net.hexip4(r.Mask)%></td>
-<td><%=ffluci.sys.net.hexip4(r.Gateway)%></td>
-<td><%=r.Metric%></td>
-<td><%=r.Iface%></td>
-</tr>
-<% end %>
-</table>
-<br />
-<%+footer%>
\ No newline at end of file
+++ /dev/null
-<%
-ffluci.http.prepare_content("text/plain")
-for k, v in pairs(ffluci.sys.wifi.getiwconfig()) do
-%>
-<tr>
-<td rowspan="2"><%=k%></td>
-<td><%=v[1]%></td>
-<td><%=v.Frequency%></td>
-<td><%=v["Tx-Power"]%></td>
-<td><%=v["Bit Rate"]%></td>
-<td><%=v["RTS thr"]%></td>
-<td><%=v["Fragment thr"]%></td>
-<td><%=v["Link Quality"]%></td>
-<td><%=v["Signal level"]%></td>
-<td><%=v["Noise level"]%></td>
-</tr>
-<tr>
-<td colspan="4"><strong>ESSID: </strong><%=v.ESSID%></td>
-<td colspan="5"><strong>BSSID: </strong><%=(v.Cell or v["Access Point"])%></td>
-</tr>
-<%end%>
+++ /dev/null
-<%
-ffluci.http.prepare_content("text/plain")
-for iface, cells in pairs(ffluci.sys.wifi.iwscan()) do
- for i, cell in ipairs(cells) do
-%>
-<tr>
-<td><%=iface%></td>
-<td><%=cell.ESSID%></td>
-<td><%=cell.Address%></td>
-<td><%=cell.Mode%></td>
-<td><%=(cell.Channel or cell.Frequency or "")%></td>
-<td><%=cell["Encryption key"]%></td>
-<td><%=cell.Quality%></td>
-<td><%=cell["Signal level"]%></td>
-<td><%=cell["Noise level"]%></td>
-</tr>
-<%
- end
-end
-%>
-
-
+++ /dev/null
-LUAC = luac
-LUAC_OPTIONS = -s
-
-FILES = i18n/* view/*/*.htm
-
-CFILES = controller/*/*.lua model/cbi/*/*.lua model/menu/*.lua
-
-DIRECTORIES = model/cbi model/menu controller i18n view
-
-
-INFILES = $(CFILES:%=src/%)
-OUTDIRS = $(DIRECTORIES:%=dist/%)
-CPFILES = $(FILES:%=src/%)
-
-.PHONY: all compile source clean depends
-
-all: compile
-
-
-depends:
- mkdir -p $(OUTDIRS)
- for i in $(CPFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
- mkdir -p dist/$$(dirname $$i); cp src/$$i dist/$$i; fi; done
-
-compile: depends
- for i in $(INFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
- mkdir -p dist/$$(dirname $$i); $(LUAC) $(LUAC_OPTIONS) -o dist/$$i src/$$i; fi; done
-
-source: depends
- for i in $(INFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
- mkdir -p dist/$$(dirname $$i); cp src/$$i dist/$$i; fi; done
-
-
-clean:
- rm dist -rf
+++ /dev/null
-module("ffluci.controller.rpc.luciinfo", package.seeall)
-
-function action_index()
- local uci = ffluci.model.uci.StateSession()
-
- ffluci.http.prepare_content("text/plain")
-
- -- General
- print("luciinfo.api=1")
- print("luciinfo.version=" .. tostring(ffluci.__version__))
-
- -- Sysinfo
- local s, m, r = ffluci.sys.sysinfo()
- local dr = ffluci.sys.net.defaultroute()
- dr = dr and ffluci.sys.net.hexip4(dr.Gateway) or ""
- local l1, l5, l15 = ffluci.sys.loadavg()
-
- print("sysinfo.system=" .. sanitize(s))
- print("sysinfo.cpu=" .. sanitize(m))
- print("sysinfo.ram=" .. sanitize(r))
- print("sysinfo.hostname=" .. sanitize(ffluci.sys.hostname()))
- print("sysinfo.load1=" .. tostring(l1))
- print("sysinfo.load5=" .. tostring(l5))
- print("sysinfo.load15=" .. tostring(l15))
- print("sysinfo.defaultgw=" .. dr)
-
-
- -- Freifunk
- local ff = uci:sections("freifunk") or {}
- for k, v in pairs(ff) do
- if k:sub(1, 1) ~= "." then
- for i, j in pairs(v) do
- print("freifunk." .. k .. "." .. i .. "=" .. j)
- end
- end
- end
-end
-
-function sanitize(val)
- return val:gsub("\n", "\t")
-end
\ No newline at end of file
--- /dev/null
+include ../../build/config.mk
+include ../../build/module.mk
\ No newline at end of file
--- /dev/null
+module("ffluci.controller.admin.index", package.seeall)
\ No newline at end of file
--- /dev/null
+module("ffluci.controller.admin.network", package.seeall)
\ No newline at end of file
--- /dev/null
+module("ffluci.controller.admin.services", package.seeall)
\ No newline at end of file
--- /dev/null
+module("ffluci.controller.admin.system", package.seeall)
+
+require("ffluci.sys")
+require("ffluci.http")
+require("ffluci.util")
+require("ffluci.fs")
+require("ffluci.model.ipkg")
+require("ffluci.model.uci")
+
+function action_editor()
+ local file = ffluci.http.formvalue("file", "")
+ local data = ffluci.http.formvalue("data")
+ local err = nil
+ local msg = nil
+ local stat = true
+
+ if file and data then
+ stat, err = ffluci.fs.writefile(file, data)
+ end
+
+ if not stat then
+ err = ffluci.util.split(err, " ")
+ table.remove(err, 1)
+ msg = table.concat(err, " ")
+ end
+
+ local cnt, err = ffluci.fs.readfile(file)
+ if cnt then
+ cnt = ffluci.util.pcdata(cnt)
+ end
+ ffluci.template.render("admin_system/editor", {fn=file, cnt=cnt, msg=msg})
+end
+
+function action_ipkg()
+ local file = "/etc/ipkg.conf"
+ local data = ffluci.http.formvalue("data")
+ local stat = nil
+ local err = nil
+
+ if data then
+ stat, err = ffluci.fs.writefile(file, data)
+ end
+
+ local cnt = ffluci.fs.readfile(file)
+ if cnt then
+ cnt = ffluci.util.pcdata(cnt)
+ end
+
+ ffluci.template.render("admin_system/ipkg", {cnt=cnt, msg=err})
+end
+
+function action_packages()
+ local ipkg = ffluci.model.ipkg
+ local void = nil
+ local submit = ffluci.http.formvalue("submit")
+
+
+ -- Search query
+ local query = ffluci.http.formvalue("query")
+ query = (query ~= '') and query or nil
+
+
+ -- Packets to be installed
+ local install = submit and ffluci.http.formvaluetable("install")
+
+ -- Install from URL
+ local url = ffluci.http.formvalue("url")
+ if url and url ~= '' and submit then
+ if not install then
+ install = {}
+ end
+ install[url] = 1
+ end
+
+ -- Do install
+ if install then
+ for k, v in pairs(install) do
+ void, install[k] = ipkg.install(k)
+ end
+ end
+
+
+ -- Remove packets
+ local remove = submit and ffluci.http.formvaluetable("remove")
+ if remove then
+ for k, v in pairs(remove) do
+ void, remove[k] = ipkg.remove(k)
+ end
+ end
+
+
+ -- Update all packets
+ local update = ffluci.http.formvalue("update")
+ if update then
+ void, update = ipkg.update()
+ end
+
+
+ -- Upgrade all packets
+ local upgrade = ffluci.http.formvalue("upgrade")
+ if upgrade then
+ void, upgrade = ipkg.upgrade()
+ end
+
+
+ -- Package info
+ local info = ffluci.model.ipkg.info(query)
+ info = info or {}
+ local pkgs = {}
+
+ -- Sort after status and name
+ for k, v in pairs(info) do
+ local x = 0
+ for i, j in pairs(pkgs) do
+ local vins = (v.Status and v.Status.installed)
+ local jins = (j.Status and j.Status.installed)
+ if vins ~= jins then
+ if vins then
+ break
+ end
+ else
+ if j.Package > v.Package then
+ break
+ end
+ end
+ x = i
+ end
+ table.insert(pkgs, x+1, v)
+ end
+
+ ffluci.template.render("admin_system/packages", {pkgs=pkgs, query=query,
+ install=install, remove=remove, update=update, upgrade=upgrade})
+end
+
+function action_passwd()
+ local p1 = ffluci.http.formvalue("pwd1")
+ local p2 = ffluci.http.formvalue("pwd2")
+ local stat = nil
+
+ if p1 or p2 then
+ if p1 == p2 then
+ stat = ffluci.sys.user.setpasswd("root", p1)
+ else
+ stat = 10
+ end
+ end
+
+ ffluci.template.render("admin_system/passwd", {stat=stat})
+end
+
+function action_reboot()
+ local reboot = ffluci.http.formvalue("reboot")
+ ffluci.template.render("admin_system/reboot", {reboot=reboot})
+ if reboot then
+ ffluci.sys.reboot()
+ end
+end
+
+function action_sshkeys()
+ local file = "/etc/dropbear/authorized_keys"
+ local data = ffluci.http.formvalue("data")
+ local stat = nil
+ local err = nil
+
+ if data then
+ stat, err = ffluci.fs.writefile(file, data)
+ end
+
+ local cnt = ffluci.fs.readfile(file)
+ if cnt then
+ cnt = ffluci.util.pcdata(cnt)
+ end
+
+ ffluci.template.render("admin_system/sshkeys", {cnt=cnt, msg=err})
+end
+
+function action_upgrade()
+ local ret = nil
+ local plat = ffluci.fs.mtime("/lib/upgrade/platform.sh")
+
+ local image = ffluci.http.formvalue("image")
+ local imgname = ffluci.http.formvalue("image_name")
+ local keepcfg = ffluci.http.formvalue("keepcfg")
+
+ if plat and imgname then
+ local kpattern = nil
+ if keepcfg then
+ local files = ffluci.model.uci.sections("luci").flash_keep
+ if files.luci and files.luci.flash_keep then
+ kpattern = ""
+ for k,v in pairs(files.luci.flash_keep) do
+ kpattern = kpattern .. " " .. v
+ end
+ end
+ end
+ ret = ffluci.sys.flash(image, kpattern)
+ end
+
+ ffluci.template.render("admin_system/upgrade", {sysupgrade=plat, ret=ret})
+end
\ No newline at end of file
--- /dev/null
+module("ffluci.controller.admin.uci", package.seeall)
+require("ffluci.util")
+require("ffluci.sys")
+
+-- This function has a higher priority than the admin_uci/apply template
+function action_apply()
+ local changes = ffluci.model.uci.changes()
+ local output = ""
+
+ if changes then
+ local com = {}
+ local run = {}
+
+ -- Collect files to be applied and commit changes
+ for i, line in ipairs(ffluci.util.split(changes)) do
+ local r = line:match("^-?([^.]+)")
+ if r then
+ com[r] = true
+
+ if ffluci.config.uci_oncommit and ffluci.config.uci_oncommit[r] then
+ run[ffluci.config.uci_oncommit[r]] = true
+ end
+ end
+ end
+
+ -- Apply
+ for config, i in pairs(com) do
+ ffluci.model.uci.commit(config)
+ end
+
+ -- Search for post-commit commands
+ for cmd, i in pairs(run) do
+ output = output .. cmd .. ":" .. ffluci.sys.exec(cmd) .. "\n"
+ end
+ end
+
+ ffluci.template.render("admin_uci/apply", {changes=changes, output=output})
+end
+
+
+function action_revert()
+ local changes = ffluci.model.uci.changes()
+ if changes then
+ local revert = {}
+
+ -- Collect files to be reverted
+ for i, line in ipairs(ffluci.util.split(changes)) do
+ local r = line:match("^-?([^.]+)")
+ if r then
+ revert[r] = true
+ end
+ end
+
+ -- Revert them
+ for k, v in pairs(revert) do
+ ffluci.model.uci.revert(k)
+ end
+ end
+
+ ffluci.template.render("admin_uci/revert", {changes=changes})
+end
\ No newline at end of file
--- /dev/null
+module("ffluci.controller.admin.wifi", package.seeall)
\ No newline at end of file
--- /dev/null
+luci = "User Interface"
+
+hello = "Hello!"
+admin1 = "This is the administration area of FFLuCI."
+admin2 = "FFLuCI is a free, flexible, and user friendly graphical interface for configuring OpenWRT Kamikaze."
+admin3 = "On the following pages you can adjust all important settings of your router."
+admin4 = "You will find a navigation leading to the different configuration pages on the left side."
+admin5 = [[As we are always want to improve this interface we are looking forward
+to your feedback and suggestions.]]
+admin6 = "And now have fun with your router!"
+team = "The FFLuCI Team"
+
+luci1 = "Here you can customize the settings and the functionality of FFLuCI."
+language = "Language"
+general = "General"
+catpriv = "Category Privileges"
+catpriv1 = [[To secure FFLuCI even further the user and group privileges of
+each category can be decreased. Therefore an attacker cannot takeover the whole system
+when a security exploit for any publicly available page is found.]]
+ucicommit = "Post-commit actions"
+ucicommit1 = [[These commands will be executed automatically when a given UCI configuration is committed allowing
+changes to be applied instantly.]]
+keepflash = "Files to be kept when flashing a new firmware"
+keepflash1 = "When flashing a new firmware with FFLuCI these files will be added to the new firmware installation."
\ No newline at end of file
--- /dev/null
+uci_applied = "The following changes were applied"
+uci_reverted = "The following changes were reverted"
\ No newline at end of file
--- /dev/null
+-- ToDo: Translate
+require("ffluci.config")
+m = Map("luci", translate("luci", "Oberfläche"), translate("luci1",
+ "Hier können Eigenschaften und die Funktionalität der Oberfläche angepasst werden."))
+
+c = m:section(NamedSection, "main", "core", translate("general", "Allgemein"))
+
+l = c:option(ListValue, "lang", translate("language", "Sprache"))
+for k, v in pairs(ffluci.config.languages) do
+ if k:sub(1, 1) ~= "." then
+ l:value(k, v)
+ end
+end
+
+t = c:option(ListValue, "mediaurlbase", translate("design", "Design"))
+for k, v in pairs(ffluci.config.themes) do
+ if k:sub(1, 1) ~= "." then
+ t:value(v, k)
+ end
+end
+
+p = m:section(NamedSection, "category_privileges", "core", translate("catpriv", "Kategorieprivilegien"),
+ translate("catpriv1", [[Zur zusätzlichen Sicherung der Oberfläche gegen Angreifer, können hier die
+Ausführungsrechte der Seiten für einzelne Kategorien reduziert werden. So können z.B. Sicherheitslücken im
+ungeschützten Bereich der Oberfläche nicht mehr zur Übernahme des Routers genutzt werden.]]))
+p.dynamic = true
+
+u = m:section(NamedSection, "uci_oncommit", "event", translate("ucicommit", "UCI-Befehle beim Anwenden"),
+ translate("ucicommit1", [[Beim Anwenden
+der Konfiguration aus der Oberflächliche heraus können automatisch die relevanten Dienste neugestart werden,
+sodass Änderungen sofort nach dem Anwenden aktiv werden und der Router nicht erst neugestartet werden muss.]]))
+u.dynamic = true
+
+f = m:section(NamedSection, "flash_keep", "extern", translate("keepflash", "Zu übernehmende Dateien bei Firmwareupgrade"),
+ translate("keepflash1", [[Die folgenden Dateien und Verzeichnisse werden beim Aktualisieren der Firmware
+über die Oberfläche automatisch in die neue Firmware übernommen.]]))
+f.dynamic = true
+
+return m
\ No newline at end of file
--- /dev/null
+-- ToDo: Translate, Add descriptions and help texts
+require("ffluci.model.uci")
+require("ffluci.sys")
+
+m = Map("dhcp", "DHCP", [[Mit Hilfe von DHCP können Netzteilnehmer automatisch
+ihre Netzwerkkonfiguration (IP-Adresse, Netzmaske, DNS-Server, DHCP, ...) beziehen.]])
+
+s = m:section(TypedSection, "dhcp")
+s.addremove = true
+s.anonymous = true
+
+iface = s:option(ListValue, "interface", "Schnittstelle")
+for k, v in pairs(ffluci.model.uci.sections("network")) do
+ if v[".type"] == "interface" and k ~= "loopback" then
+ iface:value(k)
+ s:depends("interface", k) -- Only change sections with existing interfaces
+ end
+end
+
+s:option(Value, "start", "Start", "Erste vergebene Adresse (letztes Oktett)").rmempty = true
+
+s:option(Value, "limit", "Limit", "Anzahl zu vergebender Adressen -1").rmempty = true
+
+s:option(Value, "leasetime", "Laufzeit").rmempty = true
+
+s:option(Flag, "dynamicdhcp", "Dynamisches DHCP").rmempty = true
+
+s:option(Value, "name", "Name").optional = true
+
+s:option(Flag, "ignore", "Schnittstelle ignorieren", "DHCP für dieses Netzwerk deaktivieren").optional = true
+
+s:option(Value, "netmask", "Netzmaske").optional = true
+
+s:option(Flag, "force", "Start erzwingen").optional = true
+
+for i, line in pairs(ffluci.sys.execl("dnsmasq --help dhcp")) do
+ k, v = line:match("([^ ]+) +([^ ]+)")
+ s:option(Value, "dhcp"..k, v).optional = true
+end
+
+return m
\ No newline at end of file
--- /dev/null
+-- ToDo: Translate, Add descriptions and help texts
+m = Map("network", "Schnittstellen", [[An dieser Stelle können die einzelnen Schnittstellen
+des Netzwerkes konfiguriert werden. Es können mehrere Schnittstellen zu einer Brücke zusammengefasst werden,
+indem diese durch Leerzeichen getrennt aufgezählt werden und ein entsprechender Haken im Feld Netzwerkbrücke
+gesetzt wird. Es können VLANs in der Notation SCHNITTSTELLE.VLANNR (z.B.: eth0.1) verwendet werden.]])
+
+s = m:section(TypedSection, "interface")
+s.addremove = true
+s:exclude("loopback")
+s:depends("proto", "static")
+s:depends("proto", "dhcp")
+
+p = s:option(ListValue, "proto", "Protokoll")
+p:value("static", "statisch")
+p:value("dhcp", "DHCP")
+p.default = "static"
+
+br = s:option(Flag, "type", "Netzwerkbrücke", "überbrückt angegebene Schnittstelle(n)")
+br.enabled = "bridge"
+br.rmempty = true
+
+s:option(Value, "ifname", "Schnittstelle")
+
+s:option(Value, "ipaddr", "IP-Adresse")
+
+s:option(Value, "netmask", "Netzmaske"):depends("proto", "static")
+
+gw = s:option(Value, "gateway", "Gateway")
+gw:depends("proto", "static")
+gw.rmempty = true
+
+dns = s:option(Value, "dns", "DNS-Server")
+dns:depends("proto", "static")
+dns.optional = true
+
+mtu = s:option(Value, "mtu", "MTU")
+mtu.optional = true
+mtu.isinteger = true
+
+mac = s:option(Value, "macaddr", "MAC-Adresse")
+mac.optional = true
+
+return m
\ No newline at end of file
--- /dev/null
+-- ToDo: Translate, Add descriptions and help texts
+m = Map("network", "Punkt-zu-Punkt Verbindungen", [[Punkt-zu-Punkt Verbindungen
+über PPPoE oder PPTP werden häufig dazu verwendet, um über DSL o.ä. Techniken eine
+Verbindung zum Internetgateway eines Internetzugangsanbieters aufzubauen.]])
+
+s = m:section(TypedSection, "interface")
+s.addremove = true
+s:depends("proto", "pppoe")
+s:depends("proto", "pptp")
+
+p = s:option(ListValue, "proto", "Protokoll")
+p:value("pppoe", "PPPoE")
+p:value("pptp", "PPTP")
+p.default = "pppoe"
+
+s:option(Value, "ifname", "Schnittstelle")
+
+s:option(Value, "username", "Benutzername")
+s:option(Value, "password", "Passwort")
+
+s:option(Value, "keepalive", "Keep-Alive", "Bei einer Verbindungstrennung automatisch neu verbinden").optional = true
+
+s:option(Value, "demand", "Dial on Demand (idle time)", "Zeit nach der die Verbindung bei Inaktivität getrennt wird").optional = true
+
+srv = s:option(Value, "server", "PPTP-Server")
+srv:depends("proto", "pptp")
+srv.optional = true
+
+mtu = s:option(Value, "mtu", "MTU")
+mtu.optional = true
+mtu.isinteger = true
+
+return m
\ No newline at end of file
--- /dev/null
+-- ToDo: Translate, Add descriptions and help texts
+m = Map("qos", "Quality of Service", [[Mit Hilfe von QoS kann einzelnen Rechnern oder Netzwerkdiensten
+eine höhere oder niedrigere Priorität zugewiesen werden.]])
+
+s = m:section(TypedSection, "interface", "Schnittstellen")
+s.addremove = true
+
+s:option(Flag, "enabled", "aktiviert")
+
+c = s:option(ListValue, "classgroup", "Klassifizierung")
+c:value("Default", "standard")
+c.default = "Default"
+
+s:option(Flag, "overhead", "Overheadberechnung")
+
+s:option(Value, "download", "Downlink", "kb/s")
+
+s:option(Value, "upload", "Uplink", "kb/s")
+
+s = m:section(TypedSection, "classify", "Klassifizierung")
+
+s.anonymous = true
+s.addremove = true
+
+t = s:option(ListValue, "target", "Klasse")
+t:value("Priority")
+t:value("Express")
+t:value("Normal")
+t:value("Bulk")
+t.default = "Normal"
+
+s:option(Value, "srchost", "Quelladresse", "Quellhost / Quellnetz").optional = true
+s:option(Value, "dsthost", "Zieladresse", "Zielhost / Zielnetz").optional = true
+s:option(Value, "layer7", "Layer 7").optional = true
+
+p2p = s:option(ListValue, "ipp2p", "P2P")
+p2p:value("")
+p2p:value("all", "Alle")
+p2p:value("bit", "Bittorrent")
+p2p:value("dc", "DirectConnect")
+p2p:value("edk", "eDonkey")
+p2p:value("gnu", "Gnutella")
+p2p:value("kazaa", "Kazaa")
+p2p.optional = true
+
+p = s:option(ListValue, "proto", "Protokoll")
+p:value("")
+p:value("tcp", "TCP")
+p:value("udp", "UDP")
+p:value("icmp", "ICMP")
+p.optional = true
+
+s:option(Value, "ports", "Port").optional = true
+s:option(Value, "portrange", "Portbereich").optional = true
+
+return m
\ No newline at end of file
--- /dev/null
+-- ToDo: Translate, Add descriptions and help texts
+m = Map("network", "Statische Routen", [[Statische Routen geben an,
+über welche Schnittstelle und welches Gateway ein bestimmter Host
+oder ein bestimmtes Netzwerk erreicht werden kann.]])
+
+s = m:section(TypedSection, "route")
+s.addremove = true
+s.anonymous = true
+
+iface = s:option(ListValue, "interface", "Schnittstelle")
+for k, v in pairs(ffluci.model.uci.sections("network")) do
+ if v[".type"] == "interface" and k ~= "loopback" then
+ iface:value(k)
+ end
+end
+
+s:option(Value, "target", "Ziel", "Host-IP oder Netzwerk")
+
+s:option(Value, "netmask", "Netzmaske", "falls Ziel ein Netzwerk ist").rmemepty = true
+
+s:option(Value, "gateway", "Gateway")
+
+return m
\ No newline at end of file
--- /dev/null
+-- ToDo: Autodetect things, maybe use MultiValue instead, Translate, Add descriptions
+m = Map("network", "VLAN", [[Die Netzwerkschnittstellen am Router
+können zu verschienden VLANs zusammengefasst werden, in denen Geräte miteinander direkt
+kommunizieren können. VLANs werden auch häufig dazu genutzt, um Netzwerke voneiander zu trennen.
+So ist oftmals eine Schnittstelle als Uplink zu einem größerem Netz, wie dem Internet vorkonfiguriert
+und die anderen Schnittstellen bilden ein VLAN für das lokale Netzwerk.]])
+
+s = m:section(TypedSection, "switch", nil, [[Die zu einem VLAN gehörenden Schnittstellen
+werden durch Leerzeichen getrennt. Die Schnittstelle mit der höchsten Nummer (meistens 5) bildet
+in der Regel die Verbindung zur internen Netzschnittstelle des Routers. Bei Geräten mit 5 Schnittstellen
+ist in der Regel die Schnittstelle mit der niedrigsten Nummer (0) die standardmäßige Uplinkschnittstelle des Routers.]])
+
+for i = 0, 15 do
+ s:option(Value, "vlan"..i, "vlan"..i).optional = true
+end
+
+return m
\ No newline at end of file
--- /dev/null
+m = Map("dhcp", "Dnsmasq", "Dnsmasq ist ein kombinierter DHCP-Server und DNS-Forwarder für NAT-Firewalls.")
+
+s = m:section(TypedSection, "dnsmasq", "Einstellungen")
+s.anonymous = true
+
+s:option(Flag, "domainneeded", "Anfragen nur mit Domain", "Anfragen ohne Domainnamen nicht weiterleiten")
+s:option(Flag, "authoritative", "Authoritativ", "Dies ist der einzige DHCP im lokalen Netz")
+s:option(Flag, "boguspriv", "Private Anfragen filtern", "Reverse DNS-Anfragen für lokalen Netze nicht weiterleiten")
+s:option(Flag, "filterwin2k", "Windowsanfragen filtern", "nutzlose DNS-Anfragen aktueller Windowssysteme filtern")
+s:option(Flag, "localise_queries", "Lokalisiere Anfragen", "Gibt die Adresse eines Hostnamen entsprechend seines Subnetzes zurück")
+s:option(Value, "local", "Lokale Server")
+s:option(Value, "domain", "Lokale Domain")
+s:option(Flag, "expandhosts", "Erweitere Hosts", "Fügt Domainnamen zu einfachen Hosteinträgen in der Resolvdatei hinzu")
+s:option(Flag, "nonegcache", "Unbekannte nicht cachen", "Negative DNS-Antworten nicht zwischenspeichern")
+s:option(Flag, "readethers", "Verwende /etc/ethers", "Lese Informationen aus /etc/ethers um den DHCP-Server zu konfigurieren")
+s:option(Value, "leasefile", "Leasedatei", "Speicherort für vergebenen DHCP-Adressen")
+s:option(Value, "resolvfile", "Resolvdatei", "Lokale DNS-Datei")
+s:option(Flag, "nohosts", "Ignoriere /etc/hosts").optional = true
+s:option(Flag, "strictorder", "Strikte Reihenfolge", "DNS-Server werden strikt der Reihenfolge in der Resolvdatei nach abgefragt").optional = true
+s:option(Flag, "logqueries", "Schreibe Abfragelog").optional = true
+s:option(Flag, "noresolv", "Ignoriere Resolvdatei").optional = true
+s:option(Value, "dnsforwardmax", "gleichzeitige Abfragen").optional = true
+s:option(Value, "port", "DNS-Port").optional = true
+s:option(Value, "ednspacket_max", "max. EDNS.0 Paketgröße").optional = true
+s:option(Value, "dhcpleasemax", "max. DHCP-Leases").optional = true
+s:option(Value, "addnhosts", "Zusätzliche Hostdatei").optional = true
+s:option(Value, "queryport", "Abfrageport").optional = true
+
+return m
\ No newline at end of file
--- /dev/null
+-- ToDo: Translate, Add descriptions
+m = Map("dropbear", "SSH-Server", [[Der SSH-Server ermöglicht Shell-Zugriff
+über das Netzwerk und bietet einen integrierten SCP-Dienst.]])
+
+s = m:section(TypedSection, "dropbear")
+s.anonymous = true
+
+port = s:option(Value, "Port", "Port")
+port.isinteger = true
+
+pwauth = s:option(Flag, "PasswordAuth", "Passwortanmeldung", "Erlaube Anmeldung per Passwort")
+pwauth.enabled = 'on'
+pwauth.disabled = 'off'
+
+return m
\ No newline at end of file
--- /dev/null
+-- ToDo: Translate, Add descriptions
+m = Map("httpd", "HTTP-Server", "Der HTTP-Server ist u.a. für die Bereitstellung dieser Obefläche zuständig.")
+
+s = m:section(TypedSection, "httpd")
+s.anonymous = true
+
+port = s:option(Value, "port", "Port")
+port.isinteger = true
+
+s:option(Value, "home", "Wurzelverzeichnis")
+
+config = s:option(Value, "c_file", "Konfigurationsdatei", "/etc/httpd.conf wenn leer")
+config.rmempty = true
+
+realm = s:option(Value, "realm", "Anmeldeaufforderung", "Aufforderungstext zum Anmelden im Administrationsbereich")
+realm.rmempty = true
+
+return m
\ No newline at end of file
--- /dev/null
+-- ToDo: Autodetect things, Translate, Add descriptions
+require("ffluci.fs")
+
+m = Map("olsr", "OLSR", [[OLSR ist ein flexibles Routingprotokoll,
+dass den Aufbau von mobilen Ad-Hoc Netzen unterstützt.]])
+
+s = m:section(NamedSection, "general", "olsr", "Allgemeine Einstellungen")
+
+debug = s:option(ListValue, "DebugLevel", "Debugmodus")
+for i=0, 9 do
+ debug:value(i)
+end
+
+ipv = s:option(ListValue, "IpVersion", "Internet Protokoll")
+ipv:value("4", "IPv4")
+ipv:value("6", "IPv6")
+
+noint = s:option(Flag, "AllowNoInt", "Start ohne Netzwerk")
+noint.enabled = "yes"
+noint.disabled = "no"
+
+s:option(Value, "Pollrate", "Abfragerate (Pollrate)", "s")
+
+tcr = s:option(ListValue, "TcRedundancy", "TC-Redundanz")
+tcr:value("0", "MPR-Selektoren")
+tcr:value("1", "MPR-Selektoren und MPR")
+tcr:value("2", "Alle Nachbarn")
+
+s:option(Value, "MprCoverage", "MPR-Erfassung")
+
+lql = s:option(ListValue, "LinkQualityLevel", "VQ-Level")
+lql:value("0", "deaktiviert")
+lql:value("1", "MPR-Auswahl")
+lql:value("2", "MPR-Auswahl und Routing")
+
+lqfish = s:option(Flag, "LinkQualityFishEye", "VQ-Fisheye")
+
+s:option(Value, "LinkQualityWinSize", "VQ-Fenstergröße")
+
+s:option(Value, "LinkQualityDijkstraLimit", "VQ-Dijkstralimit")
+
+hyst = s:option(Flag, "UseHysteresis", "Hysterese aktivieren")
+hyst.enabled = "yes"
+hyst.disabled = "no"
+
+
+i = m:section(TypedSection, "Interface", "Schnittstellen")
+i.anonymous = true
+i.addremove = true
+i.dynamic = true
+
+network = i:option(ListValue, "Interface", "Netzwerkschnittstellen")
+network:value("")
+for k, v in pairs(ffluci.model.uci.sections("network")) do
+ if v[".type"] == "interface" and k ~= "loopback" then
+ network:value(k)
+ end
+end
+
+i:option(Value, "HelloInterval", "Hello-Intervall")
+
+i:option(Value, "HelloValidityTime", "Hello-Gültigkeit")
+
+i:option(Value, "TcInterval", "TC-Intervall")
+
+i:option(Value, "TcValidityTime", "TC-Gültigkeit")
+
+i:option(Value, "MidInterval", "MID-Intervall")
+
+i:option(Value, "MidValidityTime", "MID-Gültigkeit")
+
+i:option(Value, "HnaInterval", "HNA-Intervall")
+
+i:option(Value, "HnaValidityTime", "HNA-Gültigkeit")
+
+
+p = m:section(TypedSection, "LoadPlugin", "Plugins")
+p.addremove = true
+p.dynamic = true
+
+lib = p:option(ListValue, "Library", "Bibliothek")
+lib:value("")
+for k, v in pairs(ffluci.fs.dir("/usr/lib")) do
+ if v:sub(1, 6) == "olsrd_" then
+ lib:value(v)
+ end
+end
+
+return m
\ No newline at end of file
--- /dev/null
+m = Map("fstab", "Einhängepunkte")
+
+mount = m:section(TypedSection, "mount", "Einhängepunkte", [[Einhängepunkte bestimmen, an welcher Stelle des Dateisystems
+bestimmte Laufwerke und Speicher zur Verwendung eingebunden werden.]])
+mount.anonymous = true
+mount.addremove = true
+
+mount:option(Flag, "enabled", "aktivieren")
+mount:option(Value, "device", "Gerät", "Die Gerätedatei des Speichers oder der Partition (z.B.: /dev/sda)")
+mount:option(Value, "target", "Einhängepunkt", "Die Stelle an der der Speicher in das Dateisystem eingehängt wird.")
+mount:option(Value, "fstype", "Dateisystem", "Das Dateisystem mit dem der Speicher formatiert ist (z.B.: ext3)")
+mount:option(Value, "options", "Optionen", "Weitere Optionen (siehe das Handbuch des Befehls 'mount')")
+
+
+swap = m:section(TypedSection, "swap", "SWAP", [[Falls der Arbeitsspeicher des Routers nicht ausreicht,
+kann dieser nicht benutzte Daten zeitweise auf einem SWAP-Laufwerk auslagern um so die
+effektive Größe des Arbeitsspeichers zu erhöhen. Die Auslagerung der Daten ist natürlich bedeutend langsamer
+als direkte Arbeitsspeicherzugriffe.]])
+swap.anonymous = true
+swap.addremove = true
+
+swap:option(Flag, "enabled", "aktivieren")
+swap:option(Value, "device", "Gerät", "Die Gerätedatei des Speichers oder der Partition (z.B.: /dev/sda)")
+
+return m
--- /dev/null
+m = Map("system", "Hostname", [[Definiert den Hostnamen des Routers.
+Der Hostname ist eine im Netzwerk eindeutige Kennung, die dieses Gerät identifiziert.]])
+
+s = m:section(TypedSection, "system")
+s.anonymous = true
+
+s:option(Value, "hostname", "Hostname")
+
+return m
\ No newline at end of file
--- /dev/null
+-- ToDo: Translate, Add descriptions and help texts
+
+m = Map("wireless", "Geräte", [[An dieser Stelle können eingebaute WLAN-Geräte konfiguriert werden.]])
+
+s = m:section(TypedSection, "wifi-device")
+--s.addremove = true
+
+en = s:option(Flag, "disabled", "Aktivieren")
+en.enabled = "0"
+en.disabled = "1"
+
+t = s:option(ListValue, "type", "Typ")
+t:value("broadcom")
+t:value("atheros")
+t:value("mac80211")
+t:value("prism2")
+--[[
+require("ffluci.sys")
+local c = ". /etc/functions.sh;for i in /lib/wifi/*;do . $i;done;echo $DRIVERS"
+for driver in ffluci.sys.execl(c)[1]:gmatch("[^ ]+") do
+ t:value(driver)
+end
+]]--
+
+mode = s:option(ListValue, "mode", "Modus")
+mode:value("", "standard")
+mode:value("11b", "802.11b")
+mode:value("11g", "802.11g")
+mode:value("11a", "802.11a")
+mode:value("11bg", "802.11b+g")
+mode.rmempty = true
+
+s:option(Value, "channel", "Funkkanal")
+
+s:option(Value, "txantenna", "Sendeantenne").rmempty = true
+
+s:option(Value, "rxantenna", "Empfangsantenne").rmempty = true
+
+s:option(Value, "distance", "Distanz",
+ "Distanz zum am weitesten entfernten Funkpartner (m)").rmempty = true
+
+s:option(Value, "diversity", "Diversität"):depends("type", "atheros")
+
+country = s:option(Value, "country", "Ländercode")
+country.optional = true
+country:depends("type", "broadcom")
+
+maxassoc = s:option(Value, "maxassoc", "Verbindungslimit")
+maxassoc:depends("type", "broadcom")
+maxassoc.optional = true
+
+return m
\ No newline at end of file
--- /dev/null
+-- ToDo: Translate, Add descriptions and help texts
+m = Map("wireless", "Netze", [[Pro WLAN-Gerät können mehrere Netze bereitgestellt werden.
+Es sollte beachtet werden, dass es hardware- / treiberspezifische Einschränkungen gibt.
+So kann pro WLAN-Gerät in der Regel entweder 1 Ad-Hoc-Zugang ODER bis zu 3 Access-Point und 1 Client-Zugang
+gleichzeitig erstellt werden.]])
+
+s = m:section(TypedSection, "wifi-iface")
+s.addremove = true
+s.anonymous = true
+
+s:option(Value, "ssid", "Netzkennung (ESSID)").maxlength = 32
+
+device = s:option(ListValue, "device", "Gerät")
+local d = ffluci.model.uci.sections("wireless")
+if d then
+ for k, v in pairs(d) do
+ if v[".type"] == "wifi-device" then
+ device:value(k)
+ end
+ end
+end
+
+network = s:option(ListValue, "network", "Netzwerk", "WLAN-Netz zu Netzwerk hinzufügen")
+network:value("")
+for k, v in pairs(ffluci.model.uci.sections("network")) do
+ if v[".type"] == "interface" and k ~= "loopback" then
+ network:value(k)
+ end
+end
+
+mode = s:option(ListValue, "mode", "Modus")
+mode:value("ap", "Access Point")
+mode:value("adhoc", "Ad-Hoc")
+mode:value("sta", "Client")
+mode:value("wds", "WDS")
+
+s:option(Value, "bssid", "BSSID").optional = true
+
+s:option(Value, "txpower", "Sendeleistung", "dbm").rmempty = true
+
+s:option(Flag, "frameburst", "Broadcom-Frameburst").optional = true
+s:option(Flag, "bursting", "Atheros-Frameburst").optional = true
+
+
+encr = s:option(ListValue, "encryption", "Verschlüsselung")
+encr:value("none", "keine")
+encr:value("wep", "WEP")
+encr:value("psk", "WPA-PSK")
+encr:value("wpa", "WPA-Radius")
+encr:value("psk2", "WPA2-PSK")
+encr:value("wpa2", "WPA2-Radius")
+
+key = s:option(Value, "key", "Schlüssel")
+key:depends("encryption", "wep")
+key:depends("encryption", "psk")
+key:depends("encryption", "wpa")
+key:depends("encryption", "psk2")
+key:depends("encryption", "wpa2")
+key.rmempty = true
+
+server = s:option(Value, "server", "Radius-Server")
+server:depends("encryption", "wpa")
+server:depends("encryption", "wpa2")
+server.rmempty = true
+
+port = s:option(Value, "port", "Radius-Port")
+port:depends("encryption", "wpa")
+port:depends("encryption", "wpa2")
+port.rmempty = true
+
+s:option(Flag, "isolate", "AP-Isolation", "Unterbindet Client-Client-Verkehr").optional = true
+
+s:option(Flag, "hidden", "ESSID verstecken").optional = true
+
+
+
+return m
\ No newline at end of file
--- /dev/null
+add("admin", "index", "Übersicht", 10)
+act("luci", "Oberfläche")
+
+add("admin", "system", "System", 30)
+act("packages", "Paketverwaltung")
+act("passwd", "Passwort ändern")
+act("sshkeys", "SSH-Schlüssel")
+act("hostname", "Hostname")
+act("fstab", "Einhängepunkte")
+act("upgrade", "Firmwareupgrade")
+act("reboot", "Neu starten")
+
+add("admin", "services", "Dienste", 40)
+if isfile("/etc/config/olsr") then
+ act("olsrd", "OLSR")
+end
+act("httpd", "HTTP-Server")
+act("dropbear", "SSH-Server")
+act("dnsmasq", "Dnsmasq")
+
+add("admin", "network", "Netzwerk", 50)
+act("vlan", "Switch")
+act("ifaces", "Schnittstellen")
+act("dhcp", "DHCP-Server")
+act("ptp", "PPPoE / PPTP")
+act("routes", "Statische Routen")
+if isfile("/etc/config/qos") then
+ act("qos", "Quality of Service")
+end
+
+add("admin", "wifi", "Drahtlos", 60)
+act("devices", "Geräte")
+act("networks", "Netze")
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:hello Hallo!%></h1>
+<p><%:admin1 Dies ist der Administrationsbereich von FFLuCI.%></p>
+<p><%:admin2 FFLuCI ist eine freie, flexible und benutzerfreundliche grafische Oberfläche zur Konfiguration von OpenWRT Kamikaze.%><br />
+<%:admin3 Auf den folgenden Seiten können alle wichtigen Einstellungen des Routers vorgenommen werden.%></p>
+<p><%:admin4 Auf der linken Seite befindet sich eine Navigation, die zu den einzelnen Konfigurationsseiten führt.%></p>
+<p><%:admin5 Wir sind natürlich stets darum bemüht, diese Oberfläche
+noch besser und intuitiver zu Gestalten und freuen uns über jegliche Art von Feedback oder Verbesserungsvorschlägen.%></p>
+<p><%:admin6 Und nun wünschen wir viel Spaß mit dem Router!%></p>
+<p><em><strong><a href="http://luci.freifunk-halle.net"><%:team Das FFLuCI-Team%></a></strong></em></p>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:ffwizard Freifunkassistent%></h1>
+<p><%:ffwizard1 Dieser Assistent konfiguriert den Router für die Benutzung im Freifunknetz%></p>
+<br />
+<form method="post" action="<%=controller%>/admin/index/wizard">
+ <div class="cbi-section-node">
+ <div class="cbi-value">
+ <div class="cbi-value-title"><%:ip IP-Adresse%>:
+ <input type="text" size="20" name="ip" /></div>
+ </div>
+ <% for i, k in ipairs(ifaces) do %>
+ <div class="cbi-value">
+ <div class="cbi-value-title"><%:wificfg Drahtlosgerät einrichten%>: <%=k%></div>
+ <div class="cbi-value-field"><input type="checkbox" name="wifi.<%=k%>" value="1" checked="checked" /></div>
+ </div>
+ <% end %>
+ <div class="cbi-value">
+ <div class="cbi-value-title"><%:cfgolsr OLSR konfigurieren%></div>
+ <div class="cbi-value-field"><input type="checkbox" name="olsr" value="1" checked="checked" /></div>
+ </div>
+ <div class="cbi-value">
+ <div class="cbi-value-title"><%:cfgdhcp Drahtlos DHCP konfigurieren%></div>
+ <div class="cbi-value-field"><input type="checkbox" name="dhcp" value="1" checked="checked" /></div>
+ </div>
+ <div class="cbi-value">
+ <div class="cbi-value-title"><%:shareinet Internet teilen%></div>
+ <div class="cbi-value-field"><input type="checkbox" name="shareinet" value="1" checked="checked" /></div>
+ </div>
+ </div>
+ <br />
+ <div>
+ <input type="submit" value="<%:configure Konfigurieren%>" />
+ <input type="reset" value="<%:reset Zurücksetzen%>" />
+ </div>
+</form>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:network Netzwerk%></h1>
+<p><%:network1 In diesem Bereich finden sich alle netzwerkbezogenen Einstellungen.%></p>
+<p><%:network2 Der Netzwerkswitch kann bei den meisten Routern frei konfiguriert
+und in mehrere VLANs aufgeteilt werden. %></p>
+<p><%:network3 Schnittstellen und PPPoE/PPTP-Einstellungen ermöglichen
+die freie Organisation des Netzwerks und die Anbindung an ein WAN.%></p>
+<p><%:network4 DHCP ermöglichst die automatische Netzwerkkonfiguration von Rechnern im (W)LAN.%></p>
+<p><%:network5 Portweiterleitung und Firewall erlauben eine effektive Absicherung des Netzes, bei gleichzeitiger
+Bereitstellung von externen Diensten.%></p>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:services Dienste%></h1>
+<p><%:services1 Dienste und Dämonen stellen bestimmte Funktionalitäten auf dem Router zur Verfügung.%></p>
+<p><%:services2 Es handelt sich hierbei meist um Netzwerkserver, die verschiedene Aufgaben auf dem Router erfüllen,
+beispielsweise Shell-Zugang ermöglichen oder diese Weboberfläche per HTTP anbieten.%></p>
+<p><%:servcies3 In diesen Bereich fallen auch die Meshnetzwerkdienste wie OLSR und BATMAN, die dabei helfen,
+ein autarkes Ad-Hoc Netzwerk aufzubauen.%></p>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:texteditor Texteditor%></h1>
+<form method="post" action="<%=controller%>/admin/system/editor">
+<div><%:file Datei%>: <input type="text" name="file" size="30" value="<%=fn%>" />
+<% if msg then %><span class="error"><%:error Fehler%>: <%=msg%></span><% end %></div>
+<br />
+<div><textarea style="width: 100%" rows="20" name="data"><%=cnt%></textarea></div>
+<br />
+<div>
+ <input type="submit" value="<%:save Speichern%>" />
+ <input type="reset" value="<%:reset Zurücksetzen%>" />
+</div>
+</form>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:system System%></h1>
+<p><%:system1 Hier finden sich Einstellungen, die das System selbst, dessen Kennung,
+installierte Software und Hardware, Authentifizierung oder eingehängte Speicher betreffen.%></p>
+<p><%:system2 Diese Einstellungen definieren die Grundlage des Systems, auf dem die
+installierte Software aufbaut.%></p>
+<p><%:system3 Beachte bitte, dass eine fehlerhafte Konfiguration den Start
+des Routers verhindern oder dich vom Zugriff auf diesen ausschließen kann.%></p>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:system System%></h1>
+<h2><%:ipkg IPKG-Konfiguration%></h2>
+
+<br />
+
+<div><strong><%:ipkg_pkglists Paketlisten%>:</strong><code>src <em>Name</em> <em>URL</em></code></div>
+<div><strong><%:ipkg_targets Installationsziele%>:</strong><code>dest <em>Name</em> <em>Pfad</em></code></div>
+
+<br />
+
+<form method="post" action="<%=controller%>/admin/system/ipkg">
+ <div class="cbi-section-node" style="width: 100%">
+ <div class="cbi-value">
+ <div class="cbi-value-field">
+ <textarea style="width: 100%" rows="10" name="data"><%=cnt%></textarea>
+ </div>
+ </div>
+ </div>
+ <div>
+ <input type="submit" value="<%:save Speichern%>" />
+ <input type="reset" value="<%:reset Zurücksetzen%>" />
+ </div>
+ <% if msg then %><br /><div class="error"><%:error Fehler%>: <%=msg%></div><% end %>
+</form>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:system System%></h1>
+<h2><%:packages Paketverwaltung%></h2>
+
+<br />
+
+<% if install or remove or update or upgrade then %>
+<div class="code"><strong><%:status Status%>:</strong><br />
+<% if update then %>
+ <%:packages_update Paketlisten aktualisieren%>: <% if update == 0 then %><span class="ok"><%:ok OK%></span><% else %><span class="error"><%:error Fehler%> (<%:code Code%> <%=update%>)</span><% end %><br />
+<% end %>
+<% if upgrade then%>
+ <%:packages_upgrade Installierte Pakete aktualisieren%>: <% if upgrade == 0 then %><span class="ok"><%:ok OK%></span><% else %><span class="error"><%:error Fehler%> (<%:code Code%> <%=upgrade%>)</span><% end %><br />
+<% end %>
+<% if install then for k,v in pairs(install) do %>
+ <%:packages_install Installation von%> '<%=k%>': <% if v == 0 then %><span class="ok"><%:ok OK%></span><% else %><span class="error"><%:error Fehler%> (<%:code Code%> <%=v%>)</span><% end %><br />
+<% end end %>
+<% if remove then for k,v in pairs(remove) do %>
+ <%:packages_remove Deinstallation von%> '<%=k%>': <% if v == 0 then %><span class="ok"><%:ok OK%></span><% else %><span class="error"><%:error Fehler%> (<%:code Code%> <%=v%>)</span><% end %><br />
+<% end end %>
+</div>
+<br />
+<% end %>
+
+<div>
+<a href="<%=controller%>/admin/system/ipkg"><%:packages_ipkg Paketlisten und Installationsziele bearbeiten%></a><br />
+<a href="<%=controller%>/admin/system/packages?update=1"><%:packages_updatelist Paketlisten aktualisieren%></a><br />
+<a href="<%=controller%>/admin/system/packages?upgrade=1"><%:packages_upgrade Installierte Pakete aktualisieren%></a>
+</div>
+
+<br />
+<br />
+
+<form method="post" action="<%=controller%>/admin/system/packages">
+ <div>
+ <span class="bold"><%:packages_installurl Paket herunterladen und installieren%>:</span><br />
+ <input type="text" name="url" size="30" value="" />
+ <input type="submit" name="submit" value="<%:ok OK%>" />
+ </div>
+
+ <br />
+ <br />
+
+ <div>
+ <span class="bold"><%:filter Filter%>:</span>
+ <input type="text" name="query" size="20" value="<%=query%>" />
+ <input type="submit" name="search" value="<%:packages_search Paket suchen%>" />
+ <input type="submit" name="submit" value="<%:packages_do Aktionen ausführen%>" />
+ </div>
+
+ <br />
+ <br />
+
+ <div>
+ <table style="font-size: 0.8em">
+ <tr>
+ <th><%:packages_name Paketname%></th>
+ <th><%:version Version%></th>
+ <th><%:install Installieren%></th>
+ <th><%:delete Löschen%></th>
+ <th><%:descr Beschreibung%></th>
+ </tr>
+ <% for k, pkg in pairs(pkgs) do %>
+ <tr>
+ <td><%=pkg.Package%></td>
+ <td><%=pkg.Version%></td>
+ <td><% if not pkg.Status or not pkg.Status.installed then %><input type="checkbox" name="install.<%=pkg.Package%>" value="1" /><% else %><%:installed installiert%><% end %></td>
+ <td><% if pkg.Status and pkg.Status.installed then %><input type="checkbox" name="remove.<%=pkg.Package%>" value="1" /><% else %><%:notinstalled nicht installiert%><% end %></td>
+ <td><%=pkg.Description%></td>
+ </tr>
+ <% end %>
+ </table>
+ </div>
+ <br />
+ <input type="submit" name="submit" value="<%:packages_do Aktionen ausführen%>" />
+</form>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:system System%></h1>
+<h2><%:passwd Passwort ändern%></h2>
+<p><%:passwd1 Ändert das Passwort des Systemverwalters (Benutzer "root")%></p>
+<div><br />
+<% if stat then %>
+ <% if stat == 0 then %>
+ <code><%:password_changed Passwort erfolgreich geändert!%></code>
+ <% elseif stat == 10 then %>
+ <code class="error"><%:password_nomatch Passwörter stimmen nicht überein! %></code>
+ <% else %>
+ <code class="error"><%:unknown_error Unbekannter Fehler!%></code>
+ <% end %>
+<% end %>
+<% if not stat or stat == 10 then %>
+ <form method="post" action="<%=controller%>/admin/system/passwd">
+ <div class="cbi-section-node">
+ <div class="cbi-value">
+ <div class="cbi-value-title"><%:password Passwort%></div>
+ <div class="cbi-value-field"><input type="password" name="pwd1" /></div>
+ </div>
+ <div class="cbi-value">
+ <div class="cbi-value-title"><%:confirmation Bestätigung%></div>
+ <div class="cbi-value-field"><input type="password" name="pwd2" /></div>
+ </div>
+ <br />
+ <div>
+ <input type="submit" value="<%:save Speichern%>" />
+ <input type="reset" value="<%:reset Zurücksetzen%>" />
+ </div>
+ </div>
+ </form>
+<% end %>
+</div>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:system System%></h1>
+<h2><%:reboot Neu starten%></h2>
+<p><%:reboot1 Startet das Betriebssystem des Routers neu.%></p>
+<% if not reboot then %>
+<p><a href="<%=controller%>/admin/system/reboot?reboot=1"><%:reboot_do Neustart durchführen%></a></p>
+<% else %>
+<p><%:reboot_running Bitte warten: Neustart wird durchgeführt...%></p>
+<script type="text/javascript">setTimeout("location='<%=controller%>/admin'", 60000)</script>
+<% end %>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:system System%></h1>
+<h2><%:sshkeys SSH-Schlüssel%></h2>
+
+<br />
+
+<div><%:sshkeys_descr Hier können öffentliche SSH-Schlüssel (einer pro Zeile)
+ zur Authentifizierung abgelegt werden.%></div>
+
+<br />
+
+<form method="post" action="<%=controller%>/admin/system/sshkeys">
+ <div class="cbi-section-node" style="width: 100%">
+ <div class="cbi-value">
+ <div class="cbi-value-field">
+ <textarea style="width: 100%" rows="10" name="data"><%=cnt%></textarea>
+ </div>
+ </div>
+ </div>
+ <div>
+ <input type="submit" value="<%:save Speichern%>" />
+ <input type="reset" value="<%:reset Zurücksetzen%>" />
+ </div>
+ <% if msg then %><br /><div class="error"><%:error Fehler%>: <%=msg%></div><% end %>
+</form>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:system System%></h1>
+<h2><%:upgrade Upgrade%></h2>
+<p><%:upgrade1 Ersetzt die installierte Firmware (das Betriebssystem des Routers) durch ein neues.
+Das Format der Firmware ist plattformabhängig.%></p>
+<br />
+<% if sysupgrade and not ret then %>
+<form method="post" action="<%=controller%>-upload/admin/system/upgrade" enctype="multipart/form-data">
+ <div class="cbi-section-node">
+ <div class="cbi-value clear">
+ <div class="cbi-value-title left"><%:fwimage Firmwareimage%></div>
+ <div class="cbi-value-field"><input type="file" size="30" name="image" /></div>
+ </div>
+ <br />
+ <div class="cbi-value clear">
+ <input type="checkbox" name="keepcfg" value="1" checked="checked" />
+ <span class="bold"><%:keepcfg Konfigurationsdateien übernehmen%></span>
+ </div>
+ <br />
+ <div>
+ <input type="submit" value="<%:fwupgrade Firmware aktualisieren%>" />
+ </div>
+ </div>
+</form>
+<% elseif ret then %>
+ <% if ret == 0 then %>
+<div class="ok"><%:flashed Flashvorgang erfolgreich. Router startet neu...%></div>
+ <% else %>
+<div class="error"><%:flasherr Flashvorgang fehlgeschlagen!%> (<%:code Code%> <%=ret%>)</div>
+ <% end %>
+<% else %>
+<div class="error"><%:notimplemented Diese Funktion steht leider (noch) nicht zur Verfügung.%></div>
+<% end %>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:config Konfiguration%></h1>
+<p><%:uci_applied Die folgenden Änderungen wurden übernommen%>:</p>
+<code><%=(changes or "-")%>
+<%=output%></code>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:config Konfiguration%></h1>
+<h2><%:changes Änderungen%></h2>
+<code><%=(ffluci.model.uci.changes() or "-")%></code>
+<form class="inline" method="get" action="<%=controller%>/admin/uci/apply">
+ <input type="submit" value="<%:apply Anwenden%>" />
+</form>
+<form class="inline" method="get" action="<%=controller%>/admin/uci/revert">
+ <input type="submit" value="<%:revert Verwerfen%>" />
+</form>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:config Konfiguration%></h1>
+<p><%:uci_reverted Die folgenden Änderungen wurden verworfen%>:</p>
+<code><%=(changes or "-")%></code>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+<%+header%>
+<h1><%:wifi Drahtlos%></h1>
+<p><%:wifi1 Hier finden sich Konfiugrationsmöglichkeiten für Drahtlos-Netzwerke nach dem WLAN-Standard.%></p>
+<p><%:wifi2 802.11b/g/a/n-Geräte können so einfach in das bestehende physische Netzwerk integriert werden.
+Die Unterstützung von virtuellen Adaptern ermöglicht auch den Einsatz als Wireless-Repeater oder von
+mehreren Netzwerken gleichzeitig auf einem Gerät.%></p>
+<p><%:wifi3 Es werden Managed, Client, Ad-Hoc und WDS-Modus unterstützt sowie WPA und WPA2-Verschlüsselung zur gesicherten
+Kommunikation.%></p>
+<%+footer%>
\ No newline at end of file
--- /dev/null
+include ../../build/config.mk
+include ../../build/module.mk
\ No newline at end of file
+++ /dev/null
-@charset "utf-8";
-
-body {
- font-family: Verdana, Arial, sans-serif;
- background-color: #aaaaaa;
-}
-
-h1 {
- margin: 0%;
- font-size: 1.4em;
- font-weight: bold;
- margin-bottom: 0.5em;
-}
-
-h2 {
- margin: 0%;
- font-size: 1.2em;
- font-weight: bold;
-}
-
-h3 {
- margin: 0%;
-}
-
-#header {
- padding: 0.2em;
- height: 4.5em;
- background-color: #262626;
-}
-
-#columns {
- border-left: 10.1em solid #262626;
- border-right: 10.1em solid #262626;
- display: block;
- background-color: white;
- padding: 0.1em;
-}
-
-#columnswrapper {
- display: block;
- margin-left: -10em;
- margin-right: -10em;
-}
-
-#content {
- margin-left: 14em;
- margin-right: 14em;
- display: block;
- position: relative;
- padding: 2px;
- font-size: 0.8em;
-}
-
-.headerlogo {
- height: 4em;
- padding: 5px;
-}
-
-.headerlogo img {
- height: 100%;
-}
-
-.headertitle {
- font-size: 2.4em;
- color: gray;
- letter-spacing: 0.5em;
- text-transform: lowercase;
-}
-
-.separator {
- padding-left: 0.25em;
- font-weight: bold;
- font-size: 0.8em;
- line-height: 1.4em;
-}
-
-.whitetext {
- color: white;
-}
-
-.yellowtext {
- color: #ffcb05;
-}
-
-.magentatext {
- color: #dc0065;
-}
-
-.inheritcolor {
- color: inherit;
-}
-
-.smalltext {
- font-size: 0.8em;
-}
-
-.yellow {
- background-color: #ffcb05;
-}
-
-.magenta {
- background-color: #dc0065;
-}
-
-.nodeco {
- text-decoration: none;
-}
-
-.redhover:hover {
- color: red;
-}
-
-.bold {
- font-weight: bold;
-}
-
-.sidebar {
- position: relative;
- padding: 0.25em;
- color: gray;
- width: 9em;
- font-weight: bold;
-}
-
-.separator a, .sidebar a {
- color: inherit;
- text-decoration: inherit;
-}
-
-.separator a:hover, .sidebar a:hover {
- color: red;
-}
-
-.sidebar div {
- padding-bottom: 0.5em;
-}
-
-.sidebar ul {
- font-size: 0.8em;
- color: white;
- list-style-type: none;
- padding-left: 1em;
- margin-top: 0%;
-}
-
-.left {
- float: left;
- text-align: left;
-}
-
-.right {
- float: right;
- text-align: right;
-}
-
-.clear {
- clear: both;
-}
-
-.hidden {
- display: none;
-}
-
-.inline {
- display: inline;
-}
-
-.code {
- background: #f7f7f7;
- border: 1px solid #d7d7d7;
- margin: 1em 1.75em;
- padding: 1em;
-}
-
-code {
- display: block;
- background: #f7f7f7;
- border: 1px solid #d7d7d7;
- margin: 1em 1.75em;
- padding: 1em;
- overflow: auto;
- white-space: pre;
-}
-
-table th, table, td {
- vertical-align: top;
- text-align: left;
- border: 1px solid gray;
-}
-
-.cbi-section {
- margin-top: 1em;
-}
-
-.cbi-section-remove {
- text-align: right;
-}
-
-.cbi-value {
- display: table-row;
-}
-
-.cbi-value-title {
- display: table-cell;
- line-height: 1.75em;
- font-weight: bold;
- padding: 0.25em;
-}
-
-.cbi-value-field {
- display: table-cell;
- text-align: left;
- padding: 0.25em;
- line-height: 1.75em;
-}
-
-.cbi-value-field input, .cbi-value-field select,
-.cbi-optionals select, .cbi-optionals input,
-.cbi-section-remove input, .cbi-section-create input {
- font-size: 0.8em;
- margin: 0%;
-}
-
-.cbi-section-descr {
- padding-bottom: 1em;
-}
-
-.cbi-value-description {
- display: inline;
- font-style: italic;
- font-size: 0.8em;
- padding: 0.25em;
- margin-bottom: 0.5em;
-}
-
-.cbi-form-separator {
- margin-top: 1em;
-}
-
-.cbi-section-node {
- display: table;
- padding: 0.25em;
- background: #f7f7f7;
- border: 1px solid #d7d7d7;
-}
-
-.cbi-section-node h3 {
- margin-bottom: 0.5em;
-}
-
-.cbi-error {
- color: red;
- font-weight: bold;
- font-size: 0.8em;
- margin-bottom: 0.75em;
-}
-
-.cbi-optionals {
- margin-top: 1em;
-}
-
-.cbi-optionals option {
- font-size: 0.8em;
-}
-
-.error {
- color: red;
- font-weight: bold;
-}
-
-.ok {
- color: green;
- font-weight: bold;
-}
\ No newline at end of file
+++ /dev/null
-var cbi_d = {};
-
-function cbi_d_add(field, target, value) {
- if (!cbi_d[target]) {
- cbi_d[target] = {};
- }
- if (!cbi_d[target][value]) {
- cbi_d[target][value] = [];
- }
- cbi_d[target][value].push(field);
-}
-
-function cbi_d_update(target) {
- if (!cbi_d[target]) {
- return;
- }
-
- for (var x in cbi_d[target]) {
- for (var i=0; i<cbi_d[target][x].length; i++) {
- var y = document.getElementById(cbi_d[target][x][i])
- y.style.display = "none";
- }
- }
-
- var t = document.getElementById(target);
- if (t && t.value && cbi_d[target][t.value]) {
- for (var i=0; i<cbi_d[target][t.value].length; i++) {
- var y = document.getElementById(cbi_d[target][t.value][i])
- if (!y.value) {
- y.style.display = "table-row";
- } else {
- y.style.display = "block";
- }
- }
- }
-}
-
-function cbi_d_init() {
- for (var x in cbi_d) {
- cbi_d_update(x);
- }
-}
\ No newline at end of file
--- /dev/null
+@charset "utf-8";
+
+body {
+ font-family: Verdana, Arial, sans-serif;
+ background-color: #aaaaaa;
+}
+
+h1 {
+ margin: 0%;
+ font-size: 1.4em;
+ font-weight: bold;
+ margin-bottom: 0.5em;
+}
+
+h2 {
+ margin: 0%;
+ font-size: 1.2em;
+ font-weight: bold;
+}
+
+h3 {
+ margin: 0%;
+}
+
+#header {
+ padding: 0.2em;
+ height: 4.5em;
+ background-color: #262626;
+}
+
+#columns {
+ border-left: 10.1em solid #262626;
+ border-right: 10.1em solid #262626;
+ display: block;
+ background-color: white;
+ padding: 0.1em;
+}
+
+#columnswrapper {
+ display: block;
+ margin-left: -10em;
+ margin-right: -10em;
+}
+
+#content {
+ margin-left: 14em;
+ margin-right: 14em;
+ display: block;
+ position: relative;
+ padding: 2px;
+ font-size: 0.8em;
+}
+
+.headerlogo {
+ height: 4em;
+ padding: 5px;
+}
+
+.headerlogo img {
+ height: 100%;
+}
+
+.headertitle {
+ font-size: 2.4em;
+ color: gray;
+ letter-spacing: 0.5em;
+ text-transform: lowercase;
+}
+
+.separator {
+ padding-left: 0.25em;
+ font-weight: bold;
+ font-size: 0.8em;
+ line-height: 1.4em;
+}
+
+.whitetext {
+ color: white;
+}
+
+.yellowtext {
+ color: #ffcb05;
+}
+
+.magentatext {
+ color: #dc0065;
+}
+
+.inheritcolor {
+ color: inherit;
+}
+
+.smalltext {
+ font-size: 0.8em;
+}
+
+.yellow {
+ background-color: #ffcb05;
+}
+
+.magenta {
+ background-color: #dc0065;
+}
+
+.nodeco {
+ text-decoration: none;
+}
+
+.redhover:hover {
+ color: red;
+}
+
+.bold {
+ font-weight: bold;
+}
+
+.sidebar {
+ position: relative;
+ padding: 0.25em;
+ color: gray;
+ width: 9em;
+ font-weight: bold;
+}
+
+.separator a, .sidebar a {
+ color: inherit;
+ text-decoration: inherit;
+}
+
+.separator a:hover, .sidebar a:hover {
+ color: red;
+}
+
+.sidebar div {
+ padding-bottom: 0.5em;
+}
+
+.sidebar ul {
+ font-size: 0.8em;
+ color: white;
+ list-style-type: none;
+ padding-left: 1em;
+ margin-top: 0%;
+}
+
+.left {
+ float: left;
+ text-align: left;
+}
+
+.right {
+ float: right;
+ text-align: right;
+}
+
+.clear {
+ clear: both;
+}
+
+.hidden {
+ display: none;
+}
+
+.inline {
+ display: inline;
+}
+
+.code {
+ background: #f7f7f7;
+ border: 1px solid #d7d7d7;
+ margin: 1em 1.75em;
+ padding: 1em;
+}
+
+code {
+ display: block;
+ background: #f7f7f7;
+ border: 1px solid #d7d7d7;
+ margin: 1em 1.75em;
+ padding: 1em;
+ overflow: auto;
+ white-space: pre;
+}
+
+table th, table, td {
+ vertical-align: top;
+ text-align: left;
+ border: 1px solid gray;
+}
+
+.cbi-section {
+ margin-top: 1em;
+}
+
+.cbi-section-remove {
+ text-align: right;
+}
+
+.cbi-value {
+ display: table-row;
+}
+
+.cbi-value-title {
+ display: table-cell;
+ line-height: 1.75em;
+ font-weight: bold;
+ padding: 0.25em;
+}
+
+.cbi-value-field {
+ display: table-cell;
+ text-align: left;
+ padding: 0.25em;
+ line-height: 1.75em;
+}
+
+.cbi-value-field input, .cbi-value-field select,
+.cbi-optionals select, .cbi-optionals input,
+.cbi-section-remove input, .cbi-section-create input {
+ font-size: 0.8em;
+ margin: 0%;
+}
+
+.cbi-section-descr {
+ padding-bottom: 1em;
+}
+
+.cbi-value-description {
+ display: inline;
+ font-style: italic;
+ font-size: 0.8em;
+ padding: 0.25em;
+ margin-bottom: 0.5em;
+}
+
+.cbi-form-separator {
+ margin-top: 1em;
+}
+
+.cbi-section-node {
+ display: table;
+ padding: 0.25em;
+ background: #f7f7f7;
+ border: 1px solid #d7d7d7;
+}
+
+.cbi-section-node h3 {
+ margin-bottom: 0.5em;
+}
+
+.cbi-error {
+ color: red;
+ font-weight: bold;
+ font-size: 0.8em;
+ margin-bottom: 0.75em;
+}
+
+.cbi-optionals {
+ margin-top: 1em;
+}
+
+.cbi-optionals option {
+ font-size: 0.8em;
+}
+
+.error {
+ color: red;
+ font-weight: bold;
+}
+
+.ok {
+ color: green;
+ font-weight: bold;
+}
\ No newline at end of file
--- /dev/null
+var cbi_d = {};
+
+function cbi_d_add(field, target, value) {
+ if (!cbi_d[target]) {
+ cbi_d[target] = {};
+ }
+ if (!cbi_d[target][value]) {
+ cbi_d[target][value] = [];
+ }
+ cbi_d[target][value].push(field);
+}
+
+function cbi_d_update(target) {
+ if (!cbi_d[target]) {
+ return;
+ }
+
+ for (var x in cbi_d[target]) {
+ for (var i=0; i<cbi_d[target][x].length; i++) {
+ var y = document.getElementById(cbi_d[target][x][i])
+ y.style.display = "none";
+ }
+ }
+
+ var t = document.getElementById(target);
+ if (t && t.value && cbi_d[target][t.value]) {
+ for (var i=0; i<cbi_d[target][t.value].length; i++) {
+ var y = document.getElementById(cbi_d[target][t.value][i])
+ if (!y.value) {
+ y.style.display = "table-row";
+ } else {
+ y.style.display = "block";
+ }
+ }
+ }
+}
+
+function cbi_d_init() {
+ for (var x in cbi_d) {
+ cbi_d_update(x);
+ }
+}
\ No newline at end of file