From 7baa5604664d973c31fb08105a78908ec9a07ed9 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sat, 14 Nov 2009 18:41:13 +0000 Subject: [PATCH] NIU: DDNS --- modules/niu/luasrc/controller/niu/network.lua | 5 ++ modules/niu/luasrc/model/cbi/niu/network/ddns.lua | 18 ++++++ modules/niu/luasrc/model/cbi/niu/network/ddns1.lua | 64 ++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 modules/niu/luasrc/model/cbi/niu/network/ddns.lua create mode 100644 modules/niu/luasrc/model/cbi/niu/network/ddns1.lua diff --git a/modules/niu/luasrc/controller/niu/network.lua b/modules/niu/luasrc/controller/niu/network.lua index 9301e2502..c0afba9e5 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 000000000..0ee821a23 --- /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 000000000..497a9c025 --- /dev/null +++ b/modules/niu/luasrc/model/cbi/niu/network/ddns1.lua @@ -0,0 +1,64 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth +Copyright 2008 Jo-Philipp Wich + +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 -- 2.11.0