summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js10
-rw-r--r--applications/luci-app-https_dns_proxy/Makefile2
-rw-r--r--applications/luci-app-https_dns_proxy/luasrc/model/cbi/https_dns_proxy.lua78
-rw-r--r--libs/luci-lib-nixio/src/address.c6
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/form.js1
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/ui.js10
6 files changed, 87 insertions, 20 deletions
diff --git a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js
index ffbfe3ccd0..63af69f8a9 100644
--- a/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js
+++ b/applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js
@@ -107,6 +107,16 @@ return L.view.extend({
return uci.get('firewall', section_id, 'name') || _('Unnamed forward');
};
+ s.handleAdd = function(ev) {
+ var config_name = this.uciconfig || this.map.config,
+ section_id = uci.add(config_name, this.sectiontype);
+
+ uci.set(config_name, section_id, 'target', 'DNAT');
+
+ this.addedSection = section_id;
+ this.renderMoreOptionsModal(section_id);
+ };
+
o = s.taboption('general', form.Value, 'name', _('Name'));
o.placeholder = _('Unnamed forward');
o.modalonly = true;
diff --git a/applications/luci-app-https_dns_proxy/Makefile b/applications/luci-app-https_dns_proxy/Makefile
index 2ae2b80f2f..afc1607239 100644
--- a/applications/luci-app-https_dns_proxy/Makefile
+++ b/applications/luci-app-https_dns_proxy/Makefile
@@ -10,7 +10,7 @@ LUCI_TITLE:=HTTPS DNS Proxy Web UI
LUCI_DESCRIPTION:=Provides Web UI for HTTPS DNS Proxy
LUCI_DEPENDS:=+luci-mod-admin-full +https_dns_proxy
LUCI_PKGARCH:=all
-PKG_RELEASE:=2
+PKG_RELEASE:=3
include ../../luci.mk
diff --git a/applications/luci-app-https_dns_proxy/luasrc/model/cbi/https_dns_proxy.lua b/applications/luci-app-https_dns_proxy/luasrc/model/cbi/https_dns_proxy.lua
index 20d486f378..03a3b4e083 100644
--- a/applications/luci-app-https_dns_proxy/luasrc/model/cbi/https_dns_proxy.lua
+++ b/applications/luci-app-https_dns_proxy/luasrc/model/cbi/https_dns_proxy.lua
@@ -1,4 +1,41 @@
local uci = require("luci.model.uci").cursor()
+function uci_del_list(conf, sect, opt, value)
+ local lval = uci:get(conf, sect, opt)
+ if lval == nil or lval == "" then
+ lval = {}
+ elseif type(lval) ~= "table" then
+ lval = { lval }
+ end
+
+ local i
+ local changed = false
+ for i = #lval, 1 do
+ if lval[i] == value then
+ table.remove(lval, i)
+ changed = true
+ end
+ end
+
+ if changed then
+ if #lval > 0 then
+ uci:set(conf, sect, opt, lval)
+ else
+ uci:delete(conf, sect, opt)
+ end
+ end
+end
+
+function uci_add_list(conf, sect, opt, value)
+ local lval = uci:get(conf, sect, opt)
+ if lval == nil or lval == "" then
+ lval = {}
+ elseif type(lval) ~= "table" then
+ lval = { lval }
+ end
+
+ lval[#lval+1] = value
+ uci:set(conf, sect, opt, lval)
+end
m = Map("https_dns_proxy", translate("HTTPS DNS Proxy Settings"))
m.template="cbi/map"
@@ -9,10 +46,22 @@ s3.sortable = false
s3.anonymous = true
s3.addremove = true
+local n = 0
+uci:foreach("https_dns_proxy", "https_dns_proxy", function(s)
+ if s[".name"] == section then
+ return false
+ end
+ n = n + 1
+end)
+
prov = s3:option(ListValue, "url_prefix", translate("Provider"))
prov:value("https://cloudflare-dns.com/dns-query?ct=application/dns-json&","Cloudflare")
prov:value("https://dns.google.com/resolve?","Google")
prov.write = function(self, section, value)
+ local la_val = la:formvalue(section)
+ local lp_val = lp:formvalue(section)
+ if not la_val then la_val = "127.0.0.1" end
+ if not lp_val then lp_val = n + 5053 end
if value and value:match("cloudflare") then
uci:set("https_dns_proxy", section, "bootstrap_dns", "1.1.1.1,1.0.0.1")
uci:set("https_dns_proxy", section, "url_prefix", "https://cloudflare-dns.com/dns-query?ct=application/dns-json&")
@@ -23,6 +72,12 @@ prov.write = function(self, section, value)
uci:set("https_dns_proxy", section, "user", "nobody")
uci:set("https_dns_proxy", section, "group", "nogroup")
uci:save("https_dns_proxy")
+ if n == 0 then
+ uci:delete("dhcp", "@dnsmasq[0]", "server")
+ end
+ uci_del_list("dhcp", "@dnsmasq[0]", "server", tostring(la_val) .. ":" .. tostring(lp_val))
+ uci_add_list("dhcp", "@dnsmasq[0]", "server", tostring(la_val) .. ":" .. tostring(lp_val))
+ uci:save("dhcp")
end
la = s3:option(Value, "listen_addr", translate("Listen address"))
@@ -31,23 +86,22 @@ la.rmempty = true
lp = s3:option(Value, "listen_port", translate("Listen port"))
lp.datatype = "port"
-lp.placeholder = "5053"
-lp.rmempty = true
-
--- user = s3:option(Value, "user", translate("User name"))
--- user.placeholder = "nobody"
--- user.rmempty = true
-
--- group = s3:option(Value, "group", translate("Group name"))
--- group.placeholder = "nogroup"
--- group.rmempty = true
+lp.value = n + 5053
+lp.write = function(self, section, value)
+ if not value then
+ uci:set("https_dns_proxy", section, "listen_port", n + 5053)
+ else
+ uci:set("https_dns_proxy", section, "listen_port", value)
+ end
+ uci:save("https_dns_proxy")
+end
sa = s3:option(Value, "subnet_addr", translate("Subnet address"))
-sa.datatype = "ip4addr"
+sa.datatype = "ip4prefix"
sa.rmempty = true
ps = s3:option(Value, "proxy_server", translate("Proxy server"))
--- ps.datatype = "or(ipaddr,hostname)"
+ps.datatype = "or(ipaddr,hostname)"
ps.rmempty = true
return m
diff --git a/libs/luci-lib-nixio/src/address.c b/libs/luci-lib-nixio/src/address.c
index 8ab4fa89c9..ed3a4a1c61 100644
--- a/libs/luci-lib-nixio/src/address.c
+++ b/libs/luci-lib-nixio/src/address.c
@@ -24,6 +24,7 @@
#ifdef __linux__
+#include <sys/time.h>
#include <signal.h>
#include <setjmp.h>
#include <unistd.h>
@@ -287,6 +288,7 @@ static int nixio_getnameinfo(lua_State *L) {
const char *family = luaL_optstring(L, 2, NULL);
#ifdef __linux__
+ const struct itimerval t = { {timeout * 1000 * 1000, 0} , {0, 0} };
struct sigaction sa_new, sa_old;
int timeout = luaL_optnumber(L, 3, 0);
if (timeout > 0 && timeout < 1000)
@@ -308,7 +310,7 @@ static int nixio_getnameinfo(lua_State *L) {
return 3;
}
- ualarm(timeout * 1000, 0);
+ setitimer(ITIMER_REAL, &t, NULL);
}
#endif
@@ -339,7 +341,7 @@ static int nixio_getnameinfo(lua_State *L) {
#ifdef __linux__
if (timeout > 0 && timeout < 1000)
{
- ualarm(0, 0);
+ alarm(0);
sigaction(SIGALRM, &sa_old, NULL);
}
#endif
diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js
index 508e2c4857..58d8f7100c 100644
--- a/modules/luci-base/htdocs/luci-static/resources/form.js
+++ b/modules/luci-base/htdocs/luci-static/resources/form.js
@@ -1461,6 +1461,7 @@ var CBIListValue = CBIValue.extend({
size: this.size,
sort: this.keylist,
optional: this.rmempty || this.optional,
+ placeholder: this.placeholder,
validate: L.bind(this.validate, this, section_id)
});
diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js
index 9c16a9a0dd..43afc698f6 100644
--- a/modules/luci-base/htdocs/luci-static/resources/ui.js
+++ b/modules/luci-base/htdocs/luci-static/resources/ui.js
@@ -287,8 +287,8 @@ var UISelect = UIElement.extend({
this.node = frameEl;
if (this.options.widget == 'select') {
- this.setUpdateEvents(frameEl, 'change', 'click', 'blur');
- this.setChangeEvents(frameEl, 'change');
+ this.setUpdateEvents(frameEl.firstChild, 'change', 'click', 'blur');
+ this.setChangeEvents(frameEl.firstChild, 'change');
}
else {
var radioEls = frameEl.querySelectorAll('input[type="radio"]');
@@ -879,7 +879,7 @@ var UIDropdown = UIElement.extend({
else
markup = '<li data-value="{{value}}">{{value}}</li>';
- new_item = E(markup.replace(/{{value}}/g, item));
+ new_item = E(markup.replace(/{{value}}/g, '%h'.format(item)));
if (sbox.options.multiple) {
sbox.transformItem(sb, new_item);
@@ -1797,7 +1797,7 @@ return L.Class.extend({
return chg[1];
case 4:
- return "'" + chg[3].replace(/'/g, "'\"'\"'") + "'";
+ return "'%h'".format(chg[3].replace(/'/g, "'\"'\"'"));
default:
return chg[m1-1];
@@ -1929,7 +1929,7 @@ return L.Class.extend({
method: 'post',
timeout: L.env.apply_timeout * 1000,
query: L.ui.changes.confirm_auth
- }).then(call);
+ }).then(call, call);
}, delay);
};