Some applications only support ipv4 so add ipv4only option
to host and hostport datatypes so that for thos applications
that when an IP address is specified only and ipv4 ip address
gets accepted.
16 files changed:
s.anonymous = true
serv = s:option(Value, "smtp_server", translate("SMTP Server Hostname or IP Address"))
s.anonymous = true
serv = s:option(Value, "smtp_server", translate("SMTP Server Hostname or IP Address"))
+serv.datatype = "host(0)"
port = s:option(Value, "smtp_port", translate("SMTP Port Number"))
port.datatype = "port"
port = s:option(Value, "smtp_port", translate("SMTP Port Number"))
port.datatype = "port"
The best thing to input is a static IP address. If your IP address is dynamic and it changes, \
your configuration will become invalid. Hence, it's recommended to set up Dynamic DNS in this case. \
and enter your Dynamic DNS hostname here. You can configure Dynamic DNS with the luci-app-ddns package."))
The best thing to input is a static IP address. If your IP address is dynamic and it changes, \
your configuration will become invalid. Hence, it's recommended to set up Dynamic DNS in this case. \
and enter your Dynamic DNS hostname here. You can configure Dynamic DNS with the luci-app-ddns package."))
p = s:taboption("remote_usage", Value, "bindport", translate("External SIP Port"),
translate("Pick a random port number between 6500 and 9500 for the service to listen on. \
p = s:taboption("remote_usage", Value, "bindport", translate("External SIP Port"),
translate("Pick a random port number between 6500 and 9500 for the service to listen on. \
end
h = s:option(Value, "host", translate("SIP Server/Registrar"))
end
h = s:option(Value, "host", translate("SIP Server/Registrar"))
p = s:option(ListValue, "register", translate("Enable Incoming Calls (Register via SIP)"),
translate("This option should be set to \"Yes\" if you have a DID \(real telephone number\) \
p = s:option(ListValue, "register", translate("Enable Incoming Calls (Register via SIP)"),
translate("This option should be set to \"Yes\" if you have a DID \(real telephone number\) \
from = s:option(Value, "fromdomain",
translate("SIP Realm (needed by some providers)"))
from.optional = true
from = s:option(Value, "fromdomain",
translate("SIP Realm (needed by some providers)"))
from.optional = true
+from.datatype = "host(0)"
port = s:option(Value, "port", translate("SIP Server/Registrar Port"))
port.optional = true
port = s:option(Value, "port", translate("SIP Server/Registrar Port"))
port.optional = true
op = s:option(Value, "outboundproxy", translate("Outbound Proxy"))
op.optional = true
op = s:option(Value, "outboundproxy", translate("Outbound Proxy"))
op.optional = true
host = s:option(Value, "Host", translate("Host"), translate("IP or hostname where to get the txtinfo output from"))
host.placeholder = "127.0.0.1"
host = s:option(Value, "Host", translate("Host"), translate("IP or hostname where to get the txtinfo output from"))
host.placeholder = "127.0.0.1"
+host.datatype = "host(1)"
host.rmempty = true
port = s:option(Value, "Port", translate("Port"))
host.rmempty = true
port = s:option(Value, "Port", translate("Port"))
ta.rmempty = true
ta.placeholder = "0.0.0.0/0"
ta.rmempty = true
ta.placeholder = "0.0.0.0/0"
v = s:option(Value, "via", translate("Via proxy"),
v = s:option(Value, "via", translate("Via proxy"),
v:depends({type="proxy"})
v.placeholder = "10.0.0.1:8080"
v:depends({type="proxy"})
v.placeholder = "10.0.0.1:8080"
+v.datatype = "ip4addrport"
pinghost = s:option(Value, "pinghosts",
translate("Ping host"),
translate("Host address to ping"))
pinghost = s:option(Value, "pinghosts",
translate("Ping host"),
translate("Host address to ping"))
-pinghost.datatype = "host"
+pinghost.datatype = "host(1)"
pinghost.default = "8.8.8.8"
pinghost:depends({mode="ping"})
pinghost.default = "8.8.8.8"
pinghost:depends({mode="ping"})
return (this.match(/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/) != null);
},
return (this.match(/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/) != null);
},
+ 'host': function(ipv4only)
{
return cbi_validators.hostname.apply(this) ||
{
return cbi_validators.hostname.apply(this) ||
- cbi_validators.ipaddr.apply(this);
+ ((ipv4only != 1) && cbi_validators.ipaddr.apply(this)) ||
+ ((ipv4only == 1) && cb_validators.ip4addr.apply(this));
},
'hostname': function()
},
'hostname': function()
cbi_validators.host.apply(this);
},
cbi_validators.host.apply(this);
},
+ 'hostport': function(ipv4only)
{
var hp = this.split(/:/);
if (hp.length == 2)
{
var hp = this.split(/:/);
if (hp.length == 2)
- return (cbi_validators.host.apply(hp[0]) &&
+ return (cbi_validators.host.apply(hp[0], ipv4only) &&
cbi_validators.port.apply(hp[1]));
return false;
cbi_validators.port.apply(hp[1]));
return false;
-function host(val)
- return hostname(val) or ipaddr(val)
+function host(val, ipv4only)
+ return hostname(val) or ((ipv4only == 1) and ip4addr(val)) or ((not (ipv4only == 1)) and ipaddr(val))
end
function network(val)
return uciname(val) or host(val)
end
end
function network(val)
return uciname(val) or host(val)
end
+function hostport(val, ipv4only)
local h, p = val:match("^([^:]+):([^:]+)$")
local h, p = val:match("^([^:]+):([^:]+)$")
- return not not (h and p and host(h) and port(p))
+ return not not (h and p and host(h, ipv4only) and port(p))
+end
+
+function ip4addrport(val, bracket)
+ local h, p = val:match("^([^:]+):([^:]+)$")
+ return (h and p and ip4addr(h) and port(p))
end
function ip4addrport(val)
end
function ip4addrport(val)
if (h and p and ip4addr(h) and port(p)) then
return true
elseif (bracket == 1) then
if (h and p and ip4addr(h) and port(p)) then
return true
elseif (bracket == 1) then
- h, p = val:match("^(%[.+%]):([^:]+)$")
+ h, p = val:match("^%[(.+)%]:([^:]+)$")
if (h and p and ip6addr(h) and port(p)) then
return true
end
if (h and p and ip6addr(h) and port(p)) then
return true
end
translate("List of domains to allow RFC1918 responses for"))
rd:depends("rebind_protection", "1")
translate("List of domains to allow RFC1918 responses for"))
rd:depends("rebind_protection", "1")
rd.placeholder = "ihost.netflix.com"
rd.placeholder = "ihost.netflix.com"
auth_server:depends({mode="ap-wds", encryption="wpa"})
auth_server:depends({mode="ap-wds", encryption="wpa2"})
auth_server.rmempty = true
auth_server:depends({mode="ap-wds", encryption="wpa"})
auth_server:depends({mode="ap-wds", encryption="wpa2"})
auth_server.rmempty = true
-auth_server.datatype = "host"
+auth_server.datatype = "host(0)"
auth_port = s:taboption("encryption", Value, "auth_port", translate("Radius-Authentication-Port"), translatef("Default %d", 1812))
auth_port:depends({mode="ap", encryption="wpa"})
auth_port = s:taboption("encryption", Value, "auth_port", translate("Radius-Authentication-Port"), translatef("Default %d", 1812))
auth_port:depends({mode="ap", encryption="wpa"})
acct_server:depends({mode="ap-wds", encryption="wpa"})
acct_server:depends({mode="ap-wds", encryption="wpa2"})
acct_server.rmempty = true
acct_server:depends({mode="ap-wds", encryption="wpa"})
acct_server:depends({mode="ap-wds", encryption="wpa2"})
acct_server.rmempty = true
-acct_server.datatype = "host"
+acct_server.datatype = "host(0)"
acct_port = s:taboption("encryption", Value, "acct_port", translate("Radius-Accounting-Port"), translatef("Default %d", 1813))
acct_port:depends({mode="ap", encryption="wpa"})
acct_port = s:taboption("encryption", Value, "acct_port", translate("Radius-Accounting-Port"), translatef("Default %d", 1813))
acct_port:depends({mode="ap", encryption="wpa"})
o = s:option(DynamicList, "server", translate("NTP server candidates"))
o = s:option(DynamicList, "server", translate("NTP server candidates"))
o:depends("enable", "1")
-- retain server list even if disabled
o:depends("enable", "1")
-- retain server list even if disabled
server = section:taboption("general", Value, "server",
translate("Tunnel setup server"),
translate("Optional, specify to override default server (tic.sixxs.net)"))
server = section:taboption("general", Value, "server",
translate("Tunnel setup server"),
translate("Optional, specify to override default server (tic.sixxs.net)"))
-server.datatype = "host"
+server.datatype = "host(0)"
oc_ca_file = "/etc/openconnect/ca-" .. ifc .. ".pem"
server = section:taboption("general", Value, "server", translate("VPN Server"))
oc_ca_file = "/etc/openconnect/ca-" .. ifc .. ".pem"
server = section:taboption("general", Value, "server", translate("VPN Server"))
-server.datatype = "host"
+server.datatype = "host(0)"
port = section:taboption("general", Value, "port", translate("VPN Server port"))
port.placeholder = "443"
port = section:taboption("general", Value, "port", translate("VPN Server port"))
port.placeholder = "443"
server = section:taboption("general", Value, "server", translate("L2TP Server"))
server = section:taboption("general", Value, "server", translate("L2TP Server"))
-server.datatype = "or(host, hostport)"
+server.datatype = "or(host(1), hostport(1))"
username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
sshuser = section:taboption("general", Value, "sshuser", translate("SSH username"))
server = section:taboption("general", Value, "server", translate("SSH server address"))
sshuser = section:taboption("general", Value, "sshuser", translate("SSH username"))
server = section:taboption("general", Value, "server", translate("SSH server address"))
-server.datatype = "host"
+server.datatype = "host(0)"
port = section:taboption("general", Value, "port", translate("SSH server port"))
port.datatype = "port"
port = section:taboption("general", Value, "port", translate("SSH server port"))
port.datatype = "port"
server = section:taboption("general", Value, "server", translate("VPN Server"))
server = section:taboption("general", Value, "server", translate("VPN Server"))
-server.datatype = "host"
+server.datatype = "host(0)"
username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))
username = section:taboption("general", Value, "username", translate("PAP/CHAP username"))