Cosmetic changes to the terminology in the UI:
[project/luci.git] / modules / niu / luasrc / model / cbi / niu / network / ddns1.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6
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
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15 local nxo = require "nixio"
16
17 m = Map("ddns", translate("Dynamic DNS"), translate("Dynamic DNS allows that this device can be reached with a fixed hostname while having a dynamically changing IP-Address."))
18
19 s = m:section(TypedSection, "service", "")
20 s:depends("enabled", "1")
21 s.addremove = true
22
23 s.defaults.enabled = "1"
24 s.defaults.ip_network = "wan"
25 s.defaults.ip_url = "http://checkip.dyndns.org http://www.whatismyip.com/automation/n09230945.asp"
26
27
28 s:tab("general", translate("General Settings"))
29
30 svc = s:taboption("general", ListValue, "service_name", translate("Service"))
31 svc:value("dyndns.org")
32 svc:value("no-ip.com")
33 svc:value("changeip.com")
34 svc:value("zoneedit.com")
35
36
37 s:taboption("general", Value, "username", translate("Username"))
38 pw = s:taboption("general", Value, "password", translate("Password"))
39 pw.password = true
40 local dom = s:taboption("general", Value, "domain", translate("Hostname"))
41
42 local current = s:taboption("general", DummyValue, "_current", "Current IP-Address")
43
44 function current.render(self, section, ...)
45         if dom:cfgvalue(section) then
46                 return DummyValue.render(self, section, ...)
47         end
48 end
49
50 function current.value(self, section)
51         local dns = nxo.getaddrinfo(dom:cfgvalue(section))
52         if dns then
53                 for _, v in ipairs(dns) do
54                         if v.family == "inet" then
55                                 return v.address
56                         end
57                 end
58         end
59         return ""
60 end
61
62 s:tab("expert", translate("Expert Settings"))
63
64 local src = s:taboption("expert", ListValue, "ip_source", "External IP Determination")
65 src.default = "web"
66 src:value("web", "CheckIP / WhatIsMyIP webservice")
67 src:value("network", "External Address as seen locally")
68
69
70
71 return m