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 interface = s:option(ListValue, "interface", translate("Event interface"), translate("Network on which the ddns-updater scripts will be started"))
30 luci.tools.webadmin.cbi_add_networks(interface)
31 interface.default = "wan"
33 svc = s:option(ListValue, "service_name", translate("Service"))
35 svc.default = "dyndns.org"
38 local fd = io.open("/usr/lib/ddns/services", "r")
43 local s = ln and ln:match('^%s*"([^"]+)"')
44 if s then services[#services+1] = s end
50 for _, v in luci.util.vspairs(services) do
54 function svc.cfgvalue(...)
55 local v = Value.cfgvalue(...)
56 if not v or #v == 0 then
63 function svc.write(self, section, value)
65 m.uci:delete("ddns", section, self.option)
67 Value.write(self, section, value)
71 svc:value("-", "-- "..translate("custom").." --")
73 local url = s:option(Value, "update_url", translate("Custom update-URL"))
74 url:depends("service_name", "-")
77 local hostname = s:option(Value, "domain", translate("Hostname"))
78 hostname.rmempty = true
79 hostname.default = "mypersonaldomain.dyndns.org"
80 hostname.datatype = "host"
82 local username = s:option(Value, "username", translate("Username"))
83 username.rmempty = true
85 local pw = s:option(Value, "password", translate("Password"))
89 require("luci.tools.webadmin")
91 local src = s:option(ListValue, "ip_source",
92 translate("Source of IP address"))
93 src.default = "network"
94 src:value("network", translate("network"))
95 src:value("interface", translate("interface"))
96 src:value("web", translate("URL"))
98 local iface = s:option(ListValue, "ip_network", translate("Network"))
99 iface:depends("ip_source", "network")
101 iface.default = "wan"
102 luci.tools.webadmin.cbi_add_networks(iface)
103 iface = s:option(ListValue, "ip_interface", translate("Interface"))
104 iface:depends("ip_source", "interface")
106 for k, v in pairs(luci.sys.net.devices()) do
110 local web = s:option(Value, "ip_url", translate("URL"))
111 web:depends("ip_source", "web")
112 web.default = "http://checkip.dyndns.com/"
116 local ci = s:option(Value, "check_interval", translate("Check for changed IP every"))
117 ci.datatype = "and(uinteger,min(1))"
120 local unit = s:option(ListValue, "check_unit", translate("Check-time unit"))
121 unit.default = "minutes"
122 unit:value("minutes", translate("min"))
123 unit:value("hours", translate("h"))
125 fi = s:option(Value, "force_interval", translate("Force update every"))
126 fi.datatype = "and(uinteger,min(1))"
129 local unit = s:option(ListValue, "force_unit", translate("Force-time unit"))
130 unit.default = "hours"
131 unit:value("minutes", translate("min"))
132 unit:value("hours", translate("h"))