2 LuCI - Lua Configuration Interface
4 Copyright 2008 Jo-Philipp Wich <xm@subsignal.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
16 local ast = require("luci.asterisk")
21 if arg[2] == "info" then
22 form = SimpleForm("asterisk", "SIP Trunk Information")
24 form.submit = "Back to overview"
26 local info, keys = ast.sip.peer(arg[1])
29 for _, key in ipairs(keys) do
32 val = type(info[key]) == "boolean"
33 and ( info[key] and "yes" or "no" )
34 or ( info[key] == nil or #info[key] == 0 )
36 or tostring(info[key])
40 itbl = form:section(Table, data, "SIP Trunk %q" % arg[1])
41 itbl:option(DummyValue, "key", "Key")
42 itbl:option(DummyValue, "val", "Value")
44 function itbl.parse(...)
46 luci.dispatcher.build_url("admin", "asterisk", "trunks")
56 cbimap = Map("asterisk", "Edit SIP Trunk")
58 peer = cbimap:section(NamedSection, arg[1])
64 back = peer:option(DummyValue, "_overview", "Back to trunk overview")
66 back.titleref = luci.dispatcher.build_url("admin", "asterisk", "trunks")
68 sipdomain = peer:option(Value, "host", "SIP Domain")
69 sipport = peer:option(Value, "port", "SIP Port")
70 function sipport.cfgvalue(...)
71 return AbstractValue.cfgvalue(...) or "5060"
74 username = peer:option(Value, "username", "Authorization ID")
75 password = peer:option(Value, "secret", "Authorization Password")
76 password.password = true
78 outboundproxy = peer:option(Value, "outboundproxy", "Outbound Proxy")
79 outboundport = peer:option(Value, "outboundproxyport", "Outbound Proxy Port")
81 register = peer:option(Flag, "register", "Register with peer")
82 register.enabled = "yes"
83 register.disabled = "no"
85 regext = peer:option(Value, "registerextension", "Extension to register (optional)")
86 regext:depends({register="1"})
88 didval = peer:option(ListValue, "_did", "Number of assigned DID numbers")
89 didval:value("", "(none)")
90 for i=1,24 do didval:value(i) end
92 dialplan = peer:option(ListValue, "context", "Dialplan Context")
93 dialplan:value(arg[1] .. "_inbound", "(default)")
94 cbimap.uci:foreach("asterisk", "dialplan",
95 function(s) dialplan:value(s['.name']) end)