diff options
author | Stan Grishin <stangri@melmac.net> | 2021-02-10 01:59:59 +0000 |
---|---|---|
committer | Stan Grishin <stangri@melmac.net> | 2021-02-10 01:59:59 +0000 |
commit | 26c772e97d81143b85766f2446ba70e07e3432cb (patch) | |
tree | 99795a5ef1a4759905b518820d06a85c1ea71225 /applications/luci-app-https-dns-proxy/luasrc/model/cbi | |
parent | 98bd6f6ec30f3ea35938050784b7d70f0ce960b4 (diff) |
luci-app-https-dns-proxy: support for Force DNS option
Signed-off-by: Stan Grishin <stangri@melmac.net>
Diffstat (limited to 'applications/luci-app-https-dns-proxy/luasrc/model/cbi')
-rw-r--r-- | applications/luci-app-https-dns-proxy/luasrc/model/cbi/https-dns-proxy.lua | 58 |
1 files changed, 30 insertions, 28 deletions
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 e38e4e39b6..98fabf86ae 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 @@ -69,38 +69,36 @@ local ubusStatus = util.ubus("service", "list", { name = packageName }) local packageVersion = getPackageVersion() if packageVersion == "" then - packageStatusCode = -1 - packageStatus = translatef("%s is not installed or not found", packageName) + packageStatusCode, packageStatus = -1, translatef("%s is not installed or not found", packageName) else - if not ubusStatus or not ubusStatus[packageName] then + packageStatusCode, packageStatus = 1, "" + for n = 1,20 do + if ubusStatus and ubusStatus[packageName] and + ubusStatus[packageName]["instances"] and + ubusStatus[packageName]["instances"]["instance" .. n] and + ubusStatus[packageName]["instances"]["instance" .. n]["running"] then + local value, k, v, url, url_flag, la, la_flag, lp, lp_flag + for k, v in pairs(ubusStatus[packageName]["instances"]["instance" .. n]["command"]) do + if la_flag then la, la_flag = v, false end + if lp_flag then lp, lp_flag = v, false end + if url_flag then url, url_flag = v, false end + if v == "-a" then la_flag = true end + if v == "-p" then lp_flag = true end + if v == "-r" then url_flag = true end + end + la = la or "127.0.0.1" + lp = lp or n + 5053 + packageStatus = packageStatus .. translatef("Running: %s DoH at %s:%s", getProviderName(url), la, lp) .. "\n" + else + break + end + end + if packageStatus == "" then packageStatusCode = 0 packageStatus = translate("Stopped") if not sys.init.enabled(packageName) then packageStatus = packageStatus .. " (" .. translate("disabled") .. ")" end - else - packageStatusCode, packageStatus = 1, "" - for n = 1,1000 do - if ubusStatus and ubusStatus[packageName] and - ubusStatus[packageName]["instances"] and - ubusStatus[packageName]["instances"]["instance" .. n] and - ubusStatus[packageName]["instances"]["instance" .. n]["running"] then - local value, k, v, url, url_flag, la, la_flag, lp, lp_flag - for k, v in pairs(ubusStatus[packageName]["instances"]["instance" .. n]["command"]) do - if la_flag then la, la_flag = v, false end - if lp_flag then lp, lp_flag = v, false end - if url_flag then url, url_flag = v, false end - if v == "-a" then la_flag = true end - if v == "-p" then lp_flag = true end - if v == "-r" then url_flag = true end - end - la = la or "127.0.0.1" - lp = lp or n + 5053 - packageStatus = packageStatus .. translatef("Running: %s DoH at %s:%s", getProviderName(url), la, lp) .. "\n" - else - break - end - end end end @@ -123,8 +121,8 @@ else buttons.template = packageName .. "/buttons" end -c = m:section(NamedSection, "config", "https-dns-proxy", translate("Configuration"), translatef("If update DNSMASQ config is selected, when you add/remove any instances below, they will be used to override the 'DNS forwardings' section of %sDHCP and DNS%s (%smore information%s).", "<a href=\"" .. dispatcher.build_url("admin/network/dhcp") .. "\">", "</a>", "<a href=\"" .. readmeURL .. "#default-settings" .. "\" target=\"_blank\">", "</a>")) -d1 = c:option(ListValue, "update_dnsmasq_config", translate("Update DNSMASQ Config on Start/Stop")) +c = m:section(NamedSection, "config", "https-dns-proxy", translate("Configuration")) +d1 = c:option(ListValue, "update_dnsmasq_config", translate("Update DNSMASQ Config on Start/Stop"), translatef("If update option is selected, the 'DNS forwardings' section of %sDHCP and DNS%s will be automatically updated to use selected DoH providers (%smore information%s).", "<a href=\"" .. dispatcher.build_url("admin/network/dhcp") .. "\">", "</a>", "<a href=\"" .. readmeURL .. "#default-settings" .. "\" target=\"_blank\">", "</a>")) d1:value('*', translate("Update all configs")) local dnsmasq_num = 0 uci:foreach("dhcp", "dnsmasq", function(s) @@ -133,6 +131,10 @@ dnsmasq_num = dnsmasq_num + 1 end) d1:value('-', translate("Do not update configs")) d1.default = '*' +f1 = c:option(ListValue, "force_dns", translate("Force Router DNS"), translate("Forces Router DNS use on local devices, also known as DNS Hijacking.")) +f1:value("0", translate("Let local devices use their own DNS servers if set")) +f1:value("1", translate("Force Router DNS server to all local devices")) +f1.default = '1' createHelperText() s3 = m:section(TypedSection, "https-dns-proxy", translate("Instances"), |