--- optional DNS Server to use resolving my IP if "ip_source"="web"
-dns = ns:taboption("advanced", Value, "dns_server",
- translate("DNS-Server"),
- translate("OPTIONAL: Use non-default DNS-Server to detect 'Registered IP'.") .. "<br />" ..
- translate("Format: IP or FQDN"))
-dns.placeholder = "mydns.lan"
-function dns.validate(self, value)
- -- if .datatype is set, then it is checked before calling this function
- if not value or (#value == 0) then
- return "" -- ignore on empty
- elseif not DTYP.host(value) then
- return nil, err_tab_adv(self) .. translate("use hostname, FQDN, IPv4- or IPv6-Address")
- else
- local ipv6 = usev6:formvalue(section)
- local force = (fipv) and fipv:formvalue(section) or "0"
- local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh verify_dns ]] ..
- value .. [[ ]] .. ipv6 .. [[ ]] .. force
- local ret = SYS.call(command)
- if ret == 0 then return value -- everything OK
- elseif ret == 2 then return nil, err_tab_adv(self) .. translate("nslookup can not resolve host")
- elseif ret == 3 then return nil, err_tab_adv(self) .. translate("nc (netcat) can not connect")
- elseif ret == 4 then return nil, err_tab_adv(self) .. translate("Forced IP Version don't matched")
- else return nil, err_tab_adv(self) .. translate("unspecific error")
+-- optional DNS Server to use resolving my IP
+if DDNS.has_dnsserver or ( ( m:get(section, "dns_server") or "" ) ~= "" ) then
+ dns = ns:taboption("advanced", Value, "dns_server",
+ translate("DNS-Server"),
+ translate("OPTIONAL: Use non-default DNS-Server to detect 'Registered IP'.") .. "<br />" ..
+ translate("Format: IP or FQDN"))
+ dns.placeholder = "mydns.lan"
+ function dns.validate(self, value)
+ -- if .datatype is set, then it is checked before calling this function
+ if not value or (#value == 0) then
+ return "" -- ignore on empty
+ elseif not DDNS.has_dnsserver then
+ return nil, err_tab_adv(self) .. translate("Specifying a DNS-Server is not supported")
+ elseif not DTYP.host(value) then
+ return nil, err_tab_adv(self) .. translate("use hostname, FQDN, IPv4- or IPv6-Address")
+ else
+ local ipv6 = usev6:formvalue(section) or "0"
+ local force = fipv:formvalue(section) or "0"
+ local command = CTRL.luci_helper .. [[ -]]
+ if (ipv6 == 1) then command = command .. [[6]] end
+ if (force == 1) then command = command .. [[f]] end
+ command = command .. [[d ]] .. value .. [[ -- verify_dns]]
+
+ local ret = SYS.call(command)
+ if ret == 0 then return value -- everything OK
+ elseif ret == 2 then return nil, err_tab_adv(self) .. translate("nslookup can not resolve host")
+ elseif ret == 3 then return nil, err_tab_adv(self) .. translate("nc (netcat) can not connect")
+ elseif ret == 4 then return nil, err_tab_adv(self) .. translate("Forced IP Version don't matched")
+ else return nil, err_tab_adv(self) .. translate("unspecific error")
+ end