6 "require https-dns-proxy.status as hdp";
10 return baseclass.extend({
11 title: _("HTTPS DNS Proxy Instances"),
15 hdp.getInitStatus(pkg.Name),
16 hdp.getProviders(pkg.Name),
17 hdp.getRuntime(pkg.Name),
21 render: function (data) {
23 status: (data[0] && data[0][pkg.Name]) || {
26 force_dns_active: null,
29 providers: (data[1] && data[1][pkg.Name]) || { providers: [] },
30 runtime: (data[2] && data[2][pkg.Name]) || { instances: [] },
32 reply.providers.sort(function (a, b) {
33 return _(a.title).localeCompare(_(b.title));
35 reply.providers.push({
38 params: { option: { type: "text" } },
41 var forceDnsText = "";
42 if (reply.status.force_dns_active) {
43 reply.status.force_dns_ports.forEach((element) => {
44 forceDnsText += element + " ";
52 { class: "table", id: "https-dns-proxy_status_table" },
54 E("tr", { class: "tr table-titles" }, [
55 E("th", { class: "th" }, _("Name / Type")),
56 E("th", { class: "th" }, _("Listen Address")),
57 E("th", { class: "th" }, _("Listen Port")),
58 E("th", { class: "th" }, _("Force DNS Ports")),
64 if (reply.runtime.instances) {
65 Object.values(reply.runtime.instances).forEach((element) => {
72 element.command.forEach((param, index, arr) => {
73 if (param === "-r") resolver = arr[index + 1];
74 if (param === "-a") address = arr[index + 1];
75 if (param === "-p") port = arr[index + 1];
77 resolver = resolver || "Unknown";
78 address = address || "127.0.0.1";
79 port = port || "Unknown";
80 reply.providers.forEach((prov) => {
81 let regexp = pkg.templateToRegexp(prov.template);
82 if (!found && regexp.test(resolver)) {
85 let match = resolver.match(regexp);
86 if (match[1] != null) {
90 prov.params.option.options
92 prov.params.option.options.forEach((opt) => {
93 if (opt.value === match[1]) option = _(opt.description);
95 name += " (" + option + ")";
97 if (match[1] !== "") name += " (" + match[1] + ")";
102 rows.push([name, address, port, forceDnsText]);
105 cbi_update_table(table, rows, E("em", _("There are no active instances.")));