luci: add hint when set dnsmasq failure.

This commit is contained in:
Nick Peng
2022-09-14 23:45:39 +08:00
parent 1f1fd118de
commit 1991a0b102
6 changed files with 482 additions and 446 deletions

View File

@@ -37,6 +37,20 @@ end
function act_status() function act_status()
local e={} local e={}
local ipv6_server;
local dnsmasq_server = luci.sys.exec("uci get dhcp.@dnsmasq[0].server")
local auto_set_dnsmasq = smartdns.get_config_option("smartdns", "smartdns", "auto_set_dnsmasq", nil);
e.auto_set_dnsmasq = auto_set_dnsmasq
e.dnsmasq_server = dnsmasq_server
e.local_port = smartdns.get_config_option("smartdns", "smartdns", "port", nil);
if e.local_port ~= nil and e.local_port ~= "53" and auto_set_dnsmasq ~= nil and auto_set_dnsmasq == "1" then
local str;
str = "127.0.0.1#" .. e.local_port
if string.sub(dnsmasq_server,1,string.len(str)) ~= str then
e.dnsmasq_redirect_failure = 1
end
end
e.running = is_running() e.running = is_running()
luci.http.prepare_content("application/json") luci.http.prepare_content("application/json")
luci.http.write_json(e) luci.http.write_json(e)

View File

@@ -52,6 +52,9 @@ msgstr "协议类型"
msgid "DNS domain result cache size" msgid "DNS domain result cache size"
msgstr "缓存DNS的结果缓存大小配置零则不缓存" msgstr "缓存DNS的结果缓存大小配置零则不缓存"
msgid "Dnsmasq Forwared To Smartdns Failure"
msgstr "重定向dnsmasq到smartdns失败"
msgid "Do not check certificate." msgid "Do not check certificate."
msgstr "不校验证书的合法性。" msgstr "不校验证书的合法性。"

View File

@@ -6,6 +6,9 @@ XHR.poll(3, '<%=luci.dispatcher.build_url("admin", "services", "smartdns", "stat
var links = ""; var links = "";
if (data.running) { if (data.running) {
links = '<b><font color=green>SmartDNS - <%:RUNNING%></font></b></em>'; links = '<b><font color=green>SmartDNS - <%:RUNNING%></font></b></em>';
if (data.dnsmasq_redirect_failure == 1) {
links += "<br></br><b><font color=red><%:Dnsmasq Forwared To Smartdns Failure%></font></b>"
}
} else { } else {
links = '<b><font color=red>SmartDNS - <%:NOT RUNNING%></font></b>'; links = '<b><font color=red>SmartDNS - <%:NOT RUNNING%></font></b>';
} }

View File

@@ -52,6 +52,9 @@ msgstr "协议类型"
msgid "DNS domain result cache size" msgid "DNS domain result cache size"
msgstr "缓存DNS的结果缓存大小配置零则不缓存" msgstr "缓存DNS的结果缓存大小配置零则不缓存"
msgid "Dnsmasq Forwared To Smartdns Failure"
msgstr "重定向dnsmasq到smartdns失败"
msgid "Do not check certificate." msgid "Do not check certificate."
msgstr "不校验证书的合法性。" msgstr "不校验证书的合法性。"

View File

@@ -17,448 +17,461 @@
*/ */
'use strict'; 'use strict';
'require fs'; 'require fs';
'require uci'; 'require uci';
'require form'; 'require form';
'require view'; 'require view';
'require poll'; 'require poll';
'require rpc'; 'require rpc';
var conf = 'smartdns'; var conf = 'smartdns';
var callServiceList = rpc.declare({ var callServiceList = rpc.declare({
object: 'service', object: 'service',
method: 'list', method: 'list',
params: ['name'], params: ['name'],
expect: { '': {} } expect: { '': {} }
}); });
function getServiceStatus() { function getServiceStatus() {
return L.resolveDefault(callServiceList(conf), {}) return L.resolveDefault(callServiceList(conf), {})
.then(function (res) { .then(function (res) {
var isrunning = false; var isrunning = false;
try { try {
isrunning = res[conf]['instances']['smartdns']['running']; isrunning = res[conf]['instances']['smartdns']['running'];
} catch (e) { } } catch (e) { }
return isrunning; return isrunning;
}); });
} }
function smartdnsServiceStatus() { function smartdnsServiceStatus() {
return Promise.all([ return Promise.all([
getServiceStatus() getServiceStatus()
]); ]);
} }
function smartdnsRenderStatus(res) { function smartdnsRenderStatus(res) {
var renderHTML = ""; var renderHTML = "";
var isRunning = res[0]; var isRunning = res[0];
if (isRunning) { var autoSetDnsmasq = uci.get_first('smartdns', 'smartdns', 'auto_set_dnsmasq');
renderHTML += "<span style=\"color:green;font-weight:bold\">SmartDNS - " + _("RUNNING") + "</span>"; var smartdnsPort = uci.get_first('smartdns', 'smartdns', 'port');
} else { var dnsmasqServer = uci.get_first('dhcp', 'dnsmasq', 'server');
renderHTML += "<span style=\"color:red;font-weight:bold\">SmartDNS - " + _("NOT RUNNING") + "</span>"; uci.unload('dhcp');
return renderHTML;
} if (isRunning) {
renderHTML += "<span style=\"color:green;font-weight:bold\">SmartDNS - " + _("RUNNING") + "</span>";
return renderHTML; } else {
} renderHTML += "<span style=\"color:red;font-weight:bold\">SmartDNS - " + _("NOT RUNNING") + "</span>";
return renderHTML;
return view.extend({ }
load: function () {
return Promise.all([ if (autoSetDnsmasq === '1' && smartdnsPort != '53') {
uci.load('smartdns'), var matchLine = "127.0.0.1#" + smartdnsPort;
uci.load('dhcp') var dnsmasqServer = uci.get_first('dhcp', 'dnsmasq', 'server') || "";
]);
}, if (dnsmasqServer.indexOf(matchLine) < 0) {
render: function (stats) { renderHTML += "<br /><span style=\"color:red;font-weight:bold\">" + _("Dnsmasq Forwared To Smartdns Failure") + "</span>";
var m, s, o; }
}
m = new form.Map('smartdns', _('SmartDNS'));
m.title = _("SmartDNS Server"); return renderHTML;
m.description = _("SmartDNS is a local high-performance DNS server, supports finding fastest IP, " }
+ "supports ad filtering, and supports avoiding DNS poisoning.");
return view.extend({
s = m.section(form.NamedSection, '_status'); load: function () {
s.anonymous = true; return Promise.all([
s.render = function (section_id) { uci.load('dhcp'),
var renderStatus = function () { uci.load('smartdns'),
return L.resolveDefault(smartdnsServiceStatus()).then(function (res) { ]);
var view = document.getElementById("service_status"); },
if (view == null) { render: function (stats) {
return; var m, s, o;
}
m = new form.Map('smartdns', _('SmartDNS'));
view.innerHTML = smartdnsRenderStatus(res); m.title = _("SmartDNS Server");
}); m.description = _("SmartDNS is a local high-performance DNS server, supports finding fastest IP, "
} + "supports ad filtering, and supports avoiding DNS poisoning.");
poll.add(renderStatus);
setTimeout(renderStatus, 1000); s = m.section(form.NamedSection, '_status');
s.anonymous = true;
return E('div', { class: 'cbi-map' }, s.render = function (section_id) {
E('div', { class: 'cbi-section' }, [ var renderStatus = function () {
E('div', { id: 'service_status' }, return L.resolveDefault(smartdnsServiceStatus()).then(function (res) {
_('Collecting data ...')) var view = document.getElementById("service_status");
]) if (view == null) {
); return;
} }
// Basic; view.innerHTML = smartdnsRenderStatus(res);
s = m.section(form.TypedSection, "smartdns", _("Settings"), _("General Settings")); });
s.anonymous = true; }
poll.add(renderStatus);
s.tab("settings", _("General Settings")); setTimeout(renderStatus, 1000);
s.tab("seconddns", _("Second Server Settings"));
s.tab("custom", _("Custom Settings")); return E('div', { class: 'cbi-map' },
E('div', { class: 'cbi-section' }, [
o = s.taboption("settings", form.Flag, "enabled", _("Enable"), _("Enable or disable smartdns server")); E('div', { id: 'service_status' },
o.rmempty = false; _('Collecting data ...'))
o.default = o.disabled; ])
);
// server name; }
o = s.taboption("settings", form.Value, "server_name", _("Server Name"), _("Smartdns server name"));
o.default = "smartdns"; // Basic;
o.datatype = "hostname"; s = m.section(form.TypedSection, "smartdns", _("Settings"), _("General Settings"));
o.rempty = false; s.anonymous = true;
// Port; s.tab("settings", _("General Settings"));
o = s.taboption("settings", form.Value, "port", _("Local Port"), s.tab("seconddns", _("Second Server Settings"));
_("Smartdns local server port, smartdns will be automatically set as main dns when the port is 53.")); s.tab("custom", _("Custom Settings"));
o.placeholder = 53;
o.default = 53; o = s.taboption("settings", form.Flag, "enabled", _("Enable"), _("Enable or disable smartdns server"));
o.datatype = "port"; o.rmempty = false;
o.rempty = false; o.default = o.disabled;
// Enable TCP server; // server name;
o = s.taboption("settings", form.Flag, "tcp_server", _("TCP Server"), _("Enable TCP DNS Server")); o = s.taboption("settings", form.Value, "server_name", _("Server Name"), _("Smartdns server name"));
o.rmempty = false; o.default = "smartdns";
o.default = o.enabled; o.datatype = "hostname";
o.rempty = false;
// Support IPV6;
o = s.taboption("settings", form.Flag, "ipv6_server", _("IPV6 Server"), _("Enable IPV6 DNS Server")); // Port;
o.rmempty = false; o = s.taboption("settings", form.Value, "port", _("Local Port"),
o.default = o.enabled; _("Smartdns local server port, smartdns will be automatically set as main dns when the port is 53."));
o.placeholder = 53;
// Support DualStack ip selection; o.default = 53;
o = s.taboption("settings", form.Flag, "dualstack_ip_selection", _("Dual-stack IP Selection"), o.datatype = "port";
_("Enable IP selection between IPV4 and IPV6")); o.rempty = false;
o.rmempty = false;
o.default = o.enabled; // Enable TCP server;
o = s.taboption("settings", form.Flag, "tcp_server", _("TCP Server"), _("Enable TCP DNS Server"));
// Domain prefetch load ; o.rmempty = false;
o = s.taboption("settings", form.Flag, "prefetch_domain", _("Domain prefetch"), o.default = o.enabled;
_("Enable domain prefetch, accelerate domain response speed."));
o.rmempty = false; // Support IPV6;
o.default = o.disabled; o = s.taboption("settings", form.Flag, "ipv6_server", _("IPV6 Server"), _("Enable IPV6 DNS Server"));
o.rmempty = false;
// Domain Serve expired o.default = o.enabled;
o = s.taboption("settings", form.Flag, "serve_expired", _("Serve expired"),
_("Attempts to serve old responses from cache with a TTL of 0 in the response without waiting for the actual resolution to finish.")); // Support DualStack ip selection;
o.rmempty = false; o = s.taboption("settings", form.Flag, "dualstack_ip_selection", _("Dual-stack IP Selection"),
o.default = o.enabled; _("Enable IP selection between IPV4 and IPV6"));
o.rmempty = false;
// cache-size; o.default = o.enabled;
o = s.taboption("settings", form.Value, "cache_size", _("Cache Size"), _("DNS domain result cache size"));
o.rempty = true; // Domain prefetch load ;
o = s.taboption("settings", form.Flag, "prefetch_domain", _("Domain prefetch"),
// cache-size; _("Enable domain prefetch, accelerate domain response speed."));
o = s.taboption("settings", form.Flag, "resolve_local_hostnames", _("Resolve Local Hostnames"), _("Resolve local hostnames by reading Dnsmasq lease file.")); o.rmempty = false;
o.rmempty = false; o.default = o.disabled;
o.default = o.enabled;
// Domain Serve expired
// auto-conf-dnsmasq; o = s.taboption("settings", form.Flag, "serve_expired", _("Serve expired"),
o = s.taboption("settings", form.Flag, "auto_set_dnsmasq", _("Automatically Set Dnsmasq"), _("Automatically set as upstream of dnsmasq when port changes.")); _("Attempts to serve old responses from cache with a TTL of 0 in the response without waiting for the actual resolution to finish."));
o.rmempty = false; o.rmempty = false;
o.default = o.enabled; o.default = o.enabled;
// Force AAAA SOA // cache-size;
o = s.taboption("settings", form.Flag, "force_aaaa_soa", _("Force AAAA SOA"), _("Force AAAA SOA.")); o = s.taboption("settings", form.Value, "cache_size", _("Cache Size"), _("DNS domain result cache size"));
o.rmempty = false; o.rempty = true;
o.default = o.disabled;
// cache-size;
// Force HTTPS SOA o = s.taboption("settings", form.Flag, "resolve_local_hostnames", _("Resolve Local Hostnames"), _("Resolve local hostnames by reading Dnsmasq lease file."));
o = s.taboption("settings", form.Flag, "force_https_soa", _("Force HTTPS SOA"), _("Force HTTPS SOA.")); o.rmempty = false;
o.rmempty = false; o.default = o.enabled;
o.default = o.disabled;
// auto-conf-dnsmasq;
// rr-ttl; o = s.taboption("settings", form.Flag, "auto_set_dnsmasq", _("Automatically Set Dnsmasq"), _("Automatically set as upstream of dnsmasq when port changes."));
o = s.taboption("settings", form.Value, "rr_ttl", _("Domain TTL"), _("TTL for all domain result.")); o.rmempty = false;
o.rempty = true; o.default = o.enabled;
// rr-ttl-min; // Force AAAA SOA
o = s.taboption("settings", form.Value, "rr_ttl_min", _("Domain TTL Min"), o = s.taboption("settings", form.Flag, "force_aaaa_soa", _("Force AAAA SOA"), _("Force AAAA SOA."));
_("Minimum TTL for all domain result.")); o.rmempty = false;
o.rempty = true; o.default = o.disabled;
o.placeholder = "600";
o.default = 600; // Force HTTPS SOA
o.optional = true; o = s.taboption("settings", form.Flag, "force_https_soa", _("Force HTTPS SOA"), _("Force HTTPS SOA."));
o.rmempty = false;
// rr-ttl-max; o.default = o.disabled;
o = s.taboption("settings", form.Value, "rr_ttl_max", _("Domain TTL Max"),
_("Maximum TTL for all domain result.")); // rr-ttl;
o.rempty = true; o = s.taboption("settings", form.Value, "rr_ttl", _("Domain TTL"), _("TTL for all domain result."));
o.rempty = true;
// rr-ttl-reply-max;
o = s.taboption("settings", form.Value, "rr_ttl_reply_max", _("Reply Domain TTL Max"), // rr-ttl-min;
_("Reply maximum TTL for all domain result.")); o = s.taboption("settings", form.Value, "rr_ttl_min", _("Domain TTL Min"),
o.rempty = true; _("Minimum TTL for all domain result."));
o.rempty = true;
// second dns server; o.placeholder = "600";
// Eanble; o.default = 600;
o = s.taboption("seconddns", form.Flag, "seconddns_enabled", _("Enable"), o.optional = true;
_("Enable or disable second DNS server."));
o.default = o.disabled; // rr-ttl-max;
o.rempty = false; o = s.taboption("settings", form.Value, "rr_ttl_max", _("Domain TTL Max"),
_("Maximum TTL for all domain result."));
// Port; o.rempty = true;
o = s.taboption("seconddns", form.Value, "seconddns_port", _("Local Port"), _("Smartdns local server port"));
o.placeholder = 6553; // rr-ttl-reply-max;
o.default = 6553; o = s.taboption("settings", form.Value, "rr_ttl_reply_max", _("Reply Domain TTL Max"),
o.datatype = "port"; _("Reply maximum TTL for all domain result."));
o.rempty = false; o.rempty = true;
// Enable TCP server; // second dns server;
o = s.taboption("seconddns", form.Flag, "seconddns_tcp_server", _("TCP Server"), _("Enable TCP DNS Server")); // Eanble;
o.rmempty = false; o = s.taboption("seconddns", form.Flag, "seconddns_enabled", _("Enable"),
o.default = o.enabled; _("Enable or disable second DNS server."));
o.default = o.disabled;
// dns server group; o.rempty = false;
o = s.taboption("seconddns", form.Value, "seconddns_server_group", _("Server Group"),
_("Query DNS through specific dns server group, such as office, home.")); // Port;
o.rmempty = true; o = s.taboption("seconddns", form.Value, "seconddns_port", _("Local Port"), _("Smartdns local server port"));
o.placeholder = "default"; o.placeholder = 6553;
o.datatype = "hostname"; o.default = 6553;
o.rempty = true; o.datatype = "port";
o.rempty = false;
o = s.taboption("seconddns", form.Flag, "seconddns_no_speed_check", _("Skip Speed Check"),
_("Do not check speed.")); // Enable TCP server;
o.rmempty = false; o = s.taboption("seconddns", form.Flag, "seconddns_tcp_server", _("TCP Server"), _("Enable TCP DNS Server"));
o.default = o.disabled; o.rmempty = false;
o.default = o.enabled;
// skip address rules;
o = s.taboption("seconddns", form.Flag, "seconddns_no_rule_addr", _("Skip Address Rules"), // dns server group;
_("Skip address rules.")); o = s.taboption("seconddns", form.Value, "seconddns_server_group", _("Server Group"),
o.rmempty = false; _("Query DNS through specific dns server group, such as office, home."));
o.default = o.disabled; o.rmempty = true;
o.placeholder = "default";
// skip name server rules; o.datatype = "hostname";
o = s.taboption("seconddns", form.Flag, "seconddns_no_rule_nameserver", _("Skip Nameserver Rule"), o.rempty = true;
_("Skip nameserver rules."));
o.rmempty = false; o = s.taboption("seconddns", form.Flag, "seconddns_no_speed_check", _("Skip Speed Check"),
o.default = o.disabled; _("Do not check speed."));
o.rmempty = false;
// skip ipset rules; o.default = o.disabled;
o = s.taboption("seconddns", form.Flag, "seconddns_no_rule_ipset", _("Skip Ipset Rule"),
_("Skip ipset rules.")); // skip address rules;
o.rmempty = false; o = s.taboption("seconddns", form.Flag, "seconddns_no_rule_addr", _("Skip Address Rules"),
o.default = o.disabled; _("Skip address rules."));
o.rmempty = false;
// skip soa address rule; o.default = o.disabled;
o = s.taboption("seconddns", form.Flag, "seconddns_no_rule_soa", _("Skip SOA Address Rule"),
_("Skip SOA address rules.")); // skip name server rules;
o.rmempty = false; o = s.taboption("seconddns", form.Flag, "seconddns_no_rule_nameserver", _("Skip Nameserver Rule"),
o.default = o.disabled; _("Skip nameserver rules."));
o.rmempty = false;
o = s.taboption("seconddns", form.Flag, "seconddns_no_dualstack_selection", _("Skip Dualstack Selection"), o.default = o.disabled;
_("Skip Dualstack Selection."));
o.rmempty = false; // skip ipset rules;
o.default = o.disabled; o = s.taboption("seconddns", form.Flag, "seconddns_no_rule_ipset", _("Skip Ipset Rule"),
_("Skip ipset rules."));
// skip cache; o.rmempty = false;
o = s.taboption("seconddns", form.Flag, "seconddns_no_cache", _("Skip Cache"), _("Skip Cache.")); o.default = o.disabled;
o.rmempty = false;
o.default = o.disabled; // skip soa address rule;
o = s.taboption("seconddns", form.Flag, "seconddns_no_rule_soa", _("Skip SOA Address Rule"),
// Force AAAA SOA _("Skip SOA address rules."));
o = s.taboption("seconddns", form.Flag, "seconddns_force_aaaa_soa", _("Force AAAA SOA"), _("Force AAAA SOA.")); o.rmempty = false;
o.rmempty = false; o.default = o.disabled;
o.default = o.disabled;
o = s.taboption("seconddns", form.Flag, "seconddns_no_dualstack_selection", _("Skip Dualstack Selection"),
// custom settings; _("Skip Dualstack Selection."));
o = s.taboption("custom", form.TextValue, "custom_conf", o.rmempty = false;
"", _("smartdns custom settings")); o.default = o.disabled;
o.rows = 20; // skip cache;
o.cfgvalue = function (section_id) { o = s.taboption("seconddns", form.Flag, "seconddns_no_cache", _("Skip Cache"), _("Skip Cache."));
return fs.trimmed('/etc/smartdns/custom.conf'); o.rmempty = false;
}; o.default = o.disabled;
o.write = function (section_id, formvalue) {
return fs.write('/etc/smartdns/custom.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n'); // Force AAAA SOA
}; o = s.taboption("seconddns", form.Flag, "seconddns_force_aaaa_soa", _("Force AAAA SOA"), _("Force AAAA SOA."));
o.rmempty = false;
o = s.taboption("custom", form.Flag, "coredump", _("Generate Coredump"), o.default = o.disabled;
_("Generate Coredump file when smartdns crash, coredump file is located at /tmp/smartdns.xxx.core."));
o.rmempty = false; // custom settings;
o.default = o.disabled; o = s.taboption("custom", form.TextValue, "custom_conf",
// Upstream servers; "", _("smartdns custom settings"));
s = m.section(form.GridSection, "server", _("Upstream Servers"),
_("Upstream Servers, support UDP, TCP protocol. Please configure multiple DNS servers, " o.rows = 20;
+ "including multiple foreign DNS servers.")); o.cfgvalue = function (section_id) {
s.anonymous = true; return fs.trimmed('/etc/smartdns/custom.conf');
s.addremove = true; };
o.write = function (section_id, formvalue) {
s.tab('general', _('General Settings')); return fs.write('/etc/smartdns/custom.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
s.tab('advanced', _('Advanced Settings')); };
// enable flag; o = s.taboption("custom", form.Flag, "coredump", _("Generate Coredump"),
o = s.taboption("general", form.Flag, "enabled", _("Enable"), _("Enable")); _("Generate Coredump file when smartdns crash, coredump file is located at /tmp/smartdns.xxx.core."));
o.rmempty = false; o.rmempty = false;
o.default = o.enabled; o.default = o.disabled;
o.editable = true; // Upstream servers;
s = m.section(form.GridSection, "server", _("Upstream Servers"),
// name; _("Upstream Servers, support UDP, TCP protocol. Please configure multiple DNS servers, "
o = s.taboption("general", form.Value, "name", _("DNS Server Name"), _("DNS Server Name")); + "including multiple foreign DNS servers."));
s.anonymous = true;
// IP address; s.addremove = true;
o = s.taboption("general", form.Value, "ip", _("ip"), _("DNS Server ip"));
o.datatype = "or(ipaddr, string)"; s.tab('general', _('General Settings'));
o.rmempty = false; s.tab('advanced', _('Advanced Settings'));
// port; // enable flag;
o = s.taboption("general", form.Value, "port", _("port"), _("DNS Server port")); o = s.taboption("general", form.Flag, "enabled", _("Enable"), _("Enable"));
o.placeholder = "default"; o.rmempty = false;
o.datatype = "port"; o.default = o.enabled;
o.rempty = true; o.editable = true;
o.depends("type", "udp");
o.depends("type", "tcp"); // name;
o.depends("type", "tls"); o = s.taboption("general", form.Value, "name", _("DNS Server Name"), _("DNS Server Name"));
// type; // IP address;
o = s.taboption("general", form.ListValue, "type", _("type"), _("DNS Server type")); o = s.taboption("general", form.Value, "ip", _("ip"), _("DNS Server ip"));
o.placeholder = "udp"; o.datatype = "or(ipaddr, string)";
o.value("udp", _("udp")); o.rmempty = false;
o.value("tcp", _("tcp"));
o.value("tls", _("tls")); // port;
o.value("https", _("https")); o = s.taboption("general", form.Value, "port", _("port"), _("DNS Server port"));
o.default = "udp"; o.placeholder = "default";
o.rempty = false; o.datatype = "port";
o.rempty = true;
// Advanced Options o.depends("type", "udp");
// server group o.depends("type", "tcp");
o = s.taboption("advanced", form.Value, "server_group", _("Server Group"), _("DNS Server group belongs to, " o.depends("type", "tls");
+ "used with nameserver, such as office, home."))
o.rmempty = true // type;
o.placeholder = "default" o = s.taboption("general", form.ListValue, "type", _("type"), _("DNS Server type"));
o.datatype = "hostname" o.placeholder = "udp";
o.rempty = true o.value("udp", _("udp"));
o.modalonly = true; o.value("tcp", _("tcp"));
o.value("tls", _("tls"));
// blacklist_ip o.value("https", _("https"));
o = s.taboption("advanced", form.Flag, "blacklist_ip", _("IP Blacklist Filtering"), o.default = "udp";
_("Filtering IP with blacklist")) o.rempty = false;
o.rmempty = false
o.default = o.disabled // Advanced Options
o.modalonly = true; // server group
o = s.taboption("advanced", form.Value, "server_group", _("Server Group"), _("DNS Server group belongs to, "
// TLS host verify + "used with nameserver, such as office, home."))
o = s.taboption("advanced", form.Value, "tls_host_verify", _("TLS Hostname Verify"), o.rmempty = true
_("Set TLS hostname to verify.")) o.placeholder = "default"
o.default = "" o.datatype = "hostname"
o.datatype = "string" o.rempty = true
o.rempty = true o.modalonly = true;
o.modalonly = true;
o.depends("type", "tls") // blacklist_ip
o.depends("type", "https") o = s.taboption("advanced", form.Flag, "blacklist_ip", _("IP Blacklist Filtering"),
_("Filtering IP with blacklist"))
// certificate verify o.rmempty = false
o = s.taboption("advanced", form.Flag, "no_check_certificate", _("No check certificate"), o.default = o.disabled
_("Do not check certificate.")) o.modalonly = true;
o.rmempty = false
o.default = o.disabled // TLS host verify
o.modalonly = true; o = s.taboption("advanced", form.Value, "tls_host_verify", _("TLS Hostname Verify"),
o.depends("type", "tls") _("Set TLS hostname to verify."))
o.depends("type", "https") o.default = ""
o.datatype = "string"
// SNI host name o.rempty = true
o = s.taboption("advanced", form.Value, "host_name", _("TLS SNI name"), o.modalonly = true;
_("Sets the server name indication for query.")) o.depends("type", "tls")
o.default = "" o.depends("type", "https")
o.datatype = "hostname"
o.rempty = true // certificate verify
o.modalonly = true; o = s.taboption("advanced", form.Flag, "no_check_certificate", _("No check certificate"),
o.depends("type", "tls") _("Do not check certificate."))
o.depends("type", "https") o.rmempty = false
o.default = o.disabled
// http host o.modalonly = true;
o = s.taboption("advanced", form.Value, "http_host", _("HTTP Host"), o.depends("type", "tls")
_("Set the HTTP host used for the query. Use this parameter when the host of the URL address is an IP address.")) o.depends("type", "https")
o.default = ""
o.datatype = "hostname" // SNI host name
o.rempty = true o = s.taboption("advanced", form.Value, "host_name", _("TLS SNI name"),
o.modalonly = true; _("Sets the server name indication for query."))
o.depends("type", "https") o.default = ""
o.datatype = "hostname"
// SPKI pin o.rempty = true
o = s.taboption("advanced", form.Value, "spki_pin", _("TLS SPKI Pinning"), o.modalonly = true;
_("Used to verify the validity of the TLS server, The value is Base64 encoded SPKI fingerprint, " o.depends("type", "tls")
+ "leaving blank to indicate that the validity of TLS is not verified.")) o.depends("type", "https")
o.default = ""
o.datatype = "string" // http host
o.rempty = true o = s.taboption("advanced", form.Value, "http_host", _("HTTP Host"),
o.modalonly = true; _("Set the HTTP host used for the query. Use this parameter when the host of the URL address is an IP address."))
o.depends("type", "tls") o.default = ""
o.depends("type", "https") o.datatype = "hostname"
o.rempty = true
// other args o.modalonly = true;
o = s.taboption("advanced", form.Value, "addition_arg", _("Additional Server Args"), o.depends("type", "https")
_("Additional Args for upstream dns servers"))
o.default = "" // SPKI pin
o.rempty = true o = s.taboption("advanced", form.Value, "spki_pin", _("TLS SPKI Pinning"),
o.modalonly = true; _("Used to verify the validity of the TLS server, The value is Base64 encoded SPKI fingerprint, "
+ "leaving blank to indicate that the validity of TLS is not verified."))
// Doman addresss; o.default = ""
s = m.section(form.TypedSection, "smartdns", _("Advanced Settings"), _("Advanced Settings")); o.datatype = "string"
s.anonymous = true; o.rempty = true
o.modalonly = true;
s.tab("domain-address", _("Domain Address"), _("Set Specific domain ip address.")); o.depends("type", "tls")
s.tab("blackip-list", _("IP Blacklist"), _("Set Specific ip blacklist.")); o.depends("type", "https")
o = s.taboption("domain-address", form.TextValue, "address_conf", // other args
"", o = s.taboption("advanced", form.Value, "addition_arg", _("Additional Server Args"),
_("Specify an IP address to return for any host in the given domains, Queries in the domains are never " _("Additional Args for upstream dns servers"))
+ "forwarded and always replied to with the specified IP address which may be IPv4 or IPv6.")); o.default = ""
o.rows = 20; o.rempty = true
o.cfgvalue = function (section_id) { o.modalonly = true;
return fs.trimmed('/etc/smartdns/address.conf');
}; // Doman addresss;
o.write = function (section_id, formvalue) { s = m.section(form.TypedSection, "smartdns", _("Advanced Settings"), _("Advanced Settings"));
return fs.write('/etc/smartdns/address.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n'); s.anonymous = true;
};
s.tab("domain-address", _("Domain Address"), _("Set Specific domain ip address."));
// IP Blacklist; s.tab("blackip-list", _("IP Blacklist"), _("Set Specific ip blacklist."));
// blacklist;
o = s.taboption("blackip-list", form.TextValue, "blackip_ip_conf", o = s.taboption("domain-address", form.TextValue, "address_conf",
"", _("Configure IP blacklists that will be filtered from the results of specific DNS server.")); "",
o.rows = 20; _("Specify an IP address to return for any host in the given domains, Queries in the domains are never "
o.cfgvalue = function (section_id) { + "forwarded and always replied to with the specified IP address which may be IPv4 or IPv6."));
return fs.trimmed('/etc/smartdns/blacklist-ip.conf'); o.rows = 20;
}; o.cfgvalue = function (section_id) {
o.write = function (section_id, formvalue) { return fs.trimmed('/etc/smartdns/address.conf');
return fs.write('/etc/smartdns/blacklist-ip.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n'); };
}; o.write = function (section_id, formvalue) {
return fs.write('/etc/smartdns/address.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
// Doman addresss; };
s = m.section(form.TypedSection, "smartdns", _("Technical Support"),
_("If you like this software, please buy me a cup of coffee.")); // IP Blacklist;
s.anonymous = true; // blacklist;
o = s.taboption("blackip-list", form.TextValue, "blackip_ip_conf",
o = s.option(form.Button, "web"); "", _("Configure IP blacklists that will be filtered from the results of specific DNS server."));
o.title = _("SmartDNS official website"); o.rows = 20;
o.inputtitle = _("open website"); o.cfgvalue = function (section_id) {
o.inputstyle = "apply"; return fs.trimmed('/etc/smartdns/blacklist-ip.conf');
o.onclick = function () { };
window.open("https://pymumu.github.io/smartdns", '_blank'); o.write = function (section_id, formvalue) {
}; return fs.write('/etc/smartdns/blacklist-ip.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
};
o = s.option(form.Button, "Donate");
o.title = _("Donate to smartdns"); // Doman addresss;
o.inputtitle = _("Donate"); s = m.section(form.TypedSection, "smartdns", _("Technical Support"),
o.inputstyle = "apply"; _("If you like this software, please buy me a cup of coffee."));
o.onclick = function () { s.anonymous = true;
window.open("https://pymumu.github.io/smartdns/#donate", '_blank');
}; o = s.option(form.Button, "web");
o.title = _("SmartDNS official website");
return m.render(); o.inputtitle = _("open website");
} o.inputstyle = "apply";
}); o.onclick = function () {
window.open("https://pymumu.github.io/smartdns", '_blank');
};
o = s.option(form.Button, "Donate");
o.title = _("Donate to smartdns");
o.inputtitle = _("Donate");
o.inputstyle = "apply";
o.onclick = function () {
window.open("https://pymumu.github.io/smartdns/#donate", '_blank');
};
return m.render();
}
});

View File

@@ -23,9 +23,9 @@ ifndef CFLAGS
CFLAGS =-O2 -g -Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing -funwind-tables -Wmissing-prototypes -Wshadow -Wextra -Wno-unused-parameter -Wno-implicit-fallthrough CFLAGS =-O2 -g -Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing -funwind-tables -Wmissing-prototypes -Wshadow -Wextra -Wno-unused-parameter -Wno-implicit-fallthrough
endif endif
override CFLAGS +=-Iinclude override CFLAGS +=-Iinclude
override CFLAGS += -DBASE_FILE_NAME=\"$(notdir $<)\" override CFLAGS += -DBASE_FILE_NAME='"$(notdir $<)"'
ifdef VER ifdef VER
override CFLAGS += -DSMARTDNS_VERION=\"$(VER)\" override CFLAGS += -DSMARTDNS_VERION='"$(VER)"'
endif endif
CXXFLAGS=-O2 -g -Wall -std=c++11 CXXFLAGS=-O2 -g -Wall -std=c++11