Compare commits
219 commits
Author | SHA1 | Date | |
---|---|---|---|
|
9feda4595b | ||
|
5dff7ab140 | ||
|
d31df673fa | ||
|
0e2071753f | ||
|
5dea416e83 | ||
|
c790400671 | ||
|
2f14ec03ae | ||
|
b8e71be773 | ||
|
395df47437 | ||
|
7a8d9beb88 | ||
|
48e35bf43a | ||
|
57dc871f5a | ||
|
9391668d82 | ||
|
80be0c046d | ||
|
40ddfa629f | ||
|
119aeff2c7 | ||
|
f77d92b2be | ||
|
4efb7b28fa | ||
|
119b6d898f | ||
|
82ca74d1b3 | ||
|
f6f39eda94 | ||
|
6afee3fff7 | ||
|
d638ce2adb | ||
|
243c3d497f | ||
|
d55e6c794c | ||
|
f0e9aaf293 | ||
|
1b3f0e7bc3 | ||
|
5ee7124e53 | ||
|
d91e8e0d1f | ||
|
f2eccfdcaf | ||
|
50f73513a9 | ||
|
de75afdeeb | ||
|
a124d0353a | ||
|
0f888230ed | ||
|
6945497fff | ||
|
9d9c18e29e | ||
|
291206c9fa | ||
|
7ff62d42c5 | ||
|
3cdccaa76c | ||
|
e8b29453c8 | ||
|
db8dab8cdf | ||
|
252a496c77 | ||
|
8090100c76 | ||
|
94a98c7004 | ||
|
ce93183e25 | ||
|
ff39f24b0a | ||
|
a710515dac | ||
|
d9e011d7cb | ||
|
87af5a13f1 | ||
|
a99076696a | ||
|
065403a514 | ||
|
1b2a207eea | ||
|
e235c7cc60 | ||
|
a32d60c3fb | ||
|
fe356792c2 | ||
|
a2696531d9 | ||
|
95bc270f06 | ||
|
14e06588ec | ||
|
5223afaf66 | ||
|
5d98d73229 | ||
|
508488e961 | ||
|
c146ab202d | ||
|
b30715381e | ||
|
168c05be7b | ||
|
3441fe8c82 | ||
|
2c59a118ed | ||
|
12a1c66478 | ||
|
3fe0697748 | ||
|
3ef4fdce75 | ||
|
583a8607f1 | ||
|
a6295e8d83 | ||
|
afe12c4b94 | ||
|
a2338d9adf | ||
|
4762f5a633 | ||
|
a88531779f | ||
|
42a09cdd1e | ||
|
2c4ff11f58 | ||
|
9444aff816 | ||
|
6ce49433c5 | ||
|
5abc657c8e | ||
|
d3083a9e7a | ||
|
773e6b78c3 | ||
|
7ae301e92c | ||
|
9823bb991e | ||
|
fe1f00bfe8 | ||
|
81241de757 | ||
|
3cdb067150 | ||
|
fa5e477e56 | ||
|
d536bdacfb | ||
|
8644cf317b | ||
|
bda9d81da7 | ||
|
d28e31fe14 | ||
|
f72e3e2ad3 | ||
|
9e0713734e | ||
|
45b90e8686 | ||
|
699c9b1e97 | ||
|
fcc5d1e3c7 | ||
|
2a5d6299fd | ||
|
8bc4c2646e | ||
|
4e33af6103 | ||
|
82cc8fddef | ||
|
723c9a900b | ||
|
2958ac689f | ||
|
ed2a86b70f | ||
|
7b3830a279 | ||
|
e9fa8eba79 | ||
|
e02b2c07b7 | ||
|
061213f9cf | ||
|
69b994469c | ||
|
25c3869fc3 | ||
|
f0e63629cb | ||
|
dff999ea08 | ||
|
8fc605c3e8 | ||
|
baf949c399 | ||
|
835f7aa6df | ||
|
d2b2092fe6 | ||
|
7d2189ddfa | ||
|
17d2f0f6b4 | ||
|
efe3fb5880 | ||
|
88db0de82f | ||
|
d6697579ef | ||
|
4fa5b90a4d | ||
|
7e68834bf4 | ||
|
183ca17dd2 | ||
|
c789622e73 | ||
|
cef08fb346 | ||
|
02cfebdf60 | ||
|
bb6c9f146b | ||
|
08145f2ad2 | ||
|
6b019d3cbe | ||
|
05d6d004b9 | ||
|
a7e91b297c | ||
|
8a4cfc4649 | ||
|
12c498821f | ||
|
3432a89362 | ||
|
bd72aa8399 | ||
|
edda488b29 | ||
|
aa4f626aab | ||
|
842c39dde3 | ||
|
f9787b70cd | ||
|
a5eca04263 | ||
|
4eeddc486c | ||
|
6c74d2d77b | ||
|
9f782466ed | ||
|
dd6dd2d8f5 | ||
|
5a91868704 | ||
|
36034591e2 | ||
|
87f3212b67 | ||
|
3c0a06e3a0 | ||
|
a6f5cd2547 | ||
|
9c07466806 | ||
|
ce8c292271 | ||
|
66e92f5fc0 | ||
|
e180231545 | ||
|
92ca7f33c2 | ||
|
79fb9f138a | ||
|
07cb5432b3 | ||
|
83d4fb3adb | ||
|
afc80c0bef | ||
|
398e0aa0a8 | ||
|
32577be4b9 | ||
|
ad8c39598e | ||
|
0764c67993 | ||
|
a545e495ba | ||
|
c2eb3ea4a5 | ||
|
0bfe00bd4e | ||
|
bed30927f8 | ||
|
853d989579 | ||
|
6ca178a10d | ||
|
98f37e437d | ||
|
8e48d1b46f | ||
|
1937aad896 | ||
|
5070549096 | ||
|
f9663bc6b6 | ||
|
81d7f37cb6 | ||
|
4918c60ac2 | ||
|
83fe3be564 | ||
|
f2c4ece600 | ||
|
db5529137f | ||
|
307540f562 | ||
|
6a4ecfeacc | ||
|
a4a3734a1d | ||
|
d6cc0cf925 | ||
|
278fd02b6a | ||
|
acfe8ea454 | ||
|
78111f8c87 | ||
|
a903a2c822 | ||
|
d4cf4403f1 | ||
|
836e65e00e | ||
|
9a876ab453 | ||
|
94785efc60 | ||
|
7ed98bf01b | ||
|
8b01581917 | ||
|
d9b28ec7a4 | ||
|
a9830fad17 | ||
|
3a06c9ee2f | ||
|
022404df01 | ||
|
579505b1d0 | ||
|
2396520413 | ||
|
2e70805812 | ||
|
7d141e7a0b | ||
|
3a631ce73b | ||
|
cc0fd37129 | ||
|
85e4cd7cdb | ||
|
86306c4324 | ||
|
cd1442893a | ||
|
75da8f7de3 | ||
|
5e544d4927 | ||
|
135261e7e4 | ||
|
d47cf50446 | ||
|
b5f48953ab | ||
|
8276e4c6bb | ||
|
9aea9f8db8 | ||
|
64c972454f | ||
|
db4a419f9d | ||
|
8d7586cffc | ||
|
2120d46596 | ||
|
de56c8e3ce | ||
|
ee63495c36 |
443 changed files with 18431 additions and 21099 deletions
18
Makefile
18
Makefile
|
@ -12,7 +12,13 @@ all: build
|
|||
build: gccbuild luabuild
|
||||
|
||||
gccbuild:
|
||||
for i in $(MODULES); do make -C$$i compile; done
|
||||
make -C libs/lmo CC="cc" CFLAGS="" LDFLAGS="" host-install
|
||||
for i in $(MODULES); do \
|
||||
make -C$$i compile || { \
|
||||
echo "*** Compilation of $$i failed!"; \
|
||||
exit 1; \
|
||||
}; \
|
||||
done
|
||||
|
||||
luabuild: i18nbuild
|
||||
for i in $(MODULES); do HOST=$(realpath host) make -C$$i luabuild; done
|
||||
|
@ -23,6 +29,7 @@ i18nbuild:
|
|||
|
||||
clean:
|
||||
rm -rf docs
|
||||
make -C libs/lmo host-clean
|
||||
for i in $(MODULES); do make -C$$i clean; done
|
||||
|
||||
|
||||
|
@ -45,15 +52,8 @@ hostenv: host ucidefaults
|
|||
ucidefaults:
|
||||
build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "$(realpath host)/bin/uci-defaults --exclude luci-freifunk-*"
|
||||
|
||||
runboa: hostenv
|
||||
libs/sgi-webuci/host/buildconfig.sh $(realpath host) > host/etc/boa/boa.conf
|
||||
build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "$(realpath host/usr/bin/boa) -c $(realpath host/etc/boa) -d"
|
||||
|
||||
runhttpd: hostenv
|
||||
build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "$(realpath host/usr/bin/lucittpd) $(realpath host)/usr/lib/lucittpd/plugins"
|
||||
|
||||
runluci: luahost
|
||||
build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "$(realpath libs/httpd/host/runluci) $(realpath host) $(HTDOCS)"
|
||||
build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "lua build/lucid.lua"
|
||||
|
||||
runlua: hostenv
|
||||
build/hostenv.sh $(realpath host) $(LUA_MODULEDIR) $(LUA_LIBRARYDIR) "lua -i build/setup.lua"
|
||||
|
|
|
@ -17,7 +17,7 @@ module("luci.controller.ddns", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("ddns")
|
||||
if not luci.fs.access("/etc/config/ddns") then
|
||||
if not nixio.fs.access("/etc/config/ddns") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -26,7 +26,7 @@ function index()
|
|||
page.dependent = true
|
||||
|
||||
|
||||
local page = entry({"mini", "network", "ddns"}, cbi("ddns/ddnsmini", {autoapply=true}), luci.i18n.translate("ddns"), 60)
|
||||
local page = entry({"mini", "network", "ddns"}, cbi("ddns/ddns", {autoapply=true}), luci.i18n.translate("ddns"), 60)
|
||||
page.i18n = "ddns"
|
||||
page.dependent = true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,22 +12,39 @@ You may obtain a copy of the License at
|
|||
|
||||
$Id$
|
||||
]]--
|
||||
require("luci.tools.webadmin")
|
||||
|
||||
local is_mini = (luci.dispatcher.context.path[1] == "mini")
|
||||
|
||||
m = Map("ddns", translate("ddns"), translate("ddns_desc"))
|
||||
|
||||
s = m:section(TypedSection, "service", "")
|
||||
s.addremove = true
|
||||
s.anonymous = false
|
||||
|
||||
s:option(Flag, "enabled", translate("enable"))
|
||||
|
||||
svc = s:option(ListValue, "service_name", translate("service"))
|
||||
svc.rmempty = true
|
||||
svc:value("")
|
||||
svc:value("dyndns.org")
|
||||
svc:value("changeip.com")
|
||||
svc:value("zoneedit.com")
|
||||
svc:value("no-ip.com")
|
||||
svc:value("freedns.afraid.org")
|
||||
|
||||
local services = { }
|
||||
local fd = io.open("/usr/lib/ddns/services", "r")
|
||||
if fd then
|
||||
local ln
|
||||
repeat
|
||||
ln = fd:read("*l")
|
||||
local s = ln and ln:match('^%s*"([^"]+)"')
|
||||
if s then services[#services+1] = s end
|
||||
until not ln
|
||||
fd:close()
|
||||
end
|
||||
|
||||
local v
|
||||
for _, v in luci.util.vspairs(services) do
|
||||
svc:value(v)
|
||||
end
|
||||
|
||||
svc:value("", translate("cbi_manual"))
|
||||
|
||||
|
||||
s:option(Value, "domain", translate("hostname")).rmempty = true
|
||||
s:option(Value, "username", translate("username")).rmempty = true
|
||||
|
@ -35,28 +52,38 @@ pw = s:option(Value, "password", translate("password"))
|
|||
pw.rmempty = true
|
||||
pw.password = true
|
||||
|
||||
src = s:option(ListValue, "ip_source")
|
||||
src:value("network", translate("network"))
|
||||
src:value("interface", translate("interface"))
|
||||
src:value("web", "URL")
|
||||
|
||||
iface = s:option(ListValue, "ip_network", translate("network"))
|
||||
iface:depends("ip_source", "network")
|
||||
iface.rmempty = true
|
||||
luci.tools.webadmin.cbi_add_networks(iface)
|
||||
if is_mini then
|
||||
s.defaults.ip_source = "network"
|
||||
s.defaults.ip_network = "wan"
|
||||
else
|
||||
require("luci.tools.webadmin")
|
||||
|
||||
iface = s:option(ListValue, "ip_interface", translate("interface"))
|
||||
iface:depends("ip_source", "interface")
|
||||
iface.rmempty = true
|
||||
for k, v in pairs(luci.sys.net.devices()) do
|
||||
iface:value(v)
|
||||
src = s:option(ListValue, "ip_source")
|
||||
src:value("network", translate("network"))
|
||||
src:value("interface", translate("interface"))
|
||||
src:value("web", "URL")
|
||||
|
||||
iface = s:option(ListValue, "ip_network", translate("network"))
|
||||
iface:depends("ip_source", "network")
|
||||
iface.rmempty = true
|
||||
luci.tools.webadmin.cbi_add_networks(iface)
|
||||
|
||||
iface = s:option(ListValue, "ip_interface", translate("interface"))
|
||||
iface:depends("ip_source", "interface")
|
||||
iface.rmempty = true
|
||||
for k, v in pairs(luci.sys.net.devices()) do
|
||||
iface:value(v)
|
||||
end
|
||||
|
||||
web = s:option(Value, "ip_url", "URL")
|
||||
web:depends("ip_source", "web")
|
||||
web.rmempty = true
|
||||
end
|
||||
|
||||
web = s:option(Value, "ip_url", "URL")
|
||||
web:depends("ip_source", "web")
|
||||
web.rmempty = true
|
||||
|
||||
s:option(Value, "update_url").optional = true
|
||||
url = s:option(Value, "update_url")
|
||||
url:depends("service_name", "")
|
||||
url.rmempty = true
|
||||
|
||||
s:option(Value, "check_interval").default = 10
|
||||
unit = s:option(ListValue, "check_unit")
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
--[[
|
||||
LuCI - Lua Configuration Interface
|
||||
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
$Id$
|
||||
]]--
|
||||
m = Map("ddns", translate("ddns"), translate("ddns_desc"))
|
||||
|
||||
s = m:section(TypedSection, "service", "")
|
||||
s.addremove = true
|
||||
|
||||
s:option(Flag, "enabled", translate("enable"))
|
||||
|
||||
svc = s:option(ListValue, "service_name", translate("service"))
|
||||
svc.rmempty = true
|
||||
svc:value("dyndns.org")
|
||||
svc:value("changeip.com")
|
||||
svc:value("zoneedit.com")
|
||||
svc:value("no-ip.com")
|
||||
svc:value("freedns.afraid.org")
|
||||
|
||||
s:option(Value, "domain", translate("hostname")).rmempty = true
|
||||
s:option(Value, "username", translate("username")).rmempty = true
|
||||
pw = s:option(Value, "password", translate("password"))
|
||||
pw.rmempty = true
|
||||
pw.password = true
|
||||
|
||||
s.defaults.ip_source = "network"
|
||||
s.defaults.ip_network = "wan"
|
||||
|
||||
s:option(Value, "check_interval").default = 10
|
||||
unit = s:option(ListValue, "check_unit")
|
||||
unit.default = "minutes"
|
||||
unit:value("minutes", "min")
|
||||
unit:value("hours", "h")
|
||||
|
||||
s:option(Value, "force_interval").default = 72
|
||||
unit = s:option(ListValue, "force_unit")
|
||||
unit.default = "hours"
|
||||
unit:value("minutes", "min")
|
||||
unit:value("hours", "h")
|
||||
|
||||
|
||||
return m
|
|
@ -19,6 +19,28 @@ local uci = require "luci.model.uci".cursor()
|
|||
local tools = require "luci.tools.ffwizard"
|
||||
local util = require "luci.util"
|
||||
local sys = require "luci.sys"
|
||||
local ip = require "luci.ip"
|
||||
|
||||
local function mksubnet(community, meship)
|
||||
local subnet_prefix = tonumber(uci:get("freifunk", community, "splash_prefix")) or 27
|
||||
local pool_network = uci:get("freifunk", community, "splash_network") or "10.104.0.0/16"
|
||||
local pool = luci.ip.IPv4(pool_network)
|
||||
|
||||
if pool then
|
||||
local hosts_per_subnet = 2^(32 - subnet_prefix)
|
||||
local number_of_subnets = (2^pool:prefix())/hosts_per_subnet
|
||||
|
||||
local seed1, seed2 = meship:match("(%d+)%.(%d+)$")
|
||||
math.randomseed(seed1 * seed2)
|
||||
|
||||
local subnet = pool:add(hosts_per_subnet * math.random(number_of_subnets))
|
||||
|
||||
local subnet_ipaddr = subnet:network(subnet_prefix):add(1):string()
|
||||
local subnet_netmask = subnet:mask(subnet_prefix):string()
|
||||
|
||||
return subnet_ipaddr, subnet_netmask
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-------------------- View --------------------
|
||||
|
@ -35,11 +57,11 @@ uci:foreach("wireless", "wifi-device",
|
|||
|
||||
main = f:field(Flag, "wifi", "Freifunkzugang einrichten")
|
||||
|
||||
net = f:field(Value, "net", "Freifunknetz", "1. Teil der IP-Adresse")
|
||||
net = f:field(Value, "net", "Freifunk Community", "Mesh Netzbereich")
|
||||
net.rmempty = true
|
||||
net:depends("wifi", "1")
|
||||
uci:foreach("freifunk", "community", function(s)
|
||||
net:value(s[".name"], "%s (%s)" % {s.name, s.prefix})
|
||||
net:value(s[".name"], "%s (%s)" % {s.name, s.mesh_network or "?"})
|
||||
end)
|
||||
|
||||
function net.cfgvalue(self, section)
|
||||
|
@ -50,49 +72,64 @@ function net.write(self, section, value)
|
|||
uci:save("freifunk")
|
||||
end
|
||||
|
||||
|
||||
subnet = f:field(Value, "subnet", "Subnetz (Projekt)", "2. Teil der IP-Adresse")
|
||||
subnet.rmempty = true
|
||||
subnet:depends("wifi", "1")
|
||||
function subnet.cfgvalue(self, section)
|
||||
return uci:get("freifunk", "wizard", "subnet")
|
||||
meship = f:field(Value, "meship", "Mesh IP Adresse", "Netzweit eindeutige Identifikation")
|
||||
meship.rmempty = true
|
||||
meship:depends("wifi", "1")
|
||||
function meship.cfgvalue(self, section)
|
||||
return uci:get("freifunk", "wizard", "meship")
|
||||
end
|
||||
function subnet.write(self, section, value)
|
||||
uci:set("freifunk", "wizard", "subnet", value)
|
||||
function meship.write(self, section, value)
|
||||
uci:set("freifunk", "wizard", "meship", value)
|
||||
uci:save("freifunk")
|
||||
end
|
||||
|
||||
node = f:field(Value, "node", "Knoten", "3. Teil der IP-Adresse")
|
||||
node.rmempty = true
|
||||
node:depends("wifi", "1")
|
||||
for i=1, 51 do
|
||||
node:value(i)
|
||||
end
|
||||
function node.cfgvalue(self, section)
|
||||
return uci:get("freifunk", "wizard", "node")
|
||||
end
|
||||
function node.write(self, section, value)
|
||||
uci:set("freifunk", "wizard", "node", value)
|
||||
uci:save("freifunk")
|
||||
function meship.validate(self, value)
|
||||
local x = ip.IPv4(value)
|
||||
return ( x and x:prefix() == 32 ) and x:string() or ""
|
||||
end
|
||||
|
||||
client = f:field(Flag, "client", "WLAN-DHCP anbieten")
|
||||
client:depends("wifi", "1")
|
||||
client.rmempty = true
|
||||
client.rmempty = false
|
||||
function client.cfgvalue(self, section)
|
||||
return uci:get("freifunk", "wizard", "dhcp_splash") or "0"
|
||||
end
|
||||
|
||||
olsr = f:field(Flag, "olsr", "OLSR einrichten")
|
||||
olsr.rmempty = true
|
||||
|
||||
lat = f:field(Value, "lat", "Latitude")
|
||||
lat:depends("olsr", "1")
|
||||
function lat.cfgvalue(self, section)
|
||||
return uci:get("freifunk", "wizard", "latitude")
|
||||
end
|
||||
function lat.write(self, section, value)
|
||||
uci:set("freifunk", "wizard", "latitude", value)
|
||||
uci:save("freifunk")
|
||||
end
|
||||
|
||||
lon = f:field(Value, "lon", "Longitude")
|
||||
lon:depends("olsr", "1")
|
||||
function lon.cfgvalue(self, section)
|
||||
return uci:get("freifunk", "wizard", "longitude")
|
||||
end
|
||||
function lon.write(self, section, value)
|
||||
uci:set("freifunk", "wizard", "longitude", value)
|
||||
uci:save("freifunk")
|
||||
end
|
||||
|
||||
share = f:field(Flag, "sharenet", "Eigenen Internetzugang freigeben")
|
||||
share.rmempty = true
|
||||
|
||||
|
||||
wansec = f:field(Flag, "wansec", "WAN-Zugriff auf Gateway beschränken")
|
||||
wansec.rmempty = false
|
||||
wansec:depends("sharenet", "1")
|
||||
function wansec.cfgvalue(self, section)
|
||||
return uci:get("freifunk", "wizard", "wan_security")
|
||||
end
|
||||
function wansec.write(self, section, value)
|
||||
uci:set("freifunk", "wizard", "wan_security", value)
|
||||
uci:save("freifunk")
|
||||
end
|
||||
|
||||
-------------------- Control --------------------
|
||||
function f.handle(self, state, data)
|
||||
|
@ -122,33 +159,26 @@ function main.write(self, section, value)
|
|||
end
|
||||
|
||||
local device = dev:formvalue(section)
|
||||
local community, external
|
||||
local node_ip, external
|
||||
|
||||
-- Collect IP-Address
|
||||
local inet = net:formvalue(section)
|
||||
local isubnet = subnet:formvalue(section)
|
||||
local inode = node:formvalue(section)
|
||||
local community = net:formvalue(section)
|
||||
|
||||
-- Invalidate fields
|
||||
if not inet then
|
||||
if not community then
|
||||
net.tag_missing[section] = true
|
||||
else
|
||||
community = inet
|
||||
external = uci:get("freifunk", community, "external") or ""
|
||||
inet = uci:get("freifunk", community, "prefix") or inet
|
||||
end
|
||||
if not isubnet then
|
||||
subnet.tag_missing[section] = true
|
||||
end
|
||||
if not inode then
|
||||
node.tag_missing[section] = true
|
||||
external = uci:get("freifunk", community, "external") or ""
|
||||
network = ip.IPv4(uci:get("freifunk", community, "mesh_network") or "104.0.0.0/8")
|
||||
node_ip = meship:formvalue(section) and ip.IPv4(meship:formvalue(section))
|
||||
|
||||
if not node_ip or not network or not network:contains(node_ip) then
|
||||
meship.tag_missing[section] = true
|
||||
node_ip = nil
|
||||
end
|
||||
end
|
||||
|
||||
if not inet or not isubnet or not inode then
|
||||
return
|
||||
end
|
||||
|
||||
local ip = "%s.%s.%s" % {inet, isubnet, inode}
|
||||
if not node_ip then return end
|
||||
|
||||
|
||||
-- Cleanup
|
||||
|
@ -232,7 +262,7 @@ function main.write(self, section, value)
|
|||
local netconfig = uci:get_all("freifunk", "interface")
|
||||
util.update(netconfig, uci:get_all(external, "interface") or {})
|
||||
netconfig.proto = "static"
|
||||
netconfig.ipaddr = ip
|
||||
netconfig.ipaddr = node_ip:string()
|
||||
uci:section("network", "interface", device, netconfig)
|
||||
|
||||
uci:save("network")
|
||||
|
@ -240,7 +270,7 @@ function main.write(self, section, value)
|
|||
tools.firewall_zone_add_interface("freifunk", device)
|
||||
|
||||
|
||||
local new_hostname = ip:gsub("%.", "-")
|
||||
local new_hostname = node_ip:string():gsub("%.", "-")
|
||||
local old_hostname = sys.hostname()
|
||||
|
||||
uci:foreach("system", "system",
|
||||
|
@ -335,11 +365,29 @@ end
|
|||
function share.write(self, section, value)
|
||||
uci:delete_all("firewall", "forwarding", {src="freifunk", dest="wan"})
|
||||
uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_dyn_gw_plain.so.0.4"})
|
||||
uci:foreach("firewall", "zone",
|
||||
function(s)
|
||||
if s.name == "wan" then
|
||||
uci:delete("firewall", s['.name'], "local_restrict")
|
||||
return false
|
||||
end
|
||||
end)
|
||||
|
||||
if value == "1" then
|
||||
uci:section("firewall", "forwarding", nil, {src="freifunk", dest="wan"})
|
||||
uci:section("olsrd", "LoadPlugin", nil, {library="olsrd_dyn_gw_plain.so.0.4"})
|
||||
|
||||
if wansec:formvalue(section) == "1" then
|
||||
uci:foreach("firewall", "zone",
|
||||
function(s)
|
||||
if s.name == "wan" then
|
||||
uci:set("firewall", s['.name'], "local_restrict", "1")
|
||||
return false
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
uci:save("firewall")
|
||||
uci:save("olsrd")
|
||||
uci:save("system")
|
||||
|
@ -348,26 +396,21 @@ end
|
|||
|
||||
function client.write(self, section, value)
|
||||
if value == "0" then
|
||||
uci:delete("freifunk", "wizard", "dhcp_splash")
|
||||
uci:save("freifunk")
|
||||
return
|
||||
end
|
||||
|
||||
local device = dev:formvalue(section)
|
||||
|
||||
-- Collect IP-Address
|
||||
local inet = net:formvalue(section)
|
||||
local isubnet = subnet:formvalue(section)
|
||||
local inode = node:formvalue(section)
|
||||
local node_ip = meship:formvalue(section)
|
||||
|
||||
if not inet or not isubnet or not inode then
|
||||
return
|
||||
end
|
||||
local community = inet
|
||||
if not node_ip then return end
|
||||
|
||||
local community = net:formvalue(section)
|
||||
local external = community and uci:get("freifunk", community, "external") or ""
|
||||
inet = uci:get("freifunk", community, "prefix") or inet
|
||||
|
||||
local dhcpbeg = 48 + tonumber(inode) * 4
|
||||
local dclient = "%s.%s.%s" % {inet:gsub("^[0-9]+", "10"), isubnet, dhcpbeg}
|
||||
local limit = dhcpbeg < 252 and 3 or 2
|
||||
local splash_ip, splash_mask = mksubnet(community, node_ip)
|
||||
|
||||
-- Delete old alias
|
||||
uci:delete("network", device .. "dhcp")
|
||||
|
@ -376,7 +419,8 @@ function client.write(self, section, value)
|
|||
local aliasbase = uci:get_all("freifunk", "alias")
|
||||
util.update(aliasbase, uci:get_all(external, "alias") or {})
|
||||
aliasbase.interface = device
|
||||
aliasbase.ipaddr = dclient
|
||||
aliasbase.ipaddr = splash_ip
|
||||
aliasbase.netmask = splash_mask
|
||||
aliasbase.proto = "static"
|
||||
uci:section("network", "alias", device .. "dhcp", aliasbase)
|
||||
uci:save("network")
|
||||
|
@ -440,6 +484,10 @@ function client.write(self, section, value)
|
|||
|
||||
-- Make sure that luci_splash is enabled
|
||||
sys.exec("/etc/init.d/luci_splash enable")
|
||||
|
||||
-- Remember state
|
||||
uci:set("freifunk", "wizard", "dhcp_splash", "1")
|
||||
uci:save("freifunk")
|
||||
end
|
||||
|
||||
return f
|
||||
|
|
|
@ -21,7 +21,6 @@ s.anonymous = true
|
|||
|
||||
iface = s:option(ListValue, "src", translate("fw_src"))
|
||||
oface = s:option(ListValue, "dest", translate("fw_dest"))
|
||||
s:option(Flag, "mtu_fix", translate("fw_mtufix"))
|
||||
|
||||
luci.model.uci.cursor():foreach("firewall", "zone",
|
||||
function (section)
|
||||
|
@ -79,4 +78,4 @@ end
|
|||
s:option(DummyValue, "target")
|
||||
|
||||
|
||||
return m
|
||||
return m
|
||||
|
|
|
@ -41,7 +41,7 @@ luci.model.uci.cursor():foreach("firewall", "zone",
|
|||
|
||||
proto = s:option(Value, "proto", translate("protocol"))
|
||||
proto.optional = true
|
||||
proto:value("")
|
||||
proto:value("all", translate("firewall_rule_proto_all", "Any"))
|
||||
proto:value("tcpudp", "TCP+UDP")
|
||||
proto:value("tcp", "TCP")
|
||||
proto:value("udp", "UDP")
|
||||
|
|
|
@ -16,6 +16,7 @@ m = Map("firewall", translate("fw_fw"), translate("fw_fw1"))
|
|||
|
||||
s = m:section(TypedSection, "defaults")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
s:option(Flag, "syn_flood")
|
||||
|
||||
|
@ -57,6 +58,7 @@ for i, v in ipairs(p) do
|
|||
end
|
||||
|
||||
s:option(Flag, "masq")
|
||||
s:option(Flag, "mtu_fix", translate("fw_mtufix"))
|
||||
|
||||
net = s:option(MultiValue, "network")
|
||||
net.widget = "select"
|
||||
|
|
|
@ -18,7 +18,7 @@ module("luci.controller.hd_idle", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("hd_idle")
|
||||
if not luci.fs.access("/etc/config/hd-idle") then
|
||||
if not nixio.fs.access("/etc/config/hd-idle") then
|
||||
return
|
||||
end
|
||||
|
|
@ -13,7 +13,7 @@ $Id$
|
|||
|
||||
]]--
|
||||
|
||||
require("luci.fs")
|
||||
require("nixio.fs")
|
||||
|
||||
m = Map("hd-idle", translate("hd_idle"), translate("hd_idle_desc"))
|
||||
|
||||
|
@ -24,8 +24,8 @@ s:option(Flag, "enabled", translate("enable", "Enable"))
|
|||
|
||||
disk = s:option(Value, "disk", translate("disk"))
|
||||
disk.rmempty = true
|
||||
for _, dev in ipairs(luci.fs.glob("/dev/[sh]d[a-z]")) do
|
||||
disk:value(luci.fs.basename(dev))
|
||||
for dev in nixio.fs.glob("/dev/[sh]d[a-z]") do
|
||||
disk:value(nixio.fs.basename(dev))
|
||||
end
|
||||
|
||||
s:option(Value, "idle_time_interval", translate("idle_time_interval")).default = 10
|
|
@ -15,7 +15,7 @@ $Id$
|
|||
module("luci.controller.init", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/rc.common") then
|
||||
if not nixio.fs.access("/etc/rc.common") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -23,7 +23,7 @@ function index()
|
|||
luci.i18n.loadc("initmgr")
|
||||
|
||||
entry(
|
||||
{"admin", "system", "init"}, form("init/init"),
|
||||
luci.i18n.translate("initmgr", "Init Scripts")
|
||||
{"admin", "services", "init"}, form("init/init"),
|
||||
luci.i18n.translate("initmgr", "Init Scripts"), 0
|
||||
).i18n = "initmgr"
|
||||
end
|
||||
|
|
|
@ -32,27 +32,54 @@ end
|
|||
|
||||
m = SimpleForm("initmgr", translate("initmgr"), translate("initmgr_desc"))
|
||||
m.reset = false
|
||||
m.submit = false
|
||||
|
||||
|
||||
s = m:section(Table, inits)
|
||||
|
||||
i = s:option(DummyValue, "index", translate("initmgr_index"))
|
||||
n = s:option(DummyValue, "name", translate("initmgr_name"))
|
||||
|
||||
e = s:option(Flag, "enabled", translate("initmgr_enabled"))
|
||||
|
||||
e.cfgvalue = function(self, section)
|
||||
return inits[section].enabled and "1" or "0"
|
||||
e = s:option(Button, "endisable", translate("initmgr_enabled"))
|
||||
|
||||
e.render = function(self, section, scope)
|
||||
if inits[section].enabled then
|
||||
self.title = translate("initmgr_enable", "Enabled")
|
||||
self.inputstyle = "save"
|
||||
else
|
||||
self.title = translate("initmgr_disable", "Disabled")
|
||||
self.inputstyle = "reset"
|
||||
end
|
||||
|
||||
Button.render(self, section, scope)
|
||||
end
|
||||
|
||||
e.write = function(self, section, value)
|
||||
if value == "1" and not inits[section].enabled then
|
||||
inits[section].enabled = true
|
||||
return luci.sys.init.enable(inits[section].name)
|
||||
elseif value == "0" and inits[section].enabled then
|
||||
e.write = function(self, section)
|
||||
if inits[section].enabled then
|
||||
inits[section].enabled = false
|
||||
return luci.sys.init.disable(inits[section].name)
|
||||
else
|
||||
inits[section].enabled = true
|
||||
return luci.sys.init.enable(inits[section].name)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
start = s:option(Button, "start", translate("initmgr_start", "Start"))
|
||||
start.inputstyle = "apply"
|
||||
start.write = function(self, section)
|
||||
luci.sys.call("/etc/init.d/%s %s" %{ inits[section].name, self.option })
|
||||
end
|
||||
|
||||
restart = s:option(Button, "restart", translate("initmgr_restart", "Restart"))
|
||||
restart.inputstyle = "reload"
|
||||
restart.write = start.write
|
||||
|
||||
stop = s:option(Button, "stop", translate("initmgr_stop", "Stop"))
|
||||
stop.inputstyle = "remove"
|
||||
stop.write = start.write
|
||||
|
||||
|
||||
return m
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
[ function(data) {
|
||||
return parseFloat(data["Signal level"])
|
||||
- parseFloat(data["Noise level"]);
|
||||
}, "S/N (dBm)"],
|
||||
}, "S/N (dB)"],
|
||||
|
||||
// Graph layout options
|
||||
{ drawBackground: false, yAxis: [ 0, 50 ],
|
||||
|
|
|
@ -18,7 +18,7 @@ module("luci.controller.mmc_over_gpio", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("mmc_over_gpio")
|
||||
if not luci.fs.access("/etc/config/mmc_over_gpio") then
|
||||
if not nixio.fs.access("/etc/config/mmc_over_gpio") then
|
||||
return
|
||||
end
|
||||
|
|
@ -17,7 +17,7 @@ module("luci.controller.ntpc", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("ntpc")
|
||||
if not luci.fs.access("/etc/config/ntpclient") then
|
||||
if not nixio.fs.access("/etc/config/ntpclient") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ m = Map("ntpclient", translate("ntpc"), translate("ntpc_desc"))
|
|||
|
||||
s = m:section(TypedSection, "ntpclient", translate("general"))
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
s:option(DummyValue, "_time", translate("ntpc_current")).value = os.date("%c")
|
||||
|
||||
|
@ -25,6 +26,8 @@ s:option(Value, "count", translate("ntpc_count"), translate("ntpc_count_desc")).
|
|||
|
||||
s2 = m:section(TypedSection, "ntpdrift", translate("ntpc_drift"))
|
||||
s2.anonymous = true
|
||||
s2.addremove = false
|
||||
|
||||
s2:option(Value, "freq", translate("ntpc_drift_freq")).rmempty = true
|
||||
|
||||
|
||||
|
@ -36,4 +39,4 @@ s3.template = "cbi/tblsection"
|
|||
s3:option(Value, "hostname", translate("hostname"))
|
||||
s3:option(Value, "port", translate("port")).rmempty = true
|
||||
|
||||
return m
|
||||
return m
|
||||
|
|
|
@ -17,6 +17,7 @@ m = Map("ntpclient", translate("ntpc"), translate("ntpc_desc"))
|
|||
|
||||
s = m:section(TypedSection, "ntpclient", translate("general"))
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
s:option(DummyValue, "_time", translate("ntpc_current")).value = os.date("%c")
|
||||
|
||||
|
@ -31,4 +32,4 @@ s3.template = "cbi/tblsection"
|
|||
s3:option(Value, "hostname", translate("hostname"))
|
||||
s3:option(Value, "port", translate("port")).rmempty = true
|
||||
|
||||
return m
|
||||
return m
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module("luci.controller.olsr", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/config/olsrd") then
|
||||
if not nixio.fs.access("/etc/config/olsrd") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -182,7 +182,7 @@ function fetch_txtinfo(otable)
|
|||
local rawdata = luci.sys.httpget("http://127.0.0.1:2006/"..otable)
|
||||
|
||||
if #rawdata == 0 then
|
||||
if luci.fs.access("/proc/net/ipv6_route", "r") then
|
||||
if nixio.fs.access("/proc/net/ipv6_route", "r") then
|
||||
rawdata = luci.sys.httpget("http://[::1]:2006/"..otable)
|
||||
if #rawdata == 0 then
|
||||
return nil
|
||||
|
|
|
@ -90,6 +90,8 @@ for i=0,7 do
|
|||
end
|
||||
willingness.optional = true
|
||||
|
||||
natthr = s:option(Value, "NatThreshold")
|
||||
natthr.optional = true
|
||||
|
||||
|
||||
i = m:section(TypedSection, "Interface", translate("interfaces"))
|
||||
|
|
|
@ -13,9 +13,8 @@ You may obtain a copy of the License at
|
|||
$Id$
|
||||
]]--
|
||||
|
||||
require("luci.fs")
|
||||
require("luci.ip")
|
||||
|
||||
local ip = require "luci.ip"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
if arg[1] then
|
||||
mp = Map("olsrd", translate("olsrd_plugins", "OLSR - Plugins"))
|
||||
|
@ -44,7 +43,7 @@ if arg[1] then
|
|||
local function Cidr2IpMask(val)
|
||||
if val then
|
||||
for i = 1, #val do
|
||||
local cidr = luci.ip.IPv4(val[i]) or luci.ip.IPv6(val[i])
|
||||
local cidr = ip.IPv4(val[i]) or ip.IPv6(val[i])
|
||||
if cidr then
|
||||
val[i] = cidr:network():string() .. " " .. cidr:mask():string()
|
||||
end
|
||||
|
@ -59,9 +58,9 @@ if arg[1] then
|
|||
local ip, mask = val[i]:gmatch("([^%s]+)%s+([^%s]+)")()
|
||||
local cidr
|
||||
if ip and mask and ip:match(":") then
|
||||
cidr = luci.ip.IPv6(ip, mask)
|
||||
cidr = ip.IPv6(ip, mask)
|
||||
elseif ip and mask then
|
||||
cidr = luci.ip.IPv4(ip, mask)
|
||||
cidr = ip.IPv4(ip, mask)
|
||||
end
|
||||
|
||||
if cidr then
|
||||
|
@ -220,7 +219,7 @@ else
|
|||
)
|
||||
|
||||
-- create a loadplugin section for each found plugin
|
||||
for k, v in pairs(luci.fs.dir("/usr/lib")) do
|
||||
for v in fs.dir("/usr/lib") do
|
||||
if v:sub(1, 6) == "olsrd_" then
|
||||
if not plugins[v] then
|
||||
mpi.uci:section(
|
||||
|
|
|
@ -39,7 +39,7 @@ $Id$
|
|||
end
|
||||
%>
|
||||
<tr>
|
||||
<td><a href="http://<%=link["Remote IP"]%>"><%=link["Remote IP"]%></a></td>
|
||||
<td><a href="http://<%=link["Remote IP"]%>/cgi-bin-nodes.html"><%=link["Remote IP"]%></a></td>
|
||||
<td><%=link["Local IP"]%></td>
|
||||
<td><%=link.LQ%></td>
|
||||
<td><%=link.NLQ%></td>
|
||||
|
|
|
@ -12,7 +12,6 @@ You may obtain a copy of the License at
|
|||
$Id$
|
||||
]]--
|
||||
|
||||
require("luci.fs")
|
||||
require("luci.ip")
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ You may obtain a copy of the License at
|
|||
$Id$
|
||||
]]--
|
||||
|
||||
require("luci.fs")
|
||||
require("luci.ip")
|
||||
require("luci.model.uci")
|
||||
|
||||
|
|
|
@ -12,13 +12,9 @@ You may obtain a copy of the License at
|
|||
$Id$
|
||||
]]--
|
||||
|
||||
require("luci.fs")
|
||||
require("luci.ip")
|
||||
require("luci.sys")
|
||||
require("luci.model.uci")
|
||||
|
||||
|
||||
local uci = luci.model.uci.cursor()
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
|
||||
local m = Map("openvpn", translate("openvpn"))
|
||||
local s = m:section( TypedSection, "openvpn", translate("openvpn_overview"), translate("openvpn_overview_desc") )
|
||||
|
@ -74,13 +70,11 @@ s:option( Flag, "enable", translate("openvpn_enable") )
|
|||
|
||||
local active = s:option( DummyValue, "_active", translate("openvpn_active") )
|
||||
function active.cfgvalue(self, section)
|
||||
if luci.fs.isfile("/var/run/openvpn_%s.pid" % section) then
|
||||
local pid = io.lines("/var/run/openvpn_%s.pid" % section)()
|
||||
if pid and #pid > 0 and tonumber(pid) ~= nil then
|
||||
return (luci.sys.process.signal(pid, 0))
|
||||
and translatef("openvpn_active_yes", pid)
|
||||
or translate("openvpn_active_no")
|
||||
end
|
||||
local pid = fs.readfile("/var/run/openvpn_%s.pid" % section)
|
||||
if pid and #pid > 0 and tonumber(pid) ~= nil then
|
||||
return (sys.process.signal(pid, 0))
|
||||
and translatef("openvpn_active_yes", pid)
|
||||
or translate("openvpn_active_no")
|
||||
end
|
||||
return translate("openvpn_active_no")
|
||||
end
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
uci batch <<-EOF
|
||||
uci batch <<-EOF 2>/dev/null
|
||||
add ucitrack freifunk_p2pblock
|
||||
set ucitrack.@freifunk_p2pblock[-1].init=freifunk-p2pblock
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -18,7 +18,7 @@ module("luci.controller.p910nd", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("p910nd")
|
||||
if not luci.fs.access("/etc/config/p910nd") then
|
||||
if not nixio.fs.access("/etc/config/p910nd") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ $Id$
|
|||
module("luci.controller.polipo", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/config/polipo") then
|
||||
if not nixio.fs.access("/etc/config/polipo") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ $Id$
|
|||
module("luci.controller.qos", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/config/qos") then
|
||||
if not nixio.fs.access("/etc/config/qos") then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -26,4 +26,4 @@ function index()
|
|||
local page = entry({"mini", "network", "qos"}, cbi("qos/qosmini", {autoapply=true}), "QoS")
|
||||
page.i18n = "qos"
|
||||
page.dependent = true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,13 +11,18 @@ You may obtain a copy of the License at
|
|||
|
||||
$Id$
|
||||
]]--
|
||||
require("luci.tools.webadmin")
|
||||
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
m = Map("qos")
|
||||
|
||||
s = m:section(TypedSection, "interface", translate("interfaces"))
|
||||
s.addremove = true
|
||||
s.anonymous = true
|
||||
|
||||
s:option(Flag, "enabled", translate("enable"))
|
||||
e = s:option(Flag, "enabled", translate("enable"))
|
||||
e.rmempty = false
|
||||
|
||||
c = s:option(ListValue, "classgroup")
|
||||
c:value("Default", "standard")
|
||||
|
@ -46,19 +51,19 @@ t.default = "Normal"
|
|||
srch = s:option(Value, "srchost")
|
||||
srch.rmempty = true
|
||||
srch:value("", translate("all"))
|
||||
luci.tools.webadmin.cbi_add_knownips(srch)
|
||||
wa.cbi_add_knownips(srch)
|
||||
|
||||
dsth = s:option(Value, "dsthost")
|
||||
dsth.rmempty = true
|
||||
dsth:value("", translate("all"))
|
||||
luci.tools.webadmin.cbi_add_knownips(dsth)
|
||||
wa.cbi_add_knownips(dsth)
|
||||
|
||||
l7 = s:option(ListValue, "layer7", translate("service"))
|
||||
l7.rmempty = true
|
||||
l7:value("", translate("all"))
|
||||
local pats = luci.fs.dir("/etc/l7-protocols")
|
||||
local pats = fs.dir("/etc/l7-protocols")
|
||||
if pats then
|
||||
for i,f in ipairs(pats) do
|
||||
for f in pats do
|
||||
if f:sub(-4) == ".pat" then
|
||||
l7:value(f:sub(1, #f-4))
|
||||
end
|
||||
|
|
|
@ -12,7 +12,10 @@ You may obtain a copy of the License at
|
|||
|
||||
$Id$
|
||||
]]--
|
||||
require("luci.tools.webadmin")
|
||||
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
m = Map("qos")
|
||||
|
||||
s = m:section(NamedSection, "wan", "interface", translate("m_n_inet"))
|
||||
|
@ -37,19 +40,19 @@ t.default = "Normal"
|
|||
srch = s:option(Value, "srchost")
|
||||
srch.rmempty = true
|
||||
srch:value("", translate("all"))
|
||||
luci.tools.webadmin.cbi_add_knownips(srch)
|
||||
wa.cbi_add_knownips(srch)
|
||||
|
||||
dsth = s:option(Value, "dsthost")
|
||||
dsth.rmempty = true
|
||||
dsth:value("", translate("all"))
|
||||
luci.tools.webadmin.cbi_add_knownips(dsth)
|
||||
wa.cbi_add_knownips(dsth)
|
||||
|
||||
l7 = s:option(ListValue, "layer7", translate("service"))
|
||||
l7.rmempty = true
|
||||
l7:value("", translate("all"))
|
||||
local pats = luci.fs.dir("/etc/l7-protocols")
|
||||
local pats = fs.dir("/etc/l7-protocols")
|
||||
if pats then
|
||||
for i,f in ipairs(pats) do
|
||||
for f in pats do
|
||||
if f:sub(-4) == ".pat" then
|
||||
l7:value(f:sub(1, #f-4))
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ $Id$
|
|||
module("luci.controller.samba", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/config/samba") then
|
||||
if not nixio.fs.access("/etc/config/samba") then
|
||||
return
|
||||
end
|
||||
require("luci.i18n")
|
||||
|
|
3
applications/luci-splash/htdocs/cgi-bin/splash/splash.sh
Executable file
3
applications/luci-splash/htdocs/cgi-bin/splash/splash.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
echo -en "Status: 302 Moved\r\n"
|
||||
echo -en "Location: http://$SERVER_ADDR/cgi-bin/luci/splash\r\n\r\n"
|
|
@ -11,9 +11,18 @@ function index()
|
|||
end
|
||||
|
||||
function action_dispatch()
|
||||
local uci = luci.model.uci.cursor_state()
|
||||
local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) or ""
|
||||
local status = luci.util.execl("luci-splash status "..mac)[1]
|
||||
if #mac > 0 and ( status == "whitelisted" or status == "lease" ) then
|
||||
local access = false
|
||||
|
||||
uci:foreach("luci_splash", "lease", function(s)
|
||||
if s.mac and s.mac:lower() == mac then access = true end
|
||||
end)
|
||||
uci:foreach("luci_splash", "whitelist", function(s)
|
||||
if s.mac and s.mac:lower() == mac then access = true end
|
||||
end)
|
||||
|
||||
if #mac > 0 and access then
|
||||
luci.http.redirect(luci.dispatcher.build_url())
|
||||
else
|
||||
luci.http.redirect(luci.dispatcher.build_url("splash", "splash"))
|
||||
|
@ -24,7 +33,7 @@ function action_activate()
|
|||
local ip = luci.http.getenv("REMOTE_ADDR") or "127.0.0.1"
|
||||
local mac = luci.sys.net.ip4mac(ip:match("^[\[::ffff:]*(%d+.%d+%.%d+%.%d+)\]*$"))
|
||||
if mac and luci.http.formvalue("accept") then
|
||||
os.execute("luci-splash add "..mac.." >/dev/null 2>&1")
|
||||
os.execute("luci-splash lease "..mac.." >/dev/null 2>&1")
|
||||
luci.http.redirect(luci.model.uci.cursor():get("freifunk", "community", "homepage"))
|
||||
else
|
||||
luci.http.redirect(luci.dispatcher.build_url())
|
||||
|
@ -35,63 +44,44 @@ function action_status_admin()
|
|||
local uci = luci.model.uci.cursor_state()
|
||||
local macs = luci.http.formvaluetable("save")
|
||||
|
||||
local function delete_mac(what, mac)
|
||||
uci:delete_all("luci_splash", what,
|
||||
function(s)
|
||||
return ( s.mac and s.mac:lower() == mac )
|
||||
end)
|
||||
end
|
||||
|
||||
local function leases(mac)
|
||||
local leases = { }
|
||||
|
||||
uci:foreach("luci_splash", "lease", function(s)
|
||||
if s.start and s.mac and s.mac:lower() ~= mac then
|
||||
leases[#leases+1] = {
|
||||
start = s.start,
|
||||
mac = s.mac
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
uci:revert("luci_splash")
|
||||
|
||||
return leases
|
||||
end
|
||||
|
||||
local function commit(leases, no_commit)
|
||||
if not no_commit then
|
||||
uci:save("luci_splash")
|
||||
uci:commit("luci_splash")
|
||||
end
|
||||
|
||||
for _, l in ipairs(leases) do
|
||||
uci:section("luci_splash", "lease", nil, l)
|
||||
end
|
||||
|
||||
uci:save("luci_splash")
|
||||
os.execute("/etc/init.d/luci_splash restart")
|
||||
end
|
||||
local changes = {
|
||||
whitelist = { },
|
||||
blacklist = { },
|
||||
lease = { },
|
||||
remove = { }
|
||||
}
|
||||
|
||||
for key, _ in pairs(macs) do
|
||||
local policy = luci.http.formvalue("policy.%s" % key)
|
||||
local mac = luci.http.protocol.urldecode(key)
|
||||
local lslist = leases(policy ~= "kick" and mac)
|
||||
|
||||
delete_mac("blacklist", mac)
|
||||
delete_mac("whitelist", mac)
|
||||
|
||||
if policy == "whitelist" or policy == "blacklist" then
|
||||
uci:section("luci_splash", policy, nil, { mac = mac })
|
||||
elseif policy == "normal" then
|
||||
lslist[#lslist+1] = { mac = mac, start = os.time() }
|
||||
elseif policy == "kick" then
|
||||
for _, l in ipairs(lslist) do
|
||||
if l.mac:lower() == mac then l.kicked="1" end
|
||||
end
|
||||
changes[policy][#changes[policy]+1] = mac
|
||||
elseif policy == "normal" then
|
||||
changes["lease"][#changes["lease"]+1] = mac
|
||||
elseif policy == "kicked" then
|
||||
changes["remove"][#changes["remove"]+1] = mac
|
||||
end
|
||||
end
|
||||
|
||||
commit(lslist)
|
||||
if #changes.whitelist > 0 then
|
||||
os.execute("luci-splash whitelist %s >/dev/null"
|
||||
% table.concat(changes.whitelist))
|
||||
end
|
||||
|
||||
if #changes.blacklist > 0 then
|
||||
os.execute("luci-splash blacklist %s >/dev/null"
|
||||
% table.concat(changes.blacklist))
|
||||
end
|
||||
|
||||
if #changes.lease > 0 then
|
||||
os.execute("luci-splash lease %s >/dev/null"
|
||||
% table.concat(changes.lease))
|
||||
end
|
||||
|
||||
if #changes.remove > 0 then
|
||||
os.execute("luci-splash remove %s >/dev/null"
|
||||
% table.concat(changes.remove))
|
||||
end
|
||||
|
||||
luci.template.render("admin_status/splash", { is_admin = true })
|
||||
|
|
|
@ -4,30 +4,39 @@ require("luci.model.uci")
|
|||
m = Map("luci_splash", "Client-Splash", [[Client-Splash ist das Freifunk Hotspot-Authentifizierungs-System.]])
|
||||
|
||||
s = m:section(NamedSection, "general", "core", "Allgemein")
|
||||
s.addremove = false
|
||||
|
||||
s:option(Value, "leasetime", "Freigabezeit", "h")
|
||||
|
||||
s:option(Value, "limit_up", "Upload-Limitierung", "Kilobit/s - limitiert die Upload-Geschwindigkeit von Clients")
|
||||
s:option(Value, "limit_down", "Download-Limitierung", "Kilobit/s - limitiert die Download-Geschwindigkeit von Clients")
|
||||
s:option(Value, "limit_up", "Upload-Limitierung", "Kilobyte/s - limitiert die Upload-Geschwindigkeit von Clients")
|
||||
s:option(Value, "limit_down", "Download-Limitierung", "Kilobyte/s - limitiert die Download-Geschwindigkeit von Clients")
|
||||
|
||||
s:option(DummyValue, "_tmp", "",
|
||||
"Bandbreitenlimitierung für Clients wird aktiviert wenn sowohl Up- als auch " ..
|
||||
"Download-Geschwindigkeit angegeben werden. Auf 0 setzen um die Limitierung zu deaktivieren. " ..
|
||||
"Clients in der Whitelist werden nicht limitiert.")
|
||||
|
||||
s = m:section(TypedSection, "iface", "Schnittstellen")
|
||||
s = m:section(TypedSection, "iface", "Schnittstellen",
|
||||
"Bestimmt die Schnittstellen auf denen Splashing aktiviert werden soll. " ..
|
||||
"Diese Einstellungen müssen normalerweise nicht angepasst werden.")
|
||||
|
||||
s.template = "cbi/tblsection"
|
||||
s.addremove = true
|
||||
s.anonymous = true
|
||||
|
||||
local uci = luci.model.uci.cursor()
|
||||
|
||||
zone = s:option(ListValue, "zone", "Firewallzone")
|
||||
zone = s:option(ListValue, "zone", "Firewallzone",
|
||||
"Splash-Regeln in der angegebenen Zone eingliedern")
|
||||
|
||||
uci:foreach("firewall", "zone",
|
||||
function (section)
|
||||
zone:value(section.name)
|
||||
end)
|
||||
|
||||
iface = s:option(ListValue, "network", "Netzwerk")
|
||||
iface = s:option(ListValue, "network", "Netzwerk",
|
||||
"Client-Verkehr auf der angegebenen Schnittstelle abfangen")
|
||||
|
||||
uci:foreach("network", "interface",
|
||||
function (section)
|
||||
if section[".name"] ~= "loopback" then
|
||||
|
@ -40,16 +49,35 @@ uci:foreach("network", "alias",
|
|||
iface:value(section[".name"])
|
||||
end)
|
||||
|
||||
s = m:section(TypedSection, "whitelist", "Automatische Freigabe")
|
||||
|
||||
s = m:section(TypedSection, "whitelist", "Whitelist",
|
||||
"MAC-Adressen in dieser Liste werden automatisch freigegeben und unterliegen " ..
|
||||
"keiner Bandbreitenlimitierung.")
|
||||
|
||||
s.template = "cbi/tblsection"
|
||||
s.addremove = true
|
||||
s.anonymous = true
|
||||
s:option(Value, "mac", "MAC-Adresse")
|
||||
|
||||
s = m:section(TypedSection, "blacklist", "Automatische Sperrung")
|
||||
|
||||
s = m:section(TypedSection, "blacklist", "Blacklist",
|
||||
"MAC-Adressen in dieser Liste werden automatisch gesperrt. Verkehr von diesen " ..
|
||||
"Adressen wird komplett verworfen und es wird kein Verbindungsaufbau via WLAN " ..
|
||||
"zugelassen.")
|
||||
|
||||
s.template = "cbi/tblsection"
|
||||
s.addremove = true
|
||||
s.anonymous = true
|
||||
s:option(Value, "mac", "MAC-Adresse")
|
||||
|
||||
s = m:section(TypedSection, "subnet", "Freigegebene Subnetze",
|
||||
"Hier eingetragene Subnetze oder Host-Adressen sind vom Splash-Vorgang ausgenommen.")
|
||||
|
||||
s.template = "cbi/tblsection"
|
||||
s.addremove = true
|
||||
s.anonymous = true
|
||||
s:option(Value, "ipaddr", "IP-Adresse")
|
||||
s:option(Value, "netmask", "Netzmaske", "optional bei Host-Adressen").rmempty = true
|
||||
|
||||
|
||||
return m
|
||||
|
|
|
@ -18,6 +18,8 @@ local utl = require "luci.util"
|
|||
local ipt = require "luci.sys.iptparser".IptParser()
|
||||
local uci = require "luci.model.uci".cursor_state()
|
||||
local wat = require "luci.tools.webadmin"
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
local clients = { }
|
||||
local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime") or 1) * 60 * 60
|
||||
local leasefile = "/tmp/dhcp.leases"
|
||||
|
@ -35,10 +37,10 @@ uci:foreach("luci_splash", "lease",
|
|||
start = tonumber(s.start),
|
||||
limit = ( tonumber(s.start) + leasetime ),
|
||||
mac = s.mac:upper(),
|
||||
ipaddr = s.ipaddr,
|
||||
policy = "normal",
|
||||
packets = 0,
|
||||
bytes = 0,
|
||||
kicked = s.kicked and true or false
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
@ -58,12 +60,24 @@ for _, r in ipairs(ipt:find({table="nat", chain="luci_splash_leases"})) do
|
|||
end
|
||||
end
|
||||
|
||||
for _, r in ipairs(ipt:find({table="filter", chain="luci_splash_counter"})) do
|
||||
if r.options and #r.options >= 2 and r.options[1] == "MAC" then
|
||||
local c = clients[r.options[2]:lower()]
|
||||
if c and c.packets == 0 then
|
||||
c.bytes = tonumber(r.bytes)
|
||||
c.packets = tonumber(r.packets)
|
||||
for mac, client in pairs(clients) do
|
||||
client.bytes_in = 0
|
||||
client.bytes_out = 0
|
||||
client.packets_in = 0
|
||||
client.packets_out = 0
|
||||
|
||||
if client.ipaddr then
|
||||
local rin = ipt:find({table="mangle", chain="luci_splash_mark_in", destination=client.ipaddr})
|
||||
local rout = ipt:find({table="mangle", chain="luci_splash_mark_out", options={"MAC", client.mac:upper()}})
|
||||
|
||||
if rin and #rin > 0 then
|
||||
client.bytes_in = rin[1].bytes
|
||||
client.packets_in = rin[1].packets
|
||||
end
|
||||
|
||||
if rout and #rout > 0 then
|
||||
client.bytes_out = rout[1].bytes
|
||||
client.packets_out = rout[1].packets
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -82,7 +96,7 @@ uci:foreach("luci_splash", "blacklist",
|
|||
end
|
||||
end)
|
||||
|
||||
if luci.fs.access(leasefile) then
|
||||
if fs.access(leasefile) then
|
||||
for l in io.lines(leasefile) do
|
||||
local time, mac, ip, name = l:match("^(%d+) (%S+) (%S+) (%S+)")
|
||||
if time and mac and ip then
|
||||
|
@ -125,7 +139,7 @@ end
|
|||
<th class="cbi-section-table-cell"><%:ff_splash_ip IP Address%></th>
|
||||
<th class="cbi-section-table-cell"><%:ff_splash_mac MAC Address%></th>
|
||||
<th class="cbi-section-table-cell"><%:ff_splash_timeleft Time remaining%></th>
|
||||
<th class="cbi-section-table-cell"><%:ff_splash_traffic Outgoing traffic%></th>
|
||||
<th class="cbi-section-table-cell"><%:ff_splash_traffic Traffic in/out%></th>
|
||||
<th class="cbi-section-table-cell"><%:ff_splash_policy Policy%></th>
|
||||
</tr>
|
||||
|
||||
|
@ -151,7 +165,7 @@ end
|
|||
(c.limit >= os.time()) and wat.date_format(c.limit-os.time()) or
|
||||
(c.policy ~= "normal") and "-" or "<em>" .. translate("ff_splash_expired", "expired") .. "</em>"
|
||||
%></td>
|
||||
<td class="cbi-section-table-cell"><%=wat.byte_format(c.bytes)%></td>
|
||||
<td class="cbi-section-table-cell"><%=wat.byte_format(c.bytes_in)%> / <%=wat.byte_format(c.bytes_out)%></td>
|
||||
<td class="cbi-section-table-cell">
|
||||
<% if is_admin then %>
|
||||
<select name="policy.<%=c.mac:lower()%>" style="width:200px">
|
||||
|
@ -159,7 +173,7 @@ end
|
|||
<option value="normal"<%=c.policy=="normal" and not c.kicked and ' selected="selected"'%>><%:ff_splash_splashed splashed%></option>
|
||||
<option value="blacklist"<%=c.policy=="blacklist" and ' selected="selected"'%>><%:ff_splash_blacklisted blacklisted%></option>
|
||||
<% if c.policy == "normal" then -%>
|
||||
<option value="kick"<%=c.kicked and ' selected="selected"'%>><%:ff_splash_tempblock temporarily blocked%> (<%=wat.date_format(c.limit-os.time())%>)</option>
|
||||
<option value="kicked"><%:ff_splash_tempblock temporarily blocked%></option>
|
||||
<%- end %>
|
||||
</select>
|
||||
<input type="submit" class="cbi-button cbi-button-save" name="save.<%=c.mac:lower()%>" value="<%:save Save%>" />
|
||||
|
|
|
@ -1,103 +1,104 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=70
|
||||
EXTRA_COMMANDS=clear_leases
|
||||
SPLASH_INTERFACES=""
|
||||
LIMIT_DOWN=0
|
||||
LIMIT_DOWN_BURST=0
|
||||
LIMIT_UP=0
|
||||
|
||||
IPT_REPLAY=/var/run/luci_splash.iptlog
|
||||
LOCK=/var/run/luci_splash.lock
|
||||
|
||||
include /lib/network
|
||||
scan_interfaces
|
||||
config_load luci_splash
|
||||
|
||||
silent() {
|
||||
"$@" 2>/dev/null
|
||||
}
|
||||
|
||||
ipt_log() {
|
||||
iptables -I "$@"
|
||||
echo iptables -D "$@" >> $IPT_REPLAY
|
||||
}
|
||||
|
||||
iface_add() {
|
||||
local cfg="$1"
|
||||
|
||||
|
||||
config_get zone "$cfg" zone
|
||||
[ -n "$zone" ] || return 0
|
||||
|
||||
|
||||
config_get net "$cfg" network
|
||||
[ -n "$net" ] || return 0
|
||||
|
||||
config_get ifname "$net" ifname
|
||||
[ -n "$ifname" ] || return 0
|
||||
|
||||
|
||||
config_get ipaddr "$net" ipaddr
|
||||
[ -n "$ipaddr" ] || return 0
|
||||
|
||||
|
||||
config_get netmask "$net" netmask
|
||||
[ -n "$netmask" ] || return 0
|
||||
|
||||
|
||||
config_get parentiface "$net" interface
|
||||
[ -n "$parentiface" ] && {
|
||||
config_get parentproto "$parentiface" proto
|
||||
config_get parentipaddr "$parentiface" ipaddr
|
||||
config_get parentnetmask "$parentiface" netmask
|
||||
}
|
||||
|
||||
eval "$(ipcalc.sh $ipaddr $netmask)"
|
||||
|
||||
iptables -t nat -A prerouting_${zone} -j luci_splash_prerouting
|
||||
iptables -t nat -A luci_splash_prerouting -s "$NETWORK/$PREFIX" -p ! tcp -j luci_splash_portal
|
||||
iptables -t nat -A luci_splash_prerouting -s "$NETWORK/$PREFIX" -d ! "$ipaddr" -j luci_splash_portal
|
||||
iptables -t nat -A luci_splash_prerouting -s "$NETWORK/$PREFIX" -d "$ipaddr" -p tcp -m multiport ! --dport 22,80,443 -j luci_splash_portal
|
||||
### Add interface specific chain entry rules
|
||||
ipt_log "zone_${zone}_prerouting" -i "${ifname%:*}" -s "$NETWORK/$PREFIX" -j luci_splash_prerouting -t nat
|
||||
ipt_log "zone_${zone}_forward" -i "${ifname%:*}" -s "$NETWORK/$PREFIX" -j luci_splash_forwarding -t filter
|
||||
|
||||
### Allow traffic to the same subnet
|
||||
iptables -t nat -I luci_splash_prerouting -d "$ipaddr/${netmask:-32}" -j RETURN
|
||||
iptables -t filter -I luci_splash_forwarding -d "$ipaddr/${netmask:-32}" -j RETURN
|
||||
|
||||
### Allow traffic to the mesh subnet
|
||||
[ "$parentproto" = "static" -a -n "$parentipaddr" ] && {
|
||||
iptables -t nat -I luci_splash_prerouting -d "$parentipaddr/${parentnetmask:-32}" -j RETURN
|
||||
iptables -t filter -I luci_splash_forwarding -d "$parentipaddr/${parentnetmask:-32}" -j RETURN
|
||||
}
|
||||
|
||||
qos_iface_add "$ifname"
|
||||
|
||||
append SPLASH_INTERFACES "$ifname"
|
||||
}
|
||||
|
||||
iface_del() {
|
||||
config_get zone "$1" zone
|
||||
config_get zone "$1" zone
|
||||
[ -n "$zone" ] || return 0
|
||||
|
||||
config_get ifname "$1" ifname
|
||||
config_get net "$1" network
|
||||
[ -n "$net" ] || return 0
|
||||
|
||||
config_get ifname "$net" ifname
|
||||
[ -n "$ifname" ] || return 0
|
||||
|
||||
while iptables -t nat -D prerouting_${zone} -j luci_splash_prerouting 2>&-; do :; done
|
||||
# Clear interface specific rules
|
||||
[ -s $IPT_REPLAY ] && {
|
||||
grep -- "-i ${ifname%:*}" $IPT_REPLAY | while read ln; do silent $ln; done
|
||||
sed -ie "/-i ${ifname%:*}/d" $IPT_REPLAY
|
||||
}
|
||||
|
||||
qos_iface_del "$ifname"
|
||||
}
|
||||
|
||||
blacklist_add() {
|
||||
local cfg="$1"
|
||||
|
||||
config_get mac "$cfg" mac
|
||||
[ -n "$mac" ] && {
|
||||
iptables -t filter -I luci_splash_counter -m mac --mac-source "$mac" -j RETURN
|
||||
iptables -t nat -I luci_splash_leases -m mac --mac-source "$mac" -j DROP
|
||||
}
|
||||
mac_add() {
|
||||
config_get mac "$1" mac
|
||||
append MACS "$mac"
|
||||
}
|
||||
|
||||
whitelist_add() {
|
||||
subnet_add() {
|
||||
local cfg="$1"
|
||||
|
||||
config_get mac "$cfg" mac
|
||||
[ -n "$mac" ] && {
|
||||
iptables -t filter -I luci_splash_counter -m mac --mac-source "$mac" -j RETURN
|
||||
iptables -t nat -I luci_splash_leases -m mac --mac-source "$mac" -j RETURN
|
||||
}
|
||||
}
|
||||
|
||||
lease_add() {
|
||||
local cfg="$1"
|
||||
|
||||
config_get mac "$cfg" mac
|
||||
config_get ban "$cfg" kicked
|
||||
config_get ipaddr "$cfg" ipaddr
|
||||
config_get netmask "$cfg" netmask
|
||||
|
||||
ban=${ban:+DROP}
|
||||
|
||||
[ -n "$mac" ] && {
|
||||
local oIFS="$IFS"; IFS=":"
|
||||
set -- $mac
|
||||
IFS="$oIFS"; unset oIFS
|
||||
|
||||
local mac_pre="$1$2"
|
||||
local mac_post="$3$4$5$6"
|
||||
local handle="$6"
|
||||
|
||||
iptables -t filter -I luci_splash_counter -m mac --mac-source "$mac" -j RETURN
|
||||
iptables -t mangle -I luci_splash_mark -m mac --mac-source "$mac" -j MARK --set-mark 79
|
||||
iptables -t nat -I luci_splash_leases -m mac --mac-source "$mac" -j "${ban:-RETURN}"
|
||||
|
||||
for i in $SPLASH_INTERFACES; do
|
||||
tc filter add dev $i parent 77:0 protocol ip prio 2 handle ::$handle u32 \
|
||||
match u16 0x0800 0xFFFF at -2 match u32 0x$mac_post 0xFFFFFFFF at -12 \
|
||||
match u16 0x$mac_pre 0xFFFF at -14 flowid 77:10
|
||||
done
|
||||
[ -n "$ipaddr" ] && {
|
||||
iptables -t nat -I luci_splash_prerouting -d "$ipaddr/${netmask:-32}" -j RETURN
|
||||
iptables -t filter -I luci_splash_forwarding -d "$ipaddr/${netmask:-32}" -j RETURN
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +107,8 @@ qos_iface_add() {
|
|||
|
||||
# 77 -> download root qdisc
|
||||
# 78 -> upload root qdisc
|
||||
# 79 -> fwmark
|
||||
# 79 -> fwmark: client->inet
|
||||
# 80 -> fwmark: inet->client
|
||||
|
||||
silent tc qdisc del dev "$iface" root handle 77:
|
||||
|
||||
|
@ -125,10 +127,14 @@ qos_iface_add() {
|
|||
# adding ingress can result in "File exists" if qos-scripts are active
|
||||
silent tc qdisc add dev "$iface" ingress
|
||||
|
||||
# set client download speed
|
||||
tc filter add dev "$iface" parent 77: protocol ip prio 2 \
|
||||
handle 80 fw flowid 77:10
|
||||
|
||||
# set client upload speed
|
||||
tc filter add dev "$iface" parent ffff: protocol ip prio 1 \
|
||||
handle 79 fw police rate ${LIMIT_UP}kbit mtu 6k burst 6k drop
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
qos_iface_del() {
|
||||
|
@ -141,20 +147,16 @@ qos_iface_del() {
|
|||
|
||||
boot() {
|
||||
### Setup splash-relay
|
||||
uci get lucid.splashr || {
|
||||
uci get uhttpd.splash 2>/dev/null || {
|
||||
uci batch <<EOF
|
||||
set lucid.splashr=daemon
|
||||
set lucid.splashr.slave=httpd
|
||||
add_list lucid.splashr.address=8082
|
||||
add_list lucid.splashr.publisher=splashredir
|
||||
set lucid.splashr.enabled=1
|
||||
set uhttpd.splash=uhttpd
|
||||
set uhttpd.splash.home="/www/cgi-bin/splash/"
|
||||
set uhttpd.splash.interpreter=".sh=/bin/ash"
|
||||
set uhttpd.splash.listen_http="8082"
|
||||
set uhttpd.splash.index_page="splash.sh"
|
||||
set uhttpd.splash.error_page="/splash.sh"
|
||||
|
||||
set lucid.splashredir=Redirector
|
||||
set lucid.splashredir.name=Splashd
|
||||
set lucid.splashredir.virtual='/'
|
||||
set lucid.splashredir.physical=':80/luci/splash'
|
||||
|
||||
commit lucid
|
||||
commit uhttpd
|
||||
EOF
|
||||
}
|
||||
|
||||
|
@ -163,96 +165,114 @@ EOF
|
|||
}
|
||||
|
||||
start() {
|
||||
### Read chains from config
|
||||
include /lib/network
|
||||
scan_interfaces
|
||||
config_load luci_splash
|
||||
|
||||
lock -w $LOCK && lock $LOCK
|
||||
|
||||
### Find QoS limits
|
||||
config_get LIMIT_UP general limit_up
|
||||
config_get LIMIT_DOWN general limit_down
|
||||
config_get LIMIT_DOWN_BURST general limit_down_burst
|
||||
|
||||
LIMIT_UP="${LIMIT_UP:-0}"
|
||||
LIMIT_DOWN="${LIMIT_DOWN:-0}"
|
||||
LIMIT_DOWN_BURST="${LIMIT_DOWN_BURST:-$(($LIMIT_DOWN * 2))}"
|
||||
LIMIT_UP="$((8*${LIMIT_UP:-0}))"
|
||||
LIMIT_DOWN="$((8*${LIMIT_DOWN:-0}))"
|
||||
LIMIT_DOWN_BURST="${LIMIT_DOWN_BURST:+$((8*$LIMIT_DOWN_BURST))}"
|
||||
LIMIT_DOWN_BURST="${LIMIT_DOWN_BURST:-$(($LIMIT_DOWN / 5 * 6))}"
|
||||
|
||||
### Load required modules
|
||||
[ "$LIMIT_UP" -gt 0 -a "$LIMIT_DOWN" -gt 0 ] && {
|
||||
silent insmod act_police
|
||||
silent insmod cls_fw
|
||||
silent insmod cls_u32
|
||||
silent insmod sch_htb
|
||||
silent insmod sch_sfq
|
||||
silent insmod sch_ingress
|
||||
}
|
||||
|
||||
### Create subchains
|
||||
iptables -t filter -N luci_splash_counter
|
||||
iptables -t nat -N luci_splash_portal
|
||||
iptables -t nat -N luci_splash_leases
|
||||
iptables -t nat -N luci_splash_prerouting
|
||||
iptables -t nat -N luci_splash_leases
|
||||
iptables -t filter -N luci_splash_forwarding
|
||||
iptables -t filter -N luci_splash_filter
|
||||
|
||||
[ "$LIMIT_UP" -gt 0 -a "$LIMIT_DOWN" -gt 0 ] && \
|
||||
iptables -t mangle -N luci_splash_mark
|
||||
### Clear iptables replay log
|
||||
[ -s $IPT_REPLAY ] && . $IPT_REPLAY
|
||||
echo -n > $IPT_REPLAY
|
||||
|
||||
### Build the main and portal rule
|
||||
config_foreach iface_add iface
|
||||
config_foreach blacklist_add blacklist
|
||||
config_foreach whitelist_add whitelist
|
||||
config_foreach lease_add lease
|
||||
|
||||
### Build the portal rule
|
||||
iptables -t filter -I INPUT -j luci_splash_counter
|
||||
iptables -t filter -I FORWARD -j luci_splash_counter
|
||||
config_foreach subnet_add subnet
|
||||
|
||||
[ "$LIMIT_UP" -gt 0 -a "$LIMIT_DOWN" -gt 0 ] && \
|
||||
iptables -t mangle -I PREROUTING -j luci_splash_mark
|
||||
|
||||
iptables -t nat -A luci_splash_portal -p udp --dport 33434:33523 -j RETURN
|
||||
iptables -t nat -A luci_splash_portal -p icmp -j RETURN
|
||||
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
|
||||
### Add interface independant prerouting rules
|
||||
iptables -t nat -A luci_splash_prerouting -j luci_splash_leases
|
||||
iptables -t nat -A luci_splash_leases -p udp --dport 53 -j REDIRECT --to-ports 53
|
||||
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
|
||||
|
||||
|
||||
### Add interface independant forwarding rules
|
||||
iptables -t filter -A luci_splash_forwarding -j luci_splash_filter
|
||||
iptables -t filter -A luci_splash_filter -p tcp -j REJECT --reject-with tcp-reset
|
||||
iptables -t filter -A luci_splash_filter -j REJECT --reject-with icmp-net-prohibited
|
||||
|
||||
### Add QoS chain
|
||||
[ "$LIMIT_UP" -gt 0 -a "$LIMIT_DOWN" -gt 0 ] && {
|
||||
iptables -t mangle -N luci_splash_mark_out
|
||||
iptables -t mangle -N luci_splash_mark_in
|
||||
iptables -t mangle -I PREROUTING -j luci_splash_mark_out
|
||||
iptables -t mangle -I POSTROUTING -j luci_splash_mark_in
|
||||
}
|
||||
|
||||
### Find active mac addresses
|
||||
MACS=""
|
||||
config_foreach mac_add lease
|
||||
config_foreach mac_add blacklist
|
||||
config_foreach mac_add whitelist
|
||||
|
||||
### Add crontab entry
|
||||
test -f /etc/crontabs/root || touch /etc/crontabs/root
|
||||
grep -q luci-splash /etc/crontabs/root || {
|
||||
echo '*/5 * * * * /usr/sbin/luci-splash sync' >> /etc/crontabs/root
|
||||
}
|
||||
|
||||
lock -u $LOCK
|
||||
|
||||
### Populate iptables
|
||||
[ -n "$MACS" ] && luci-splash add-rules $MACS
|
||||
}
|
||||
|
||||
stop() {
|
||||
lock -w $LOCK && lock $LOCK
|
||||
|
||||
### Clear interface rules
|
||||
config_load luci_splash
|
||||
config_foreach iface_del iface
|
||||
|
||||
silent iptables -t filter -D INPUT -j luci_splash_counter
|
||||
silent iptables -t filter -D FORWARD -j luci_splash_counter
|
||||
silent iptables -t mangle -D PREROUTING -j luci_splash_mark
|
||||
|
||||
silent iptables -t mangle -D PREROUTING -j luci_splash_mark_out
|
||||
silent iptables -t mangle -D POSTROUTING -j luci_splash_mark_in
|
||||
|
||||
### Clear subchains
|
||||
silent iptables -t nat -F luci_splash_leases
|
||||
silent iptables -t nat -F luci_splash_portal
|
||||
silent iptables -t nat -F luci_splash_prerouting
|
||||
silent iptables -t filter -F luci_splash_counter
|
||||
silent iptables -t mangle -F luci_splash_mark
|
||||
|
||||
silent iptables -t nat -F luci_splash_leases
|
||||
silent iptables -t filter -F luci_splash_forwarding
|
||||
silent iptables -t filter -F luci_splash_filter
|
||||
silent iptables -t mangle -F luci_splash_mark_out
|
||||
silent iptables -t mangle -F luci_splash_mark_in
|
||||
|
||||
### Delete subchains
|
||||
silent iptables -t nat -X luci_splash_leases
|
||||
silent iptables -t nat -X luci_splash_portal
|
||||
silent iptables -t nat -X luci_splash_prerouting
|
||||
silent iptables -t filter -X luci_splash_counter
|
||||
silent iptables -t mangle -X luci_splash_mark
|
||||
|
||||
silent iptables -t nat -X luci_splash_leases
|
||||
silent iptables -t filter -X luci_splash_forwarding
|
||||
silent iptables -t filter -X luci_splash_filter
|
||||
silent iptables -t mangle -X luci_splash_mark_out
|
||||
silent iptables -t mangle -X luci_splash_mark_in
|
||||
|
||||
sed -ie '/\/usr\/sbin\/luci-splash sync/d' /var/spool/cron/crontabs/root
|
||||
|
||||
lock -u $LOCK
|
||||
}
|
||||
|
||||
|
||||
clear_leases() {
|
||||
stop
|
||||
while uci -P /var/state del luci_splash.@lease[0] 2>&-;do :; done
|
||||
start
|
||||
### Find active mac addresses
|
||||
MACS=""
|
||||
config_foreach mac_add lease
|
||||
|
||||
### Clear leases
|
||||
[ -n "$MACS" ] && luci-splash remove $MACS
|
||||
}
|
||||
|
||||
|
|
|
@ -2,191 +2,329 @@
|
|||
|
||||
require("luci.util")
|
||||
require("luci.model.uci")
|
||||
require("luci.sys")
|
||||
require("luci.sys.iptparser")
|
||||
|
||||
-- Init state session
|
||||
local uci = luci.model.uci.cursor_state()
|
||||
local ipt = luci.sys.iptparser.IptParser()
|
||||
local net = luci.sys.net
|
||||
|
||||
local splash_interfaces = { }
|
||||
local limit_up = 0
|
||||
local limit_down = 0
|
||||
|
||||
function lock()
|
||||
os.execute("lock -w /var/run/luci_splash.lock && lock /var/run/luci_splash.lock")
|
||||
end
|
||||
|
||||
function unlock()
|
||||
os.execute("lock -u /var/run/luci_splash.lock")
|
||||
end
|
||||
|
||||
function main(argv)
|
||||
local cmd = argv[1]
|
||||
local arg = argv[2]
|
||||
local cmd = table.remove(argv, 1)
|
||||
local arg = argv[1]
|
||||
|
||||
limit_up = tonumber(uci:get("luci_splash", "general", "limit_up")) or 0
|
||||
limit_down = tonumber(uci:get("luci_splash", "general", "limit_down")) or 0
|
||||
|
||||
uci:foreach("luci_splash", "iface", function(s)
|
||||
if s.network then
|
||||
splash_interfaces[#splash_interfaces+1] = uci:get("network", s.network, "ifname")
|
||||
end
|
||||
end)
|
||||
|
||||
if cmd == "status" and arg then
|
||||
if islisted("whitelist", arg) then
|
||||
print("whitelisted")
|
||||
elseif islisted("blacklist", arg) then
|
||||
print("blacklisted")
|
||||
else
|
||||
local lease = haslease(arg)
|
||||
if lease and lease.kicked then
|
||||
print("kicked")
|
||||
elseif lease then
|
||||
print("lease")
|
||||
if ( cmd == "lease" or cmd == "add-rules" or cmd == "remove" or
|
||||
cmd == "whitelist" or cmd == "blacklist" or cmd == "status" ) and #argv > 0
|
||||
then
|
||||
lock()
|
||||
|
||||
local arp_cache = net.arptable()
|
||||
local leased_macs = get_known_macs("lease")
|
||||
local blacklist_macs = get_known_macs("blacklist")
|
||||
local whitelist_macs = get_known_macs("whitelist")
|
||||
|
||||
for i, adr in ipairs(argv) do
|
||||
local mac = nil
|
||||
if adr:find(":") then
|
||||
mac = adr:lower()
|
||||
else
|
||||
print("unknown")
|
||||
for _, e in ipairs(arp_cache) do
|
||||
if e["IP address"] == adr then
|
||||
mac = e["HW address"]:lower()
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if mac and cmd == "add-rules" then
|
||||
if leased_macs[mac] then
|
||||
add_lease(mac, arp_cache, true)
|
||||
elseif blacklist_macs[mac] then
|
||||
add_blacklist_rule(mac)
|
||||
elseif whitelist_macs[mac] then
|
||||
add_whitelist_rule(mac)
|
||||
end
|
||||
elseif mac and cmd == "status" then
|
||||
print(leased_macs[mac] and "lease"
|
||||
or whitelist_macs[mac] and "whitelist"
|
||||
or blacklist_macs[mac] and "blacklist"
|
||||
or "new")
|
||||
elseif mac and ( cmd == "whitelist" or cmd == "blacklist" or cmd == "lease" ) then
|
||||
if cmd ~= "lease" and leased_macs[mac] then
|
||||
print("Removing %s from leases" % mac)
|
||||
remove_lease(mac)
|
||||
leased_macs[mac] = nil
|
||||
end
|
||||
|
||||
if cmd ~= "whitelist" and whitelist_macs[mac] then
|
||||
print("Removing %s from whitelist" % mac)
|
||||
remove_whitelist(mac)
|
||||
whitelist_macs[mac] = nil
|
||||
end
|
||||
|
||||
if cmd ~= "blacklist" and blacklist_macs[mac] then
|
||||
print("Removing %s from blacklist" % mac)
|
||||
remove_blacklist(mac)
|
||||
blacklist_macs[mac] = nil
|
||||
end
|
||||
|
||||
if cmd == "lease" and not leased_macs[mac] then
|
||||
print("Adding %s to leases" % mac)
|
||||
add_lease(mac)
|
||||
leased_macs[mac] = true
|
||||
elseif cmd == "whitelist" and not whitelist_macs[mac] then
|
||||
print("Adding %s to whitelist" % mac)
|
||||
add_whitelist(mac)
|
||||
whitelist_macs[mac] = true
|
||||
elseif cmd == "blacklist" and not blacklist_macs[mac] then
|
||||
print("Adding %s to blacklist" % mac)
|
||||
add_blacklist(mac)
|
||||
blacklist_macs[mac] = true
|
||||
else
|
||||
print("The mac %s is already %sed" %{ mac, cmd })
|
||||
end
|
||||
elseif mac and cmd == "remove" then
|
||||
if leased_macs[mac] then
|
||||
print("Removing %s from leases" % mac)
|
||||
remove_lease(mac)
|
||||
leased_macs[mac] = nil
|
||||
elseif whitelist_macs[mac] then
|
||||
print("Removing %s from whitelist" % mac)
|
||||
remove_whitelist(mac)
|
||||
whitelist_macs[mac] = nil
|
||||
elseif blacklist_macs[mac] then
|
||||
print("Removing %s from blacklist" % mac)
|
||||
remove_blacklist(mac)
|
||||
blacklist_macs[mac] = nil
|
||||
else
|
||||
print("The mac %s is not known" % mac)
|
||||
end
|
||||
else
|
||||
print("Can not find mac for ip %s" % argv[i])
|
||||
end
|
||||
end
|
||||
os.exit(0)
|
||||
elseif cmd == "add" and arg then
|
||||
if not haslease(arg) then
|
||||
add_lease(arg)
|
||||
else
|
||||
print("already leased!")
|
||||
os.exit(2)
|
||||
end
|
||||
os.exit(0)
|
||||
elseif cmd == "remove" and arg then
|
||||
remove_lease(arg)
|
||||
os.exit(0)
|
||||
|
||||
unlock()
|
||||
os.exit(0)
|
||||
elseif cmd == "sync" then
|
||||
sync()
|
||||
os.exit(0)
|
||||
elseif cmd == "list" then
|
||||
list()
|
||||
os.exit(0)
|
||||
else
|
||||
print("Usage: " .. argv[0] .. " <status|add|remove|sync> [MAC]")
|
||||
print("Usage:")
|
||||
print("\n luci-splash list\n List connected, black- and whitelisted clients")
|
||||
print("\n luci-splash sync\n Synchronize firewall rules and clear expired leases")
|
||||
print("\n luci-splash lease <MAC-or-IP>\n Create a lease for the given address")
|
||||
print("\n luci-splash blacklist <MAC-or-IP>\n Add given address to blacklist")
|
||||
print("\n luci-splash whitelist <MAC-or-IP>\n Add given address to whitelist")
|
||||
print("\n luci-splash remove <MAC-or-IP>\n Remove given address from the lease-, black- or whitelist")
|
||||
print("")
|
||||
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
-- Get a list of known mac addresses
|
||||
function get_known_macs(list)
|
||||
local leased_macs = { }
|
||||
|
||||
if not list or list == "lease" then
|
||||
uci:foreach("luci_splash", "lease",
|
||||
function(s) leased_macs[s.mac:lower()] = true end)
|
||||
end
|
||||
|
||||
if not list or list == "whitelist" then
|
||||
uci:foreach("luci_splash", "whitelist",
|
||||
function(s) leased_macs[s.mac:lower()] = true end)
|
||||
end
|
||||
|
||||
if not list or list == "blacklist" then
|
||||
uci:foreach("luci_splash", "blacklist",
|
||||
function(s) leased_macs[s.mac:lower()] = true end)
|
||||
end
|
||||
|
||||
return leased_macs
|
||||
end
|
||||
|
||||
|
||||
-- Get a list of known ip addresses
|
||||
function get_known_ips(macs, arp)
|
||||
local leased_ips = { }
|
||||
if not macs then macs = get_known_macs() end
|
||||
for _, e in ipairs(arp or net.arptable()) do
|
||||
if macs[e["HW address"]:lower()] then leased_ips[e["IP address"]] = true end
|
||||
end
|
||||
return leased_ips
|
||||
end
|
||||
|
||||
|
||||
-- Helper to delete iptables rules
|
||||
function ipt_delete_all(args, comp, off)
|
||||
off = off or { }
|
||||
for i, r in ipairs(ipt:find(args)) do
|
||||
if comp == nil or comp(r) then
|
||||
off[r.table] = off[r.table] or { }
|
||||
off[r.table][r.chain] = off[r.table][r.chain] or 0
|
||||
|
||||
os.execute("iptables -t %q -D %q %d 2>/dev/null"
|
||||
%{ r.table, r.chain, r.index - off[r.table][r.chain] })
|
||||
|
||||
off[r.table][r.chain] = off[r.table][r.chain] + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Add a lease to state and invoke add_rule
|
||||
function add_lease(mac)
|
||||
uci:section("luci_splash", "lease", nil, {
|
||||
mac = mac,
|
||||
start = os.time()
|
||||
})
|
||||
add_rule(mac)
|
||||
|
||||
uci:save("luci_splash")
|
||||
function add_lease(mac, arp, no_uci)
|
||||
mac = mac:lower()
|
||||
|
||||
-- Get current ip address
|
||||
local ipaddr
|
||||
for _, entry in ipairs(arp or net.arptable()) do
|
||||
if entry["HW address"]:lower() == mac then
|
||||
ipaddr = entry["IP address"]
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- Add lease if there is an ip addr
|
||||
if ipaddr then
|
||||
if not no_uci then
|
||||
uci:section("luci_splash", "lease", nil, {
|
||||
mac = mac,
|
||||
ipaddr = ipaddr,
|
||||
start = os.time()
|
||||
})
|
||||
uci:save("luci_splash")
|
||||
end
|
||||
add_lease_rule(mac, ipaddr)
|
||||
else
|
||||
print("Found no active IP for %s, lease not added" % mac)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Remove a lease from state and invoke remove_rule
|
||||
function remove_lease(mac)
|
||||
mac = mac:lower()
|
||||
remove_rule(mac)
|
||||
|
||||
uci:delete_all("luci_splash", "lease",
|
||||
function(s) return ( s.mac:lower() == mac ) end)
|
||||
function(s)
|
||||
if s.mac:lower() == mac then
|
||||
remove_lease_rule(mac, s.ipaddr)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end)
|
||||
|
||||
uci:save("luci_splash")
|
||||
end
|
||||
|
||||
|
||||
-- Add a whitelist entry
|
||||
function add_whitelist(mac)
|
||||
uci:section("luci_splash", "whitelist", nil, { mac = mac })
|
||||
uci:save("luci_splash")
|
||||
uci:commit("luci_splash")
|
||||
add_whitelist_rule(mac)
|
||||
end
|
||||
|
||||
|
||||
-- Add a blacklist entry
|
||||
function add_blacklist(mac)
|
||||
uci:section("luci_splash", "blacklist", nil, { mac = mac })
|
||||
uci:save("luci_splash")
|
||||
uci:commit("luci_splash")
|
||||
add_blacklist_rule(mac)
|
||||
end
|
||||
|
||||
|
||||
-- Remove a whitelist entry
|
||||
function remove_whitelist(mac)
|
||||
mac = mac:lower()
|
||||
uci:delete_all("luci_splash", "whitelist",
|
||||
function(s) return not s.mac or s.mac:lower() == mac end)
|
||||
uci:save("luci_splash")
|
||||
uci:commit("luci_splash")
|
||||
remove_lease_rule(mac)
|
||||
end
|
||||
|
||||
|
||||
-- Remove a blacklist entry
|
||||
function remove_blacklist(mac)
|
||||
mac = mac:lower()
|
||||
uci:delete_all("luci_splash", "blacklist",
|
||||
function(s) return not s.mac or s.mac:lower() == mac end)
|
||||
uci:save("luci_splash")
|
||||
uci:commit("luci_splash")
|
||||
remove_lease_rule(mac)
|
||||
end
|
||||
|
||||
|
||||
-- Add an iptables rule
|
||||
function add_rule(mac)
|
||||
local a, b, c, d, e, f = mac:match("(%w+):(%w+):(%w+):(%w+):(%w+):(%w+)")
|
||||
local mac_pre = "%s%s" %{ a, b }
|
||||
local mac_post = "%s%s%s%s" %{ c, d, e, f }
|
||||
local handle = f
|
||||
|
||||
function add_lease_rule(mac, ipaddr)
|
||||
if limit_up > 0 and limit_down > 0 then
|
||||
os.execute("iptables -t mangle -I luci_splash_mark -m mac --mac-source %q -j MARK --set-mark 79" % mac)
|
||||
|
||||
for _, i in ipairs(splash_interfaces) do
|
||||
os.execute("tc filter add dev %q parent 77:0 protocol ip prio 2 " % i ..
|
||||
"handle ::%q u32 " % handle ..
|
||||
"match u16 0x0800 0xFFFF at -2 match u32 0x%q 0xFFFFFFFF at -12 " % mac_post ..
|
||||
"match u16 0x%q 0xFFFF at -14 flowid 77:10" % mac_pre)
|
||||
end
|
||||
os.execute("iptables -t mangle -I luci_splash_mark_out -m mac --mac-source %q -j MARK --set-mark 79" % mac)
|
||||
os.execute("iptables -t mangle -I luci_splash_mark_in -d %q -j MARK --set-mark 80" % ipaddr)
|
||||
end
|
||||
|
||||
os.execute("iptables -t filter -I luci_splash_counter -m mac --mac-source %q -j RETURN" % mac)
|
||||
return os.execute("iptables -t nat -I luci_splash_leases -m mac --mac-source %q -j RETURN" % mac)
|
||||
os.execute("iptables -t filter -I luci_splash_filter -m mac --mac-source %q -j RETURN" % mac)
|
||||
os.execute("iptables -t nat -I luci_splash_leases -m mac --mac-source %q -j RETURN" % mac)
|
||||
end
|
||||
|
||||
|
||||
-- Remove an iptables rule
|
||||
function remove_rule(mac)
|
||||
local handle = mac:match("%w+:%w+:%w+:%w+:%w+:(%w+)")
|
||||
|
||||
local function ipt_delete_foreach(args)
|
||||
for _, r in ipairs(ipt:find(args)) do
|
||||
if r.options and #r.options >= 2 and r.options[1] == "MAC" and
|
||||
r.options[2]:lower() == mac:lower()
|
||||
then
|
||||
os.execute("iptables -t %q -D %q -m mac --mac-source %q %s 2>/dev/null"
|
||||
%{ r.table, r.chain, mac,
|
||||
r.target == "MARK" and "-j MARK --set-mark 79" or
|
||||
r.target and "-j %q" % r.target or "" })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ipt_delete_foreach({table="filter", chain="luci_splash_counter"})
|
||||
ipt_delete_foreach({table="mangle", chain="luci_splash_mark"})
|
||||
ipt_delete_foreach({table="nat", chain="luci_splash_leases"})
|
||||
|
||||
for _, i in ipairs(splash_interfaces) do
|
||||
os.execute("tc filter del dev %q parent 77:0 protocol ip prio 2 " % i ..
|
||||
"handle 800::%q u32 2>/dev/null" % handle)
|
||||
end
|
||||
|
||||
-- Remove lease, black- or whitelist rules
|
||||
function remove_lease_rule(mac, ipaddr)
|
||||
ipt:resync()
|
||||
end
|
||||
|
||||
|
||||
-- Check whether a MAC-Address is listed in the lease state list
|
||||
function haslease(mac)
|
||||
mac = mac:lower()
|
||||
local lease = nil
|
||||
|
||||
uci:foreach("luci_splash", "lease",
|
||||
function (section)
|
||||
if section.mac:lower() == mac then
|
||||
lease = section
|
||||
end
|
||||
end)
|
||||
|
||||
return lease
|
||||
end
|
||||
|
||||
|
||||
-- Check whether a MAC-Address is in given list
|
||||
function islisted(what, mac)
|
||||
mac = mac:lower()
|
||||
|
||||
uci:foreach("luci_splash", what,
|
||||
function (section)
|
||||
if section.mac:lower() == mac then
|
||||
stat = true
|
||||
return
|
||||
end
|
||||
end)
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
-- Returns a list of MAC-Addresses for which a rule is existing
|
||||
function listrules()
|
||||
local macs = { }
|
||||
for i, r in ipairs(ipt:find({table="nat", chain="luci_splash_leases"})) do
|
||||
if r.options and #r.options >= 2 and r.options[1] == "MAC" then
|
||||
macs[r.options[2]:lower()] = true
|
||||
end
|
||||
if ipaddr then
|
||||
ipt_delete_all({table="mangle", chain="luci_splash_mark_in", destination=ipaddr})
|
||||
ipt_delete_all({table="mangle", chain="luci_splash_mark_out", options={"MAC", mac:upper()}})
|
||||
end
|
||||
return luci.util.keys(macs)
|
||||
|
||||
ipt_delete_all({table="filter", chain="luci_splash_filter", options={"MAC", mac:upper()}})
|
||||
ipt_delete_all({table="nat", chain="luci_splash_leases", options={"MAC", mac:upper()}})
|
||||
end
|
||||
|
||||
|
||||
-- Add whitelist rules
|
||||
function add_whitelist_rule(mac)
|
||||
os.execute("iptables -t filter -I luci_splash_filter -m mac --mac-source %q -j RETURN" % mac)
|
||||
os.execute("iptables -t nat -I luci_splash_leases -m mac --mac-source %q -j RETURN" % mac)
|
||||
end
|
||||
|
||||
|
||||
-- Add blacklist rules
|
||||
function add_blacklist_rule(mac)
|
||||
os.execute("iptables -t filter -I luci_splash_filter -m mac --mac-source %q -j DROP" % mac)
|
||||
os.execute("iptables -t nat -I luci_splash_leases -m mac --mac-source %q -j DROP" % mac)
|
||||
end
|
||||
|
||||
|
||||
-- Synchronise leases, remove abandoned rules
|
||||
function sync()
|
||||
local written = {}
|
||||
lock()
|
||||
|
||||
local time = os.time()
|
||||
|
||||
|
||||
-- Current leases in state files
|
||||
local leases = uci:get_all("luci_splash")
|
||||
|
||||
|
@ -197,36 +335,105 @@ function sync()
|
|||
uci:load("luci_splash")
|
||||
uci: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)
|
||||
remove_lease_rule(v.mac, v.ipaddr)
|
||||
else
|
||||
-- Rewrite state
|
||||
uci:section("luci_splash", "lease", nil, {
|
||||
mac = v.mac,
|
||||
start = v.start,
|
||||
kicked = v.kicked
|
||||
ipaddr = v.ipaddr,
|
||||
start = v.start
|
||||
})
|
||||
written[v.mac:lower()] = 1
|
||||
end
|
||||
elseif v[".type"] == "whitelist" or v[".type"] == "blacklist" then
|
||||
written[v.mac:lower()] = 1
|
||||
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:save("luci_splash")
|
||||
|
||||
-- Get current IPs and MAC addresses
|
||||
local macs = get_known_macs()
|
||||
local ips = get_known_ips(macs)
|
||||
|
||||
ipt:resync()
|
||||
|
||||
ipt_delete_all({table="filter", chain="luci_splash_filter", options={"MAC"}},
|
||||
function(r) return not macs[r.options[2]:lower()] end)
|
||||
|
||||
ipt_delete_all({table="nat", chain="luci_splash_leases", options={"MAC"}},
|
||||
function(r) return not macs[r.options[2]:lower()] end)
|
||||
|
||||
ipt_delete_all({table="mangle", chain="luci_splash_mark_out", options={"MAC", "MARK", "set"}},
|
||||
function(r) return not macs[r.options[2]:lower()] end)
|
||||
|
||||
ipt_delete_all({table="mangle", chain="luci_splash_mark_in", options={"MARK", "set"}},
|
||||
function(r) return not ips[r.destination] end)
|
||||
|
||||
unlock()
|
||||
end
|
||||
|
||||
-- Show client info
|
||||
function list()
|
||||
-- Get current arp cache
|
||||
local arpcache = { }
|
||||
for _, entry in ipairs(net.arptable()) do
|
||||
arpcache[entry["HW address"]:lower()] = { entry["Device"]:lower(), entry["IP address"]:lower() }
|
||||
end
|
||||
|
||||
-- Find traffic usage
|
||||
local function traffic(lease)
|
||||
local traffic_in = 0
|
||||
local traffic_out = 0
|
||||
|
||||
local rin = ipt:find({table="mangle", chain="luci_splash_mark_in", destination=lease.ipaddr})
|
||||
local rout = ipt:find({table="mangle", chain="luci_splash_mark_out", options={"MAC", lease.mac:upper()}})
|
||||
|
||||
if rin and #rin > 0 then traffic_in = math.floor( rin[1].bytes / 1024) end
|
||||
if rout and #rout > 0 then traffic_out = math.floor(rout[1].bytes / 1024) end
|
||||
|
||||
return traffic_in, traffic_out
|
||||
end
|
||||
|
||||
-- Print listings
|
||||
local leases = uci:get_all("luci_splash")
|
||||
|
||||
print(string.format(
|
||||
"%-17s %-15s %-9s %-4s %-7s %20s",
|
||||
"MAC", "IP", "State", "Dur.", "Intf.", "Traffic down/up"
|
||||
))
|
||||
|
||||
-- Leases
|
||||
for _, s in pairs(leases) do
|
||||
if s[".type"] == "lease" and s.mac then
|
||||
local ti, to = traffic(s)
|
||||
local mac = s.mac:lower()
|
||||
local arp = arpcache[mac]
|
||||
print(string.format(
|
||||
"%-17s %-15s %-9s %3dm %-7s %7dKB %7dKB",
|
||||
mac, s.ipaddr, "leased",
|
||||
math.floor(( os.time() - tonumber(s.start) ) / 60),
|
||||
arp and arp[1] or "?", ti, to
|
||||
))
|
||||
end
|
||||
end
|
||||
|
||||
-- Whitelist, Blacklist
|
||||
for _, s in luci.util.spairs(leases,
|
||||
function(a,b) return leases[a][".type"] > leases[b][".type"] end
|
||||
) do
|
||||
if (s[".type"] == "whitelist" or s[".type"] == "blacklist") and s.mac then
|
||||
local mac = s.mac:lower()
|
||||
local arp = arpcache[mac]
|
||||
print(string.format(
|
||||
"%-17s %-15s %-9s %4s %-7s %9s %9s",
|
||||
mac, arp and arp[2] or "?", s[".type"],
|
||||
"- ", arp and arp[1] or "?", "-", "-"
|
||||
))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
main(arg)
|
||||
|
|
|
@ -4,4 +4,6 @@
|
|||
|
||||
/etc/init.d/luci_statistics enabled || /etc/init.d/luci_statistics enable
|
||||
/etc/init.d/collectd enabled || /etc/init.d/collectd enable
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ module("luci.controller.luci_statistics.luci_statistics", package.seeall)
|
|||
|
||||
function index()
|
||||
|
||||
require("luci.fs")
|
||||
require("nixio.fs")
|
||||
require("luci.util")
|
||||
require("luci.i18n")
|
||||
require("luci.statistics.datatree")
|
||||
|
@ -32,7 +32,7 @@ function index()
|
|||
-- override entry(): check for existance <plugin>.so where <plugin> is derived from the called path
|
||||
function _entry( path, ... )
|
||||
local file = path[5] or path[4]
|
||||
if luci.fs.access( "/usr/lib/collectd/" .. file .. ".so" ) then
|
||||
if nixio.fs.access( "/usr/lib/collectd/" .. file .. ".so" ) then
|
||||
entry( path, ... )
|
||||
end
|
||||
end
|
||||
|
@ -161,16 +161,28 @@ function statistics_render()
|
|||
local span = vars.timespan or uci:get( "luci_statistics", "rrdtool", "default_timespan" ) or spans[1]
|
||||
local graph = luci.statistics.rrdtool.Graph( luci.util.parse_units( span ) )
|
||||
|
||||
-- deliver image
|
||||
if vars.img then
|
||||
local l12 = require "luci.ltn12"
|
||||
local png = io.open(graph.opts.imgpath .. "/" .. vars.img:gsub("%.+", "."), "r")
|
||||
if png then
|
||||
luci.http.prepare_content("image/png")
|
||||
l12.pump.all(l12.source.file(png), luci.http.write)
|
||||
png:close()
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local plugin, instances
|
||||
local images = { }
|
||||
|
||||
-- find requested plugin and instance
|
||||
for i, p in ipairs( luci.dispatcher.context.path ) do
|
||||
if luci.dispatcher.context.path[i] == "graph" then
|
||||
plugin = luci.dispatcher.context.path[i+1]
|
||||
instances = { luci.dispatcher.context.path[i+2] }
|
||||
end
|
||||
for i, p in ipairs( luci.dispatcher.context.path ) do
|
||||
if luci.dispatcher.context.path[i] == "graph" then
|
||||
plugin = luci.dispatcher.context.path[i+1]
|
||||
instances = { luci.dispatcher.context.path[i+2] }
|
||||
end
|
||||
end
|
||||
|
||||
-- no instance requested, find all instances
|
||||
if #instances == 0 then
|
||||
|
|
|
@ -17,7 +17,7 @@ module("luci.statistics.datatree", package.seeall)
|
|||
|
||||
local util = require("luci.util")
|
||||
local sys = require("luci.sys")
|
||||
local fs = require("luci.fs")
|
||||
local fs = require("nixio.fs")
|
||||
local uci = require("luci.model.uci").cursor()
|
||||
local sections = uci:get_all("luci_statistics")
|
||||
|
||||
|
@ -50,6 +50,19 @@ function Instance._mkpath( self, plugin, pinstance )
|
|||
return dir
|
||||
end
|
||||
|
||||
function Instance._ls( self, ... )
|
||||
local ditr = fs.dir(self:_mkpath(...))
|
||||
if ditr then
|
||||
local dirs = { }
|
||||
while true do
|
||||
local d = ditr()
|
||||
if not d then break end
|
||||
dirs[#dirs+1] = d
|
||||
end
|
||||
return dirs
|
||||
end
|
||||
end
|
||||
|
||||
function Instance._notzero( self, table )
|
||||
for k in pairs(table) do
|
||||
return true
|
||||
|
@ -59,7 +72,7 @@ function Instance._notzero( self, table )
|
|||
end
|
||||
|
||||
function Instance._scan( self )
|
||||
local dirs = fs.dir( self:_mkpath() )
|
||||
local dirs = self:_ls()
|
||||
if not dirs then
|
||||
return
|
||||
end
|
||||
|
@ -72,7 +85,7 @@ function Instance._scan( self )
|
|||
|
||||
for _, dir in ipairs(dirs) do
|
||||
if dir ~= "." and dir ~= ".." and
|
||||
fs.stat(self:_mkpath(dir)).type == "directory"
|
||||
fs.stat(self:_mkpath(dir)).type == "dir"
|
||||
then
|
||||
local plugin = dir:gsub("%-.+$", "")
|
||||
if not self._plugins[plugin] then
|
||||
|
@ -83,7 +96,7 @@ function Instance._scan( self )
|
|||
|
||||
for plugin, instances in pairs( self._plugins ) do
|
||||
|
||||
local dirs = fs.dir( self:_mkpath() )
|
||||
local dirs = self:_ls()
|
||||
|
||||
if type(dirs) == "table" then
|
||||
for i, dir in ipairs(dirs) do
|
||||
|
@ -101,7 +114,7 @@ function Instance._scan( self )
|
|||
|
||||
for instance, data_instances in pairs( instances ) do
|
||||
|
||||
dirs = fs.dir( self:_mkpath( plugin, instance ) )
|
||||
dirs = self:_ls(plugin, instance)
|
||||
|
||||
if type(dirs) == "table" then
|
||||
for i, file in ipairs(dirs) do
|
||||
|
|
|
@ -43,13 +43,13 @@ end
|
|||
|
||||
function Instance.title( self, plugin, pinst, dtype, dinst )
|
||||
|
||||
local title = self.i18n.translate(
|
||||
local title = self.i18n.string(
|
||||
string.format( "stat_dg_title_%s_%s_%s", plugin, pinst, dtype ),
|
||||
self.i18n.translate(
|
||||
self.i18n.string(
|
||||
string.format( "stat_dg_title_%s_%s", plugin, pinst ),
|
||||
self.i18n.translate(
|
||||
self.i18n.string(
|
||||
string.format( "stat_dg_title_%s__%s", plugin, dtype ),
|
||||
self.i18n.translate(
|
||||
self.i18n.string(
|
||||
string.format( "stat_dg_title_%s", plugin ),
|
||||
self.graph:_mkpath( plugin, pinst, dtype )
|
||||
)
|
||||
|
@ -68,13 +68,13 @@ end
|
|||
|
||||
function Instance.label( self, plugin, pinst, dtype, dinst )
|
||||
|
||||
local label = self.i18n.translate(
|
||||
local label = self.i18n.string(
|
||||
string.format( "stat_dg_label_%s_%s_%s", plugin, pinst, dtype ),
|
||||
self.i18n.translate(
|
||||
self.i18n.string(
|
||||
string.format( "stat_dg_label_%s_%s", plugin, pinst ),
|
||||
self.i18n.translate(
|
||||
self.i18n.string(
|
||||
string.format( "stat_dg_label_%s__%s", plugin, dtype ),
|
||||
self.i18n.translate(
|
||||
self.i18n.string(
|
||||
string.format( "stat_dg_label_%s", plugin ),
|
||||
self.graph:_mkpath( plugin, pinst, dtype )
|
||||
)
|
||||
|
@ -93,13 +93,13 @@ end
|
|||
|
||||
function Instance.ds( self, source )
|
||||
|
||||
local label = self.i18n.translate(
|
||||
local label = self.i18n.string(
|
||||
string.format( "stat_ds_%s_%s_%s", source.type, source.instance, source.ds ),
|
||||
self.i18n.translate(
|
||||
self.i18n.string(
|
||||
string.format( "stat_ds_%s_%s", source.type, source.instance ),
|
||||
self.i18n.translate(
|
||||
self.i18n.string(
|
||||
string.format( "stat_ds_label_%s__%s", source.type, source.ds ),
|
||||
self.i18n.translate(
|
||||
self.i18n.string(
|
||||
string.format( "stat_ds_%s", source.type ),
|
||||
source.type .. "_" .. source.instance:gsub("[^%w]","_") .. "_" .. source.ds
|
||||
)
|
||||
|
|
|
@ -22,7 +22,8 @@ require("luci.statistics.i18n")
|
|||
require("luci.model.uci")
|
||||
require("luci.util")
|
||||
require("luci.sys")
|
||||
require("luci.fs")
|
||||
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
|
||||
Graph = luci.util.class()
|
||||
|
@ -96,7 +97,7 @@ function Graph._rrdtool( self, def, rrd )
|
|||
|
||||
-- prepare directory
|
||||
local dir = def[1]:gsub("/[^/]+$","")
|
||||
luci.fs.mkdir( dir, true )
|
||||
fs.mkdirr( dir )
|
||||
|
||||
-- construct commandline
|
||||
local cmdline = "rrdtool graph"
|
||||
|
@ -500,7 +501,7 @@ function Graph.render( self, plugin, plugin_instance )
|
|||
|
||||
-- check for a whole graph handler
|
||||
local plugin_def = "luci.statistics.rrdtool.definitions." .. plugin
|
||||
local stat, def = luci.util.copcall( require, plugin_def )
|
||||
local stat, def = pcall( require, plugin_def )
|
||||
|
||||
if stat and def and type(def.rrdargs) == "function" then
|
||||
|
||||
|
@ -539,7 +540,7 @@ function Graph.render( self, plugin, plugin_instance )
|
|||
|
||||
-- check for data type handler
|
||||
local dtype_def = plugin_def .. "." .. dtype
|
||||
local stat, def = luci.util.copcall( require, dtype_def )
|
||||
local stat, def = pcall( require, dtype_def )
|
||||
|
||||
if stat and def and type(def.rrdargs) == "function" then
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ $Id$
|
|||
module("luci.statistics.rrdtool.definitions", package.seeall)
|
||||
|
||||
require("luci.util")
|
||||
require("luci.fs")
|
||||
|
||||
|
||||
Instance = luci.util.class()
|
||||
|
|
|
@ -22,7 +22,7 @@ about open tcp connections, interface traffic, iptables rules etc.%></p>
|
|||
<p><%:stat_networkplugins_installed Installed network plugins:%>
|
||||
<ul>
|
||||
<% for plugin, desc in pairs(plugins) do %>
|
||||
<% if luci.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
|
||||
<% if nixio.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
|
||||
<li><a href="<%=controller%>/admin/statistics/collectd/network/<%=plugin%>"><%=desc%></a></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -23,7 +23,7 @@ and to transmit the data over the network to other collectd instances.%></p>
|
|||
<p><%:stat_outputplugins_installed Installed output plugins:%>
|
||||
<ul>
|
||||
<% for plugin, desc in pairs(plugins) do %>
|
||||
<% if luci.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
|
||||
<% if nixio.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
|
||||
<li><a href="<%=controller%>/admin/statistics/collectd/output/<%=plugin%>"><%=desc%></a></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -19,7 +19,7 @@ $Id$
|
|||
<p><%:stat_systemplugins_desc System plugins collecting values about system state and ressource usage on the device.:%>
|
||||
<ul>
|
||||
<% for plugin, desc in pairs(plugins) do %>
|
||||
<% if luci.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
|
||||
<% if nixio.fs.access("/usr/lib/collectd/" .. plugin .. ".so") then %>
|
||||
<li><a href="<%=controller%>/admin/statistics/collectd/system/<%=plugin%>"><%=desc%></a></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -31,7 +31,7 @@ $Id$
|
|||
|
||||
<div style="text-align: center">
|
||||
<% for i, img in ipairs(images) do %>
|
||||
<img src="/rrdimg/<%=img%>" />
|
||||
<img src="<%=REQUEST_URI%>?img=<%=img%>" />
|
||||
<br />
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
config 'statistics' 'rrdtool'
|
||||
option 'default_timespan' '1hour'
|
||||
option 'image_width' '400'
|
||||
option 'image_width' '600'
|
||||
option 'image_path' '/tmp/rrdimg'
|
||||
|
||||
config 'statistics' 'collectd'
|
||||
|
@ -8,7 +8,7 @@ config 'statistics' 'collectd'
|
|||
option 'Include' '/etc/collectd/conf.d'
|
||||
option 'PIDFile' '/var/run/collectd.pid'
|
||||
option 'PluginDir' '/usr/lib/collectd'
|
||||
option 'TypesDB' '/usr/lib/collectd/types.db'
|
||||
option 'TypesDB' '/usr/share/collectd/types.db'
|
||||
option 'Interval' '30'
|
||||
option 'ReadThreads' '2'
|
||||
|
||||
|
|
|
@ -13,14 +13,13 @@ start() {
|
|||
/usr/bin/stat-genconfig > /var/etc/collectd.conf
|
||||
|
||||
### prepare rrdimg directory
|
||||
if [ ! -L /www/rrdimg ]; then
|
||||
imagepath="$(uci get luci_statistics.rrdtool.image_path)"
|
||||
ln -s ${imagepath:-/tmp/rrdimg}/ /www/rrdimg
|
||||
if [ -f /etc/config/lucid ] && [ -x /etc/init.d/lucid ] && /etc/init.d/lucid enabled && \
|
||||
[ "$(uci get luci_statistics.rrdtool.image_path 2>/dev/null)" != "$(uci get lucid.statistics.physical 2>/dev/null)" ]; then
|
||||
uci set lucid.statistics.physical=$(uci get luci_statistics.rrdtool.image_path)
|
||||
uci commit lucid
|
||||
/etc/init.d/lucid restart
|
||||
fi
|
||||
|
||||
### flush LuCI index cache
|
||||
test -f /var/luci-indexcache && rm /var/luci-indexcache
|
||||
|
||||
### workaround broken permissions on /tmp
|
||||
chmod 1777 /tmp
|
||||
}
|
||||
|
|
|
@ -1,7 +1,35 @@
|
|||
#!/bin/sh
|
||||
|
||||
uci batch <<-EOF
|
||||
# register commit handler
|
||||
[ -f /etc/config/ucitrack ] && \
|
||||
[ "$(uci get ucitrack.@luci_statistics[0] 2>/dev/null)" != "luci_statistics" ] && \
|
||||
uci batch <<-EOF >/dev/null 2>/dev/null
|
||||
add ucitrack luci_statistics
|
||||
set ucitrack.@luci_statistics[-1].init=luci_statistics
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
# register LuCId virtual path handler
|
||||
[ -f /etc/config/lucid ] && \
|
||||
[ "$(uci get lucid.statistics 2>/dev/null)" != "DirectoryPublisher" ] && \
|
||||
uci batch <<-EOF >/dev/null 2>/dev/null
|
||||
set lucid.statistics=DirectoryPublisher
|
||||
set lucid.statistics.name='RRDTool Image Cache'
|
||||
set lucid.statistics.physical=/tmp/rrdimg
|
||||
set lucid.statistics.virtual=/rrdimg
|
||||
set lucid.statistics.domain=''
|
||||
|
||||
add_list lucid.http.publisher=statistics
|
||||
add_list lucid.https.publisher=statistics
|
||||
|
||||
commit lucid
|
||||
EOF
|
||||
|
||||
# symlink for busybox httpd
|
||||
[ -x /usr/sbin/httpd ] && [ ! -h /www/rrdimg ] && \
|
||||
ln -s /tmp/rrdimg /www/rrdimg
|
||||
|
||||
# restart LuCId service
|
||||
[ -x /etc/init.d/lucid ] && /etc/init.d/lucid enabled && /etc/init.d/lucid restart
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -25,6 +25,11 @@ local uci = luci.model.uci.cursor()
|
|||
local sections = uci:get_all( "luci_statistics" )
|
||||
|
||||
|
||||
function print(...)
|
||||
nixio.stdout:write(...)
|
||||
nixio.stdout:write("\n")
|
||||
end
|
||||
|
||||
function section( plugin )
|
||||
|
||||
local config = sections[ "collectd_" .. plugin ] or sections["collectd"]
|
||||
|
|
|
@ -15,11 +15,11 @@ $Id$
|
|||
module("luci.controller.tinyproxy", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/config/tinyproxy") then
|
||||
if not nixio.fs.access("/etc/config/tinyproxy") then
|
||||
return
|
||||
end
|
||||
|
||||
local page = entry({"admin", "services", "tinyproxy"}, cbi("tinyproxy"), "Tinyproxy")
|
||||
page.dependent = true
|
||||
page.i18n = "tinyproxy"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ $Id$
|
|||
module("luci.controller.upnp", package.seeall)
|
||||
|
||||
function index()
|
||||
if not luci.fs.access("/etc/config/upnpd") then
|
||||
if not nixio.fs.access("/etc/config/upnpd") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -18,18 +18,6 @@ s = m:section(NamedSection, "config", "upnpd", "")
|
|||
e = s:option(Flag, "enabled", translate("enable"))
|
||||
e.rmempty = false
|
||||
|
||||
function e.write(self, section, value)
|
||||
local cmd = (value == "1") and "enable" or "disable"
|
||||
if value ~= "1" then
|
||||
os.execute("/etc/init.d/miniupnpd stop")
|
||||
end
|
||||
os.execute("/etc/init.d/miniupnpd " .. cmd)
|
||||
end
|
||||
|
||||
function e.cfgvalue(self, section)
|
||||
return (os.execute("/etc/init.d/miniupnpd enabled") == 0) and "1" or "0"
|
||||
end
|
||||
|
||||
s:option(Flag, "secure_mode").rmempty = true
|
||||
s:option(Flag, "log_output").rmempty = true
|
||||
s:option(Value, "download", nil, "kByte/s").rmempty = true
|
||||
|
|
|
@ -18,18 +18,6 @@ s = m:section(NamedSection, "config", "upnpd", "")
|
|||
e = s:option(Flag, "enabled", translate("enable"))
|
||||
e.rmempty = false
|
||||
|
||||
function e.write(self, section, value)
|
||||
local cmd = (value == "1") and "enable" or "disable"
|
||||
if value ~= "1" then
|
||||
os.execute("/etc/init.d/miniupnpd stop")
|
||||
end
|
||||
os.execute("/etc/init.d/miniupnpd " .. cmd)
|
||||
end
|
||||
|
||||
function e.cfgvalue(self, section)
|
||||
return (os.execute("/etc/init.d/miniupnpd enabled") == 0) and "1" or "0"
|
||||
end
|
||||
|
||||
s:option(Value, "download", nil, "kByte/s").rmempty = true
|
||||
s:option(Value, "upload", nil, "kByte/s").rmempty = true
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ module("luci.controller.ushare", package.seeall)
|
|||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("ushare")
|
||||
if not luci.fs.access("/etc/config/ushare") then
|
||||
if not nixio.fs.access("/etc/config/ushare") then
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/sh
|
||||
[ -n "${IPKG_INSTROOT}" ] || {
|
||||
( . /etc/uci-defaults/luci-uvc_streamer ) && rm -f /etc/uci-defaults/luci-uvc_streamer
|
||||
/etc/init.d/uvc-streamer enabled || /etc/init.d/uvc-streamer enable
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
--[[
|
||||
|
||||
LuCI UVC Streamer
|
||||
(c) 2008 Yanira <forum-2008@email.de>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
$Id$
|
||||
|
||||
]]--
|
||||
|
||||
module("luci.controller.uvc_streamer", package.seeall)
|
||||
|
||||
function index()
|
||||
require("luci.i18n")
|
||||
luci.i18n.loadc("uvc_streamer")
|
||||
if not luci.fs.access("/etc/config/uvc-streamer") then
|
||||
return
|
||||
end
|
||||
|
||||
local page = entry({"admin", "services", "uvc_streamer"}, cbi("uvc_streamer"), luci.i18n.translate("uvc_streamer", "UVC Streaming"), 60)
|
||||
page.i18n = "uvc_streamer"
|
||||
page.dependent = true
|
||||
end
|
|
@ -1,47 +0,0 @@
|
|||
--[[
|
||||
|
||||
LuCI UVC Streamer
|
||||
(c) 2008 Yanira <forum-2008@email.de>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
$Id$
|
||||
|
||||
]]--
|
||||
|
||||
-- find current lan address and port of first uvc_streamer config section
|
||||
local uci = luci.model.uci.cursor_state()
|
||||
local addr = uci:get("network", "lan", "ipaddr")
|
||||
local port
|
||||
|
||||
uci:foreach( "uvc-streamer", "uvc-streamer",
|
||||
function(section) port = port or tonumber(section.port) end )
|
||||
|
||||
addr = addr or "192.168.1.1"
|
||||
port = port or 8080
|
||||
|
||||
m = Map("uvc-streamer", translate("uvc_streamer"),
|
||||
translatef("uvc_streamer_desc", nil, addr, port, addr, port))
|
||||
|
||||
s = m:section(TypedSection, "uvc-streamer", translate("settings"))
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
s:option(Flag, "enabled", translate("enabled", "Enable"))
|
||||
|
||||
s:option(Value, "device", translate("device")).rmempty = true
|
||||
|
||||
nm = s:option(Value, "resolution", translate("resolution"))
|
||||
nm:value("640x480")
|
||||
nm:value("320x240")
|
||||
nm:value("160x120")
|
||||
|
||||
s:option(Value, "framespersecond", translate("framespersecond")).rmempty = true
|
||||
|
||||
s:option(Value, "port", translate("port", "Port")).rmempty = true
|
||||
|
||||
return m
|
|
@ -1,7 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
uci batch <<-EOF
|
||||
add ucitrack uvc-streamer
|
||||
set ucitrack.@uvc-streamer[-1].init=uvc-streamer
|
||||
commit ucitrack
|
||||
EOF
|
|
@ -1,41 +0,0 @@
|
|||
#package uvc-streamer
|
||||
|
||||
config package
|
||||
option title 'UVC-Streamer webcam streaming configuration'
|
||||
|
||||
config section
|
||||
option name 'uvc-streamer'
|
||||
option package 'uvc-streamer'
|
||||
option title 'Settings'
|
||||
option unique true
|
||||
option required true
|
||||
|
||||
config variable
|
||||
option name 'enabled'
|
||||
option section 'uvc-streamer.uvc-streamer'
|
||||
option title 'Enable'
|
||||
option required true
|
||||
option datatype boolean
|
||||
|
||||
config variable
|
||||
option name 'device'
|
||||
option section 'uvc-streamer.uvc-streamer'
|
||||
option title 'Device'
|
||||
|
||||
config variable
|
||||
option name 'resolution'
|
||||
option section 'uvc-streamer.uvc-streamer'
|
||||
option title 'Resolution'
|
||||
option required true
|
||||
|
||||
config variable
|
||||
option name 'framespersecond'
|
||||
option section 'uvc-streamer.uvc-streamer'
|
||||
option title 'Frames per second'
|
||||
option datatype uint
|
||||
|
||||
config variable
|
||||
option name 'port'
|
||||
option section 'uvc-streamer.uvc-streamer'
|
||||
option title 'Port'
|
||||
option datatype port
|
|
@ -10,7 +10,7 @@ RANLIB = ranlib
|
|||
CFLAGS = -O2
|
||||
FPIC = -fPIC
|
||||
EXTRA_CFLAGS = --std=gnu99
|
||||
WFLAGS = -Wall -Werror -pedantic
|
||||
WFLAGS = -Wall -pedantic
|
||||
CPPFLAGS =
|
||||
COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $(WFLAGS)
|
||||
ifeq ($(OS),Darwin)
|
||||
|
|
|
@ -10,67 +10,17 @@ if( ! -d $target_dir )
|
|||
system('mkdir', '-p', $target_dir);
|
||||
}
|
||||
|
||||
|
||||
my %target_strings;
|
||||
|
||||
|
||||
if( open F, "find $source_dir -type f -name '*.po' |" )
|
||||
{
|
||||
while( chomp( my $file = readline F ) )
|
||||
{
|
||||
if( open L, "< $file" )
|
||||
{
|
||||
my $content = 0;
|
||||
my ( $lang, $basename ) = $file =~ m{.+/(\w+)/([^/]+)\.po$};
|
||||
$lang = lc $lang;
|
||||
$lang =~ s/_/-/g;
|
||||
|
||||
if( open D, "> $target_dir/$basename.$lang.lua" )
|
||||
{
|
||||
printf "Generating %-40s ", "$target_dir/$basename.$lang.lua";
|
||||
my ( $lang, $basename ) = $file =~ m{.+/(\w+)/([^/]+)\.po$};
|
||||
$lang = lc $lang;
|
||||
$lang =~ s/_/-/g;
|
||||
|
||||
my ( $k, $v );
|
||||
|
||||
while( chomp( my $line = readline L ) || ( defined($k) && defined($v) ) )
|
||||
{
|
||||
if( $line =~ /^msgid "(.+)"/ )
|
||||
{
|
||||
$k = $1;
|
||||
}
|
||||
elsif( $k && $line =~ /^msgstr "(.*)"/ )
|
||||
{
|
||||
$v = $1;
|
||||
}
|
||||
elsif( $k && defined($v) && $line =~ /^"(.+)"/ )
|
||||
{
|
||||
$v .= $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( $k && defined($v) && length($v) > 0 )
|
||||
{
|
||||
$v =~ s/\\(['"\\])/$1/g;
|
||||
$v =~ s/(['\\])/\\$1/g;
|
||||
|
||||
printf D "%s='%s'\n", $k, $v;
|
||||
$content++;
|
||||
}
|
||||
|
||||
$k = $v = undef;
|
||||
}
|
||||
}
|
||||
|
||||
print $content ? "done ($content strings)\n" : "empty\n";
|
||||
|
||||
close D;
|
||||
|
||||
|
||||
unlink("$target_dir/$basename.$lang.lua")
|
||||
unless( $content > 0 );
|
||||
}
|
||||
|
||||
close L;
|
||||
}
|
||||
printf "Generating %-40s ", "$target_dir/$basename.$lang.lmo";
|
||||
system("./build/po2lmo", $file, "$target_dir/$basename.$lang.lmo");
|
||||
print ( -f "$target_dir/$basename.$lang.lmo" ? "done\n" : "empty\n" );
|
||||
}
|
||||
|
||||
close F;
|
||||
|
|
2
build/lucid.lua
Normal file
2
build/lucid.lua
Normal file
|
@ -0,0 +1,2 @@
|
|||
dofile "build/setup.lua"
|
||||
require "luci.lucid".start()
|
|
@ -11,10 +11,17 @@ else
|
|||
fi
|
||||
|
||||
cat <<EOF > $1
|
||||
local pcall, dofile, _G = pcall, dofile, _G
|
||||
|
||||
module "luci.version"
|
||||
|
||||
distname = "${2:-OpenWrt}"
|
||||
distversion = "${3:-Development Snapshot}"
|
||||
if pcall(dofile, "/etc/openwrt_release") and _G.DISTRIB_DESCRIPTION then
|
||||
distname = ""
|
||||
distversion = _G.DISTRIB_DESCRIPTION
|
||||
else
|
||||
distname = "${2:-OpenWrt}"
|
||||
distversion = "${3:-Development Snapshot}"
|
||||
end
|
||||
|
||||
luciname = "$variant"
|
||||
luciversion = "${5:-svn}"
|
||||
|
|
|
@ -27,7 +27,7 @@ luasource:
|
|||
ifneq ($(PO),)
|
||||
mkdir -p dist$(LUCI_I18NDIR)
|
||||
for file in $(PO); do \
|
||||
cp $(HOST)/lua-po/$$file.$(if $(PO_LANG),$(PO_LANG),*).lua dist$(LUCI_I18NDIR)/ 2>/dev/null || true; \
|
||||
cp $(HOST)/lua-po/$$file.$(if $(PO_LANG),$(PO_LANG),*).* dist$(LUCI_I18NDIR)/ 2>/dev/null || true; \
|
||||
done
|
||||
endif
|
||||
|
||||
|
|
|
@ -9,3 +9,5 @@
|
|||
x(self, schemedir or SYSROOT .. "/lib/uci/schema")
|
||||
end
|
||||
|
||||
local sys = require "luci.sys"
|
||||
sys.user.checkpasswd = function() return true end
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2008 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
# $Id$
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=axtls
|
||||
PKG_VERSION:=1.2.0
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_BUILD_DIR=$(BUILD_DIR)/axTLS
|
||||
PKG_SOURCE:=axTLS-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@SF/axtls
|
||||
PKG_MD5SUM:=af805c76c0da1dbfc0c5e6b8dbd6706a
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
# set to 1 to enable debugging
|
||||
DEBUG=
|
||||
|
||||
define Package/libaxtls
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=axTLS embedded SSL library
|
||||
endef
|
||||
|
||||
define Package/axhttpd
|
||||
SUBMENU:=Web
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+libaxtls
|
||||
TITLE:=axTLS embedded http/https server
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
$(INSTALL_DIR) $(PKG_BUILD_DIR)/config
|
||||
$(CP) ./files/axtls-config $(PKG_BUILD_DIR)/config/.config
|
||||
$(CP) ./files/axtls-config.h $(PKG_BUILD_DIR)/config/config.h
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += $(FPIC)
|
||||
|
||||
#define Build/Compile
|
||||
# $(MAKE) -C $(PKG_BUILD_DIR)
|
||||
#endef
|
||||
|
||||
define Package/libaxtls/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_BUILD_DIR)/_stage/libaxtls.so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/axhttpd/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/_stage/axhttpd $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,libaxtls))
|
||||
$(eval $(call BuildPackage,axhttpd))
|
|
@ -1,116 +0,0 @@
|
|||
#
|
||||
# Automatically generated make config: don't edit
|
||||
#
|
||||
HAVE_DOT_CONFIG=y
|
||||
CONFIG_PLATFORM_LINUX=y
|
||||
# CONFIG_PLATFORM_CYGWIN is not set
|
||||
# CONFIG_PLATFORM_WIN32 is not set
|
||||
|
||||
#
|
||||
# General Configuration
|
||||
#
|
||||
PREFIX="/usr/local"
|
||||
# CONFIG_DEBUG is not set
|
||||
# CONFIG_STRIP_UNWANTED_SECTIONS is not set
|
||||
# CONFIG_VISUAL_STUDIO_7_0 is not set
|
||||
# CONFIG_VISUAL_STUDIO_8_0 is not set
|
||||
CONFIG_VISUAL_STUDIO_7_0_BASE=""
|
||||
CONFIG_VISUAL_STUDIO_8_0_BASE=""
|
||||
CONFIG_EXTRA_CFLAGS_OPTIONS="-fPIC"
|
||||
CONFIG_EXTRA_LDFLAGS_OPTIONS="-lc -lm"
|
||||
|
||||
#
|
||||
# SSL Library
|
||||
#
|
||||
# CONFIG_SSL_SERVER_ONLY is not set
|
||||
# CONFIG_SSL_CERT_VERIFICATION is not set
|
||||
# CONFIG_SSL_ENABLE_CLIENT is not set
|
||||
# CONFIG_SSL_FULL_MODE is not set
|
||||
CONFIG_SSL_SKELETON_MODE=y
|
||||
# CONFIG_SSL_PROT_LOW is not set
|
||||
# CONFIG_SSL_PROT_MEDIUM is not set
|
||||
# CONFIG_SSL_PROT_HIGH is not set
|
||||
# CONFIG_SSL_USE_DEFAULT_KEY is not set
|
||||
CONFIG_SSL_PRIVATE_KEY_LOCATION=""
|
||||
CONFIG_SSL_PRIVATE_KEY_PASSWORD=""
|
||||
CONFIG_SSL_X509_CERT_LOCATION=""
|
||||
# CONFIG_SSL_GENERATE_X509_CERT is not set
|
||||
CONFIG_SSL_X509_COMMON_NAME=""
|
||||
CONFIG_SSL_X509_ORGANIZATION_NAME=""
|
||||
CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME=""
|
||||
CONFIG_SSL_ENABLE_V23_HANDSHAKE=y
|
||||
# CONFIG_SSL_HAS_PEM is not set
|
||||
# CONFIG_SSL_USE_PKCS12 is not set
|
||||
CONFIG_SSL_EXPIRY_TIME=0
|
||||
CONFIG_X509_MAX_CA_CERTS=0
|
||||
CONFIG_SSL_MAX_CERTS=2
|
||||
# CONFIG_SSL_CTX_MUTEXING is not set
|
||||
CONFIG_USE_DEV_URANDOM=y
|
||||
# CONFIG_WIN32_USE_CRYPTO_LIB is not set
|
||||
# CONFIG_OPENSSL_COMPATIBLE is not set
|
||||
# CONFIG_PERFORMANCE_TESTING is not set
|
||||
# CONFIG_SSL_TEST is not set
|
||||
CONFIG_AXHTTPD=y
|
||||
|
||||
#
|
||||
# Axhttpd Configuration
|
||||
#
|
||||
# CONFIG_HTTP_STATIC_BUILD is not set
|
||||
CONFIG_HTTP_PORT=80
|
||||
CONFIG_HTTP_HTTPS_PORT=443
|
||||
CONFIG_HTTP_SESSION_CACHE_SIZE=5
|
||||
CONFIG_HTTP_WEBROOT="/www"
|
||||
CONFIG_HTTP_TIMEOUT=300
|
||||
|
||||
#
|
||||
# CGI
|
||||
#
|
||||
CONFIG_HTTP_HAS_CGI=y
|
||||
CONFIG_HTTP_CGI_EXTENSIONS="luci"
|
||||
# CONFIG_HTTP_ENABLE_LUA is not set
|
||||
CONFIG_HTTP_LUA_PREFIX=""
|
||||
CONFIG_HTTP_LUA_CGI_LAUNCHER=""
|
||||
# CONFIG_HTTP_BUILD_LUA is not set
|
||||
CONFIG_HTTP_DIRECTORIES=y
|
||||
# CONFIG_HTTP_HAS_AUTHORIZATION is not set
|
||||
# CONFIG_HTTP_HAS_IPV6 is not set
|
||||
# CONFIG_HTTP_ENABLE_DIFFERENT_USER is not set
|
||||
CONFIG_HTTP_USER=""
|
||||
# CONFIG_HTTP_VERBOSE is not set
|
||||
CONFIG_HTTP_IS_DAEMON=y
|
||||
|
||||
#
|
||||
# Language Bindings
|
||||
#
|
||||
# CONFIG_BINDINGS is not set
|
||||
# CONFIG_CSHARP_BINDINGS is not set
|
||||
# CONFIG_VBNET_BINDINGS is not set
|
||||
CONFIG_DOT_NET_FRAMEWORK_BASE=""
|
||||
# CONFIG_JAVA_BINDINGS is not set
|
||||
CONFIG_JAVA_HOME=""
|
||||
# CONFIG_PERL_BINDINGS is not set
|
||||
CONFIG_PERL_CORE=""
|
||||
CONFIG_PERL_LIB=""
|
||||
# CONFIG_LUA_BINDINGS is not set
|
||||
CONFIG_LUA_CORE=""
|
||||
|
||||
#
|
||||
# Samples
|
||||
#
|
||||
# CONFIG_SAMPLES is not set
|
||||
# CONFIG_C_SAMPLES is not set
|
||||
# CONFIG_CSHARP_SAMPLES is not set
|
||||
# CONFIG_VBNET_SAMPLES is not set
|
||||
# CONFIG_JAVA_SAMPLES is not set
|
||||
# CONFIG_PERL_SAMPLES is not set
|
||||
# CONFIG_LUA_SAMPLES is not set
|
||||
# CONFIG_BIGINT_CLASSICAL is not set
|
||||
# CONFIG_BIGINT_MONTGOMERY is not set
|
||||
# CONFIG_BIGINT_BARRETT is not set
|
||||
# CONFIG_BIGINT_CRT is not set
|
||||
# CONFIG_BIGINT_KARATSUBA is not set
|
||||
MUL_KARATSUBA_THRESH=0
|
||||
SQU_KARATSUBA_THRESH=0
|
||||
# CONFIG_BIGINT_SLIDING_WINDOW is not set
|
||||
# CONFIG_BIGINT_SQUARE is not set
|
||||
# CONFIG_BIGINT_CHECK_ON is not set
|
|
@ -1,117 +0,0 @@
|
|||
/*
|
||||
* Automatically generated header file: don't edit
|
||||
*/
|
||||
|
||||
#define HAVE_DOT_CONFIG 1
|
||||
#define CONFIG_PLATFORM_LINUX 1
|
||||
#undef CONFIG_PLATFORM_CYGWIN
|
||||
#undef CONFIG_PLATFORM_WIN32
|
||||
|
||||
/*
|
||||
* General Configuration
|
||||
*/
|
||||
#define PREFIX "/usr/local"
|
||||
#undef CONFIG_DEBUG
|
||||
#undef CONFIG_STRIP_UNWANTED_SECTIONS
|
||||
#undef CONFIG_VISUAL_STUDIO_7_0
|
||||
#undef CONFIG_VISUAL_STUDIO_8_0
|
||||
#define CONFIG_VISUAL_STUDIO_7_0_BASE ""
|
||||
#define CONFIG_VISUAL_STUDIO_8_0_BASE ""
|
||||
#define CONFIG_EXTRA_CFLAGS_OPTIONS "-fPIC"
|
||||
#define CONFIG_EXTRA_LDFLAGS_OPTIONS "-lc -lm"
|
||||
|
||||
/*
|
||||
* SSL Library
|
||||
*/
|
||||
#undef CONFIG_SSL_SERVER_ONLY
|
||||
#undef CONFIG_SSL_CERT_VERIFICATION
|
||||
#undef CONFIG_SSL_ENABLE_CLIENT
|
||||
#undef CONFIG_SSL_FULL_MODE
|
||||
#define CONFIG_SSL_SKELETON_MODE 1
|
||||
#undef CONFIG_SSL_PROT_LOW
|
||||
#undef CONFIG_SSL_PROT_MEDIUM
|
||||
#undef CONFIG_SSL_PROT_HIGH
|
||||
#undef CONFIG_SSL_USE_DEFAULT_KEY
|
||||
#define CONFIG_SSL_PRIVATE_KEY_LOCATION ""
|
||||
#define CONFIG_SSL_PRIVATE_KEY_PASSWORD ""
|
||||
#define CONFIG_SSL_X509_CERT_LOCATION ""
|
||||
#undef CONFIG_SSL_GENERATE_X509_CERT
|
||||
#define CONFIG_SSL_X509_COMMON_NAME ""
|
||||
#define CONFIG_SSL_X509_ORGANIZATION_NAME ""
|
||||
#define CONFIG_SSL_X509_ORGANIZATION_UNIT_NAME ""
|
||||
#define CONFIG_SSL_ENABLE_V23_HANDSHAKE 1
|
||||
#undef CONFIG_SSL_HAS_PEM
|
||||
#undef CONFIG_SSL_USE_PKCS12
|
||||
#define CONFIG_SSL_EXPIRY_TIME
|
||||
#define CONFIG_X509_MAX_CA_CERTS
|
||||
#define CONFIG_SSL_MAX_CERTS 2
|
||||
#undef CONFIG_SSL_CTX_MUTEXING
|
||||
#define CONFIG_USE_DEV_URANDOM 1
|
||||
#undef CONFIG_WIN32_USE_CRYPTO_LIB
|
||||
#undef CONFIG_OPENSSL_COMPATIBLE
|
||||
#undef CONFIG_PERFORMANCE_TESTING
|
||||
#undef CONFIG_SSL_TEST
|
||||
#define CONFIG_AXHTTPD 1
|
||||
|
||||
/*
|
||||
* Axhttpd Configuration
|
||||
*/
|
||||
#undef CONFIG_HTTP_STATIC_BUILD
|
||||
#define CONFIG_HTTP_PORT 80
|
||||
#define CONFIG_HTTP_HTTPS_PORT 443
|
||||
#define CONFIG_HTTP_SESSION_CACHE_SIZE 5
|
||||
#define CONFIG_HTTP_WEBROOT "/www"
|
||||
#define CONFIG_HTTP_TIMEOUT 300
|
||||
|
||||
/*
|
||||
* CGI
|
||||
*/
|
||||
#define CONFIG_HTTP_HAS_CGI 1
|
||||
#define CONFIG_HTTP_CGI_EXTENSIONS "luci"
|
||||
#undef CONFIG_HTTP_ENABLE_LUA
|
||||
#define CONFIG_HTTP_LUA_PREFIX ""
|
||||
#define CONFIG_HTTP_LUA_CGI_LAUNCHER ""
|
||||
#undef CONFIG_HTTP_BUILD_LUA
|
||||
#define CONFIG_HTTP_DIRECTORIES 1
|
||||
#undef CONFIG_HTTP_HAS_AUTHORIZATION
|
||||
#undef CONFIG_HTTP_HAS_IPV6
|
||||
#undef CONFIG_HTTP_ENABLE_DIFFERENT_USER
|
||||
#define CONFIG_HTTP_USER ""
|
||||
#undef CONFIG_HTTP_VERBOSE
|
||||
#define CONFIG_HTTP_IS_DAEMON 1
|
||||
|
||||
/*
|
||||
* Language Bindings
|
||||
*/
|
||||
#undef CONFIG_BINDINGS
|
||||
#undef CONFIG_CSHARP_BINDINGS
|
||||
#undef CONFIG_VBNET_BINDINGS
|
||||
#define CONFIG_DOT_NET_FRAMEWORK_BASE ""
|
||||
#undef CONFIG_JAVA_BINDINGS
|
||||
#define CONFIG_JAVA_HOME ""
|
||||
#undef CONFIG_PERL_BINDINGS
|
||||
#define CONFIG_PERL_CORE ""
|
||||
#define CONFIG_PERL_LIB ""
|
||||
#undef CONFIG_LUA_BINDINGS
|
||||
#define CONFIG_LUA_CORE ""
|
||||
|
||||
/*
|
||||
* Samples
|
||||
*/
|
||||
#undef CONFIG_SAMPLES
|
||||
#undef CONFIG_C_SAMPLES
|
||||
#undef CONFIG_CSHARP_SAMPLES
|
||||
#undef CONFIG_VBNET_SAMPLES
|
||||
#undef CONFIG_JAVA_SAMPLES
|
||||
#undef CONFIG_PERL_SAMPLES
|
||||
#undef CONFIG_LUA_SAMPLES
|
||||
#undef CONFIG_BIGINT_CLASSICAL
|
||||
#undef CONFIG_BIGINT_MONTGOMERY
|
||||
#undef CONFIG_BIGINT_BARRETT
|
||||
#undef CONFIG_BIGINT_CRT
|
||||
#undef CONFIG_BIGINT_KARATSUBA
|
||||
#define MUL_KARATSUBA_THRESH
|
||||
#define SQU_KARATSUBA_THRESH
|
||||
#undef CONFIG_BIGINT_SLIDING_WINDOW
|
||||
#undef CONFIG_BIGINT_SQUARE
|
||||
#undef CONFIG_BIGINT_CHECK_ON
|
|
@ -1,12 +0,0 @@
|
|||
diff -urb axTLS.orig/ssl/Makefile axTLS/ssl/Makefile
|
||||
--- axTLS.orig/ssl/Makefile 2008-11-09 00:58:43.000000000 +0000
|
||||
+++ axTLS/ssl/Makefile 2008-11-09 00:58:57.000000000 +0000
|
||||
@@ -96,7 +96,7 @@
|
||||
|
||||
$(TARGET2) : $(OBJ)
|
||||
ifndef CONFIG_PLATFORM_CYGWIN
|
||||
- $(LD) $(LDFLAGS) $(LDSHARED) -Wl,-soname,$(LIBMAJOR) -o $(AXTLS_HOME)/$(STAGE)/$(LIBMINOR) $(CRYPTO_OBJ) $(OBJ)
|
||||
+ $(LD) $(LDFLAGS) $(LDSHARED) -o $(AXTLS_HOME)/$(STAGE)/$(LIBMINOR) $(CRYPTO_OBJ) $(OBJ)
|
||||
cd $(AXTLS_HOME)/$(STAGE); ln -sf $(LIBMINOR) $(LIBMAJOR); ln -sf $(LIBMAJOR) $(BASETARGET); cd -
|
||||
else
|
||||
$(LD) $(LDFLAGS) $(LDSHARED) -o $(AXTLS_HOME)/$(STAGE)/cygaxtls.dll \
|
|
@ -1,12 +0,0 @@
|
|||
diff -urb axTLS.orig/httpd/Makefile axTLS/httpd/Makefile
|
||||
--- axTLS.orig/httpd/Makefile 2008-11-09 00:58:44.000000000 +0000
|
||||
+++ axTLS/httpd/Makefile 2008-11-09 01:29:55.000000000 +0000
|
||||
@@ -95,7 +95,7 @@
|
||||
ifndef CONFIG_PLATFORM_WIN32
|
||||
|
||||
$(TARGET): $(OBJ) $(AXTLS_HOME)/$(STAGE)/libaxtls.a
|
||||
- $(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
||||
+ $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
||||
ifdef CONFIG_STRIP_UNWANTED_SECTIONS
|
||||
strip --remove-section=.comment $(TARGET)
|
||||
endif
|
|
@ -1,37 +0,0 @@
|
|||
diff -urb axTLS.orig/httpd/axhttp.h axTLS/httpd/axhttp.h
|
||||
--- axTLS.orig/httpd/axhttp.h 2008-11-09 00:58:44.000000000 +0000
|
||||
+++ axTLS/httpd/axhttp.h 2008-11-09 02:33:44.000000000 +0000
|
||||
@@ -91,6 +91,7 @@
|
||||
uint8_t is_lua;
|
||||
#endif
|
||||
int content_length;
|
||||
+ char content_type[MAXREQUESTLENGTH];
|
||||
char remote_addr[MAXREQUESTLENGTH];
|
||||
char uri_request[MAXREQUESTLENGTH];
|
||||
char uri_path_info[MAXREQUESTLENGTH];
|
||||
diff -urb axTLS.orig/httpd/proc.c axTLS/httpd/proc.c
|
||||
--- axTLS.orig/httpd/proc.c 2008-11-09 00:58:44.000000000 +0000
|
||||
+++ axTLS/httpd/proc.c 2008-11-09 02:43:32.000000000 +0000
|
||||
@@ -129,6 +129,10 @@
|
||||
|
||||
my_strncpy(cn->server_name, value, MAXREQUESTLENGTH);
|
||||
}
|
||||
+ else if (strcmp(buf, "Content-Type:") == 0 )
|
||||
+ {
|
||||
+ my_strncpy(cn->content_type, value, MAXREQUESTLENGTH);
|
||||
+ }
|
||||
else if (strcmp(buf, "Connection:") == 0 && strcmp(value, "close") == 0)
|
||||
{
|
||||
cn->close_when_done = 1;
|
||||
@@ -673,8 +677,9 @@
|
||||
type = "POST";
|
||||
sprintf(cgienv[cgi_index++],
|
||||
"CONTENT_LENGTH=%d", cn->content_length);
|
||||
- strcpy(cgienv[cgi_index++], /* hard-code? */
|
||||
- "CONTENT_TYPE=application/x-www-form-urlencoded");
|
||||
+ snprintf(cgienv[cgi_index++], MAXREQUESTLENGTH,
|
||||
+ "CONTENT_TYPE=%s", cn->content_type);
|
||||
+
|
||||
break;
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
--- axTLS/httpd/proc.c 2008-11-13 14:05:02.000000000 +0100
|
||||
+++ axTLS.new/httpd/proc.c 2008-11-13 16:07:12.000000000 +0100
|
||||
@@ -556,13 +556,13 @@
|
||||
int tmp_stdout;
|
||||
#endif
|
||||
|
||||
- snprintf(cgienv[0], MAXREQUESTLENGTH,
|
||||
+ if (cn->reqtype == TYPE_HEAD)
|
||||
+ {
|
||||
+ snprintf(cgienv[0], MAXREQUESTLENGTH,
|
||||
HTTP_VERSION" 200 OK\nServer: %s\n%s",
|
||||
server_version, (cn->reqtype == TYPE_HEAD) ? "\n" : "");
|
||||
- special_write(cn, cgienv[0], strlen(cgienv[0]));
|
||||
+ special_write(cn, cgienv[0], strlen(cgienv[0]));
|
||||
|
||||
- if (cn->reqtype == TYPE_HEAD)
|
||||
- {
|
||||
removeconnection(cn);
|
||||
return;
|
||||
}
|
1
contrib/bitlib/.gitignore
vendored
1
contrib/bitlib/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
bitlib-*
|
|
@ -1,36 +0,0 @@
|
|||
include ../../build/config.mk
|
||||
include ../../build/gccconfig.mk
|
||||
|
||||
BITLIB_VERSION = 25
|
||||
BITLIB_SITE = http://dev.luci.freifunk-halle.net/sources/
|
||||
BITLIB_DIR = bitlib-$(BITLIB_VERSION)
|
||||
BITLIB_FILE = $(BITLIB_DIR).tar.gz
|
||||
BITLIB_URL = $(BITLIB_SITE)/$(BITLIB_FILE)
|
||||
|
||||
all: compile
|
||||
|
||||
include ../../build/module.mk
|
||||
|
||||
$(BITLIB_FILE):
|
||||
wget -O $@ $(BITLIB_URL) || rm -f $@
|
||||
|
||||
$(BITLIB_DIR)/.prepared: $(BITLIB_FILE)
|
||||
rm -rf $(BITLIB_DIR)
|
||||
tar xvfz $(BITLIB_FILE)
|
||||
test -f $(BITLIB_DIR)/config.h || cp $(BITLIB_DIR)/config.h.in $(BITLIB_DIR)/config.h
|
||||
touch $@
|
||||
|
||||
compile: $(BITLIB_DIR)/.prepared dist$(LUA_LIBRARYDIR)/bit.so
|
||||
|
||||
dist$(LUA_LIBRARYDIR)/bit.so:
|
||||
mkdir -p dist$(LUA_LIBRARYDIR)
|
||||
$(COMPILE) -DHAVE_CONFIG_H -I$(BITLIB_DIR) -O2 -c $(BITLIB_DIR)/lbitlib.c $(FPIC) $(LUA_CFLAGS) -o $(BITLIB_DIR)/lbitlib.o
|
||||
$(LINK) $(SHLIB_FLAGS) $(LDFLAGS) $(BITLIB_DIR)/lbitlib.o $(LUA_SHLIBS) -lm -ldl -o dist$(LUA_LIBRARYDIR)/bit.so
|
||||
|
||||
luasource:
|
||||
luastrip:
|
||||
luacompile:
|
||||
compile-all: compile
|
||||
|
||||
clean:
|
||||
rm -rf $(BITLIB_DIR) $(BITLIB_FILE)
|
|
@ -5,6 +5,7 @@ LDFLAGS :=
|
|||
OBJ = cli.o lar.o md5.o
|
||||
BIN = lar
|
||||
|
||||
compile:
|
||||
cli: $(OBJ)
|
||||
$(GCC) $(CFLAGS) -o $(BIN) $(OBJ) $(LDFLAGS)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
local assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type = assert, getfenv, ipairs, loadstring, pairs, setfenv, tostring, tonumber, type
|
||||
local io = require"io"
|
||||
local posix = require "posix"
|
||||
local posix = require "nixio.fs"
|
||||
local lp = require "luadoc.lp"
|
||||
local luadoc = require"luadoc"
|
||||
local package = package
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
local assert, pairs, tostring, type = assert, pairs, tostring, type
|
||||
local io = require "io"
|
||||
local posix = require "posix"
|
||||
local posix = require "nixio.fs"
|
||||
local luadoc = require "luadoc"
|
||||
local util = require "luadoc.util"
|
||||
local tags = require "luadoc.taglet.standard.tags"
|
||||
|
@ -505,14 +505,14 @@ end
|
|||
-- @return table with documentation
|
||||
|
||||
function directory (path, doc)
|
||||
for f in posix.files(path) do
|
||||
for f in posix.dir(path) do
|
||||
local fullpath = path .. "/" .. f
|
||||
local attr = posix.stat(fullpath)
|
||||
assert(attr, string.format("error stating file `%s'", fullpath))
|
||||
|
||||
if attr.type == "regular" then
|
||||
if attr.type == "reg" then
|
||||
doc = file(fullpath, doc)
|
||||
elseif attr.type == "directory" and f ~= "." and f ~= ".." then
|
||||
elseif attr.type == "dir" and f ~= "." and f ~= ".." then
|
||||
doc = directory(fullpath, doc)
|
||||
end
|
||||
end
|
||||
|
@ -550,9 +550,9 @@ function start (files, doc)
|
|||
local attr = posix.stat(path)
|
||||
assert(attr, string.format("error stating path `%s'", path))
|
||||
|
||||
if attr.type == "regular" then
|
||||
if attr.type == "reg" then
|
||||
doc = file(path, doc)
|
||||
elseif attr.type == "directory" then
|
||||
elseif attr.type == "dir" then
|
||||
doc = directory(path, doc)
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
-- @release $Id: util.lua,v 1.16 2008/02/17 06:42:51 jasonsantos Exp $
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local posix = require "posix"
|
||||
local posix = require "nixio.fs"
|
||||
local type, table, string, io, assert, tostring, setmetatable, pcall = type, table, string, io, assert, tostring, setmetatable, pcall
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
|
3
contrib/luaposix/.gitignore
vendored
3
contrib/luaposix/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
|||
luaposix-*
|
||||
lua-posix_*
|
||||
patches/series
|
|
@ -1,35 +0,0 @@
|
|||
include ../../build/config.mk
|
||||
include ../../build/gccconfig.mk
|
||||
|
||||
LUAPOSIX_VERSION = 5.1.4
|
||||
LUAPOSIX_SITE = http://dev.luci.freifunk-halle.net/sources/
|
||||
LUAPOSIX_DIR = luaposix-$(LUAPOSIX_VERSION)
|
||||
LUAPOSIX_FILE = lua-posix_5.1.4.orig.tar.gz
|
||||
LUAPOSIX_URL = $(LUAPOSIX_SITE)/$(LUAPOSIX_FILE)
|
||||
LUAPOSIX_PATCHDIR = patches
|
||||
|
||||
all: compile
|
||||
|
||||
include ../../build/module.mk
|
||||
|
||||
$(LUAPOSIX_FILE):
|
||||
wget -O $@ $(LUAPOSIX_URL) || rm -f $@
|
||||
|
||||
$(LUAPOSIX_DIR)/.prepared: $(LUAPOSIX_FILE)
|
||||
rm -rf $(LUAPOSIX_DIR)
|
||||
tar xvfz $(LUAPOSIX_FILE)
|
||||
touch $@
|
||||
|
||||
compile: $(LUAPOSIX_DIR)/.prepared
|
||||
$(MAKE) -C $(LUAPOSIX_DIR) CC=$(CC) CFLAGS="$(CFLAGS) $(LUA_CFLAGS)" LDFLAGS="$(LDFLAGS) $(LUA_SHLIBS)" OS="$(OS)"
|
||||
mkdir -p dist$(LUA_LIBRARYDIR)
|
||||
cp $(LUAPOSIX_DIR)/posix.so dist$(LUA_LIBRARYDIR)
|
||||
|
||||
luasource:
|
||||
luastrip:
|
||||
luacompile:
|
||||
compile-all: compile
|
||||
|
||||
clean:
|
||||
rm -rf $(LUAPOSIX_DIR) $(LUAPOSIX_FILE)
|
||||
rm -f $(LUAPOSIX_PATCHDIR)/series
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +0,0 @@
|
|||
## startup options for /etc/init.d/asterisk
|
||||
|
||||
ENABLE_ASTERISK="uci"
|
||||
OPTIONS=""
|
|
@ -1,127 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
START=50
|
||||
STOP=50
|
||||
|
||||
DEST=
|
||||
OPTIONS=""
|
||||
DEFAULT=$DEST/etc/default/asterisk
|
||||
UCILIB=$DEST/usr/lib/asterisk/uci
|
||||
EXTRAPARAM=$1
|
||||
|
||||
export EXTRA_COMMANDS="console check down"
|
||||
export EXTRA_HELP="\
|
||||
console Start asterisk console
|
||||
check Test asterisk uci config
|
||||
down Force asterisk to stop"
|
||||
|
||||
reboot_ata() {
|
||||
cd /tmp
|
||||
wget -q http://ata.lan/admin/reboot -O - >&- 2>&-
|
||||
}
|
||||
|
||||
load_ucilib() . ${UCILIB}/asteriskuci
|
||||
|
||||
start_uci() {
|
||||
load_ucilib
|
||||
|
||||
start_uci_asterisk $DEST
|
||||
}
|
||||
restart_uci() {
|
||||
load_ucilib
|
||||
|
||||
restart_uci_asterisk $DEST
|
||||
}
|
||||
|
||||
stop_uci() {
|
||||
load_ucilib
|
||||
|
||||
stop_uci_asterisk $DEST
|
||||
}
|
||||
reload_uci() {
|
||||
load_ucilib
|
||||
|
||||
reload_uci_asterisk "$DEST"
|
||||
}
|
||||
|
||||
start() {
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
case ${ENABLE_ASTERISK-no} in
|
||||
uci) start_uci ;;
|
||||
yes)
|
||||
# Handle zappseudo in the wrong place.
|
||||
[ -e /dev/zappseudo ] && [ ! -d /dev/zap -o ! -e /dev/zap/pseudo ] && mkdir -p /dev/zap && ln -s /dev/zappseudo /dev/zap/pseudo
|
||||
[ -d /var/run ] || mkdir -p /var/run
|
||||
[ -d $DEST/var/log/asterisk ] || mkdir -p $DEST/var/log/asterisk
|
||||
[ -d $DEST/var/spool/asterisk ] || mkdir -p $DEST/var/spool/asterisk
|
||||
[ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk
|
||||
[ -h $DEST/usr/lib/asterisk/astdb ] || ln -sf /var/spool/asterisk/astdb $DEST/usr/lib/asterisk/astdb
|
||||
$DEST/usr/sbin/asterisk $OPTIONS -f 2>&1 > $DEST/var/log/asterisk/asterisk_proc &
|
||||
( sleep 5; reboot_ata ) &
|
||||
;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
stop() {
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
case ${ENABLE_ASTERISK} in
|
||||
uci) stop_uci ;;
|
||||
*) [ -f /var/run/asterisk.pid ] && kill $(cat /var/run/asterisk.pid) 2>&- >&-
|
||||
esac
|
||||
}
|
||||
|
||||
console() {
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
case ${ENABLE_ASTERISK} in
|
||||
uci) $DEST/usr/sbin/asterisk $UCIOPTIONS -C /tmp/asterisk/asterisk.conf -r ;;
|
||||
yes) $DEST/usr/sbin/asterisk $OPTIONS -r ;;
|
||||
esac
|
||||
|
||||
}
|
||||
check() {
|
||||
load_ucilib
|
||||
|
||||
setup_asterisk "$DEST" test "$EXTRAPARAM"
|
||||
}
|
||||
|
||||
reload() {
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
case ${ENABLE_ASTERISK-no} in
|
||||
uci) reload_uci ;;
|
||||
yes) restart ;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
restart() {
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
case ${ENABLE_ASTERISK-no} in
|
||||
uci) restart_uci ;;
|
||||
yes)
|
||||
if [ -r /var/run/asterisk.ctl ] ; then
|
||||
if $DEST/usr/sbin/asterisk -r -x "restart gracefully" 2>&- >&- ; then
|
||||
echo "Restarting when convenient"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
stop
|
||||
start
|
||||
esac
|
||||
}
|
||||
|
||||
down() {
|
||||
if [ -r /var/run/asterisk.ctl ] ; then
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
case ${ENABLE_ASTERISK} in
|
||||
uci) $DEST/usr/sbin/asterisk -C /tmp/asterisk/asterisk.conf -r -x "stop now" 2>&- >&- ;;
|
||||
*) $DEST/usr/sbin/asterisk $OPTIONS -r -x "stop now" 2>&- >&-
|
||||
esac
|
||||
[ -f /var/run/asterisk.pid ] && sleep 1
|
||||
fi
|
||||
[ -f /var/run/asterisk.pid ] && kill $(cat /var/run/asterisk.pid) 2>&- >&-
|
||||
[ -f /var/run/asterisk.pid ] && sleep 2
|
||||
[ -f /var/run/asterisk.pid ] && kill -9 $(cat /var/run/asterisk.pid) 2>&- >&-
|
||||
}
|
||||
|
||||
# vim:ts=2 sw=2
|
|
@ -1,23 +0,0 @@
|
|||
; Talking clock by Michael Geddes
|
||||
; Borrowed from bits here and there.
|
||||
[macro-talkingclock] ; (TimeFormat, DateFormat, Zone)
|
||||
exten => s,1,Answer
|
||||
exten => s,n,set(tcTimeFormat=${ARG1})
|
||||
exten => s,n,GotoIf($["${tcTimeFormat}" = ""]?:tfOK)
|
||||
exten => s,n,set(tcTimeFormat=HM\'vm-and\'S\'seconds\')
|
||||
exten => s,n(tfOK),set(tcDateFormat=${ARG2})
|
||||
exten => s,n,GotoIf($["${tcDateFormat}" = ""]?:dfOK)
|
||||
exten => s,n,set(tcDateFormat=AdBY)
|
||||
exten => s,n(dfOK),set(tcZone=${ARG3})
|
||||
exten => s,n,GotoIf($["${tcZone}" = ""]?:znOK)
|
||||
exten => s,n,set(tcZone=${TalkingClockZone})
|
||||
exten => s,n(znOK),SayUnixTime(,${tcZone},${tcDateFormat})
|
||||
exten => s,n(again),Wait(2)
|
||||
exten => s,n,Set(FutureTime=$[${EPOCH} + 6])
|
||||
exten => s,n,Playback(misc/at-tone-time-exactly)
|
||||
exten => s,n,SayUnixTime(${FutureTime},${tcZone},${tcTimeFormat})
|
||||
; Wait to say the beep.
|
||||
exten => s,n(waitforit),noop
|
||||
exten => s,n,GotoIf($[ ${EPOCH} < ${FutureTime} ]?waitforit:)
|
||||
exten => s,n,playback(beep)
|
||||
exten => s,n,goto(again)
|
|
@ -1,88 +0,0 @@
|
|||
; Last-Called number storage and calling.
|
||||
; Author: Michael Geddes aka FrogOnWheels
|
||||
|
||||
; depends: app_macro app_system app_record func_callerid
|
||||
; app_sayunixtime app_playback func_db
|
||||
; format_gsm codec_gsm
|
||||
;[globals]
|
||||
;LASTCALL_DIR=/etc/asterisk/directory
|
||||
|
||||
[macro-lastcallstore] ; (Number , EntryType, BufferSize)
|
||||
exten => s,1,set(lcsName=lastcall)
|
||||
exten => s,n,set(lcsCount=10)
|
||||
exten => s,n,GotoIf($["${ARG2}" = ""]?blankarg)
|
||||
exten => s,n,GotoIf($["${ARG2}" = "lastcall"]?blankarg)
|
||||
exten => s,n,Set(lcsName=lastcall_${ARG2})
|
||||
exten => s,n(blankarg),GotoIf($["${ARG3}" = ""]?nocount)
|
||||
exten => s,n,Set(lcsCount=${ARG3})
|
||||
exten => s,n(nocount),Noop(${lcsName}:${DB(${lcsName}/number1)}:${ARG1})
|
||||
exten => s,n,GotoIf($["${DB(${lcsName}/number1)}" = "${ARG1}"]?setdate)
|
||||
exten => s,n,set(CallerPointer=1)
|
||||
|
||||
exten => s,n(again),GotoIf($["${DB(${lcsName}/ddate${CallerPointer})}" = ""]?copynext)
|
||||
exten => s,n,GotoIf($["${DB(${lcsName}/number${CallerPointer})}" = "${ARG1}"]?copynext)
|
||||
exten => s,n,Set(CallerPointer=$[${CallerPointer}+1])
|
||||
exten => s,n,GotoIf($[${CallerPointer} <= ${lcsCount}]?again)
|
||||
|
||||
exten => s,n(copynext),set(DB(${lcsName}/ddate$[${CallerPointer}])=${DB(${lcsName}/ddate$[${CallerPointer}-1])})
|
||||
exten => s,n,set(DB(${lcsName}/number$[${CallerPointer}])=${DB(${lcsName}/number$[${CallerPointer}-1])})
|
||||
exten => s,n,set(CallerPointer=$[${CallerPointer}-1])
|
||||
exten => s,n,GotoIf($[${CallerPointer} > 0]?copynext)
|
||||
exten => s,n,set(DB(${lcsName}/number1)=${ARG1})
|
||||
exten => s,n(setdate),set(DB(${lcsName}/ddate1)=${EPOCH})
|
||||
|
||||
[macro-lastcallapp] ; (Entrytype, Count, RingContext, Tag)
|
||||
exten => s,1,set(lcsName=lastcall)
|
||||
exten => s,n,set(lcsCount=10)
|
||||
exten => s,n,GotoIf($["${ARG1}" = ""]?blankName)
|
||||
exten => s,n,Set(lcsName=lastcall_${ARG1})
|
||||
exten => s,n(blankName),GotoIf($["${ARG2}" = ""]?nocount)
|
||||
exten => s,n,Set(lcsCount=${ARG2})
|
||||
exten => s,n(nocount),set(lcsCallContext=internal)
|
||||
exten => s,n,GotoIf($["${ARG3}" = ""]?blankContext)
|
||||
exten => s,n,Set(lcsCallContext=${ARG3})
|
||||
exten => s,n(blankContext),set(lcsTag=${ARG4})
|
||||
exten => s,n,GotoIf($["${lcsTag}" != ""]?hasTag)
|
||||
exten => s,n,Set(lcsTag=lastcall/previous-numbers)
|
||||
exten => s,n(hasTag),Set(lcsPointer=1)
|
||||
exten => s,n,GotoIf($["${DB(${lcsName}/ddate1)}" != ""]?macrobody_lastcallapp|s|1)
|
||||
exten => s,n,playback(${lcsTag}&lastcall/none-available)
|
||||
[macrobody_lastcallapp]
|
||||
exten => s,1(repeat),Background(${lcsTag})
|
||||
exten => s,n(again),wait(1)
|
||||
exten => s,n,Set(lcsLastnum=${DB(${lcsName}/number${lcsPointer})})
|
||||
exten => s,n,Set(ddate=${DB(${lcsName}/ddate${lcsPointer})})
|
||||
exten => s,n,Set(lcsLastDate=${DB(${lcsName}/ddate$[ ${lcsPointer} + 1])})
|
||||
exten => s,n,GotoIf($["${lcsLastnum}" != "anonymous"]?checkblank)
|
||||
exten => s,n,Set(lcsLastnum="")
|
||||
exten => s,n(checkblank),GotoIf($["${lcsLastnum}" = ""]?noinfo)
|
||||
exten => s,n,Macro(backgroundtagnumber,${lcsLastnum},${LASTCALL_DIR})
|
||||
exten => s,n,wait(.5)
|
||||
exten => s,n,sayunixtime(${ddate},${LASTCALLZONE},QIMp)
|
||||
exten => s,n(saymenu),background(silence/1)
|
||||
exten => s,n,GotoIf($[$[${lcsPointer} = ${lcsCount}] | $["${lcsLastDate}" = ""]]?noprev)
|
||||
exten => s,n,background(lastcall/next)
|
||||
exten => s,n(noprev),GotoIf($["${lcsLastnum}" = ""]?nocall)
|
||||
exten => s,n,background(lastcall/call-number)
|
||||
exten => s,n,background(lastcall/tag-number)
|
||||
exten => s,n(nocall),GotoIf($[${lcsPointer} = 1]?nonext)
|
||||
exten => s,n,background(lastcall/previous)
|
||||
exten => s,n(nonext),background(silence/10)
|
||||
exten => s,n,Goto(repeat)
|
||||
exten => s,n(noinfo),background(lastcall/no-number-info)
|
||||
exten => s,n,goto(saycalltime)
|
||||
exten => 5,1,GotoIf($["${lcsLastnum}" = ""]?noinfo])
|
||||
exten => 5,n,Ringing()
|
||||
exten => 5,n,Goto(${lcsCallContext},${lcsLastnum},1)
|
||||
exten => 6,1,GotoIf($[$[${lcsPointer} = ${lcsCount}] | $["${lcsLastDate}" = ""]]?sayn)
|
||||
exten => 6,n,Set(lcsPointer=$[${lcsPointer} + 1])
|
||||
exten => 4,1,GotoIf($[${lcsPointer}=1]?sayn)
|
||||
exten => 4,n,Set(lcsPointer=$[${lcsPointer} - 1])
|
||||
exten => _[46],n(sayn),Background(h-${lcsPointer})
|
||||
exten => _[46],n,goto(s|again)
|
||||
exten => 7,1,GotoIf($["${lcsLastNum}" = ""]?noinfo])
|
||||
exten => 7,2,macro(tagnumber,${lcsLastNum},${LASTCALL_DIR})
|
||||
exten => 7,3,goto(s|again)
|
||||
exten => i,1,Goto(s|again)
|
||||
exten => t,1,playback(goodbye)
|
||||
exten => t,n,Hangup
|
|
@ -1,58 +0,0 @@
|
|||
; Number tagging
|
||||
; Author: Michael Geddes aka FrogOnWheels
|
||||
|
||||
; Depends: app_stack app_macro app_system
|
||||
|
||||
[macro-tagnumber] ; Number / Tag Directory / Return
|
||||
exten => s,1,Set(tagNumber=${ARG1})
|
||||
exten => s,n,Set(tagDirectory=${ARG2})
|
||||
exten => s,n,Set(tagRetContext=${MACRO_CONTEXT})
|
||||
exten => s,n,Set(tagRetExtn=${MACRO_EXTEN})
|
||||
exten => s,n,Set(tagRetPriority=$[${MACRO_PRIORITY} + 1])
|
||||
;exten => s,n,Set(tagReturn=${ARG3})
|
||||
;exten => s,n,Gosub(macrobody_tagnumber,s,1)
|
||||
exten => s,n,Goto(macrobody_tagnumber,s,1)
|
||||
exten => s,n(return),Noop(Returned)
|
||||
[macrobody_tagnumber]
|
||||
exten => s,1(again),Background(voicetag/recordname)
|
||||
exten => s,n,Record(/tmp/tmprectag:gsm|2|5)
|
||||
exten => s,n(askagain),Background(voicetag/tagfor)
|
||||
exten => s,n,Macro(backgroundphone,${tagNumber})
|
||||
exten => s,n,Background(/tmp/tmprectag)
|
||||
exten => s,n,Background(voicetag/confirmnumber)
|
||||
exten => s,n,Background(voicetag/tryagain)
|
||||
exten => s,n,Background(voicetag/cancelrecord)
|
||||
exten => s,n,WaitExten(5)
|
||||
exten => s,n,Goto(s|askagain)
|
||||
exten => 1,1,System(mkdir -p ${tagDirectory})
|
||||
exten => 1,2,System(mv /tmp/tmprectag.gsm ${tagDirectory}/${tagNumber}.gsm)
|
||||
exten => 1,3,Goto(${tagRetContext}|${tagRetExtn}|${tagRetPriority})
|
||||
exten => 2,1,Goto(s|again)
|
||||
exten => 3,1,system(rm -f /tmp/tmprectag.gsm)
|
||||
exten => 3,2,Goto(${tagRetContext}|${tagRetExtn}|${tagRetPriority})
|
||||
exten => h,1,system(rm -f /tmp/tmrectag.gsm)
|
||||
|
||||
[macro-backgroundtagnumber] ; Number, directory
|
||||
exten => s,1,TrySystem(test -f ${ARG2}/${ARG1}.gsm)
|
||||
exten => s,n,GotoIf($[${SYSTEMSTATUS} != SUCCESS]?s-saynum|1)
|
||||
exten => s,n,Background(${ARG2}/${ARG1})
|
||||
exten => s-saynum,1,Macro(backgroundphone,${ARG1})
|
||||
|
||||
; Say Phone number in the background
|
||||
[macro-backgroundphone]
|
||||
exten => s,1,Set(bgDigits=${ARG1})
|
||||
exten => s,n(loop),Set(bgDigit=${bgDigits:0:1})
|
||||
exten => s,n,GotoIf($["${bgDigits:0:3}" = "000"]?saythousand)
|
||||
exten => s,n,GotoIf($["${bgDigits:0:2}" = "00"]?sayhundred)
|
||||
exten => s,n,GotoIf($["${bgDigits}" = ""]?exitloop)
|
||||
exten => s,n,Set(bgDigits=${bgDigits:1})
|
||||
exten => s,n,Background(digits/${bgDigit})
|
||||
exten => s,n,Goto(loop)
|
||||
exten => s,n(saythousand),Background(digits/thousand)
|
||||
exten => s,n,Set(bgDigits=${bgDigits:3})
|
||||
exten => s,n,Goto(loop)
|
||||
exten => s,n(sayhundred),Background(digits/hundred)
|
||||
exten => s,n,Set(bgDigits=${bgDigits:2})
|
||||
exten => s,n,Goto(loop)
|
||||
exten => s,n(exitloop),NOOP
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
;
|
||||
; Asterisk configuration file
|
||||
;
|
||||
; Module Loader configuration file
|
||||
;
|
||||
|
||||
[modules]
|
||||
autoload=yes
|
||||
;
|
||||
; Any modules that need to be loaded before the Asterisk core has been
|
||||
; initialized (just after the logger has been initialized) can be loaded
|
||||
; using 'preload'. This will frequently be needed if you wish to map all
|
||||
; module configuration files into Realtime storage, since the Realtime
|
||||
; driver will need to be loaded before the modules using those configuration
|
||||
; files are initialized.
|
||||
;
|
||||
; An example of loading ODBC support would be:
|
||||
;preload => res_odbc.so
|
||||
;preload => res_config_odbc.so
|
||||
;
|
||||
noload => res_config_mysql.so ;
|
||||
noload => res_crypto.so ; Cryptographic Digital Signatures
|
||||
; load => res_features.so ; Call Parking Resource
|
||||
noload => res_indications.so ; Indications Configuration
|
||||
noload => res_monitor.so ; Call Monitoring Resource
|
||||
; load => res_musiconhold.so ; Music On Hold Resource
|
||||
noload => cdr_csv.so ; Comma Separated Values CDR Backend
|
||||
noload => cdr_custom.so ; Customizable Comma Separated Values CDR Backend
|
||||
noload => cdr_manager.so ; Asterisk Call Manager CDR Backend
|
||||
noload => cdr_mysql.so ; MySQL CDR Backend
|
||||
noload => cdr_pgsql.so ; PostgreSQL CDR Backend
|
||||
noload => cdr_sqlite.so ; SQLite CDR Backend
|
||||
noload => chan_alsa.so ; Channel driver for GTalk
|
||||
noload => chan_agent.so ; Agent Proxy Channel
|
||||
noload => chan_gtalk.so ; Channel driver for GTalk
|
||||
; load => chan_iax2.so ; Inter Asterisk eXchange (Ver 2)
|
||||
; load => chan_local.so ; Local Proxy Channel
|
||||
; load => chan_sip.so ; Session Initiation Protocol (SIP)
|
||||
noload => codec_a_mu.so ; A-law and Mulaw direct Coder/Decoder
|
||||
noload => codec_adpcm.so ; Adaptive Differential PCM Coder/Decoder
|
||||
noload => codec_alaw.so ; A-law Coder/Decoder
|
||||
noload => codec_g726.so ; ITU G.726-32kbps G726 Transcoder
|
||||
; load => codec_gsm.so ; GSM/PCM16 (signed linear) Codec Translation
|
||||
; load => codec_ulaw.so ; Mu-law Coder/Decoder
|
||||
noload => codec_speex.so ; Speex/PCM16 (signed linear) Codec Translator
|
||||
noload => format_au.so ; Sun Microsystems AU format (signed linear)
|
||||
noload => format_g723.so ; G.723.1 Simple Timestamp File Format
|
||||
noload => format_g726.so ; Raw G.726 (16/24/32/40kbps) data
|
||||
noload => format_g729.so ; Raw G729 data
|
||||
; load => format_gsm.so ; Raw GSM data
|
||||
noload => format_h263.so ; Raw h263 data
|
||||
noload => format_jpeg.so ; JPEG (Joint Picture Experts Group) Image
|
||||
; load => format_pcm.so ; Raw uLaw 8khz Audio support (PCM)
|
||||
noload => format_pcm_alaw.so ; Raw aLaw 8khz PCM Audio support
|
||||
noload => format_sln.so ; Raw Signed Linear Audio support (SLN)
|
||||
noload => format_vox.so ; Dialogic VOX (ADPCM) File Format
|
||||
; load => format_wav.so ; Microsoft WAV format (8000hz Signed Line
|
||||
; load => format_wav_gsm.so ; Microsoft WAV format (Proprietary GSM)
|
||||
noload => app_alarmreceiver.so ; Alarm Receiver Application
|
||||
noload => app_authenticate.so ; Authentication Application
|
||||
noload => app_cdr.so ; Make sure asterisk doesn't save CDR
|
||||
noload => app_chanisavail.so ; Check if channel is available
|
||||
noload => app_chanspy.so ; Listen in on any channel
|
||||
noload => app_controlplayback.so ; Control Playback Application
|
||||
noload => app_cut.so ; Cuts up variables
|
||||
noload => app_db.so ; Database access functions
|
||||
; load => app_dial.so ; Dialing Application
|
||||
noload => app_dictate.so ; Virtual Dictation Machine Application
|
||||
noload => app_directory.so ; Extension Directory
|
||||
noload => app_directed_pickup.so ; Directed Call Pickup Support
|
||||
noload => app_disa.so ; DISA (Direct Inward System Access) Application
|
||||
noload => app_dumpchan.so ; Dump channel variables Application
|
||||
; load => app_echo.so ; Simple Echo Application
|
||||
noload => app_enumlookup.so ; ENUM Lookup
|
||||
noload => app_eval.so ; Reevaluates strings
|
||||
noload => app_exec.so ; Executes applications
|
||||
noload => app_externalivr.so ; External IVR application interface
|
||||
noload => app_forkcdr.so ; Fork The CDR into 2 seperate entities
|
||||
noload => app_getcpeid.so ; Get ADSI CPE ID
|
||||
noload => app_groupcount.so ; Group Management Routines
|
||||
noload => app_ices.so ; Encode and Stream via icecast and ices
|
||||
noload => app_image.so ; Image Transmission Application
|
||||
noload => app_lookupblacklist.so ; Look up Caller*ID name/number from black
|
||||
noload => app_lookupcidname.so ; Look up CallerID Name from local databas
|
||||
; load => app_macro.so ; Extension Macros
|
||||
noload => app_math.so ; A simple math Application
|
||||
noload => app_md5.so ; MD5 checksum Application
|
||||
; load => app_milliwatt.so ; Digital Milliwatt (mu-law) Test Application
|
||||
noload => app_mixmonitor.so ; Record a call and mix the audio during the recording
|
||||
noload => app_parkandannounce.so ; Call Parking and Announce Application
|
||||
; load => app_playback.so ; Trivial Playback Application
|
||||
noload => app_privacy.so ; Require phone number to be entered
|
||||
noload => app_queue.so ; True Call Queueing
|
||||
noload => app_random.so ; Random goto
|
||||
noload => app_read.so ; Read Variable Application
|
||||
noload => app_readfile.so ; Read in a file
|
||||
noload => app_realtime.so ; Realtime Data Lookup/Rewrite
|
||||
noload => app_record.so ; Trivial Record Application
|
||||
; load => app_sayunixtime.so ; Say time
|
||||
noload => app_senddtmf.so ; Send DTMF digits Application
|
||||
noload => app_sendtext.so ; Send Text Applications
|
||||
noload => app_setcallerid.so ; Set CallerID Application
|
||||
noload => app_setcdruserfield.so ; CDR user field apps
|
||||
noload => app_setcidname.so ; Set CallerID Name
|
||||
noload => app_setcidnum.so ; Set CallerID Number
|
||||
noload => app_setrdnis.so ; Set RDNIS Number
|
||||
noload => app_settransfercapability.so ; Set ISDN Transfer Capability
|
||||
noload => app_sms.so ; SMS/PSTN handler
|
||||
noload => app_softhangup.so ; Hangs up the requested channel
|
||||
noload => app_stack.so ; Stack Routines
|
||||
noload => app_system.so ; Generic System() application
|
||||
noload => app_talkdetect.so ; Playback with Talk Detection
|
||||
noload => app_test.so ; Interface Test Application
|
||||
noload => app_transfer.so ; Transfer
|
||||
noload => app_txtcidname.so ; TXTCIDName
|
||||
noload => app_url.so ; Send URL Applications
|
||||
noload => app_userevent.so ; Custom User Event Application
|
||||
; load => app_verbose.so ; Send verbose output
|
||||
noload => app_waitforring.so ; Waits until first ring after time
|
||||
noload => app_waitforsilence.so ; Wait For Silence Application
|
||||
noload => app_while.so ; While Loops and Conditional Execution
|
||||
noload => func_callerid.so ; Caller ID related dialplan functions
|
||||
noload => func_enum.so ; ENUM Functions
|
||||
noload => func_uri.so ; URI encoding / decoding functions
|
||||
noload => pbx_ael.so ; Asterisk Extension Language Compiler
|
||||
; load => pbx_config.so ; Text Extension Configuration
|
||||
noload => pbx_functions.so ; Builtin dialplan functions
|
||||
noload => pbx_loopback.so ; Loopback Switch
|
||||
noload => pbx_realtime.so ; Realtime Switch
|
||||
noload => pbx_spool.so ; Outgoing Spool Support
|
||||
noload => pbx_wilcalu.so ; Wil Cal U (Auto Dialer)
|
||||
;
|
||||
; Module names listed in "global" section will have symbols globally
|
||||
; exported to modules loaded after them.
|
||||
;
|
||||
[global]
|
||||
chan_modem.so=no
|
|
@ -1,144 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Asterisk.conf
|
||||
|
||||
init_asteriskconf() {
|
||||
|
||||
ast_add_reload dialplan
|
||||
ast_enable_type asterisk
|
||||
ast_enable_type setglobal
|
||||
ast_enable_type include
|
||||
# ast_enable_type hardware
|
||||
ast_enable_type hardwarereboot
|
||||
|
||||
|
||||
asterisk_zone="Australia/Perth"
|
||||
asterisk_spooldir="${DEST}/var/spool/asterisk"
|
||||
asterisk_logdir="${DEST}/var/log/asterisk"
|
||||
asterisk_agidir="${DEST}/usr/lib/asterisk/agi-bin"
|
||||
return 0
|
||||
}
|
||||
|
||||
asterisk_option_list="verbose debug quiet dontwarn timestamp execincludes \
|
||||
highpriority initcrypto nocolor dumpcore languageprefix internal_timing \
|
||||
systemname maxcalls maxload cache_record_files record_cache_dir \
|
||||
transmit_silence_during_record transcode_via_sln runuser rungroup"
|
||||
asterisk_path_list="spooldir logdir agidir"
|
||||
|
||||
valid_asterisk_option() {
|
||||
is_in_list $1 ${asterisk_option_list} ${asterisk_path_list} zone
|
||||
return $?
|
||||
}
|
||||
|
||||
create_asteriskconf() {
|
||||
# echo ${DEST_DIR}
|
||||
file=${DEST_DIR}/asterisk.conf
|
||||
get_checksum asterisk_conf $file
|
||||
|
||||
echo "${asteriskuci_gen}${N}[directories]
|
||||
astetcdir => ${DEST_DIR}
|
||||
astmoddir => ${DEST}/usr/lib/asterisk/modules
|
||||
astvarlibdir => ${DEST}/usr/lib/asterisk
|
||||
astdatadir => ${DEST}/usr/lib/asterisk
|
||||
astrundir => /var/run" > $file
|
||||
for i in ${asterisk_path_list} ; do
|
||||
eval "value=\"\${asterisk_$i}\""
|
||||
if [ ! -z $value ] ; then
|
||||
echo "ast$i => $value" >> $file
|
||||
fi
|
||||
done
|
||||
echo "${N}[options]" >> $file
|
||||
|
||||
for i in ${asterisk_option_list} ; do
|
||||
eval "value=\"\${asterisk_$i}\""
|
||||
if [ ! -z $value ] ; then
|
||||
echo "$i => $value" >> $file
|
||||
fi
|
||||
done
|
||||
|
||||
echo "${N}; Changing the following lines may compromise your security.
|
||||
[files]
|
||||
astctlpermissions = 0660
|
||||
astctlowner = root
|
||||
astctlgroup = nogroup
|
||||
astctl = asterisk.ctl " >> $file
|
||||
check_checksum "$asterisk_conf" "$file" || ast_restart=1
|
||||
|
||||
}
|
||||
|
||||
handle_asterisk() {
|
||||
option_cb() {
|
||||
case $1 in
|
||||
zone)
|
||||
asterisk_zone="$2";;
|
||||
*)
|
||||
if valid_asterisk_option $1 $2 ; then
|
||||
eval "asterisk_${1}=\"$2\""
|
||||
else
|
||||
logerror "Invalid Asterisk option: $1"
|
||||
fi
|
||||
esac
|
||||
}
|
||||
}
|
||||
|
||||
handle_include(){
|
||||
option_cb() {
|
||||
case $1 in
|
||||
dialplan|dialplan_ITEM*)
|
||||
append dialplan_includes "#include <$2>" "${N}"
|
||||
;;
|
||||
dialplan_COUNT) ;;
|
||||
*) logerror "Invalid option \"$1\" for include" ;;
|
||||
esac
|
||||
}
|
||||
}
|
||||
|
||||
handle_setglobal() {
|
||||
option_cb() {
|
||||
case $1 in
|
||||
set_COUNT) ;;
|
||||
set|set_ITEM*)
|
||||
if [ "${2%=*}" == "${2}" ] ; then
|
||||
logerror "SetGlobal option \"$2\" not of the form VARIABLE=Value"
|
||||
else
|
||||
append dialplan_globals "" "${N}"
|
||||
fi ;;
|
||||
*) logerror "Invalid option \"$1\" for setglobal" ;;
|
||||
esac
|
||||
}
|
||||
}
|
||||
|
||||
handle_hardwarereboot() handle_hardware reboot
|
||||
|
||||
# Handle hardware options (reboot) for Softphones
|
||||
handle_hardware() {
|
||||
case $1 in
|
||||
reboot)
|
||||
hardware_method=
|
||||
hardware_param=
|
||||
option_cb() {
|
||||
case $1 in
|
||||
method)
|
||||
hardware_method="$2";;
|
||||
param)
|
||||
case ${hardware_method} in
|
||||
web) append hardware_reboots "wget -q $2 -O - >&- 2>&-" "${N}" ;;
|
||||
system) append hardware_reboots "$2 >&- 2>&-" "${N}" ;;
|
||||
*) logerror "Invalid Hardware reboot method: ${hardware_method}"
|
||||
esac
|
||||
esac
|
||||
|
||||
}
|
||||
;;
|
||||
*) logerror "Invalid Hardware option: $1"
|
||||
esac
|
||||
}
|
||||
|
||||
reboot_hardware() {
|
||||
cd /tmp
|
||||
eval ${hardware_reboots}
|
||||
}
|
||||
|
||||
|
||||
|
||||
# vim: ts=2 sw=2 noet foldmethod=indent
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
asterisk
|
||||
zone - Default TimeZone
|
||||
|
||||
Various asterisk.conf options
|
||||
verbose
|
||||
debug
|
||||
quiet
|
||||
dontwarn
|
||||
timestamp
|
||||
execincludes
|
||||
highpriority
|
||||
initcrypto
|
||||
nocolor
|
||||
dumpcore
|
||||
languageprefix
|
||||
internal_timing
|
||||
systemname
|
||||
maxcalls
|
||||
maxload
|
||||
cache_record_files
|
||||
record_cache_dir
|
||||
transmit_silence_during_record
|
||||
transcode_via_sln
|
||||
runuser
|
||||
rungroup
|
||||
|
||||
spooldir
|
||||
logdir
|
||||
agidir
|
||||
|
||||
setglobal
|
||||
set (list) - VARIABLE=Value Global Variables
|
||||
|
||||
include
|
||||
dialplan (list) - Files to #include
|
||||
|
||||
hardwarereboot - Reboot phone hardware
|
||||
method - web (wget), system
|
||||
param - url/program for reboot
|
||||
|
|
@ -1,377 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Author: Michael Geddes <michael at frog dot wheelycreek dot net>
|
||||
# Copyright 2008 Michael Geddes
|
||||
# Licensed under GPL
|
||||
Version=0.8
|
||||
|
||||
|
||||
# Todo
|
||||
# Calling of Macros in dialplan
|
||||
# Create a Menu
|
||||
# Incoming Zones
|
||||
|
||||
debuglevel=0
|
||||
|
||||
. /etc/functions.sh
|
||||
|
||||
asteriskuci_gen="; Generated by Openwrt AstriskUCI script version ${Version}$N"
|
||||
|
||||
# Utils
|
||||
|
||||
logerror() {
|
||||
echo "Error: $1"
|
||||
}
|
||||
|
||||
logdebug() {
|
||||
if [ $(expr $1 "<=" ${debuglevel-0}) == 1 ] ; then
|
||||
echo "Log: $2"
|
||||
fi
|
||||
}
|
||||
|
||||
is_in_list(){
|
||||
val=$1
|
||||
shift
|
||||
for i in $* ; do
|
||||
[ $i == $val ] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
split_append() { # {list} {prefix} {item} {func call}
|
||||
local lhs="$2"
|
||||
local rhs="$3"
|
||||
|
||||
while [ ! -z "$rhs" ] ; do
|
||||
cur=${rhs%%,*}
|
||||
nvar=${rhs#*,}
|
||||
[ -z "$5" ] || eval "$5 ${cur}"
|
||||
append $1 "${lhs}${cur}" "$4"
|
||||
[ "$nvar" == "$rhs" ] && break
|
||||
rhs=${nvar}
|
||||
done
|
||||
}
|
||||
|
||||
get_checksum() {
|
||||
if [ -r "$2" ] ; then
|
||||
local sum=`md5sum $2 | cut -d " " -f 1`
|
||||
eval "$1=\"$sum\""
|
||||
else
|
||||
eval "$1=NONE"
|
||||
fi
|
||||
#eval "logdebug 1 \"Checksum $2 : \${$1}\""
|
||||
}
|
||||
|
||||
check_checksum() {
|
||||
if [ -r "$2" ] ; then
|
||||
local sum=`md5sum $2 | cut -d " " -f 1`
|
||||
else
|
||||
eval sum=NONE
|
||||
fi
|
||||
#logdebug 1 "Compare $1 checksum $2 with new checksum $sum "
|
||||
[ "$sum" == "$1" ]
|
||||
return $?
|
||||
}
|
||||
|
||||
# Add config module to initialise list
|
||||
ast_add_conf() append asterisk_conf_list $1 " "
|
||||
# Add module to initialise list
|
||||
ast_add_module() {
|
||||
append asterisk_module_list $1 " "
|
||||
eval "createdialplan_$1() return 0"
|
||||
}
|
||||
# Add to 'reload' list.
|
||||
ast_add_reload() append asterisk_load_list $1 " "
|
||||
|
||||
# Enable a top-level type
|
||||
ast_enable_type() eval "enabled_section_${1}=1"
|
||||
|
||||
# Is a top-level type enabled?
|
||||
ast_type_enabled() {
|
||||
eval "local res=\${enabled_section_${1}}"
|
||||
if [ "$res" != 1 ] ; then
|
||||
return 1 #Fail
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# For use in sections - make sure that the last section is processed
|
||||
check_add() {
|
||||
logdebug 1 "Check add $1"
|
||||
if [ ! -z "${last_added_checked}" ] ; then
|
||||
logdebug 1 "Eval check-add ${last_added_checked}"
|
||||
eval "check_add_${last_added_checked}"
|
||||
fi
|
||||
last_added_checked=$1
|
||||
}
|
||||
|
||||
# Process the section yet to be checked.
|
||||
check_all_added() check_add ""
|
||||
|
||||
# Create static links for stuff we dont want to configure yet.
|
||||
create_staticlinks() {
|
||||
logdebug 1 "Link in a few mostly static configurations"
|
||||
linkconfigs="codecs.conf say.conf sip_notify.conf udptl.conf logger.conf"
|
||||
module_enabled res_indications && append linkconfigs indications.conf " "
|
||||
for i in ${linkconfigs} ; do
|
||||
[ -e $DEST_DIR/$i ] || ln -s $DEST/etc/asterisk/$i $DEST_DIR
|
||||
done
|
||||
|
||||
logdebug 1 "Link in #include directories"
|
||||
for i in include inc libs lib library macro macros ; do
|
||||
if [ -e $DEST/etc/asterisk/$i -a ! -d "$DEST_DIR/$i" -a ! -e "$DEST_DIR/$i" ] ; then
|
||||
ln -s $DEST/etc/asterisk/$i $DEST_DIR
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# default reboot
|
||||
reboot_hardware() {}
|
||||
|
||||
|
||||
# Top level handler
|
||||
setup_asterisk() {
|
||||
DEST=${1%/}
|
||||
DEST_DIR=/tmp/asterisk
|
||||
|
||||
testing_mode=0
|
||||
if [ "$2" == "testonly" ] ; then
|
||||
testing_mode=1
|
||||
elif [ "$2" == "test" ] ; then
|
||||
DEST_DIR=/tmp/asterisk.tmp
|
||||
echo Using Test dir: $DEST_DIR
|
||||
testing_mode=2
|
||||
fi
|
||||
|
||||
[ -z "$3" ] || debuglevel=$3
|
||||
|
||||
logdebug 1 "Loading Asterisk Config"
|
||||
. ${UCILIB}/asteriskconf
|
||||
logdebug 2 "Loading Module Config"
|
||||
. ${UCILIB}/moduleconf
|
||||
logdebug 2 "Loading Dialplan Config"
|
||||
. ${UCILIB}/dialplanconf
|
||||
|
||||
for f in ${DEST}/etc/asterisk/conf.d/* ; do
|
||||
logdebug 1 "Loading Module $f"
|
||||
[ -f $f ] && . $f
|
||||
done
|
||||
|
||||
include /lib/network
|
||||
scan_interfaces
|
||||
|
||||
init_asteriskconf
|
||||
init_moduleconf
|
||||
init_dialplanconf
|
||||
|
||||
for i in ${asterisk_module_list} ; do
|
||||
logdebug 1 "Init $i module"
|
||||
eval "init_${i}"
|
||||
done
|
||||
|
||||
for i in ${asterisk_conf_list} ; do
|
||||
logdebug 1 "Init $i config"
|
||||
eval "init_${i}conf"
|
||||
done
|
||||
|
||||
config_cb() {
|
||||
cur_section=$1/$2
|
||||
logdebug 2 "Load $1/$2"
|
||||
eval "local val=\"\${dups_$2}\""
|
||||
if [ "${val}" == "" ] ; then
|
||||
eval "dups_$2=1"
|
||||
else
|
||||
logerror "Duplicate Section Name: $2 (type $1)"
|
||||
fi
|
||||
|
||||
if ast_type_enabled $1 ; then
|
||||
eval "handle_$1 \$2"
|
||||
elif [ ! -z "$1" ] ; then
|
||||
|
||||
logerror "Unknown section: $1/$2"
|
||||
option_cb() {
|
||||
logerror "Invalid option '$1' for invalid section"
|
||||
}
|
||||
fi
|
||||
}
|
||||
config_load asterisk
|
||||
check_all_added
|
||||
|
||||
if [ "$testing_mode" != "1" ] ; then
|
||||
mkdir -p ${DEST_DIR}
|
||||
|
||||
create_asteriskconf
|
||||
for i in ${asterisk_conf_list} ; do
|
||||
logdebug 1 "Create $i config"
|
||||
eval "create_${i}conf"
|
||||
done
|
||||
|
||||
for i in ${asterisk_module_list} ; do
|
||||
logdebug 1 "Create Dialplan for module $i"
|
||||
eval "createdialplan_${i}"
|
||||
done
|
||||
create_dialplanconf
|
||||
create_moduleconf
|
||||
|
||||
# Link in a few mostly static configurations
|
||||
create_staticlinks
|
||||
fi
|
||||
[ "$testing_mode" == "2" ] && reload_check_asterisk
|
||||
return 0
|
||||
}
|
||||
|
||||
astcmd() {
|
||||
ASTCMD="${DEST%/}/usr/sbin/asterisk -C /tmp/asterisk/asterisk.conf "
|
||||
logdebug 1 "Command: $1"
|
||||
if [ -z "${2-}" ] ; then
|
||||
${ASTCMD} -r -x "$1" 2>&- 1>&-
|
||||
else
|
||||
eval "$2=`${ASTCMD} -r -x \"$1\"`"
|
||||
fi
|
||||
return $?
|
||||
}
|
||||
|
||||
# waitfor() {
|
||||
# while [ -d /proc/$1 ] ; do
|
||||
# sleep 1
|
||||
# done
|
||||
# }
|
||||
|
||||
restart_gracefully() {
|
||||
stop_uci_asterisk "$DEST"
|
||||
startup_asterisk "$DEST"
|
||||
#ret=0
|
||||
#echo "Check for pid"
|
||||
#if [ -r /var/run/asterisk.ctl ] ; then
|
||||
# astcmd "stop gracefully"
|
||||
# local ret=$?
|
||||
# [ ${ret} = 0 ] || return $ret
|
||||
# waitfor `cat /var/run/asterisk.pid`
|
||||
#fi
|
||||
#startup_asterisk ${DEST}
|
||||
return 0
|
||||
}
|
||||
astcmds() {
|
||||
while [ ! -z "$1" ] ; do
|
||||
astcmd "$1"
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
reload_check_asterisk() {
|
||||
logdebug 1 "Check Reloading"
|
||||
local reboot=0
|
||||
if [ "${ast_restart-}" == 1 ] ; then
|
||||
logdebug 1 "Restarting Gracefully"
|
||||
reboot=0
|
||||
else
|
||||
for i in ${asterisk_load_list} ; do
|
||||
logdebug 1 "Checking ${i} reload"
|
||||
eval "local doload=\${ast_${i}_restart}"
|
||||
case $doload in
|
||||
1) logdebug 1 "Reloading ${i}" ;;
|
||||
2) logdebug 1 "Unloading ${i}" ;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
[ ${reboot} = 1 ] && logdebug 1 "reboot hardware"
|
||||
}
|
||||
|
||||
reload_asterisk() {
|
||||
logdebug 1 "Reloading"
|
||||
local reboot=0
|
||||
if [ "${ast_restart-}" == 1 ] ; then
|
||||
logdebug 2 "Restarting Gracefully"
|
||||
restart_gracefully
|
||||
reboot=0
|
||||
else
|
||||
for i in ${asterisk_load_list} ; do
|
||||
logdebug 3 "Checking ${i} reload"
|
||||
eval "local doload=\${ast_${i}_restart}"
|
||||
case $doload in
|
||||
1) logdebug 1 "Reloading ${i}"
|
||||
eval "reload_${i}" || reboot=1 ;;
|
||||
2) logdebug 1 "Unloading ${i}"
|
||||
eval "unload_${i}" || reboot=1 ;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if [ ${reboot} = 1 ] ; then
|
||||
( sleep 5; reboot_hardware ) &
|
||||
fi
|
||||
}
|
||||
|
||||
startup_asterisk() {
|
||||
DEST="${1%/}"
|
||||
DEFAULT=$DEST/etc/default/asterisk
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
[ -d /var/run ] || mkdir -p /var/run
|
||||
[ -d ${asterisk_logdir} ] || mkdir -p ${asterisk_logdir}
|
||||
[ -d ${asterisk_spooldir} ] || mkdir -p ${asterisk_spooldir}
|
||||
[ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk
|
||||
[ -h $DEST/usr/lib/asterisk/astdb ] || ln -sf /var/spool/asterisk/astdb $DEST/usr/lib/asterisk/astdb
|
||||
[ -e /dev/zappseudo ] && [ ! -d /dev/zap -o ! -e /dev/zap/pseudo ] && mkdir -p /dev/zap && ln -s /dev/zappseudo /dev/zap/pseudo
|
||||
|
||||
$DEST/usr/sbin/asterisk -C /tmp/asterisk/asterisk.conf $UCIOPTIONS -f 2>&1 > ${asterisk_logdir}/asterisk_proc &
|
||||
# Wait a bit then reboot the hardware
|
||||
( sleep 5; reboot_hardware ) &
|
||||
}
|
||||
|
||||
# Init.d start() handler
|
||||
start_uci_asterisk() {
|
||||
DEST="${1%/}"
|
||||
|
||||
if setup_asterisk $DEST ; then
|
||||
startup_asterisk "$DEST"
|
||||
fi
|
||||
}
|
||||
|
||||
restart_uci_asterisk() {
|
||||
DEST="${1%/}"
|
||||
if setup_asterisk $DEST ; then
|
||||
echo "Trying to Restart gracefully"
|
||||
if [ -r /var/run/asterisk.ctl ] ; then
|
||||
# if astcmd "restart gracefully" ; then
|
||||
echo "Sending restart"
|
||||
if restart_gracefully ; then
|
||||
echo "Restarting gracefully"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
stop_uci_asterisk "$DEST"
|
||||
startup_asterisk "$DEST"
|
||||
else
|
||||
stop_uci_asterisk $1
|
||||
echo "Setup Failed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# init.d stop() handler
|
||||
stop_uci_asterisk() {
|
||||
DEST=${1%/}
|
||||
if [ -r /var/run/asterisk.ctl ] ; then
|
||||
astcmd "stop now"
|
||||
sleep 1
|
||||
fi
|
||||
[ -f /var/run/asterisk.pid ] && kill $(cat /var/run/asterisk.pid) >/dev/null 2>&1
|
||||
}
|
||||
|
||||
reload_uci_asterisk() {
|
||||
DEST=${1%/}
|
||||
DEFAULT=$DEST/etc/default/asterisk
|
||||
|
||||
if [ -r /var/run/asterisk.ctl ] ; then
|
||||
|
||||
[ -e /dev/zappseudo ] && [ ! -d /dev/zap -o ! -e /dev/zap/pseudo ] && mkdir -p /dev/zap && ln -s /dev/zappseudo /dev/zap/pseudo
|
||||
if setup_asterisk "$DEST" ; then
|
||||
# Selective reload modules.
|
||||
reload_asterisk
|
||||
fi
|
||||
else
|
||||
start_uci_asterisk "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# vim: ts=2 sw=2 noet foldmethod=indent
|
|
@ -1,855 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Dialplans (extensions.conf)
|
||||
|
||||
# Implicit: ast_add_conf dialplan
|
||||
init_dialplanconf() {
|
||||
ast_enable_type dialplangeneral
|
||||
ast_enable_type dialplan
|
||||
ast_enable_type dialplanexten
|
||||
ast_enable_type dialplangoto
|
||||
ast_enable_type dialplansaytime
|
||||
ast_enable_type dialzone
|
||||
ast_enable_type inzone
|
||||
ast_enable_type incominggeneral
|
||||
ast_enable_type incoming
|
||||
|
||||
dialplan_allowtransfer=no
|
||||
dialplan_dialtimeout=30
|
||||
dialplan_answerfirst=no
|
||||
dialplan_static=yes
|
||||
dialplan_writeprotect=no
|
||||
dialplan_canreinvite=no
|
||||
dialplan_includes=
|
||||
dialplan_globals=
|
||||
return 0
|
||||
}
|
||||
|
||||
match_all="_[0-9*+#]."
|
||||
match_all_s="_[0-9*+#s]."
|
||||
|
||||
dialplangeneral_list="static writeprotect canreinvite clearglobalvars"
|
||||
dialplangeneral_list_ex="lastdialed lastdialedtype voiceboxext answerfirst dialtimeout allowtransfer international internationalout"
|
||||
|
||||
valid_dialplangeneral() {
|
||||
for i in ${dialplangeneral_list} ${dialplangeneral_list_ex} ; do
|
||||
[ "$i" == "$1" ] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
check_add_context() {
|
||||
local context="${1}"
|
||||
local check="${context#macro-}"
|
||||
[ "${context}" == ${check} ] || check="macro__${check}"
|
||||
eval "local isadded=\"\${dialplan_add_context_${check}-0}\""
|
||||
if [ "$isadded" != "1" ] ; then
|
||||
eval "dialplan_add_context_${check}=1"
|
||||
append dialplan_contexts "$context"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
append_dialplan_context() {
|
||||
local context="${1}"
|
||||
local check="${context#macro-}"
|
||||
[ "${context}" == ${check} ] || check="macro__${check}"
|
||||
append dialplan_context_${check} "${2}" "${N}"
|
||||
}
|
||||
|
||||
reload_dialplan() astcmd "dialplan reload"
|
||||
|
||||
add_dialplan_exten() {
|
||||
local context=$1
|
||||
logdebug 3 "Exten: $2"
|
||||
local ext="exten => $2,"
|
||||
local planopt=
|
||||
local timeout=${dialplan_dialtimeout}
|
||||
# Answer extensions first.
|
||||
local answerfirst=${dialplan_answerfirst}
|
||||
local mailbox=$4
|
||||
[ -z "$5" ] || timeout=$5
|
||||
[ -z "$6" ] || answerfirst=$6
|
||||
|
||||
check_add_context "$context"
|
||||
|
||||
if [ "$dialplan_allowtransfer" == "yes" ] ; then
|
||||
planopt=${planopt}t
|
||||
fi
|
||||
if [ ! -z "${planopt}" ] ; then
|
||||
planopt=",${timeout},${planopt}"
|
||||
elif [ ! -z "${timeout}" ] ; then
|
||||
planopt=",${timeout}"
|
||||
fi
|
||||
local dial="Dial($3$planopt)"
|
||||
local item="1,"
|
||||
if [ "$answerfirst" == "yes" ] ; then
|
||||
append_dialplan_context ${context} "${ext}1,Answer"
|
||||
item="n,"
|
||||
fi
|
||||
append_dialplan_context ${context} "${ext}${item}${dial}"
|
||||
if [ ! -z "${mailbox}" ] ; then
|
||||
enable_voicemail
|
||||
append_dialplan_context ${context} "${ext}n,VoiceMail(${mailbox})"
|
||||
fi
|
||||
|
||||
append_dialplan_context ${context} "${ext}n,Congestion"
|
||||
}
|
||||
|
||||
add_dialplan_include() {
|
||||
local context=$1
|
||||
logdebug 1 "Adding Dialplan Include $1 $2"
|
||||
check_add_context "$context"
|
||||
|
||||
split_append dialplan_context_${context} "include => " "$2" "${N}"
|
||||
}
|
||||
|
||||
add_dialplan_saytime() {
|
||||
local context=$1
|
||||
logdebug 1 "Adding Dialplan saytime $1 $2"
|
||||
check_add_context "$context"
|
||||
local ext="exten => $2,"
|
||||
if [ "$dialplan_add_context_saytime" != 1 ] ; then
|
||||
append dialplan_contexts saytime " "
|
||||
dialplan_add_context_saytime=1
|
||||
enable_format gsm
|
||||
enable_module app_sayunixtime
|
||||
local zone=${asterisk_zone}
|
||||
[ ! -z "$3" ] && zone="$3"
|
||||
local format="IMp AdbY"
|
||||
[ ! -z "$4" ] && format="$4"
|
||||
append dialplan_context_saytime "exten => s,1,SayUnixTime(,${zone},${format})" "${N}"
|
||||
fi
|
||||
append_dialplan_context ${context} "${ext}1,Goto(saytime,s,1)"
|
||||
}
|
||||
|
||||
add_dialplan_goto() {
|
||||
local context=$1
|
||||
logdebug 1 "Adding Dialplan goto $1 $2 $3"
|
||||
check_add_context "$context"
|
||||
append dialplan_context_${context} "exten => $2,1,Goto($3,\${EXTEN},1)" "${N}"
|
||||
}
|
||||
|
||||
dialplan_inzone_list="match caller goto"
|
||||
|
||||
valid_dialplan_inzone() {
|
||||
is_in_list $1 ${valid_inzone_list}
|
||||
return $?
|
||||
}
|
||||
|
||||
check_append_inzone() {
|
||||
local context="${1}"
|
||||
eval "local isadded=\"\${dialplan_add_inzone_${context}-0}\""
|
||||
if [ "$isadded" != "1" ] ; then
|
||||
eval "dialplan_add_inzone_${check}=1"
|
||||
append inzone_contexts "$context"
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
handle_inzone() {
|
||||
|
||||
context_name=${1}
|
||||
check_append_inzone ${context_name}
|
||||
|
||||
option_cb(){
|
||||
case $1 in
|
||||
goto) eval "inzone_${context_name}_goto=\"\$2\"" ;;
|
||||
match_ITEM*|match) append inzone_${context_name}_match "$2" " " ;;
|
||||
caller_ITEM*|caller) append inzone_${context_name}_caller "$2" " " ;;
|
||||
include_ITEM*|include) append inzone_${context_name}_include "$2" " " ;;
|
||||
match_LENGTH|caller_LENGTH|include_LENGTH) ;;
|
||||
_*) ;;
|
||||
*) logerror "Invalid Dialplan inzone option: $1" ;;
|
||||
esac
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
append_dialplan_inzone() {
|
||||
local file=$1
|
||||
for context in ${inzone_contexts} ; do
|
||||
for i in goto match caller include ; do
|
||||
eval "iz_$i=\"\${inzone_${context}_${i}}\""
|
||||
done
|
||||
if [ -z "${iz_goto}" ] ; then
|
||||
logerror "Missing goto for inzone: ${context}"
|
||||
elif [ -z "${iz_match}" -a -z "${iz_caller}" ] ; then
|
||||
logerror "Missing match for inzone: ${context}"
|
||||
else
|
||||
echo "${N}[${context}]" >> ${file}
|
||||
for curmatch in ${iz_include} ; do
|
||||
echo "include => ${curmatch}" >> $file
|
||||
done
|
||||
|
||||
local gotoline="Goto(${iz_goto},\${EXTEN},1)"
|
||||
[ -z "${iz_match}" ] && iz_match=${match_all}
|
||||
for curmatch in ${iz_match} ; do
|
||||
if [ -z "${iz_caller}" ] ; then
|
||||
echo "exten => ${curmatch},1,${gotoline}" >> $file
|
||||
else
|
||||
for curcaller in ${iz_caller} ; do
|
||||
echo "exten => ${curmatch}/${curcaller},1,${gotoline}" >> $file
|
||||
done
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
append_dialplan_dialzone() {
|
||||
local file=$1
|
||||
|
||||
# Add the dialzone contexts
|
||||
logdebug 1 "Dialplan: Add the dialzone contexts"
|
||||
for zonename in ${dzones_match} ; do
|
||||
eval "local diallist=\${dzone_${zonename}_match-}"
|
||||
echo "${N}[${zonename}]" >> $file
|
||||
eval "dialz=\${dzone_match_use_${zonename}-}"
|
||||
|
||||
logdebug 3 "Find international options for zone ${zonename} from ${dialz}"
|
||||
for v in prefix internationalprefix alwaysinternational countrycode ; do
|
||||
eval "local $v=\${target_${v}_${dialz}:-}"
|
||||
eval logdebug 3 "\"${v} = '\${$v}'\""
|
||||
done
|
||||
|
||||
for v in localzone addprefix localprefix; do
|
||||
eval "local $v=\${dzone_${zonename}_${v}:-}"
|
||||
done
|
||||
while [ ! -z "$diallist" ] ; do
|
||||
cur=${diallist%%,*}
|
||||
nvar=${diallist#*,}
|
||||
if [ "${alwaysinternational}" = "yes" ] ; then
|
||||
# Always dial international number with this target
|
||||
# remove 'localprefix' (usually 0) from 'addprefix'
|
||||
logdebug 3 "Removing ${localprefix} from ${addprefix}"
|
||||
addprefix=${addprefix#$localprefix}
|
||||
local curlen=`expr length "${localprefix}"`
|
||||
if [ $curlen != 0 ] ; then
|
||||
# remove 0 (or local prefix)
|
||||
echo "exten => _${localprefix}${cur},1,Goto(${dialz}_dial,${countrycode}${addprefix}\${EXTEN:$curlen},1)" >> $file
|
||||
fi
|
||||
echo "exten => _${cur},1,Goto(${dialz}_dial,${countrycode}${addprefix}\${EXTEN},1)" >> $file
|
||||
else
|
||||
echo "exten => _${cur},1,Goto(${dialz}_dial,${addprefix}\${EXTEN},1)" >> $file
|
||||
fi
|
||||
[ "$nvar" == "$diallist" ] && break
|
||||
diallist=${nvar}
|
||||
done
|
||||
eval "local diallist=\${dzone_${zonename}_international-}"
|
||||
if [ ! -z "${diallist}" ] ; then
|
||||
logdebug 2 "International: ${diallist}"
|
||||
while [ ! -z "$diallist" ] ; do
|
||||
cur="${diallist%%,*}"
|
||||
nvar="${diallist#*,}"
|
||||
logdebug 4 "Adding international ${cur}"
|
||||
|
||||
local curlen=`expr length "${cur}"`
|
||||
if [ "$alwaysinternational" = "yes" ] ; then
|
||||
echo "exten => _${cur},1,Goto(${dialz}_dial,${addprefix}\${EXTEN:${curlen}},1)" >> $file
|
||||
else
|
||||
echo "exten => _${cur}.,1,Goto(${zonename}_check,${addprefix}\${EXTEN:${curlen}},1)" >> $file
|
||||
fi
|
||||
[ "$nvar" == "$diallist" ] && break
|
||||
diallist="${nvar}"
|
||||
done
|
||||
|
||||
if [ "$alwaysinternational" != "yes" ] ; then
|
||||
logdebug 2 "Not Always International:"
|
||||
# Check for local country code
|
||||
echo "[${zonename}_check]" >> $file
|
||||
|
||||
local locallen=`expr length "${countrycode}"`
|
||||
echo "exten => _${countrycode}X.,1,Goto(${localzone-default},${localprefix-0}\${EXTEN:${locallen}},1)" >> $file
|
||||
echo "exten => _X.,1,Goto(${dialz}_dial,${internationalprefix}\${EXTEN},1)" >> $file
|
||||
fi
|
||||
fi
|
||||
done
|
||||
logdebug 1 "Dialplan: Finish the dialzone contexts"
|
||||
|
||||
}
|
||||
|
||||
append_dialplan_dialzone_out(){
|
||||
local file=$1
|
||||
|
||||
# Add the dialzone target contexts (dialing out)
|
||||
logdebug 1 "Dialplan: Add the dialzone target contexts"
|
||||
for contype in SIP IAX ; do
|
||||
eval local conlist=\${dzones_${contype}-}
|
||||
logdebug 1 "Adding ${contype} targets: ${conlist}"
|
||||
for conname in $conlist ; do
|
||||
echo "${N}[${contype}_${conname}_dial]" >> $file
|
||||
for v in prefix internationalprefix alwaysinternational countrycode timeout lastdialed lastdialedtype ; do
|
||||
eval "local $v=\${target_${v}_${contype}_${conname}:-}"
|
||||
done
|
||||
|
||||
if [ -z "${lastdialed}" ] ; then
|
||||
lastdialed=${dialplan_lastdialed}
|
||||
lastdialedtype=${dialplan_lastdialedtype}
|
||||
fi
|
||||
|
||||
# [ -z "${lastcallout}" ] && lastcallout=${feature_lastcall_outqueue}
|
||||
# if [ ! -z "${lastcalloutexten}" ] ; then
|
||||
# eval "local added=\${lastcallout_outqueue_extension_${lastcalloutexten}}"
|
||||
# if [ ! "${added}" == 1 ] ; then
|
||||
# add_dialplan_lastcall extensions "${lastcalloutexten}" "${lastcallout}" "${feature_lastcall_outcount}"
|
||||
# eval "local lastcallout_outqueue_extension_${lastcalloutexten}=1"
|
||||
# fi
|
||||
# fi
|
||||
local ext="exten => _X.,"
|
||||
local en="1,"
|
||||
# Do not use prefix unles 'alwaysinternational' is yes
|
||||
[ "$alwaysinternational" != "yes" ] && internationalprefix=
|
||||
|
||||
# if [ ! -z "${lastcallout}" ] ; then # Add lastcall out
|
||||
# enable_lastcall
|
||||
# echo "${ext}${en}Macro(lastcallstore,${internationalprefix}\${EXTEN},${lastcallout},${feature_lastcall_outcount})" >> $file
|
||||
# en="n,"
|
||||
# fi
|
||||
|
||||
if [ ! -z "${lastdialed}" ] ; then
|
||||
enable_module func_callerid
|
||||
local lastparam="\${EXTEN}"
|
||||
local lastmacro=${lastdialed}
|
||||
local lastmacrotype=${lastdialedtype}
|
||||
[ -z ${lastdialedtype} ] && lastdialedtype=macro
|
||||
|
||||
local jumpmacroline=
|
||||
gen_jumpmacro jumpmacroline "${ext}${en}" "" "${lastmacrotype}" "${lastmacro}" "${lastparam}"
|
||||
echo ${jumpmacroline} >> $file
|
||||
en="n,"
|
||||
fi
|
||||
echo "${ext}${en}Dial(${contype}/${prefix}${internationalprefix}\${EXTEN}@${conname},$timeout)" >> $file
|
||||
echo "exten => _X.,n,Congestion" >> $file
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
gen_jumpmacro() {
|
||||
logdebug 3 "Gen JumpMacro /$1/=/$2/$3/$4/$5/$6/"
|
||||
local leader=$2
|
||||
local condition=$3
|
||||
local macrotype=$4
|
||||
local name=$5
|
||||
local param=$6
|
||||
|
||||
if [ -z "${condition}" ] ; then
|
||||
local cond="("
|
||||
else
|
||||
local cond="If(${condition}?"
|
||||
fi
|
||||
case ${macrotype} in
|
||||
gosub)
|
||||
enable_module app_stack # for gosub
|
||||
logdebug 1 "${1}=\"\${leader}Gosub\${cond}\${name},\${param},1)\""
|
||||
eval "${1}=\"\${leader}Gosub\${cond}\${name},\${param},1)\"" ;;
|
||||
gosub_s)
|
||||
enable_module app_stack # for gosub
|
||||
logdebug 1 "${1}=\"\${leader}Gosub\${cond}\${name},s,1(\${param}))\""
|
||||
eval "${1}=\"\${leader}Gosub\${cond}\${name},s,1(\${param}))\"" ;;
|
||||
macro)
|
||||
enable_module app_macro
|
||||
logdebug 1 "${1}=\"\${leader}Macro\${cond}\${name},\${param})\""
|
||||
eval "${1}=\"\${leader}Macro\${cond}\${name},\${param})\"" ;;
|
||||
|
||||
s|start)
|
||||
enable_module app_goto
|
||||
logdebug 1 "${1}=\"\${leader}Goto(\${iz_target},s,1)\""
|
||||
eval "${1}=\"\${leader}Goto(\${iz_target},s,1)\"" ;;
|
||||
*)
|
||||
enable_module app_goto
|
||||
logdebug 1 "${1}=\"\${leader}Goto\${cond}\${name},\${param},1)\""
|
||||
eval "${1}=\"\${leader}Goto\${cond}\${name},\${param},1)\"" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
append_jumpmacro(){
|
||||
local context=$1
|
||||
local jumpmacroline=""
|
||||
gen_jumpmacro "jumpmacroline" "$2" "$3" "$4" "$5" "$6"
|
||||
append_dialplan_context ${context} "${jumpmacroline}"
|
||||
}
|
||||
|
||||
append_dialplan_incoming(){
|
||||
local file=$1
|
||||
# Evaluate the incoming ringing dialplans
|
||||
logdebug 1 "Add the 'incoming' dialplans: ${dialplan_extensions_incoming}"
|
||||
for context in ${dialplan_extensions_incoming} ; do
|
||||
eval "local curext=\"\${dialplan_incoming_$context}\""
|
||||
logdebug 2 "Adding incoming ${curext}"
|
||||
|
||||
check_add_context "$context"
|
||||
# lastcall lastcallexten lastmissed lastmissedexten
|
||||
for i in answerfirst beforeanswer timeout menucontext \
|
||||
lastcall lastcalltype missed missedtype allowtransfer mailbox match matchcaller aftertimeout aftertimeouttype; do
|
||||
eval "local iz_$i=\"\${incoming_${context}_$i}\""
|
||||
eval "logdebug 1 \"Incoming \$context: iz_\$i=\${iz_$i}\""
|
||||
done
|
||||
[ ! -z ${iz_menucontext} ] && iz_answerfirst=yes
|
||||
|
||||
if [ ! -z ${curext} ] ; then
|
||||
[ -z ${iz_answerfirst} ] && iz_answerfirst=${incoming_answerfirst}
|
||||
# [ -z ${iz_lastcall} ] && iz_lastcall=${feature_lastcall_inqueue}
|
||||
if [ -z ${iz_lastcall} ] ; then
|
||||
iz_lastcall=${incoming_lastcall}
|
||||
iz_lastcalltype=${incoming_lastcalltype}
|
||||
fi
|
||||
if [ -z ${iz_missed} ] ; then
|
||||
iz_missed=${incoming_missed}
|
||||
iz_missedtype=${incoming_missedtype}
|
||||
fi
|
||||
[ -z ${iz_mailbox} ] && iz_mailbox=${incoming_mailbox}
|
||||
[ -z ${iz_timeout} ] && iz_timeout=${incoming_timeout}
|
||||
[ -z ${iz_allowtransfer} ] && iz_allowtransfer=${incoming_allowtransfer}
|
||||
fi
|
||||
|
||||
[ -z ${iz_match} ] && iz_match=_X.
|
||||
[ ! -z ${iz_matchcaller} ] && iz_match=${iz_match}/${iz_matchcaller}
|
||||
|
||||
local ext="exten => ${iz_match},"
|
||||
local planopt=
|
||||
[ "${iz_allowtransfer}" == "yes" ] && planopt=${planopt}t
|
||||
local item="1,"
|
||||
|
||||
#append_dialplan_context ${context} "${ext}${item}Ringing()"
|
||||
if [ ! -z "${iz_lastcall}" ] ; then
|
||||
|
||||
enable_module func_callerid
|
||||
local lastparam="\${CALLERID(num)}"
|
||||
local lastmacrotype="${iz_lastcalltype}"
|
||||
[ -z "${iz_lastcalltype}" ] && lastmacrotype=macro
|
||||
local lastmacro=${iz_lastcall}
|
||||
append_jumpmacro "${context}" "${ext}${item}" "" "${lastmacrotype}" "${lastmacro}" "${lastparam}"
|
||||
item="n,"
|
||||
fi
|
||||
if [ ! -z "${iz_missed}" ] ; then
|
||||
enable_module func_callerid
|
||||
local missedparam="\${CALLERID(num)}"
|
||||
[ -z "${iz_missedtype}" ] && iz_missedtype=macro
|
||||
|
||||
append_dialplan_context ${context} "${ext}${item}Set(lcsMissed=\${CALLERID(num)})"
|
||||
item="n,"
|
||||
fi
|
||||
# Ring before answering
|
||||
if [ ! -z "${iz_beforeanswer}" -a ! -z "${curext}" ] ; then
|
||||
append_dialplan_context ${context} "${ext}${item}Dial(${curext},${iz_beforeanswer},${planopt})"
|
||||
iz_answerfirst=yes
|
||||
item="n,"
|
||||
fi
|
||||
# Now answer
|
||||
if [ "$iz_answerfirst" == "yes" ] ; then
|
||||
append_dialplan_context ${context} "${ext}${item}Answer"
|
||||
item="n,"
|
||||
fi
|
||||
# if [ ! -z ${iz_lastcallexten} ] ; then
|
||||
# enable_lastcall
|
||||
# add_dialplan_lastcall extensions "${iz_lastcallexten}" "${iz_lastcall}" "${feature_lastcall_incount}"
|
||||
# fi
|
||||
|
||||
if [ ! -z ${curext} ] ; then
|
||||
if [ ! -z ${iz_menucontext} ] ; then
|
||||
planopt=${planopt}rd
|
||||
enable_module res_indications
|
||||
# wait so the next ring connects.
|
||||
append_dialplan_context ${context} "${ext}${item}Wait(1)"
|
||||
append_dialplan_context ${context} "${ext}n,Set(EXITCONTEXT=${iz_menucontext})"
|
||||
fi
|
||||
|
||||
if [ ! -z ${planopt} ] ; then
|
||||
planopt=",${iz_timeout-},${planopt}"
|
||||
elif [ ! -z ${iz_timeout-} ] ; then
|
||||
planopt=",${iz_timeout-}"
|
||||
fi
|
||||
local dial="Dial(${curext}${planopt})"
|
||||
|
||||
append_dialplan_context ${context} "${ext}n,${dial})"
|
||||
|
||||
if [ ! -z ${iz_missed} ] ; then
|
||||
# It went to voicemail or was hung up - consider missed
|
||||
append_jumpmacro ${context} "${ext}${item}" "" "${iz_missedtype}" "${iz_missed}" "\${lcsMissed}"
|
||||
fi
|
||||
fi
|
||||
|
||||
local need_hangup=1
|
||||
# Add a goto or macro at the end
|
||||
if [ ! -z ${iz_target} ] ; then
|
||||
case ${iz_aftertimeouttype} in
|
||||
macro) append_dialplan_context ${context} "${ext}${item}Macro(${iz_target})";;
|
||||
s|start) append_dialplan_context ${context} "${ext}${item}Goto(${iz_target},s,1)"
|
||||
need_hangup=0;;
|
||||
*) append_dialplan_context ${context} "${ext}${item}Goto(${iz_target},\${EXTEN},1)"
|
||||
need_hangup=0;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ ! -z ${iz_mailbox} ] ; then
|
||||
enable_voicemail
|
||||
append_dialplan_context ${context} "${ext}n,VoiceMail(${iz_mailbox})"
|
||||
fi
|
||||
|
||||
[ "${need_hangup}" = "1" ] && append_dialplan_context ${context} "${ext}n,Hangup"
|
||||
|
||||
if [ ! -z ${iz_missed} ] ; then
|
||||
# Check for missed call
|
||||
|
||||
append_jumpmacro ${context} "exten => h,1," "\$[\"\${DIALSTATUS}\" = \"CANCEL\"]" "${iz_missedtype}" "${iz_missed}" "\${lcsMissed}"
|
||||
#append dialplan_context_${context} \
|
||||
# "exten => h,1,MacroIf(\$[\"\${DIALSTATUS}\" = \"CANCEL\"]?lastcallstore,\${lcsMissed},${iz_lastmissed},${feature_lastcall_incount})" "${N}"
|
||||
# [ ! -z ${iz_lastmissedexten} ] && \
|
||||
# add_dialplan_lastcall extensions "${iz_lastmissedexten}" "${iz_lastmissed}" "${feature_lastcall_incount}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
append_dialplan_extensions(){
|
||||
local file=$1
|
||||
# Evaluate the 'extension' dialplans
|
||||
logdebug 1 "Add the 'extension' dialplans: ${dialplan_exts}"
|
||||
for i in ${dialplan_exts} ; do
|
||||
eval "local curext=\"\${dialplan_ext_$i}\""
|
||||
add_dialplan_exten extensions $i $curext
|
||||
done
|
||||
}
|
||||
|
||||
append_include() {
|
||||
append dialplan_includes "#include <$1>" "$N"
|
||||
}
|
||||
|
||||
|
||||
create_dialplanconf() {
|
||||
# Add general section
|
||||
logdebug 1 "Dialplan: Add general section"
|
||||
local file=${DEST_DIR}/extensions.conf
|
||||
get_checksum dialplan_conf $file
|
||||
|
||||
echo "${asteriskuci_gen}" > $file
|
||||
|
||||
[ -z "${dialplan_includes}" ] || (echo "${dialplan_includes}${N}" >> $file)
|
||||
|
||||
if [ ! -z "${dialplan_globals}" ] ; then
|
||||
echo "[globals]${N}${dialplan_globals}${N}" >> $file
|
||||
fi
|
||||
|
||||
echo "[general]" >> $file
|
||||
for i in ${dialplangeneral_list} ; do
|
||||
eval "local val=\"\$dialplan_$i\""
|
||||
if [ ! -z "$val" ] ; then
|
||||
echo "$i=$val" >> $file
|
||||
fi
|
||||
done
|
||||
|
||||
append_dialplan_dialzone "$file"
|
||||
|
||||
append_dialplan_dialzone_out "$file"
|
||||
|
||||
append_dialplan_park "$file"
|
||||
|
||||
append_dialplan_extensions "$file"
|
||||
|
||||
append_dialplan_inzone "$file"
|
||||
|
||||
append_dialplan_incoming "$file"
|
||||
|
||||
|
||||
# append_dialplan_lastcall "$file"
|
||||
|
||||
# Add all the contexts
|
||||
logdebug 1 "Dialplan: Add all the contexts"
|
||||
for i in ${dialplan_contexts} ; do
|
||||
echo "${N}[$i]" >> $file
|
||||
[ "${i#macro-}" == "${i}" ] || i=macro__${i#macro-}
|
||||
eval "local curcontext=\"\${dialplan_context_$i-}\""
|
||||
echo "$curcontext">> $file
|
||||
eval unset dialplan_context_$i
|
||||
done
|
||||
|
||||
check_checksum "$dialplan_conf" "$file" || ast_dialplan_restart=1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
handle_dialplangeneral() {
|
||||
option_cb(){
|
||||
if valid_dialplangeneral $1 $2 ; then
|
||||
eval "dialplan_$1=\"$2\""
|
||||
else
|
||||
logerror "Invalid Dialplan General option: $1"
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
handle_dialplan(){
|
||||
context_name=$1
|
||||
if [ -z ${context_name} ] ; then
|
||||
logerror "Context name required for dialplan"
|
||||
context_name=default
|
||||
fi
|
||||
option_cb() {
|
||||
logdebug 4 "dialplan ${context_name}: '$1' '$2'"
|
||||
case $1 in
|
||||
include_LENGTH) ;;
|
||||
include|include_ITEM*) add_dialplan_include ${context_name} $2 ;;
|
||||
_*) ;;
|
||||
*)
|
||||
lhs=$1
|
||||
logdebug 4 "Add extension $lhs"
|
||||
if [ "$(expr $lhs : [0-9][0-9]\*)" != 0 ] ; then
|
||||
addtype=${2%%:*}
|
||||
if [ "${addtype}" == "$2" ]; then
|
||||
addparam=
|
||||
else
|
||||
addparam=${2#*:}
|
||||
fi
|
||||
case ${addtype} in
|
||||
mailbox|voice)
|
||||
add_dialplan_voice ${context_name} $1 $addparam ;;
|
||||
meetme|conf|conference) add_dialplan_meetme ${context_name} $1 $addparam ;;
|
||||
saytime|time) add_dialplan_saytime ${context_name} $1 $addparam ;;
|
||||
clock) add_dialplan_talkclock ${context_name} $1 $addparam ;;
|
||||
*) logerror "Unknown type '${addtype}' in dialplan ${context_name}, extension ${1}"
|
||||
esac
|
||||
else
|
||||
logerror "Invalid option: $1 for dialplan ${context_name}"
|
||||
fi
|
||||
esac
|
||||
}
|
||||
}
|
||||
|
||||
handle_dialplanexten() {
|
||||
check_add dialplanexten
|
||||
option_cb() {
|
||||
case $1 in
|
||||
dialplan|extension|type|target|dialextension|voicebox|timeout|answerfirst)
|
||||
eval "dial_exten_$1=\"$2\""
|
||||
esac
|
||||
}
|
||||
}
|
||||
|
||||
check_add_dialplanexten() {
|
||||
if [ ! -z "${dial_exten_dialplan}" -a ! -z "${dial_exten_extension}" ] ; then
|
||||
|
||||
local dialext_type=
|
||||
local dialext_ext=
|
||||
if ! split_targettype dialext_type dialext_ext "${dial_exten_target}" ; then
|
||||
if [ -z "${dial_exten_type}" ] ; then
|
||||
logerror "No extension type specified for ${dial_exten_dialplan} ${dial_exten_extension}"
|
||||
return 1
|
||||
fi
|
||||
dialext_type="${dial_exten_type}"
|
||||
dialext_ext="${dial_exten_target}"
|
||||
fi
|
||||
|
||||
|
||||
local dialtarget="${dialext_type}/${dialexten_ext}${dial_exten_dialextension+/}${dial_exten_dialextension}"
|
||||
|
||||
check_add_context ${dial_exten_dialplan}
|
||||
add_dialplan_exten "${dial_exten_dialplan}" "${dial_exten_extension}" \
|
||||
"${dialtarget}" "${dial_exten_voicebox}" "${dial_exten_timeout}" \
|
||||
"${dial_exten_answerfirst}"
|
||||
fi
|
||||
for i in dialplan extension voicebox type target dialextension timeout answerfirst ; do
|
||||
eval "unset dial_voice_$i"
|
||||
done
|
||||
}
|
||||
|
||||
handle_dialplansaytime() {
|
||||
check_add dialplansaytime
|
||||
option_cb() {
|
||||
case $1 in
|
||||
dialplan|extension|zone|format)
|
||||
eval "dial_saytime_$1=\"$2\""
|
||||
esac
|
||||
}
|
||||
}
|
||||
|
||||
check_add_dialplansaytime() {
|
||||
logdebug 1 "Add Saytime to $1 / $2"
|
||||
if [ ! -z "${dial_saytime_dialplan}" -a ! -z "${dial_saytime_extension}" ] ; then
|
||||
# local ext="exten => ${dial_saytime_extension},"
|
||||
[ -z "${dial_saytime_dialplan}" ] && dial_saytime_dialplan=default
|
||||
|
||||
add_dialplan_saytime "${dial_saytime_dialplan}" "${dial_saytime_extension}" \
|
||||
"${dial_saytime_zone}" "${dial_saytime_format}"
|
||||
fi
|
||||
for i in dialplan extension zone format; do
|
||||
eval "unset dial_saytime_$i"
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
handle_dialzone_match() {
|
||||
eval "local isadded=\"\${dzone_${zone_name}-0}\""
|
||||
if [ "${isadded}" != "1" ] ; then
|
||||
eval "dzone_${zone_name}=1"
|
||||
append dzones_match ${zone_name} " "
|
||||
fi
|
||||
append dzone_${zone_name}_match $1 ","
|
||||
}
|
||||
|
||||
# Set up outgoing zones (match patterns)
|
||||
handle_dialzone() {
|
||||
zone_name=$1
|
||||
logdebug 2 "Loading dialzone: $zone_name"
|
||||
option_cb(){
|
||||
logdebug 2 "Dialzone $1/$2"
|
||||
case $1 in
|
||||
uses)
|
||||
local areatype=
|
||||
local areaname=
|
||||
split_targettype areatype areaname "$2"
|
||||
logdebug 3 "Added: $areatype $areaname"
|
||||
eval "local isadded=\"\${dzone_${areatype}_${areaname}-0}\""
|
||||
if [ "${isadded}" != "1" ] ; then
|
||||
eval dzone_${areatype}_${areaname}=1
|
||||
append dzones_${areatype} "${areaname}" " "
|
||||
fi
|
||||
eval "dzone_match_use_${zone_name}=${areatype}_${areaname}"
|
||||
logdebug 3 "Finished uses"
|
||||
;;
|
||||
match_LENGTH) ;;
|
||||
match|match_ITEM*)
|
||||
handle_dialzone_match "$2"
|
||||
;;
|
||||
international_LENGTH) ;;
|
||||
international|international_ITEM*)
|
||||
eval "local isadded=\"$dzone_${zone_name}\""
|
||||
if [ "${isadded}" != "1" ] ; then
|
||||
eval "dzone_${zone_name}=1"
|
||||
append dzones_match ${zone_name} " "
|
||||
fi
|
||||
append dzone_${zone_name}_international $2 ","
|
||||
;;
|
||||
countrycode|localzone|addprefix|localprefix)
|
||||
eval "dzone_${zone_name}_${1}=\"$2\""
|
||||
eval "y=\${dzone_${zone_name}_${1}}"
|
||||
;;
|
||||
*)
|
||||
logerror "Invalid Dialzone option: $1 in zone '${zone_name}'" ;;
|
||||
esac
|
||||
}
|
||||
}
|
||||
|
||||
check_add_dialplangoto() {
|
||||
logdebug 1 "Add Goto to $1 / $2"
|
||||
if [ ! -z "${dial_goto_dialplan}" -a ! -z "${dial_goto_extension}" ] ; then
|
||||
local ext="exten => ${dial_goto_extension},"
|
||||
check_add_context ${dial_goto_dialplan}
|
||||
append_dialplan_context ${dial_goto_dialplan} "${ext}1,Goto(${dial_goto_target})"
|
||||
fi
|
||||
for i in dialplan extension room ; do
|
||||
eval "unset dial_goto_$i"
|
||||
done
|
||||
}
|
||||
|
||||
handle_dialplangoto(){
|
||||
check_add dialplangoto
|
||||
option_cb() {
|
||||
case $1 in
|
||||
dialplan|extension|target)
|
||||
eval "dial_goto_$1=\"$2\"" ;;
|
||||
*) logerror "Invalid dialplangoto option: $1"
|
||||
esac
|
||||
}
|
||||
}
|
||||
|
||||
# Options for incoming calls.
|
||||
|
||||
valid_incoming_list="allowtransfer timeout answerfirst mailbox lastcall lastcalltype missed missedtype"
|
||||
|
||||
valid_incoming_option() {
|
||||
is_in_list $1 ${valid_incoming_list}
|
||||
return $?
|
||||
}
|
||||
|
||||
handle_incominggeneral() {
|
||||
option_cb() {
|
||||
if valid_incoming_option $1 ; then
|
||||
logdebug 3 "Add Incoming General option $1=$2"
|
||||
eval "incoming_${1}=\"$2\""
|
||||
else
|
||||
logerror "Invalid incominggeneral option $1"
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
add_incoming_context() {
|
||||
local context=$1
|
||||
eval "local added=\${dialplan_incoming_${context}_added}"
|
||||
if [ "${added}" != "1" ] ; then
|
||||
append dialplan_extensions_incoming "${context}" " "
|
||||
eval "dialplan_incoming_${context}_added=1"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# Add to incoming ringing
|
||||
add_incoming() {
|
||||
local rhs="$3"
|
||||
|
||||
while [ ! -z "$rhs" ] ; do
|
||||
cur=${rhs%%,*}
|
||||
nvar=${rhs#*,}
|
||||
add_incoming_context ${cur}
|
||||
append dialplan_incoming_${cur} "$1/$2" "&"
|
||||
[ "$nvar" == "$rhs" ] && break
|
||||
rhs=${nvar}
|
||||
done
|
||||
}
|
||||
|
||||
to_upper() {
|
||||
eval "$1=`echo \"$2\"|tr [a-z] [A-Z]`"
|
||||
}
|
||||
to_lower() {
|
||||
eval "$1=`echo \"$2\"|tr [A-Z] [a-z]`"
|
||||
}
|
||||
|
||||
split_targettype() { # TYPE target inputEntry
|
||||
local l_targettype="${3%[-_/]*}"
|
||||
if [ "${l_targettype}" == "$3" ] ; then
|
||||
return 1
|
||||
fi
|
||||
local l_targetname="${3#*[-_/]}"
|
||||
to_upper "$1" "${l_targettype}"
|
||||
eval "$2=\"${l_targetname}\""
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
handle_incoming() {
|
||||
incoming_context=$1
|
||||
incoming_list=
|
||||
add_incoming_context "${incoming_context}"
|
||||
|
||||
option_cb() {
|
||||
logdebug 1 "Incoming ${incoming_context} $1=$2"
|
||||
case $1 in
|
||||
lastcall|lastcalltype|missed|missedtype) eval "incoming_${incoming_context}_${1}=\"$2\"" ;;
|
||||
# lastcall|lastcallexten|lastmissed|lastmissedexten)
|
||||
# enable_lastcall
|
||||
# eval "incoming_${incoming_context}_${1}=\"$2\""
|
||||
# ;;
|
||||
mailbox|allowtransfer|answerfirst|beforeanswer|timeout|menucontext|match|matchcaller|aftertimeout|aftertimeouttype)
|
||||
eval "incoming_${incoming_context}_${1}=\"$2\""
|
||||
;;
|
||||
target|target_ITEM*)
|
||||
local targettype=
|
||||
local targetname=
|
||||
if split_targettype targettype targetname "${2}" ; then
|
||||
append dialplan_incoming_${incoming_context} "${targettype}/${targetname}" "&"
|
||||
else
|
||||
logerror "No target type specified for target=$2 in ${incoming_context}"
|
||||
fi
|
||||
;;
|
||||
target_LENGTH|member_LENGTH) ;;
|
||||
*) logerror "Invalid option $1 in incoming" ;;
|
||||
esac
|
||||
}
|
||||
}
|
||||
|
||||
# vim: ts=2 sw=2 noet foldmethod=indent
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue