diff options
author | Steven Barth <steven@midlink.org> | 2008-05-08 15:37:41 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-05-08 15:37:41 +0000 |
commit | aa9ccf77c6648515ba58c37b9345cdbd561028db (patch) | |
tree | b0270202d47b6c5e179f8475302bb3ef0d1c9402 /applications | |
parent | a3a51464fd8cffa6d18fa3f18be9c699901abd0d (diff) |
* Mördercommit ;-)
* Major Repository Reorganisation
* API 0.4 Softfreeze to come
Diffstat (limited to 'applications')
31 files changed, 692 insertions, 0 deletions
diff --git a/applications/community-leipzig/Makefile b/applications/community-leipzig/Makefile new file mode 100644 index 000000000..81a96f6a8 --- /dev/null +++ b/applications/community-leipzig/Makefile @@ -0,0 +1,2 @@ +include ../../build/config.mk +include ../../build/module.mk
\ No newline at end of file diff --git a/applications/community-leipzig/root/etc/uci-defaults/ffluci-community-leipzig b/applications/community-leipzig/root/etc/uci-defaults/ffluci-community-leipzig new file mode 100644 index 000000000..e73ff913c --- /dev/null +++ b/applications/community-leipzig/root/etc/uci-defaults/ffluci-community-leipzig @@ -0,0 +1,15 @@ +#!/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 diff --git a/applications/luci-fw/Makefile b/applications/luci-fw/Makefile new file mode 100644 index 000000000..81a96f6a8 --- /dev/null +++ b/applications/luci-fw/Makefile @@ -0,0 +1,2 @@ +include ../../build/config.mk +include ../../build/module.mk
\ No newline at end of file diff --git a/applications/luci-fw/root/etc/config/luci_fw b/applications/luci-fw/root/etc/config/luci_fw new file mode 100644 index 000000000..c7dec7f2c --- /dev/null +++ b/applications/luci-fw/root/etc/config/luci_fw @@ -0,0 +1,2 @@ + +
\ No newline at end of file diff --git a/applications/luci-fw/root/etc/init.d/luci_fw b/applications/luci-fw/root/etc/init.d/luci_fw new file mode 100644 index 000000000..e98b3f729 --- /dev/null +++ b/applications/luci-fw/root/etc/init.d/luci_fw @@ -0,0 +1,124 @@ +#!/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 +} diff --git a/applications/luci-fw/src/model/cbi/admin_network/firewall.lua b/applications/luci-fw/src/model/cbi/admin_network/firewall.lua new file mode 100644 index 000000000..4ff15db53 --- /dev/null +++ b/applications/luci-fw/src/model/cbi/admin_network/firewall.lua @@ -0,0 +1,63 @@ +-- 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 diff --git a/applications/luci-fw/src/model/cbi/admin_network/portfw.lua b/applications/luci-fw/src/model/cbi/admin_network/portfw.lua new file mode 100644 index 000000000..96822b53a --- /dev/null +++ b/applications/luci-fw/src/model/cbi/admin_network/portfw.lua @@ -0,0 +1,25 @@ +-- 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 diff --git a/applications/luci-fw/src/model/menu/50luci-fw.lua b/applications/luci-fw/src/model/menu/50luci-fw.lua new file mode 100644 index 000000000..93aba2fab --- /dev/null +++ b/applications/luci-fw/src/model/menu/50luci-fw.lua @@ -0,0 +1,3 @@ +sel("admin", "network") +act("portfw", "Portweiterleitung") +act("firewall", "Firewall")
\ No newline at end of file diff --git a/applications/luci-splash/Makefile b/applications/luci-splash/Makefile new file mode 100644 index 000000000..81a96f6a8 --- /dev/null +++ b/applications/luci-splash/Makefile @@ -0,0 +1,2 @@ +include ../../build/config.mk +include ../../build/module.mk
\ No newline at end of file diff --git a/applications/luci-splash/root/etc/config/luci_splash b/applications/luci-splash/root/etc/config/luci_splash new file mode 100644 index 000000000..c4cfef5dd --- /dev/null +++ b/applications/luci-splash/root/etc/config/luci_splash @@ -0,0 +1,2 @@ +config core general + option leasetime 1
\ No newline at end of file diff --git a/applications/luci-splash/root/etc/cron.minutely/luci_splash b/applications/luci-splash/root/etc/cron.minutely/luci_splash new file mode 100644 index 000000000..eae429474 --- /dev/null +++ b/applications/luci-splash/root/etc/cron.minutely/luci_splash @@ -0,0 +1,2 @@ +#!/bin/sh +[ "$(date +%M | cut -c2)" == "5" ] && luci-splash sync
\ No newline at end of file diff --git a/applications/luci-splash/root/etc/init.d/luci_splash b/applications/luci-splash/root/etc/init.d/luci_splash new file mode 100644 index 000000000..20f7865fd --- /dev/null +++ b/applications/luci-splash/root/etc/init.d/luci_splash @@ -0,0 +1,85 @@ +#!/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 +} + diff --git a/applications/luci-splash/root/etc/luci_splash_httpd.conf b/applications/luci-splash/root/etc/luci_splash_httpd.conf new file mode 100644 index 000000000..6007e80db --- /dev/null +++ b/applications/luci-splash/root/etc/luci_splash_httpd.conf @@ -0,0 +1 @@ +E404:index.html
\ No newline at end of file diff --git a/applications/luci-splash/root/usr/lib/luci-splash/htdocs/cgi-bin/index.cgi b/applications/luci-splash/root/usr/lib/luci-splash/htdocs/cgi-bin/index.cgi new file mode 100644 index 000000000..3bff85ee5 --- /dev/null +++ b/applications/luci-splash/root/usr/lib/luci-splash/htdocs/cgi-bin/index.cgi @@ -0,0 +1,52 @@ +#!/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 diff --git a/applications/luci-splash/root/usr/lib/luci-splash/htdocs/index.html b/applications/luci-splash/root/usr/lib/luci-splash/htdocs/index.html new file mode 100644 index 000000000..58387a5fe --- /dev/null +++ b/applications/luci-splash/root/usr/lib/luci-splash/htdocs/index.html @@ -0,0 +1,10 @@ +<?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 diff --git a/applications/luci-splash/root/www/cgi-bin/luci_splash.cgi b/applications/luci-splash/root/www/cgi-bin/luci_splash.cgi new file mode 100644 index 000000000..188ad7aa0 --- /dev/null +++ b/applications/luci-splash/root/www/cgi-bin/luci_splash.cgi @@ -0,0 +1,4 @@ +#!/bin/sh +echo "Status: 302 Found" +echo "Location: /cgi-bin/ffluci/splash/splash$PATH_INFO" +echo
\ No newline at end of file diff --git a/applications/luci-splash/src/controller/controller.lua b/applications/luci-splash/src/controller/controller.lua new file mode 100644 index 000000000..62088be52 --- /dev/null +++ b/applications/luci-splash/src/controller/controller.lua @@ -0,0 +1,19 @@ +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 diff --git a/applications/luci-splash/src/model/cbi/admin_services/splash.lua b/applications/luci-splash/src/model/cbi/admin_services/splash.lua new file mode 100644 index 000000000..fe4d2c3ee --- /dev/null +++ b/applications/luci-splash/src/model/cbi/admin_services/splash.lua @@ -0,0 +1,30 @@ +-- 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 diff --git a/applications/luci-splash/src/model/menu/50luci-splash.lua b/applications/luci-splash/src/model/menu/50luci-splash.lua new file mode 100644 index 000000000..99f7caa52 --- /dev/null +++ b/applications/luci-splash/src/model/menu/50luci-splash.lua @@ -0,0 +1,2 @@ +sel("admin", "services") +act("splash", "Client-Splash")
\ No newline at end of file diff --git a/applications/luci-splash/src/model/view/splash/splash.htm b/applications/luci-splash/src/model/view/splash/splash.htm new file mode 100644 index 000000000..db4bd0f78 --- /dev/null +++ b/applications/luci-splash/src/model/view/splash/splash.htm @@ -0,0 +1,31 @@ +<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 diff --git a/applications/luci-splash/src/model/view/splash_splash/index.htm b/applications/luci-splash/src/model/view/splash_splash/index.htm new file mode 100644 index 000000000..75aa02658 --- /dev/null +++ b/applications/luci-splash/src/model/view/splash_splash/index.htm @@ -0,0 +1,2 @@ +<%+header%> +<%+footer%>
\ No newline at end of file diff --git a/applications/luci-splash/src/model/view/splash_splash/splash.htm b/applications/luci-splash/src/model/view/splash_splash/splash.htm new file mode 100644 index 000000000..9c165802f --- /dev/null +++ b/applications/luci-splash/src/model/view/splash_splash/splash.htm @@ -0,0 +1,7 @@ +<%+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 diff --git a/applications/sgi-haserl/Makefile b/applications/sgi-haserl/Makefile new file mode 100644 index 000000000..81a96f6a8 --- /dev/null +++ b/applications/sgi-haserl/Makefile @@ -0,0 +1,2 @@ +include ../../build/config.mk +include ../../build/module.mk
\ No newline at end of file diff --git a/applications/sgi-haserl/root/www/cgi-bin/ffluci b/applications/sgi-haserl/root/www/cgi-bin/ffluci new file mode 100755 index 000000000..183a6ad41 --- /dev/null +++ b/applications/sgi-haserl/root/www/cgi-bin/ffluci @@ -0,0 +1,4 @@ +#!/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 diff --git a/applications/sgi-haserl/root/www/cgi-bin/ffluci-upload b/applications/sgi-haserl/root/www/cgi-bin/ffluci-upload new file mode 100755 index 000000000..0128c2dd7 --- /dev/null +++ b/applications/sgi-haserl/root/www/cgi-bin/ffluci-upload @@ -0,0 +1,4 @@ +#!/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 diff --git a/applications/sgi-haserl/root/www/cgi-bin/index.cgi b/applications/sgi-haserl/root/www/cgi-bin/index.cgi new file mode 100755 index 000000000..31705ccf2 --- /dev/null +++ b/applications/sgi-haserl/root/www/cgi-bin/index.cgi @@ -0,0 +1,3 @@ +#!/usr/bin/haserl --shell=luac +print("Status: 302 Found") +print("Location: ffluci\n") diff --git a/applications/sgi-haserl/root/www/index.html b/applications/sgi-haserl/root/www/index.html new file mode 100644 index 000000000..58387a5fe --- /dev/null +++ b/applications/sgi-haserl/root/www/index.html @@ -0,0 +1,10 @@ +<?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 diff --git a/applications/sgi-haserl/src/sgi/haserl.lua b/applications/sgi-haserl/src/sgi/haserl.lua new file mode 100644 index 000000000..027697e2e --- /dev/null +++ b/applications/sgi-haserl/src/sgi/haserl.lua @@ -0,0 +1,76 @@ +--[[ +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 diff --git a/applications/sgi-webuci/Makefile b/applications/sgi-webuci/Makefile new file mode 100644 index 000000000..81a96f6a8 --- /dev/null +++ b/applications/sgi-webuci/Makefile @@ -0,0 +1,2 @@ +include ../../build/config.mk +include ../../build/module.mk
\ No newline at end of file diff --git a/applications/sgi-webuci/root/lib/webuci/main.lua b/applications/sgi-webuci/root/lib/webuci/main.lua new file mode 100644 index 000000000..50ac8184b --- /dev/null +++ b/applications/sgi-webuci/root/lib/webuci/main.lua @@ -0,0 +1,23 @@ +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 diff --git a/applications/sgi-webuci/src/sgi/webuci.lua b/applications/sgi-webuci/src/sgi/webuci.lua new file mode 100644 index 000000000..bc1c7be7a --- /dev/null +++ b/applications/sgi-webuci/src/sgi/webuci.lua @@ -0,0 +1,83 @@ +--[[ +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 |