2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
16 require("luci.tools.webadmin")
18 local is_mini = (luci.dispatcher.context.path[1] == "mini")
21 m = Map("ddns", translate("Dynamic DNS"),
22 translate("Dynamic DNS allows that your router can be reached with " ..
23 "a fixed hostname while having a dynamically changing " ..
26 s = m:section(TypedSection, "service", "")
30 s:option(Flag, "enabled", translate("Enable"))
32 interface = s:option(ListValue, "interface", translate("Event interface"), translate("On which interface up should start the ddns script process."))
33 luci.tools.webadmin.cbi_add_networks(interface)
34 interface.default = "wan"
36 svc = s:option(ListValue, "service_name", translate("Service"))
40 local fd = io.open("/usr/lib/ddns/services", "r")
45 local s = ln and ln:match('^%s*"([^"]+)"')
46 if s then services[#services+1] = s end
52 for _, v in luci.util.vspairs(services) do
56 function svc.cfgvalue(...)
57 local v = Value.cfgvalue(...)
58 if not v or #v == 0 then
65 function svc.write(self, section, value)
67 m.uci:delete("ddns", section, self.option)
69 Value.write(self, section, value)
73 svc:value("-", "-- "..translate("custom").." --")
75 url = s:option(Value, "update_url", translate("Custom update-URL"))
76 url:depends("service_name", "-")
79 s:option(Value, "domain", translate("Hostname")).rmempty = true
80 s:option(Value, "username", translate("Username")).rmempty = true
81 pw = s:option(Value, "password", translate("Password"))
87 s.defaults.ip_source = "network"
88 s.defaults.ip_network = "wan"
91 src = s:option(ListValue, "ip_source",
92 translate("Source of IP address"))
93 src:value("network", translate("network"))
94 src:value("interface", translate("interface"))
95 src:value("web", translate("URL"))
97 iface = s:option(ListValue, "ip_network", translate("Network"))
98 iface:depends("ip_source", "network")
100 luci.tools.webadmin.cbi_add_networks(iface)
102 iface = s:option(ListValue, "ip_interface", translate("Interface"))
103 iface:depends("ip_source", "interface")
105 for k, v in pairs(luci.sys.net.devices()) do
109 web = s:option(Value, "ip_url", translate("URL"))
110 web:depends("ip_source", "web")
115 s:option(Value, "check_interval",
116 translate("Check for changed IP every")).default = 10
117 unit = s:option(ListValue, "check_unit", translate("Check-time unit"))
118 unit.default = "minutes"
119 unit:value("minutes", translate("min"))
120 unit:value("hours", translate("h"))
122 s:option(Value, "force_interval", translate("Force update every")).default = 72
123 unit = s:option(ListValue, "force_unit", translate("Force-time unit"))
124 unit.default = "hours"
125 unit:value("minutes", translate("min"))
126 unit:value("hours", translate("h"))