diff options
Diffstat (limited to 'applications/luci-app-https-dns-proxy/htdocs/luci-static/resources')
3 files changed, 173 insertions, 3 deletions
diff --git a/applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/https-dns-proxy/status.js b/applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/https-dns-proxy/status.js index bdc99fcbda..24efea0fce 100644 --- a/applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/https-dns-proxy/status.js +++ b/applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/https-dns-proxy/status.js @@ -2,6 +2,7 @@ // This code wouldn't have been possible without help from: // - [@stokito](https://github.com/stokito) // - [@vsviridov](https://github.com/vsviridov) +// noinspection JSAnnotator "require ui"; "require rpc"; @@ -241,7 +242,7 @@ var status = baseclass.extend({ }); name += " (" + option + ")"; } else { - if (match[1] != "") name += " (" + match[1] + ")"; + if (match[1] !== "") name += " (" + match[1] + ")"; } } } diff --git a/applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js b/applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js index a0d809cd32..280ffc289e 100644 --- a/applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js +++ b/applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/https-dns-proxy/overview.js @@ -3,6 +3,7 @@ // - [@jow-](https://github.com/jow-) // - [@stokito](https://github.com/stokito) // - [@vsviridov](https://github.com/vsviridov) +// noinspection JSAnnotator "use strict"; "require form"; @@ -12,12 +13,15 @@ "require https-dns-proxy.status as hdp"; var pkg = { + get Name() { return "https-dns-proxy"; }, + get URL() { return "https://docs.openwrt.melmac.net/" + pkg.Name + "/"; }, + templateToRegexp: function (template) { return RegExp( "^" + @@ -32,6 +36,7 @@ var pkg = { "$" ); }, + templateToResolver: function (template, args) { return template.replace(/{(\w+)}/g, (_, v) => args[v]); }, @@ -72,6 +77,7 @@ return view.extend({ m = new form.Map(pkg.Name, _("HTTPS DNS Proxy - Configuration")); s = m.section(form.NamedSection, "config", pkg.Name); + o = s.option( form.ListValue, "dnsmasq_config_update", @@ -86,6 +92,7 @@ return view.extend({ ) ); o.value("*", _("Update all configs")); + var sections = uci.sections("dhcp", "dnsmasq"); sections.forEach((element) => { var description; @@ -317,48 +324,57 @@ return view.extend({ o.default = ""; o.modalonly = true; o.optional = true; + o = s.option(form.Value, "listen_addr", _("Listen Address")); o.datatype = "ipaddr"; o.default = ""; o.optional = true; o.placeholder = "127.0.0.1"; - var n = 0; + o = s.option(form.Value, "listen_port", _("Listen Port")); o.datatype = "port"; o.default = ""; o.optional = true; - o.placeholder = n + 5053; + o.placeholder = "5053"; + o = s.option(form.Value, "user", _("Run As User")); o.default = ""; o.modalonly = true; o.optional = true; + o = s.option(form.Value, "group", _("Run As Group")); o.default = ""; o.modalonly = true; o.optional = true; + o = s.option(form.Value, "dscp_codepoint", _("DSCP Codepoint")); o.datatype = "and(uinteger, range(0,63))"; o.default = ""; o.modalonly = true; o.optional = true; + o = s.option(form.Value, "verbosity", _("Logging Verbosity")); o.datatype = "and(uinteger, range(0,4))"; o.default = ""; o.modalonly = true; o.optional = true; + o = s.option(form.Value, "logfile", _("Logging File Path")); o.default = ""; o.modalonly = true; o.optional = true; + o = s.option(form.Value, "polling_interval", _("Polling Interval")); o.datatype = "and(uinteger, range(5,3600))"; o.default = ""; o.modalonly = true; o.optional = true; + o = s.option(form.Value, "proxy_server", _("Proxy Server")); o.default = ""; o.modalonly = true; o.optional = true; + o = s.option(form.ListValue, "use_http1", _("Use HTTP/1")); o.modalonly = true; o.optional = true; @@ -366,6 +382,7 @@ return view.extend({ o.value("", _("Use negotiated HTTP version")); o.value("1", _("Force use of HTTP/1")); o.default = ""; + o = s.option( form.ListValue, "use_ipv6_resolvers_only", diff --git a/applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/status/include/71_https-dns-proxy.js b/applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/status/include/71_https-dns-proxy.js new file mode 100644 index 0000000000..1f22f6d6d7 --- /dev/null +++ b/applications/luci-app-https-dns-proxy/htdocs/luci-static/resources/view/status/include/71_https-dns-proxy.js @@ -0,0 +1,152 @@ +"require ui"; +"require rpc"; +"require uci"; +"require form"; +"require baseclass"; + +var pkg = { + get Name() { + return "https-dns-proxy"; + }, + get URL() { + return "https://docs.openwrt.melmac.net/" + pkg.Name + "/"; + }, + templateToRegexp: function (template) { + return RegExp( + "^" + + template + .split(/(\{\w+\})/g) + .map((part) => { + let placeholder = part.match(/^\{(\w+)\}$/); + if (placeholder) return `(?<${placeholder[1]}>.*?)`; + else return part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + }) + .join("") + + "$" + ); + }, +}; + +var getInitStatus = rpc.declare({ + object: "luci." + pkg.Name, + method: "getInitStatus", + params: ["name"], +}); + +var getPlatformSupport = rpc.declare({ + object: "luci." + pkg.Name, + method: "getPlatformSupport", + params: ["name"], +}); + +var getProviders = rpc.declare({ + object: "luci." + pkg.Name, + method: "getProviders", + params: ["name"], +}); + +var getRuntime = rpc.declare({ + object: "luci." + pkg.Name, + method: "getRuntime", + params: ["name"], +}); + +return baseclass.extend({ + title: _("HTTPS DNS Proxy Instances"), + + load: function () { + return Promise.all([ + getInitStatus(pkg.Name), + getProviders(pkg.Name), + getRuntime(pkg.Name), + ]); + }, + + render: function (data) { + var reply = { + status: (data[0] && data[0][pkg.Name]) || { + enabled: null, + running: null, + force_dns_active: null, + version: null, + }, + providers: (data[1] && data[1][pkg.Name]) || { providers: [] }, + runtime: (data[2] && data[2][pkg.Name]) || { instances: [] }, + }; + reply.providers.sort(function (a, b) { + return _(a.title).localeCompare(_(b.title)); + }); + reply.providers.push({ + title: "Custom", + template: "{option}", + params: { option: { type: "text" } }, + }); + + var forceDnsText = ""; + if (reply.status.force_dns_active) { + reply.status.force_dns_ports.forEach((element) => { + forceDnsText += element + " "; + }); + } else { + forceDnsText = "-"; + } + + var table = E( + "table", + { class: "table", id: "https-dns-proxy_status_table" }, + [ + E("tr", { class: "tr table-titles" }, [ + E("th", { class: "th" }, _("Name / Type")), + E("th", { class: "th" }, _("Listen Address")), + E("th", { class: "th" }, _("Listen Port")), + E("th", { class: "th" }, _("Force DNS Ports")), + ]), + ] + ); + + var rows = []; + Object.values(reply.runtime.instances).forEach((element) => { + var resolver; + var address; + var port; + var name; + var option; + var found; + element.command.forEach((param, index, arr) => { + if (param === "-r") resolver = arr[index + 1]; + if (param === "-a") address = arr[index + 1]; + if (param === "-p") port = arr[index + 1]; + }); + resolver = resolver || "Unknown"; + address = address || "127.0.0.1"; + port = port || "Unknown"; + reply.providers.forEach((prov) => { + let regexp = pkg.templateToRegexp(prov.template); + if (!found && regexp.test(resolver)) { + found = true; + name = _(prov.title); + let match = resolver.match(regexp); + if (match[1] != null) { + if ( + prov.params && + prov.params.option && + prov.params.option.options + ) { + prov.params.option.options.forEach((opt) => { + if (opt.value === match[1]) option = _(opt.description); + }); + name += " (" + option + ")"; + } else { + if (match[1] !== "") name += " (" + match[1] + ")"; + } + } + } + }); + rows.push([name, address, port, forceDnsText]); + }); + + cbi_update_table(table, rows, E("em", _("There are no active instances."))); + + return table; + }, +}); |