2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6 Copyright 2013 Manuel Munz <freifunk at somakoma dot de>
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
16 require("luci.tools.webadmin")
18 m = Map("ddns", translate("Dynamic DNS"),
19 translate("Dynamic DNS allows that your router can be reached with " ..
20 "a fixed hostname while having a dynamically changing " ..
23 s = m:section(TypedSection, "service", "")
27 s:option(Flag, "enabled", translate("Enable"))
29 svc = s:option(ListValue, "service_name", translate("Service"))
31 svc.default = "dyndns.org"
34 local fd = io.open("/usr/lib/ddns/services", "r")
39 local s = ln and ln:match('^%s*"([^"]+)"')
40 if s then services[#services+1] = s end
46 for _, v in luci.util.vspairs(services) do
50 function svc.cfgvalue(...)
51 local v = Value.cfgvalue(...)
52 if not v or #v == 0 then
59 function svc.write(self, section, value)
61 m.uci:delete("ddns", section, self.option)
63 Value.write(self, section, value)
67 svc:value("-", "-- "..translate("custom").." --")
69 local url = s:option(Value, "update_url", translate("Custom update-URL"))
70 url:depends("service_name", "-")
73 local hostname = s:option(Value, "domain", translate("Hostname"))
74 hostname.rmempty = true
75 hostname.default = "mypersonaldomain.dyndns.org"
76 hostname.datatype = "host"
78 local username = s:option(Value, "username", translate("Username"))
79 username.rmempty = true
81 local pw = s:option(Value, "password", translate("Password"))
85 require("luci.tools.webadmin")
87 local src = s:option(ListValue, "ip_source",
88 translate("Source of IP address"))
89 src.default = "network"
90 src:value("network", translate("network"))
91 src:value("interface", translate("interface"))
92 src:value("web", translate("URL"))
94 local iface = s:option(ListValue, "ip_network", translate("Network"))
95 iface:depends("ip_source", "network")
98 luci.tools.webadmin.cbi_add_networks(iface)
99 iface = s:option(ListValue, "ip_interface", translate("Interface"))
100 iface:depends("ip_source", "interface")
102 for k, v in pairs(luci.sys.net.devices()) do
106 local web = s:option(Value, "ip_url", translate("URL"))
107 web:depends("ip_source", "web")
108 web.default = "http://checkip.dyndns.com/"
112 local ci = s:option(Value, "check_interval", translate("Check for changed IP every"))
113 ci.datatype = "and(uinteger,min(1))"
116 local unit = s:option(ListValue, "check_unit", translate("Check-time unit"))
117 unit.default = "minutes"
118 unit:value("minutes", translate("min"))
119 unit:value("hours", translate("h"))
121 fi = s:option(Value, "force_interval", translate("Force update every"))
122 fi.datatype = "and(uinteger,min(1))"
125 local unit = s:option(ListValue, "force_unit", translate("Force-time unit"))
126 unit.default = "hours"
127 unit:value("minutes", translate("min"))
128 unit:value("hours", translate("h"))