diff options
author | Steven Barth <steven@midlink.org> | 2009-11-14 18:41:13 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2009-11-14 18:41:13 +0000 |
commit | 7baa5604664d973c31fb08105a78908ec9a07ed9 (patch) | |
tree | c164d2fdbff7df6bae6fbfe03c6ddd99a18cc00a /modules/niu/luasrc | |
parent | 730a9b6f69ecd1ce26b0e1c9bcd51ccf42f56f31 (diff) |
NIU: DDNS
Diffstat (limited to 'modules/niu/luasrc')
-rw-r--r-- | modules/niu/luasrc/controller/niu/network.lua | 5 | ||||
-rw-r--r-- | modules/niu/luasrc/model/cbi/niu/network/ddns.lua | 18 | ||||
-rw-r--r-- | modules/niu/luasrc/model/cbi/niu/network/ddns1.lua | 64 |
3 files changed, 87 insertions, 0 deletions
diff --git a/modules/niu/luasrc/controller/niu/network.lua b/modules/niu/luasrc/controller/niu/network.lua index 9301e25028..c0afba9e52 100644 --- a/modules/niu/luasrc/controller/niu/network.lua +++ b/modules/niu/luasrc/controller/niu/network.lua @@ -41,6 +41,11 @@ function index() entry({"niu", "network", "conntrack"}, call("cnntrck"), "Display Local Network Activity", 50) + + if fs.access("/etc/config/ddns") then + entry({"niu", "network", "ddns"}, cbi("niu/network/ddns", toniu), + "Configure Dynamic-DNS names", 60) + end end function cnntrck() diff --git a/modules/niu/luasrc/model/cbi/niu/network/ddns.lua b/modules/niu/luasrc/model/cbi/niu/network/ddns.lua new file mode 100644 index 0000000000..0ee821a23e --- /dev/null +++ b/modules/niu/luasrc/model/cbi/niu/network/ddns.lua @@ -0,0 +1,18 @@ +local uci = require "luci.model.uci" +local cursor = uci.cursor() +local d = Delegator() +d.allow_finish = true +d.allow_back = true +d.allow_cancel = true + +d:add("ddns1", load("niu/network/ddns1")) + +function d.on_cancel() + cursor:revert("ddns") +end + +function d.on_done() + cursor:commit("ddns") +end + +return d
\ No newline at end of file diff --git a/modules/niu/luasrc/model/cbi/niu/network/ddns1.lua b/modules/niu/luasrc/model/cbi/niu/network/ddns1.lua new file mode 100644 index 0000000000..497a9c0256 --- /dev/null +++ b/modules/niu/luasrc/model/cbi/niu/network/ddns1.lua @@ -0,0 +1,64 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- +local nxo = require "nixio" + +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.")) + +s = m:section(TypedSection, "service", "") +s:depends("enabled", "1") +s.addremove = true + +s.defaults.enabled = "1" +s.defaults.ip_network = "wan" +s.defaults.ip_url = "http://checkip.dyndns.org http://www.whatismyip.com/automation/n09230945.asp" + + +s:tab("general", translate("General Settings")) + +svc = s:taboption("general", ListValue, "service_name", translate("Service")) +svc:value("dyndns.org") +svc:value("no-ip.com") +svc:value("changeip.com") +svc:value("zoneedit.com") + + +s:taboption("general", Value, "username", translate("Username")) +pw = s:taboption("general", Value, "password", translate("Password")) +pw.password = true +local dom = s:taboption("general", Value, "domain", translate("Hostname")) + +local current = s:taboption("general", DummyValue, "_current", "Current IP-Address") +function current.value(self, section) + local dns = nxo.getaddrinfo(dom:cfgvalue(section)) + if dns then + for _, v in ipairs(dns) do + if v.family == "inet" then + return v.address + end + end + end + return "" +end + +s:tab("expert", translate("Expert Settings")) + +local src = s:taboption("expert", ListValue, "ip_source", "External IP Determination") +src.default = "web" +src:value("web", "CheckIP / WhatIsMyIP webservice") +src:value("network", "External Address as seen locally") + + + +return m |