497a9c02566ee39d90bf16a9b9b4ba693c861413
[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 your router 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 function current.value(self, section)
44         local dns = nxo.getaddrinfo(dom:cfgvalue(section))
45         if dns then
46                 for _, v in ipairs(dns) do
47                         if v.family == "inet" then
48                                 return v.address
49                         end
50                 end
51         end
52         return ""
53 end
54
55 s:tab("expert", translate("Expert Settings"))
56
57 local src = s:taboption("expert", ListValue, "ip_source", "External IP Determination")
58 src.default = "web"
59 src:value("web", "CheckIP / WhatIsMyIP webservice")
60 src:value("network", "External Address as seen locally")
61
62
63
64 return m