mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-10 11:09:57 +08:00
smartdns: drop upstreamed package
This commit is contained in:
parent
7ba1d8c0cd
commit
01f3822a64
@ -1,26 +0,0 @@
|
||||
#
|
||||
# Copyright 2018-2020 Nick Peng <pymumu@gmail.com>
|
||||
# Licensed to the public under the GPL V3 License.
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_LICENSE:=GPL-3.0-or-later
|
||||
PKG_MAINTAINER:=Nick Peng <pymumu@gmail.com>
|
||||
PKG_VERSION:=1.2020.30
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LUCI_TITLE:=LuCI for smartdns
|
||||
LUCI_DESCRIPTION:=Provides Luci for smartdns
|
||||
LUCI_DEPENDS:=+smartdns
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
define Package/$(PKG_NAME)/config
|
||||
# shown in make menuconfig <Help>
|
||||
help
|
||||
$(LUCI_TITLE)
|
||||
Version: $(PKG_VERSION)-$(PKG_RELEASE)
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
@ -1,492 +0,0 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* Copyright (C) 2018-2020 Ruilin Peng (Nick) <pymumu@gmail.com>.
|
||||
*
|
||||
* smartdns is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* smartdns is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
'use strict';
|
||||
'require fs';
|
||||
'require uci';
|
||||
'require form';
|
||||
'require rpc';
|
||||
|
||||
var conf = 'smartdns';
|
||||
var callServiceList = rpc.declare({
|
||||
object: 'service',
|
||||
method: 'list',
|
||||
params: ['name'],
|
||||
expect: { '': {} }
|
||||
});
|
||||
|
||||
function getPidOfSmartdns() {
|
||||
return L.resolveDefault(callServiceList(conf), {})
|
||||
.then(function (res) {
|
||||
var isrunning = false;
|
||||
try {
|
||||
isrunning = res[conf]['instances']['smartdns']['running'];
|
||||
} catch (e) { }
|
||||
return isrunning;
|
||||
});
|
||||
}
|
||||
|
||||
function getIPTablesRedirect() {
|
||||
return fs.exec('/usr/sbin/iptables', ['-t', 'nat', '-nL', 'PREROUTING']).then(function (res) {
|
||||
if (res.code === 0) {
|
||||
return res.stdout.trim();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getIP6TablesRedirect() {
|
||||
return fs.exec('/usr/sbin/ip6tables', ['-t', 'nat', '-nL', 'PREROUTING']).then(function (res) {
|
||||
if (res.code === 0) {
|
||||
return res.stdout.trim();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function smartdnsServiceStatus() {
|
||||
return Promise.all([
|
||||
getPidOfSmartdns(),
|
||||
getIPTablesRedirect(),
|
||||
getIP6TablesRedirect()
|
||||
]);
|
||||
}
|
||||
|
||||
function smartdnsRenderStatus(res) {
|
||||
var renderHTML = "";
|
||||
var isRunning = res[0];
|
||||
var ipt = res[1];
|
||||
var ip6t = res[2];
|
||||
|
||||
var serverPort = uci.get_first('smartdns', 'smartdns', 'port');
|
||||
var redirectMode = uci.get_first('smartdns', 'smartdns', 'redirect');
|
||||
var ipv6Enabled = uci.get_first('smartdns', 'smartdns', 'ipv6_server');
|
||||
|
||||
if (isRunning) {
|
||||
renderHTML += "<span style=\"color:green;font-weight:bold\">SmartDNS - " + _("RUNNING") + "</span>";
|
||||
} else {
|
||||
renderHTML += "<span style=\"color:red;font-weight:bold\">SmartDNS - " + _("NOT RUNNING") + "</span>";
|
||||
return renderHTML;
|
||||
}
|
||||
|
||||
if (redirectMode === "dnsmasq-upstream") {
|
||||
var matchLine = "127.0.0.1#" + serverPort;
|
||||
var dnsmasqServer = uci.get_first('dhcp', 'dnsmasq', 'server') || "";
|
||||
|
||||
if (dnsmasqServer.indexOf(matchLine) < 0) {
|
||||
renderHTML += "<br /><span style=\"color:red;font-weight:bold\">" + _("Dnsmasq Forwared To Smartdns Failure") + "</span>";
|
||||
}
|
||||
} else if (redirectMode === "redirect") {
|
||||
var redirectRules = (ipt || '').split(/\n/).filter(function (rule) {
|
||||
return rule.match(/REDIRECT/) && rule.match(/dpt:53/) && rule.match("ports " + serverPort);
|
||||
});
|
||||
|
||||
if (redirectRules.length <= 0) {
|
||||
renderHTML += "<br /><span style=\"color:red;font-weight:bold\">" + _("IPV4 53 Port Redirect Failure") + "</span>";
|
||||
if (ipv6Enabled) {
|
||||
var redirectRules = (ip6t || '').split(/\n/).filter(function (rule) {
|
||||
return rule.match(/REDIRECT/) && rule.match(/dpt:53/) && rule.match("ports " + serverPort);
|
||||
});
|
||||
if (redirectRules.length <= 0) {
|
||||
renderHTML += "<br /><span style=\"color:red;font-weight:bold\">" + _("IPV6 53 Port Redirect Failure") + "</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return renderHTML;
|
||||
}
|
||||
|
||||
return L.view.extend({
|
||||
load: function () {
|
||||
return Promise.all([
|
||||
uci.load('smartdns'),
|
||||
uci.load('dhcp')
|
||||
]);
|
||||
},
|
||||
render: function (stats) {
|
||||
var m, s, o;
|
||||
|
||||
m = new form.Map('smartdns', _('SmartDNS'));
|
||||
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.");
|
||||
|
||||
s = m.section(form.NamedSection, '_status');
|
||||
s.anonymous = true;
|
||||
s.render = function (section_id) {
|
||||
L.Poll.add(function () {
|
||||
return L.resolveDefault(smartdnsServiceStatus()).then(function (res) {
|
||||
var view = document.getElementById("service_status");
|
||||
view.innerHTML = smartdnsRenderStatus(res);
|
||||
});
|
||||
});
|
||||
|
||||
return E('div', { class: 'cbi-map' },
|
||||
E('div', { class: 'cbi-section' }, [
|
||||
E('div', { id: 'service_status' },
|
||||
_('Collecting data ...'))
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
// Basic;
|
||||
s = m.section(form.TypedSection, "smartdns", _("Settings"), _("General Settings"));
|
||||
s.anonymous = true;
|
||||
|
||||
s.tab("settings", _("General Settings"));
|
||||
s.tab("seconddns", _("Second Server Settings"));
|
||||
s.tab("custom", _("Custom Settings"));
|
||||
|
||||
// Eanble;
|
||||
o = s.taboption("settings", form.Flag, "enabled", _("Enable"), _("Enable or disable smartdns server"));
|
||||
o.default = o.disabled;
|
||||
o.rempty = false;
|
||||
|
||||
// server name;
|
||||
o = s.taboption("settings", form.Value, "server_name", _("Server Name"), _("Smartdns server name"));
|
||||
o.default = "smartdns";
|
||||
o.datatype = "hostname";
|
||||
o.rempty = false;
|
||||
|
||||
// Port;
|
||||
o = s.taboption("settings", form.Value, "port", _("Local Port"), _("Smartdns local server port"));
|
||||
o.placeholder = 6053;
|
||||
o.default = 6053;
|
||||
o.datatype = "port";
|
||||
o.rempty = false;
|
||||
|
||||
// Enable TCP server;
|
||||
o = s.taboption("settings", form.Flag, "tcp_server", _("TCP Server"), _("Enable TCP DNS Server"));
|
||||
o.rmempty = false;
|
||||
o.default = o.enabled;
|
||||
|
||||
// Support IPV6;
|
||||
o = s.taboption("settings", form.Flag, "ipv6_server", _("IPV6 Server"), _("Enable IPV6 DNS Server"));
|
||||
o.rmempty = false;
|
||||
o.default = o.enabled;
|
||||
|
||||
// Support DualStack ip selection;
|
||||
o = s.taboption("settings", form.Flag, "dualstack_ip_selection", _("Dual-stack IP Selection"),
|
||||
_("Enable IP selection between IPV4 and IPV6"));
|
||||
o.rmempty = false;
|
||||
o.default = o.disabled;
|
||||
|
||||
// Domain prefetch load ;
|
||||
o = s.taboption("settings", form.Flag, "prefetch_domain", _("Domain prefetch"),
|
||||
_("Enable domain prefetch, accelerate domain response speed."));
|
||||
o.rmempty = false;
|
||||
o.default = o.disabled;
|
||||
|
||||
// Domain Serve expired
|
||||
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."));
|
||||
o.rmempty = false;
|
||||
o.default = o.disabled;
|
||||
|
||||
// Redirect;
|
||||
o = s.taboption("settings", form.ListValue, "redirect", _("Redirect"), _("SmartDNS redirect mode"));
|
||||
o.placeholder = "none";
|
||||
o.value("none", _("none"));
|
||||
o.value("dnsmasq-upstream", _("Run as dnsmasq upstream server"));
|
||||
o.value("redirect", _("Redirect 53 port to SmartDNS"));
|
||||
o.default = "none";
|
||||
o.rempty = false;
|
||||
|
||||
// cache-size;
|
||||
o = s.taboption("settings", form.Value, "cache_size", _("Cache Size"), _("DNS domain result cache size"));
|
||||
o.rempty = true;
|
||||
|
||||
// rr-ttl;
|
||||
o = s.taboption("settings", form.Value, "rr_ttl", _("Domain TTL"), _("TTL for all domain result."));
|
||||
o.rempty = true;
|
||||
|
||||
// rr-ttl-min;
|
||||
o = s.taboption("settings", form.Value, "rr_ttl_min", _("Domain TTL Min"),
|
||||
_("Minimum TTL for all domain result."));
|
||||
o.rempty = true;
|
||||
o.placeholder = "300";
|
||||
o.default = 300;
|
||||
o.optional = true;
|
||||
|
||||
// second dns server;
|
||||
// rr-ttl-max;
|
||||
o = s.taboption("settings", form.Value, "rr_ttl_max", _("Domain TTL Max"),
|
||||
_("Maximum TTL for all domain result."));
|
||||
o.rempty = true;
|
||||
|
||||
// Eanble;
|
||||
o = s.taboption("seconddns", form.Flag, "seconddns_enabled", _("Enable"),
|
||||
_("Enable or disable second DNS server."));
|
||||
o.default = o.disabled;
|
||||
o.rempty = false;
|
||||
|
||||
// Port;
|
||||
o = s.taboption("seconddns", form.Value, "seconddns_port", _("Local Port"), _("Smartdns local server port"));
|
||||
o.placeholder = 6553;
|
||||
o.default = 6553;
|
||||
o.datatype = "port";
|
||||
o.rempty = false;
|
||||
|
||||
// Enable TCP server;
|
||||
o = s.taboption("seconddns", form.Flag, "seconddns_tcp_server", _("TCP Server"), _("Enable TCP DNS Server"));
|
||||
o.rmempty = false;
|
||||
o.default = o.enabled;
|
||||
|
||||
// dns server group;
|
||||
o = s.taboption("seconddns", form.Value, "seconddns_server_group", _("Server Group"),
|
||||
_("Query DNS through specific dns server group, such as office, home."));
|
||||
o.rmempty = true;
|
||||
o.placeholder = "default";
|
||||
o.datatype = "hostname";
|
||||
o.rempty = true;
|
||||
|
||||
o = s.taboption("seconddns", form.Flag, "seconddns_no_speed_check", _("Skip Speed Check"),
|
||||
_("Do not check speed."));
|
||||
o.rmempty = false;
|
||||
o.default = o.disabled;
|
||||
|
||||
// skip address rules;
|
||||
o = s.taboption("seconddns", form.Flag, "seconddns_no_rule_addr", _("Skip Address Rules"),
|
||||
_("Skip address rules."));
|
||||
o.rmempty = false;
|
||||
o.default = o.disabled;
|
||||
|
||||
// skip name server rules;
|
||||
o = s.taboption("seconddns", form.Flag, "seconddns_no_rule_nameserver", _("Skip Nameserver Rule"),
|
||||
_("Skip nameserver rules."));
|
||||
o.rmempty = false;
|
||||
o.default = o.disabled;
|
||||
|
||||
// skip ipset rules;
|
||||
o = s.taboption("seconddns", form.Flag, "seconddns_no_rule_ipset", _("Skip Ipset Rule"),
|
||||
_("Skip ipset rules."));
|
||||
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"),
|
||||
_("Skip SOA address rules."));
|
||||
o.rmempty = false;
|
||||
o.default = o.disabled;
|
||||
|
||||
o = s.taboption("seconddns", form.Flag, "seconddns_no_dualstack_selection", _("Skip Dualstack Selection"),
|
||||
_("Skip Dualstack Selection."));
|
||||
o.rmempty = false;
|
||||
o.default = o.disabled;
|
||||
|
||||
// skip cache;
|
||||
o = s.taboption("seconddns", form.Flag, "seconddns_no_cache", _("Skip Cache"), _("Skip Cache."));
|
||||
o.rmempty = false;
|
||||
o.default = o.disabled;
|
||||
|
||||
// Force AAAA SOA
|
||||
o = s.taboption("seconddns", form.Flag, "force_aaaa_soa", _("Force AAAA SOA"), _("Force AAAA SOA."));
|
||||
o.rmempty = false;
|
||||
o.default = o.disabled;
|
||||
|
||||
// custom settings;
|
||||
o = s.taboption("custom", form.TextValue, "custom_conf",
|
||||
"", _("smartdns custom settings"));
|
||||
|
||||
o.rows = 20;
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/smartdns/custom.conf');
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
return fs.write('/etc/smartdns/custom.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
|
||||
};
|
||||
|
||||
o = s.taboption("custom", form.Flag, "coredump", _("Generate Coredump"),
|
||||
_("Generate Coredump file when smartdns crash, coredump file is located at /tmp/smartdns.xxx.core."));
|
||||
o.rmempty = false;
|
||||
o.default = o.disabled;
|
||||
// Upstream servers;
|
||||
s = m.section(form.GridSection, "server", _("Upstream Servers"),
|
||||
_("Upstream Servers, support UDP, TCP protocol. Please configure multiple DNS servers, "
|
||||
+ "including multiple foreign DNS servers."));
|
||||
s.anonymous = true;
|
||||
s.addremove = true;
|
||||
|
||||
s.tab('general', _('General Settings'));
|
||||
s.tab('advanced', _('Advanced Settings'));
|
||||
|
||||
// enable flag;
|
||||
o = s.taboption("general", form.Flag, "enabled", _("Enable"), _("Enable"));
|
||||
o.rmempty = false;
|
||||
o.default = o.enabled;
|
||||
o.editable = true;
|
||||
|
||||
// name;
|
||||
o = s.taboption("general", form.Value, "name", _("DNS Server Name"), _("DNS Server Name"));
|
||||
|
||||
// IP address;
|
||||
o = s.taboption("general", form.Value, "ip", _("ip"), _("DNS Server ip"));
|
||||
o.datatype = "or(ipaddr, string)";
|
||||
o.rmempty = false;
|
||||
|
||||
// port;
|
||||
o = s.taboption("general", form.Value, "port", _("port"), _("DNS Server port"));
|
||||
o.placeholder = "default";
|
||||
o.datatype = "port";
|
||||
o.rempty = true;
|
||||
o.depends("type", "udp");
|
||||
o.depends("type", "tcp");
|
||||
o.depends("type", "tls");
|
||||
|
||||
// type;
|
||||
o = s.taboption("general", form.ListValue, "type", _("type"), _("DNS Server type"));
|
||||
o.placeholder = "udp";
|
||||
o.value("udp", _("udp"));
|
||||
o.value("tcp", _("tcp"));
|
||||
o.value("tls", _("tls"));
|
||||
o.value("https", _("https"));
|
||||
o.default = "udp";
|
||||
o.rempty = false;
|
||||
|
||||
// Advanced Options
|
||||
// server group
|
||||
o = s.taboption("advanced", form.Value, "server_group", _("Server Group"), _("DNS Server group belongs to, "
|
||||
+ "used with nameserver, such as office, home."))
|
||||
o.rmempty = true
|
||||
o.placeholder = "default"
|
||||
o.datatype = "hostname"
|
||||
o.rempty = true
|
||||
o.modalonly = true;
|
||||
|
||||
// blacklist_ip
|
||||
o = s.taboption("advanced", form.Flag, "blacklist_ip", _("IP Blacklist Filtering"),
|
||||
_("Filtering IP with blacklist"))
|
||||
o.rmempty = false
|
||||
o.default = o.disabled
|
||||
o.modalonly = true;
|
||||
|
||||
// TLS host verify
|
||||
o = s.taboption("advanced", form.Value, "tls_host_verify", _("TLS Hostname Verify"),
|
||||
_("Set TLS hostname to verify."))
|
||||
o.default = ""
|
||||
o.datatype = "string"
|
||||
o.rempty = true
|
||||
o.modalonly = true;
|
||||
o.depends("type", "tls")
|
||||
o.depends("type", "https")
|
||||
|
||||
// certificate verify
|
||||
o = s.taboption("advanced", form.Flag, "no_check_certificate", _("No check certificate"),
|
||||
_("Do not check certificate."))
|
||||
o.rmempty = false
|
||||
o.default = o.disabled
|
||||
o.modalonly = true;
|
||||
o.depends("type", "tls")
|
||||
o.depends("type", "https")
|
||||
|
||||
// SNI host name
|
||||
o = s.taboption("advanced", form.Value, "host_name", _("TLS SNI name"),
|
||||
_("Sets the server name indication for query."))
|
||||
o.default = ""
|
||||
o.datatype = "hostname"
|
||||
o.rempty = true
|
||||
o.modalonly = true;
|
||||
o.depends("type", "tls")
|
||||
o.depends("type", "https")
|
||||
|
||||
// http host
|
||||
o = s.taboption("advanced", form.Value, "http_host", _("HTTP Host"),
|
||||
_("Set the HTTP host used for the query. Use this parameter when the host of the URL address is an IP address."))
|
||||
o.default = ""
|
||||
o.datatype = "hostname"
|
||||
o.rempty = true
|
||||
o.modalonly = true;
|
||||
o.depends("type", "https")
|
||||
|
||||
// SPKI pin
|
||||
o = s.taboption("advanced", form.Value, "spki_pin", _("TLS SPKI Pinning"),
|
||||
_("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."))
|
||||
o.default = ""
|
||||
o.datatype = "string"
|
||||
o.rempty = true
|
||||
o.modalonly = true;
|
||||
o.depends("type", "tls")
|
||||
o.depends("type", "https")
|
||||
|
||||
// other args
|
||||
o = s.taboption("advanced", form.Value, "addition_arg", _("Additional Server Args"),
|
||||
_("Additional Args for upstream dns servers"))
|
||||
o.default = ""
|
||||
o.rempty = true
|
||||
o.modalonly = true;
|
||||
|
||||
// Doman addresss;
|
||||
s = m.section(form.TypedSection, "smartdns", _("Advanced Settings"), _("Advanced Settings"));
|
||||
s.anonymous = true;
|
||||
|
||||
s.tab("domain-address", _("Domain Address"), _("Set Specific domain ip address."));
|
||||
s.tab("blackip-list", _("IP Blacklist"), _("Set Specific ip blacklist."));
|
||||
|
||||
o = s.taboption("domain-address", form.TextValue, "address_conf",
|
||||
"",
|
||||
_("Specify an IP address to return for any host in the given domains, Queries in the domains are never "
|
||||
+ "forwarded and always replied to with the specified IP address which may be IPv4 or IPv6."));
|
||||
o.rows = 20;
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/smartdns/address.conf');
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
return fs.write('/etc/smartdns/address.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
|
||||
};
|
||||
|
||||
// IP Blacklist;
|
||||
// blacklist;
|
||||
o = s.taboption("blackip-list", form.TextValue, "blackip_ip_conf",
|
||||
"", _("Configure IP blacklists that will be filtered from the results of specific DNS server."));
|
||||
o.rows = 20;
|
||||
o.cfgvalue = function (section_id) {
|
||||
return fs.trimmed('/etc/smartdns/blacklist-ip.conf');
|
||||
};
|
||||
o.write = function (section_id, formvalue) {
|
||||
return fs.write('/etc/smartdns/blacklist-ip.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."));
|
||||
s.anonymous = true;
|
||||
|
||||
o = s.option(form.Button, "web");
|
||||
o.title = _("SmartDNS official website");
|
||||
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();
|
||||
}
|
||||
});
|
@ -1,311 +0,0 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
||||
msgid "SmartDNS"
|
||||
msgstr "SmartDNS"
|
||||
|
||||
msgid "SmartDNS is a local high-performance DNS server"
|
||||
msgstr "SmartDNS是一个本地高性能DNS服务器"
|
||||
|
||||
msgid "SmartDNS Server"
|
||||
msgstr "SmartDNS 服务器"
|
||||
|
||||
msgid "SmartDNS is a local high-performance DNS server, supports finding fastest IP, supports ad filtering, and supports avoiding DNS poisoning."
|
||||
msgstr "SmartDNS是一个本地高性能DNS服务器,支持返回最快IP,支持广告过滤。"
|
||||
|
||||
msgid "Custom Settings"
|
||||
msgstr "自定义设置"
|
||||
|
||||
msgid "General Settings"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Settings"
|
||||
msgstr "设置"
|
||||
|
||||
msgid "Advanced Settings"
|
||||
msgstr "高级设置"
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "Generate Coredump"
|
||||
msgstr "生成coredump"
|
||||
|
||||
msgid "Generate Coredump file when smartdns crash, coredump file is located at /tmp/smartdns.xxx.core."
|
||||
msgstr "当smartdns异常时生成coredump文件,coredump文件在/tmp/smartdns.xxx.core."
|
||||
|
||||
msgid "Server Name"
|
||||
msgstr "服务器名称"
|
||||
|
||||
msgid "Smartdns server name"
|
||||
msgstr "SmartDNS的服务器名称,默认为smartdns,留空为主机名"
|
||||
|
||||
msgid "SmartDNS is a local dns server to find fastest ip."
|
||||
msgstr "本地高性能服务器,优化网络访问性能。"
|
||||
|
||||
msgid "Enable or disable smartdns server"
|
||||
msgstr "启用或禁用SmartDNS服务"
|
||||
|
||||
msgid "Local Port"
|
||||
msgstr "本地端口"
|
||||
|
||||
msgid "Smartdns local server port"
|
||||
msgstr "SmartDNS本地服务端口"
|
||||
|
||||
msgid "IPV4 53 Port Redirect Failure"
|
||||
msgstr "IPV4 53端口重定向失败"
|
||||
|
||||
msgid "IPV6 53 Port Redirect Failure"
|
||||
msgstr "IPV6 53端口重定向失败"
|
||||
|
||||
msgid "Dnsmasq Forwared To Smartdns Failure"
|
||||
msgstr "重定向dnsmasq到smartdns失败"
|
||||
|
||||
msgid "TCP Server"
|
||||
msgstr "TCP服务器"
|
||||
|
||||
msgid "Enable TCP DNS Server"
|
||||
msgstr "启用TCP服务器"
|
||||
|
||||
msgid "IPV6 Server"
|
||||
msgstr "IPV6服务器"
|
||||
|
||||
msgid "Enable IPV6 DNS Server"
|
||||
msgstr "启用IPV6服务器"
|
||||
|
||||
msgid "Dual-stack IP Selection"
|
||||
msgstr "双栈IP优选"
|
||||
|
||||
msgid "Enable IP selection between IPV4 and IPV6"
|
||||
msgstr "启用或禁用IPV4,IPV6间的IP优选策略。"
|
||||
|
||||
msgid "Domain prefetch"
|
||||
msgstr "域名预加载"
|
||||
|
||||
msgid "Enable domain prefetch, accelerate domain response speed."
|
||||
msgstr "启用域名预加载,加速域名响应速度。"
|
||||
|
||||
msgid "Serve expired"
|
||||
msgstr "缓存过期服务"
|
||||
|
||||
msgid "Attempts to serve old responses from cache with a TTL of 0 in the response without waiting for the actual resolution to finish."
|
||||
msgstr "查询性能优化,有请求时尝试回应TTL为0的过期记录,以避免查询等待。"
|
||||
|
||||
msgid "Redirect"
|
||||
msgstr "重定向"
|
||||
|
||||
msgid "SmartDNS redirect mode"
|
||||
msgstr "SmartDNS 重定向模式"
|
||||
|
||||
msgid "Run as dnsmasq upstream server"
|
||||
msgstr "作为dnsmasq的上游服务器"
|
||||
|
||||
msgid "Redirect 53 port to SmartDNS"
|
||||
msgstr "重定向53端口到SmartDNS"
|
||||
|
||||
msgid "Cache Size"
|
||||
msgstr "缓存大小"
|
||||
|
||||
msgid "DNS domain result cache size"
|
||||
msgstr "缓存DNS的结果,缓存大小,配置零则不缓存"
|
||||
|
||||
msgid "Domain TTL"
|
||||
msgstr "域名TTL"
|
||||
|
||||
msgid "TTL for all domain result."
|
||||
msgstr "设置所有域名的TTL值"
|
||||
|
||||
msgid "Domain TTL Min"
|
||||
msgstr "域名TTL最小值"
|
||||
|
||||
msgid "Minimum TTL for all domain result."
|
||||
msgstr "设置所有域名的TTL最小值"
|
||||
|
||||
msgid "Domain TTL Max"
|
||||
msgstr "域名TTL最大值"
|
||||
|
||||
msgid "Maximum TTL for all domain result."
|
||||
msgstr "设置所有域名的TTL最大值"
|
||||
|
||||
msgid "smartdns custom settings"
|
||||
msgstr "smartdns 自定义设置,具体配置参数参考指导"
|
||||
|
||||
msgid "Second Server Settings"
|
||||
msgstr "第二DNS服务器"
|
||||
|
||||
msgid "Enable or disable second DNS server."
|
||||
msgstr "是否启用第二DNS服务器。"
|
||||
|
||||
msgid "Skip Speed Check"
|
||||
msgstr "跳过测速"
|
||||
|
||||
msgid "Do not check speed."
|
||||
msgstr "禁用测速。"
|
||||
|
||||
msgid "Server Group"
|
||||
msgstr "服务器组"
|
||||
|
||||
msgid "Query DNS through specific dns server group, such as office, home."
|
||||
msgstr "使用指定服务器组查询,比如office, home。"
|
||||
|
||||
msgid "Skip Address Rules"
|
||||
msgstr "跳过address规则"
|
||||
|
||||
msgid "Skip address rules."
|
||||
msgstr "跳过address规则。"
|
||||
|
||||
msgid "Skip Nameserver Rule"
|
||||
msgstr "跳过Nameserver规则"
|
||||
|
||||
msgid "Skip nameserver rules."
|
||||
msgstr "跳过Nameserver规则。"
|
||||
|
||||
msgid "Skip Ipset Rule"
|
||||
msgstr "跳过ipset规则"
|
||||
|
||||
msgid "Skip ipset rules."
|
||||
msgstr "跳过ipset规则。"
|
||||
|
||||
msgid "Skip SOA Address Rule"
|
||||
msgstr "跳过address SOA(#)规则"
|
||||
|
||||
msgid "Skip SOA address rules."
|
||||
msgstr "跳过address SOA(#)规则。"
|
||||
|
||||
msgid "Skip Dualstack Selection"
|
||||
msgstr "跳过双栈优选"
|
||||
|
||||
msgid "Skip Dualstack Selection."
|
||||
msgstr "跳过双栈优选。"
|
||||
|
||||
msgid "Skip Cache"
|
||||
msgstr "跳过cache"
|
||||
|
||||
msgid "Skip Cache."
|
||||
msgstr "跳过cache。"
|
||||
|
||||
msgid "Force AAAA SOA"
|
||||
msgstr "停用IPV6地址解析"
|
||||
|
||||
msgid "Force AAAA SOA."
|
||||
msgstr "停用IPV6地址解析。"
|
||||
|
||||
msgid "Upstream Servers"
|
||||
msgstr "上游服务器"
|
||||
|
||||
msgid "Upstream Servers, support UDP, TCP protocol. Please configure multiple DNS servers, including multiple foreign DNS servers."
|
||||
msgstr "上游DNS服务器列表,支持UDP,TCP协议,请配置多个上游DNS服务器,包括多个国内外服务器"
|
||||
|
||||
msgid "DNS Server Name"
|
||||
msgstr "DNS服务器名称"
|
||||
|
||||
msgid "port"
|
||||
msgstr "端口"
|
||||
|
||||
msgid "DNS Server port"
|
||||
msgstr "DNS服务器端口"
|
||||
|
||||
msgid "DNS Server ip"
|
||||
msgstr "DNS服务器IP"
|
||||
|
||||
msgid "type"
|
||||
msgstr "类型"
|
||||
|
||||
msgid "DNS Server type"
|
||||
msgstr "协议类型"
|
||||
|
||||
msgid "Domain Address"
|
||||
msgstr "域名地址"
|
||||
|
||||
msgid "TLS Hostname Verify"
|
||||
msgstr "校验TLS主机名"
|
||||
|
||||
msgid "Set TLS hostname to verify."
|
||||
msgstr "设置校验TLS主机名。"
|
||||
|
||||
msgid "No check certificate"
|
||||
msgstr "停用证书校验"
|
||||
|
||||
msgid "Do not check certificate."
|
||||
msgstr "不校验证书的合法性。"
|
||||
|
||||
msgid "TLS SNI name"
|
||||
msgstr "TLS SNI名称"
|
||||
|
||||
msgid "HTTP Host"
|
||||
msgstr "HTTP主机"
|
||||
|
||||
msgid "Sets the server name indication for query."
|
||||
msgstr "设置查询时使用的服务器SNI名称。"
|
||||
|
||||
msgid "Set the HTTP host used for the query. Use this parameter when the host of the URL address is an IP address."
|
||||
msgstr "设置查询时使用的HTTP主机,当URL地址的host是IP地址时,使用此参数。"
|
||||
|
||||
msgid "Server Group"
|
||||
msgstr "服务器组"
|
||||
|
||||
msgid "DNS Server group belongs to, used with nameserver, such as office, home."
|
||||
msgstr "DNS服务器所属组, 配合nameserver使用,例如:office,home。"
|
||||
|
||||
msgid "IP Blacklist Filtering"
|
||||
msgstr "IP黑名单过滤"
|
||||
|
||||
msgid "Anti Answer Forgery"
|
||||
msgstr "反回答伪造"
|
||||
|
||||
msgid "Anti answer forgery, if DNS does not work properly after enabling, please turn off this feature"
|
||||
msgstr "反回答伪造,如果启用后DNS工作不正常,请关闭此功能。"
|
||||
|
||||
msgid "Filtering IP with blacklist"
|
||||
msgstr "使用IP黑名单过滤"
|
||||
|
||||
msgid "TLS SPKI Pinning"
|
||||
msgstr "TLS SPKI 指纹"
|
||||
|
||||
msgid "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."
|
||||
msgstr "用于校验TLS服务器的有效性,数值为Base64编码的SPKI指纹, 留空表示不验证TLS的合法性"
|
||||
|
||||
msgid "Additional Server Args"
|
||||
msgstr "额外的服务器参数"
|
||||
|
||||
msgid "Additional Args for upstream dns servers"
|
||||
msgstr "额外的上游DNS服务器参数"
|
||||
|
||||
msgid "Upstream DNS Server Configuration"
|
||||
msgstr "上游DNS服务器配置"
|
||||
|
||||
msgid "Set Specific domain ip address."
|
||||
msgstr "指定特定域名的IP地址"
|
||||
|
||||
msgid "Specify an IP address to return for any host in the given domains, Queries in the domains are never forwarded and always replied to with the specified IP address which may be IPv4 or IPv6."
|
||||
msgstr "配置特定域名返回特定的IP地址,域名查询将不到上游服务器请求,直接返回配置的IP地址,可用于广告屏蔽。"
|
||||
|
||||
msgid "IP Blacklist"
|
||||
msgstr "IP黑名单"
|
||||
|
||||
msgid "Set Specific ip blacklist."
|
||||
msgstr "设置IP黑名单列表"
|
||||
|
||||
msgid "Configure IP blacklists that will be filtered from the results of specific DNS server."
|
||||
msgstr "配置需要从指定域名服务器结果过滤的IP黑名单。"
|
||||
|
||||
msgid "Technical Support"
|
||||
msgstr "技术支持"
|
||||
|
||||
msgid "If you like this software, please buy me a cup of coffee."
|
||||
msgstr "如果本软件对你有帮助,请给作者加个蛋。"
|
||||
|
||||
msgid "SmartDNS official website"
|
||||
msgstr "SmartDNS官方网站"
|
||||
|
||||
msgid "open website"
|
||||
msgstr "打开网站"
|
||||
|
||||
msgid "Donate to smartdns"
|
||||
msgstr "捐助smartdns项目"
|
||||
|
||||
msgid "Donate"
|
||||
msgstr "捐助"
|
@ -1,12 +0,0 @@
|
||||
{
|
||||
"admin/services/smartdns": {
|
||||
"title": "SmartDNS",
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "smartdns/smartdns"
|
||||
},
|
||||
"depends": {
|
||||
"uci": { "smartdns": true }
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
{
|
||||
"luci-app-smartdns": {
|
||||
"description": "Grant access to LuCI app smartdns",
|
||||
"read": {
|
||||
"file": {
|
||||
"uci": [ "smartdns" ],
|
||||
"/etc/smartdns/*": [ "read" ],
|
||||
"/usr/sbin/iptables -t nat -nL PREROUTING": [ "exec" ],
|
||||
"/usr/sbin/ip6tables -t nat -nL PREROUTING": [ "exec" ],
|
||||
"/usr/sbin/smartdns": [ "exec" ]
|
||||
},
|
||||
"ubus": {
|
||||
"service": [ "list" ]
|
||||
},
|
||||
"uci": [ "smartdns" ]
|
||||
},
|
||||
"write": {
|
||||
"file": {
|
||||
"uci": [ "smartdns" ],
|
||||
"/etc/smartdns/*": [ "write" ]
|
||||
},
|
||||
"uci": [ "smartdns" ]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2018-2020 Ruilin Peng (Nick) <pymumu@gmail.com>.
|
||||
#
|
||||
# smartdns is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# smartdns is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=smartdns
|
||||
PKG_VERSION:=5.2020.04
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/pymumu/smartdns.git
|
||||
PKG_SOURCE_VERSION:=770ce9e8bc502b2769f897676df9495129fb3afa
|
||||
PKG_MIRROR_HASH:=14bf2f569af822f254c02389786496cdd179edf753ada061fad77e16f989be47
|
||||
|
||||
PKG_MAINTAINER:=Nick Peng <pymumu@gmail.com>
|
||||
PKG_LICENSE:=GPL-3.0-or-later
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
MAKE_VARS += VER=$(PKG_VERSION)
|
||||
MAKE_PATH:=src
|
||||
|
||||
define Package/smartdns
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=smartdns server
|
||||
DEPENDS:=+libpthread +libopenssl
|
||||
URL:=https://www.github.com/pymumu/smartdns/
|
||||
endef
|
||||
|
||||
define Package/smartdns/description
|
||||
SmartDNS is a local DNS server which accepts DNS query requests from local network clients,
|
||||
get DNS query results from multiple upstream DNS servers concurrently, and returns the fastest IP to clients.
|
||||
Unlike dnsmasq's all-servers, smartdns returns the fastest IP.
|
||||
endef
|
||||
|
||||
define Package/smartdns/conffiles
|
||||
/etc/config/smartdns
|
||||
/etc/smartdns/address.conf
|
||||
/etc/smartdns/blacklist-ip.conf
|
||||
/etc/smartdns/custom.conf
|
||||
endef
|
||||
|
||||
define Package/smartdns/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d $(1)/etc/smartdns
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/smartdns $(1)/usr/sbin/smartdns
|
||||
$(INSTALL_BIN) $(CURDIR)/conf/smartdns.init $(1)/etc/init.d/smartdns
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/address.conf $(1)/etc/smartdns/address.conf
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/blacklist-ip.conf $(1)/etc/smartdns/blacklist-ip.conf
|
||||
$(INSTALL_CONF) $(CURDIR)/conf/custom.conf $(1)/etc/smartdns/custom.conf
|
||||
$(INSTALL_CONF) $(CURDIR)/conf/smartdns.conf $(1)/etc/config/smartdns
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,smartdns))
|
@ -1,50 +0,0 @@
|
||||
# Add custom settings here.
|
||||
|
||||
# set log level
|
||||
# log-level [level], level=fatal, error, warn, notice, info, debug
|
||||
# log-level error
|
||||
|
||||
# log-size k,m,g
|
||||
# log-size 128k
|
||||
|
||||
# log-file /var/log/smartdns.log
|
||||
# log-num 2
|
||||
|
||||
# List of hosts that supply bogus NX domain results
|
||||
# bogus-nxdomain [ip/subnet]
|
||||
|
||||
speed-check-mode tcp:80,ping
|
||||
|
||||
server 202.141.178.13:5353
|
||||
server 202.38.93.153:5353
|
||||
server 202.141.162.123:5353
|
||||
server 2001:da8::666
|
||||
|
||||
server-tcp 9.9.9.9 -group fq_dns -exclude-default-group
|
||||
server-tcp 8.8.8.8 -group fq_dns -exclude-default-group
|
||||
server-tcp 1.0.0.1 -group fq_dns -exclude-default-group
|
||||
|
||||
server-tls 115.159.131.230 -host-name dns.rubyfish.cn
|
||||
server-tls dns.rubyfish.cn
|
||||
server-tls dns.233py.com
|
||||
server-tls 8.8.8.8 -host-name dns.google -group fq_dns -exclude-default-group
|
||||
server-tls dns.google -group fq_dns -exclude-default-group
|
||||
server-tls 1.0.0.1 -host-name 1dot1dot1dot1.cloudflare-dns.com -group fq_dns -exclude-default-group
|
||||
server-tls 1dot1dot1dot1.cloudflare-dns.com -group fq_dns -exclude-default-group
|
||||
|
||||
server-https https://202.141.178.13/resolve -host-name neatdns.ustclug.org -http-host neatdns.ustclug.org
|
||||
server-https https://202.38.93.153/resolve -host-name neatdns.ustclug.org -http-host neatdns.ustclug.org
|
||||
server-https https://neatdns.ustclug.org/resolve
|
||||
server-https https://115.159.131.230/resolve -host-name dns.rubyfish.cn -http-host dns.rubyfish.cn
|
||||
server-https https://dns.rubyfish.cn/dns-query
|
||||
server-https https://45.77.180.10/resolve -host-name dns.containerpi.com -http-host dns.containerpi.com
|
||||
server-https https://dns.containerpi.com/dns-query
|
||||
server-https https://210.17.9.228/dns-query -host-name dns.twnic.tw -http-host dns.twnic.tw
|
||||
server-https https://dns.twnic.tw/dns-query
|
||||
server-https https://i.233py.com/dns-query
|
||||
server-https https://9.9.9.9/dns-query -host-name dns9.quad9.net -http-host dns9.quad9.net -group fq_dns -exclude-default-group
|
||||
server-https https://dns9.quad9.net/dns-query -group fq_dns -exclude-default-group
|
||||
server-https https://1.0.0.1/dns-query -group fq_dns -exclude-default-group
|
||||
server-https https://cloudflare-dns.com/dns-query -group fq_dns -exclude-default-group
|
||||
server-https https://146.112.41.2/dns-query -host-name doh.opendns.com -http-host doh.opendns.com -group fq_dns -exclude-default-group
|
||||
server-https https://doh.opendns.com/dns-query -group fq_dns -exclude-default-group
|
@ -1,28 +0,0 @@
|
||||
config smartdns
|
||||
option server_name 'smartdns'
|
||||
option dualstack_ip_selection '1'
|
||||
option prefetch_domain '1'
|
||||
option serve_expired '1'
|
||||
option seconddns_no_speed_check '0'
|
||||
option seconddns_no_dualstack_selection '0'
|
||||
option seconddns_no_cache '0'
|
||||
option tcp_server '0'
|
||||
option seconddns_tcp_server '0'
|
||||
option coredump '0'
|
||||
option port '6053'
|
||||
option ipv6_server '0'
|
||||
option redirect 'dnsmasq-upstream'
|
||||
option seconddns_port '5335'
|
||||
option seconddns_server_group 'fq_dns'
|
||||
option seconddns_enabled '1'
|
||||
option seconddns_no_rule_addr '0'
|
||||
option seconddns_no_rule_nameserver '0'
|
||||
option seconddns_no_rule_ipset '0'
|
||||
option seconddns_no_rule_soa '0'
|
||||
option enabled '0'
|
||||
option cache_size '20000'
|
||||
option rr_ttl '3600'
|
||||
option rr_ttl_min '5'
|
||||
list old_redirect 'dnsmasq-upstream'
|
||||
list old_port '6053'
|
||||
list old_enabled '0'
|
@ -1,388 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2018-2020 Ruilin Peng (Nick) <pymumu@gmail.com>.
|
||||
#
|
||||
# smartdns is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# smartdns is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
START=99
|
||||
NAME=smartdns
|
||||
USE_PROCD=1
|
||||
SERVICE_USE_PID=1
|
||||
SERVICE_WRITE_PID=1
|
||||
SERVICE_DAEMONIZE=1
|
||||
SERVICE_PID_FILE="/var/run/smartdns.pid"
|
||||
SMARTDNS_CONF_DIR="/etc/smartdns"
|
||||
SMARTDNS_VAR_CONF_DIR="/var/etc/smartdns"
|
||||
SMARTDNS_CONF="$SMARTDNS_VAR_CONF_DIR/smartdns.conf"
|
||||
ADDRESS_CONF="$SMARTDNS_CONF_DIR/address.conf"
|
||||
BLACKLIST_IP_CONF="$SMARTDNS_CONF_DIR/blacklist-ip.conf"
|
||||
CUSTOM_CONF="$SMARTDNS_CONF_DIR/custom.conf"
|
||||
SMARTDNS_CONF_TMP="${SMARTDNS_CONF}.tmp"
|
||||
COREDUMP="0"
|
||||
RESPAWN="1"
|
||||
|
||||
set_forward_dnsmasq()
|
||||
{
|
||||
local PORT="$1"
|
||||
addr="127.0.0.1#$PORT"
|
||||
OLD_SERVER="$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)"
|
||||
if echo "$OLD_SERVER" | grep "^$addr" >/dev/null 2>&1; then
|
||||
return
|
||||
fi
|
||||
uci delete dhcp.@dnsmasq[0].server 2>/dev/null
|
||||
uci add_list dhcp.@dnsmasq[0].server="$addr"
|
||||
for server in $OLD_SERVER; do
|
||||
[ "$server" = "$addr" ] && continue
|
||||
uci add_list dhcp.@dnsmasq[0].server="$server"
|
||||
done
|
||||
uci set dhcp.@dnsmasq[0].noresolv=1
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq restart
|
||||
}
|
||||
|
||||
stop_forward_dnsmasq()
|
||||
{
|
||||
local OLD_PORT="$1"
|
||||
addr="127.0.0.1#$OLD_PORT"
|
||||
OLD_SERVER="$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)"
|
||||
if ! echo "$OLD_SERVER" | grep "^$addr" >/dev/null 2>&1; then
|
||||
return
|
||||
fi
|
||||
|
||||
uci del_list dhcp.@dnsmasq[0].server="$addr" 2>/dev/null
|
||||
addrlist="$(uci get dhcp.@dnsmasq[0].server 2>/dev/null)"
|
||||
[ -z "$addrlist" ] && {
|
||||
uci delete dhcp.@dnsmasq[0].noresolv 2>/dev/null
|
||||
}
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq restart
|
||||
}
|
||||
|
||||
set_iptable()
|
||||
{
|
||||
local ipv6_server=$1
|
||||
local tcp_server=$2
|
||||
|
||||
IPS="$(ifconfig | grep "inet addr" | grep -v ":127" | grep "Bcast" | awk '{print $2}' | awk -F : '{print $2}')"
|
||||
for IP in $IPS
|
||||
do
|
||||
if [ "$tcp_server" = "1" ]; then
|
||||
iptables -t nat -A PREROUTING -p tcp -d "$IP" --dport 53 -j REDIRECT --to-ports "$SMARTDNS_PORT" >/dev/null 2>&1
|
||||
fi
|
||||
iptables -t nat -A PREROUTING -p udp -d "$IP" --dport 53 -j REDIRECT --to-ports "$SMARTDNS_PORT" >/dev/null 2>&1
|
||||
done
|
||||
|
||||
[ "$ipv6_server" = 0 ] && return
|
||||
|
||||
IPS="$(ifconfig | grep "inet6 addr" | grep -v " fe80::" | grep -v " ::1" | grep "Global" | awk '{print $3}')"
|
||||
for IP in $IPS
|
||||
do
|
||||
if [ "$tcp_server" = "1" ]; then
|
||||
ip6tables -t nat -A PREROUTING -p tcp -d "$IP" --dport 53 -j REDIRECT --to-ports "$SMARTDNS_PORT" >/dev/null 2>&1
|
||||
fi
|
||||
ip6tables -t nat -A PREROUTING -p udp -d "$IP" --dport 53 -j REDIRECT --to-ports "$SMARTDNS_PORT" >/dev/null 2>&1
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
clear_iptable()
|
||||
{
|
||||
local OLD_PORT="$1"
|
||||
local ipv6_server=$2
|
||||
IPS="$(ifconfig | grep "inet addr" | grep -v ":127" | grep "Bcast" | awk '{print $2}' | awk -F : '{print $2}')"
|
||||
for IP in $IPS
|
||||
do
|
||||
iptables -t nat -D PREROUTING -p udp -d "$IP" --dport 53 -j REDIRECT --to-ports "$OLD_PORT" >/dev/null 2>&1
|
||||
iptables -t nat -D PREROUTING -p tcp -d "$IP" --dport 53 -j REDIRECT --to-ports "$OLD_PORT" >/dev/null 2>&1
|
||||
done
|
||||
|
||||
[ "$ipv6_server" = 0 ] && return
|
||||
|
||||
IPS="$(ifconfig | grep "inet6 addr" | grep -v " fe80::" | grep -v " ::1" | grep "Global" | awk '{print $3}')"
|
||||
for IP in $IPS
|
||||
do
|
||||
ip6tables -t nat -D PREROUTING -p udp -d "$IP" --dport 53 -j REDIRECT --to-ports "$OLD_PORT" >/dev/null 2>&1
|
||||
ip6tables -t nat -D PREROUTING -p tcp -d "$IP" --dport 53 -j REDIRECT --to-ports "$OLD_PORT" >/dev/null 2>&1
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger firewall
|
||||
procd_add_reload_trigger smartdns
|
||||
}
|
||||
|
||||
conf_append()
|
||||
{
|
||||
echo "$1 $2" >> $SMARTDNS_CONF_TMP
|
||||
}
|
||||
|
||||
get_tz()
|
||||
{
|
||||
SET_TZ=""
|
||||
|
||||
[ -e "/etc/localtime" ] && return
|
||||
|
||||
for tzfile in /etc/TZ /var/etc/TZ
|
||||
do
|
||||
[ -e "$tzfile" ] || continue
|
||||
tz="$(cat $tzfile 2>/dev/null)"
|
||||
done
|
||||
|
||||
[ -z "$tz" ] && return
|
||||
|
||||
SET_TZ=$tz
|
||||
}
|
||||
|
||||
load_server()
|
||||
{
|
||||
local section="$1"
|
||||
local ADDITIONAL_ARGS=""
|
||||
local DNS_ADDRESS=""
|
||||
|
||||
config_get_bool enabled "$section" "enabled" "1"
|
||||
config_get port "$section" "port" ""
|
||||
config_get type "$section" "type" "udp"
|
||||
config_get ip "$section" "ip" ""
|
||||
config_get tls_host_verify "$section" "tls_host_verify" ""
|
||||
config_get host_name "$section" "host_name" ""
|
||||
config_get http_host "$section" "http_host" ""
|
||||
config_get server_group "$section" "server_group" ""
|
||||
config_get blacklist_ip "$section" "blacklist_ip" "0"
|
||||
config_get check_edns "$section" "check_edns" "0"
|
||||
config_get spki_pin "$section" "spki_pin" ""
|
||||
config_get addition_arg "$section" "addition_arg" ""
|
||||
|
||||
[ "$enabled" = "0" ] && return
|
||||
|
||||
if [ -z "$ip" ] || [ -z "$type" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
SERVER="server"
|
||||
if [ "$type" = "tcp" ]; then
|
||||
SERVER="server-tcp"
|
||||
elif [ "$type" = "tls" ]; then
|
||||
SERVER="server-tls"
|
||||
elif [ "$type" = "https" ]; then
|
||||
SERVER="server-https"
|
||||
fi
|
||||
|
||||
if echo "$ip" | grep ":" | grep -q -v "https://" >/dev/null 2>&1; then
|
||||
if ! echo "$ip" | grep -q "\\[" >/dev/null 2>&1; then
|
||||
ip="[$ip]"
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -z "$tls_host_verify" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -tls-host-verify $tls_host_verify"
|
||||
[ -z "$host_name" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -host-name $host_name"
|
||||
[ -z "$http_host" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -http-host $http_host"
|
||||
[ -z "$server_group" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -group $server_group"
|
||||
[ "$blacklist_ip" = "0" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -blacklist-ip"
|
||||
[ "$check_edns" = "0" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -check-edns"
|
||||
[ -z "$spki_pin" ] || ADDITIONAL_ARGS="$ADDITIONAL_ARGS -spki-pin $spki_pin"
|
||||
|
||||
if [ -z "$port" ]; then
|
||||
DNS_ADDRESS="$ip"
|
||||
else
|
||||
DNS_ADDRESS="$ip:$port"
|
||||
fi
|
||||
|
||||
[ "$type" = "https" ] && DNS_ADDRESS="$ip"
|
||||
|
||||
conf_append "$SERVER" "$DNS_ADDRESS $ADDITIONAL_ARGS $addition_arg"
|
||||
}
|
||||
|
||||
load_second_server()
|
||||
{
|
||||
local section="$1"
|
||||
local ARGS=""
|
||||
local ADDR=""
|
||||
|
||||
config_get_bool seconddns_enabled "$section" "seconddns_enabled" "0"
|
||||
[ "$seconddns_enabled" = "0" ] && return
|
||||
|
||||
config_get seconddns_port "$section" "seconddns_port" "6553"
|
||||
|
||||
config_get_bool seconddns_no_speed_check "$section" "seconddns_no_speed_check" "0"
|
||||
[ "$seconddns_no_speed_check" = "1" ] && ARGS="$ARGS -no-speed-check"
|
||||
|
||||
config_get seconddns_server_group "$section" "seconddns_server_group" ""
|
||||
[ -z "$seconddns_server_group" ] || ARGS="$ARGS -group $seconddns_server_group"
|
||||
|
||||
config_get_bool seconddns_no_rule_addr "$section" "seconddns_no_rule_addr" "0"
|
||||
[ "$seconddns_no_rule_addr" = "1" ] && ARGS="$ARGS -no-rule-addr"
|
||||
|
||||
config_get_bool seconddns_no_rule_nameserver "$section" "seconddns_no_rule_nameserver" "0"
|
||||
[ "$seconddns_no_rule_nameserver" = "1" ] && ARGS="$ARGS -no-rule-nameserver"
|
||||
|
||||
config_get_bool seconddns_no_rule_ipset "$section" "seconddns_no_rule_ipset" "0"
|
||||
[ "$seconddns_no_rule_ipset" = "1" ] && ARGS="$ARGS -no-rule-ipset"
|
||||
|
||||
config_get_bool seconddns_no_rule_soa "$section" "seconddns_no_rule_soa" "0"
|
||||
[ "$seconddns_no_rule_soa" = "1" ] && ARGS="$ARGS -no-rule-soa"
|
||||
|
||||
config_get_bool seconddns_no_dualstack_selection "$section" "seconddns_no_dualstack_selection" "0"
|
||||
[ "$seconddns_no_dualstack_selection" = "1" ] && ARGS="$ARGS -no-dualstack-selection"
|
||||
|
||||
config_get_bool seconddns_no_cache "$section" "seconddns_no_cache" "0"
|
||||
[ "$seconddns_no_cache" = "1" ] && ARGS="$ARGS -no-cache"
|
||||
|
||||
config_get_bool force_aaaa_soa "$section" "force_aaaa_soa" "0"
|
||||
[ "$force_aaaa_soa" = "1" ] && ARGS="$ARGS -force-aaaa-soa"
|
||||
|
||||
config_get ipv6_server "$section" "ipv6_server" "1"
|
||||
if [ "$ipv6_server" = "1" ]; then
|
||||
ADDR="[::]"
|
||||
else
|
||||
ADDR=""
|
||||
fi
|
||||
|
||||
conf_append "bind" "$ADDR:$seconddns_port $ARGS"
|
||||
config_get_bool "seconddns_tcp_server" "$section" "seconddns_tcp_server" "1"
|
||||
[ "$seconddns_tcp_server" = "1" ] && conf_append "bind-tcp" "$ADDR:$seconddns_port $ARGS"
|
||||
}
|
||||
|
||||
load_service()
|
||||
{
|
||||
local section="$1"
|
||||
args=""
|
||||
|
||||
mkdir -p $SMARTDNS_VAR_CONF_DIR
|
||||
rm -f $SMARTDNS_CONF_TMP
|
||||
|
||||
config_get_bool enabled "$section" "enabled" '0'
|
||||
|
||||
config_get server_name "$section" "server_name" ""
|
||||
[ -z "$server_name" ] || conf_append "server-name" "$server_name"
|
||||
|
||||
config_get coredump "$section" "coredump" "0"
|
||||
[ "$coredump" = "1" ] && COREDUMP="1"
|
||||
|
||||
config_get port "$section" "port" "6053"
|
||||
config_get ipv6_server "$section" "ipv6_server" "1"
|
||||
config_get tcp_server "$section" "tcp_server" "1"
|
||||
if [ "$ipv6_server" = "1" ]; then
|
||||
conf_append "bind" "[::]:$port"
|
||||
else
|
||||
conf_append "bind" ":$port"
|
||||
fi
|
||||
|
||||
[ "$tcp_server" = "1" ] && {
|
||||
if [ "$ipv6_server" = "1" ]; then
|
||||
conf_append "bind-tcp" "[::]:$port"
|
||||
else
|
||||
conf_append "bind-tcp" ":$port"
|
||||
fi
|
||||
}
|
||||
config_get dualstack_ip_selection "$section" "dualstack_ip_selection" "0"
|
||||
[ "$dualstack_ip_selection" = "1" ] && conf_append "dualstack-ip-selection" "yes"
|
||||
|
||||
config_get prefetch_domain "$section" "prefetch_domain" "0"
|
||||
[ "$prefetch_domain" = "1" ] && conf_append "prefetch-domain" "yes"
|
||||
|
||||
config_get serve_expired "$section" "serve_expired" "0"
|
||||
[ "$serve_expired" = "1" ] && conf_append "serve-expired" "yes"
|
||||
|
||||
SMARTDNS_PORT="$port"
|
||||
|
||||
config_get cache_size "$section" "cache_size" ""
|
||||
[ -z "$cache_size" ] || conf_append "cache-size" "$cache_size"
|
||||
|
||||
config_get rr_ttl "$section" "rr_ttl" ""
|
||||
[ -z "$rr_ttl" ] || conf_append "rr-ttl" "$rr_ttl"
|
||||
|
||||
config_get rr_ttl_min "$section" "rr_ttl_min" ""
|
||||
[ -z "$rr_ttl_min" ] || conf_append "rr-ttl-min" "$rr_ttl_min"
|
||||
|
||||
config_get rr_ttl_max "$section" "rr_ttl_max" ""
|
||||
[ -z "$rr_ttl_max" ] || conf_append "rr-ttl-max" "$rr_ttl_max"
|
||||
|
||||
config_get log_size "$section" "log_size" "64K"
|
||||
[ -z "$log_size" ] || conf_append "log-size" "$log_size"
|
||||
|
||||
config_get log_num "$section" "log_num" "1"
|
||||
[ -z "$log_num" ] || conf_append "log-num" "$log_num"
|
||||
|
||||
config_get log_level "$section" "log_level" "error"
|
||||
[ -z "$log_level" ]|| conf_append "log-level" "$log_level"
|
||||
|
||||
config_get log_file "$section" "log_file" ""
|
||||
[ -z "$log_file" ] || conf_append "log-file" "$log_file"
|
||||
|
||||
config_get redirect "$section" "redirect" "none"
|
||||
config_get old_redirect "$section" "old_redirect" "none"
|
||||
config_get old_port "$section" "old_port" "0"
|
||||
config_get old_enabled "$section" "old_enabled" "0"
|
||||
|
||||
if [ "$old_redirect" != "$redirect" ] || [ "$old_port" != "$SMARTDNS_PORT" ] || [ "$old_enabled" = "1" -a "$enabled" = "0" ]; then
|
||||
[ "$old_redirect" = "none" ] || {
|
||||
[ "$old_port" = "0" ] || clear_iptable "$old_port" "$ipv6_server"
|
||||
[ "$old_redirect" = "dnsmasq-upstream" ] && stop_forward_dnsmasq "$old_port"
|
||||
}
|
||||
fi
|
||||
|
||||
uci delete smartdns.@smartdns[0].old_redirect 2>/dev/null
|
||||
uci delete smartdns.@smartdns[0].old_port 2>/dev/null
|
||||
uci delete smartdns.@smartdns[0].old_enabled 2>/dev/null
|
||||
uci add_list smartdns.@smartdns[0].old_redirect="$redirect" 2>/dev/null
|
||||
uci add_list smartdns.@smartdns[0].old_port="$SMARTDNS_PORT" 2>/dev/null
|
||||
uci add_list smartdns.@smartdns[0].old_enabled="$enabled" 2>/dev/null
|
||||
uci commit smartdns
|
||||
|
||||
[ "$enabled" -gt 0 ] || return 1
|
||||
|
||||
if [ "$redirect" = "redirect" ]; then
|
||||
set_iptable $ipv6_server $tcp_server
|
||||
elif [ "$redirect" = "dnsmasq-upstream" ]; then
|
||||
set_forward_dnsmasq "$SMARTDNS_PORT"
|
||||
fi
|
||||
|
||||
load_second_server $section
|
||||
|
||||
config_foreach load_server "server"
|
||||
|
||||
{
|
||||
echo "conf-file $ADDRESS_CONF"
|
||||
echo "conf-file $BLACKLIST_IP_CONF"
|
||||
echo "conf-file $CUSTOM_CONF"
|
||||
} >> $SMARTDNS_CONF_TMP
|
||||
mv $SMARTDNS_CONF_TMP $SMARTDNS_CONF
|
||||
|
||||
procd_open_instance "smartdns"
|
||||
[ "$COREDUMP" = "1" ] && {
|
||||
args="$args -S"
|
||||
procd_set_param limits core="unlimited"
|
||||
}
|
||||
|
||||
get_tz
|
||||
[ -z "$SET_TZ" ] || procd_set_param env TZ="$SET_TZ"
|
||||
|
||||
procd_set_param command /usr/sbin/smartdns -f -c $SMARTDNS_CONF $args
|
||||
[ "$RESPAWN" = "1" ] && procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
|
||||
procd_set_param file "$SMARTDNS_CONF"
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
start_service()
|
||||
{
|
||||
config_load "smartdns"
|
||||
config_foreach load_service "smartdns"
|
||||
}
|
||||
|
||||
reload_service()
|
||||
{
|
||||
stop
|
||||
start
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user