make dns configurable
This commit is contained in:
5 files changed
+465
-12
No files matched your search
@@ -11,6 +11,14 @@ let
|
||||
sb = cfg.singBox;
|
||||
direct = rules.direct;
|
||||
|
||||
mkDnsServer =
|
||||
tag: upstream: detour: {
|
||||
inherit tag detour;
|
||||
type = upstream.type;
|
||||
server = upstream.address;
|
||||
server_port = upstream.port;
|
||||
};
|
||||
|
||||
clashApiBlock = lib.optionalAttrs (sb.selection != "first") {
|
||||
experimental = {
|
||||
clash_api = {
|
||||
@@ -21,20 +29,12 @@ let
|
||||
|
||||
dnsConfig = {
|
||||
servers = [
|
||||
{
|
||||
tag = "remote";
|
||||
type = "udp";
|
||||
server = "1.1.1.1";
|
||||
detour = "proxy";
|
||||
}
|
||||
{
|
||||
tag = "local";
|
||||
type = "udp";
|
||||
server = "1.1.1.1";
|
||||
(mkDnsServer "remote" sb.dns.remote "proxy")
|
||||
(
|
||||
# In TUN mode, routing DNS through direct can conflict with auto_redirect.
|
||||
# In TProxy/mixed mode, direct is fine for local traffic.
|
||||
detour = "direct";
|
||||
}
|
||||
mkDnsServer "local" sb.dns.local "direct"
|
||||
)
|
||||
];
|
||||
rules =
|
||||
lib.optional (builtins.elem "google" sb.routing.proxy.geosites) {
|
||||
|
||||
@@ -183,6 +183,40 @@ let
|
||||
};
|
||||
};
|
||||
|
||||
dnsUpstreamType = types.submodule {
|
||||
options = {
|
||||
type = mkOption {
|
||||
type = types.enum [
|
||||
"udp"
|
||||
"tcp"
|
||||
"tls"
|
||||
];
|
||||
default = "udp";
|
||||
description = ''
|
||||
sing-box DNS transport type for this upstream resolver.
|
||||
'';
|
||||
example = "tls";
|
||||
};
|
||||
|
||||
address = mkOption {
|
||||
type = types.strMatching ".+";
|
||||
description = ''
|
||||
Resolver address or hostname used for this DNS upstream.
|
||||
'';
|
||||
example = "1.1.1.1";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 53;
|
||||
description = ''
|
||||
Destination port for this DNS upstream.
|
||||
'';
|
||||
example = 853;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
zapretPresetType = types.enum [
|
||||
"general"
|
||||
"google"
|
||||
@@ -488,6 +522,50 @@ in
|
||||
example = true;
|
||||
};
|
||||
|
||||
dns = {
|
||||
local = mkOption {
|
||||
type = dnsUpstreamType;
|
||||
default = {
|
||||
type = "udp";
|
||||
address = "1.1.1.1";
|
||||
port = 53;
|
||||
};
|
||||
description = ''
|
||||
DNS upstream used for the built-in "local" resolver role.
|
||||
This resolver is also used as sing-box route.default_domain_resolver.
|
||||
|
||||
The module keeps detour policy automatic: in mixed/TProxy mode,
|
||||
"local" uses direct; in TUN mode, it is forced through the proxy to
|
||||
avoid auto_redirect conflicts.
|
||||
'';
|
||||
example = {
|
||||
type = "tcp";
|
||||
address = "9.9.9.9";
|
||||
port = 53;
|
||||
};
|
||||
};
|
||||
|
||||
remote = mkOption {
|
||||
type = dnsUpstreamType;
|
||||
default = {
|
||||
type = "udp";
|
||||
address = "1.1.1.1";
|
||||
port = 53;
|
||||
};
|
||||
description = ''
|
||||
DNS upstream used for the built-in "remote" resolver role.
|
||||
|
||||
This resolver always detours through the proxy and becomes the
|
||||
generated dns.final target when singBox.proxyByDefault = true.
|
||||
'';
|
||||
example = {
|
||||
type = "tls";
|
||||
address = "1.1.1.1";
|
||||
port = 853;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
tun = {
|
||||
enable = mkEnableOption "TUN mode service (opt-in, mutually exclusive with proxy-suite-tproxy)";
|
||||
|
||||
|
||||
Reference in new issue
Block a user