NIU: DDNS

This commit is contained in:
Steven Barth 2009-11-14 18:41:13 +00:00
parent 730a9b6f69
commit 7baa560466
3 changed files with 87 additions and 0 deletions

View file

@ -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()

View file

@ -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

View file

@ -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