feat: cahining + stats
This commit is contained in:
28 files changed
+898
-72
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{ lib, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkOption;
|
||||
inherit (lib) mkOption types;
|
||||
t = import ./types.nix { inherit lib; };
|
||||
cloudflare = {
|
||||
type = "udp";
|
||||
@@ -31,5 +31,83 @@ in
|
||||
port = 853;
|
||||
};
|
||||
};
|
||||
|
||||
strategy = mkOption {
|
||||
type = types.nullOr (
|
||||
types.enum [
|
||||
"prefer_ipv4"
|
||||
"prefer_ipv6"
|
||||
"ipv4_only"
|
||||
"ipv6_only"
|
||||
]
|
||||
);
|
||||
default = null;
|
||||
description = "Which addresses sing-box asks for. `ipv4_only` for an uplink without IPv6. sing-box and hybrid backends.";
|
||||
example = "ipv4_only";
|
||||
};
|
||||
|
||||
clientSubnet = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
EDNS client subnet sent with every query, so a resolver reached through the proxy still
|
||||
answers with CDN nodes near this network. sing-box and hybrid backends.
|
||||
'';
|
||||
example = "203.0.113.0/24";
|
||||
};
|
||||
|
||||
fakeIp = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
In TUN mode (global and per-app), answer A queries from the TUN with a fake address and
|
||||
AAAA ones with nothing; sing-box maps the address back to the name when the connection
|
||||
comes. Saves a lookup per new site and no real lookup leaves for proxied names. Names that
|
||||
proxy.dns.singBox.rules or the direct geosites send elsewhere keep real answers. Mappings
|
||||
do not survive a restart: an app holding a fake address fails until it looks the name up
|
||||
again. sing-box and hybrid backends; XRay's TUN already uses its own fake DNS.
|
||||
'';
|
||||
};
|
||||
|
||||
inet4Range = mkOption {
|
||||
type = types.str;
|
||||
default = "198.18.0.0/15";
|
||||
description = "Range the fake addresses come from.";
|
||||
};
|
||||
};
|
||||
|
||||
singBox = {
|
||||
servers = mkOption {
|
||||
type = types.listOf types.attrs;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Extra sing-box DNS servers, as sing-box JSON, for proxy.dns.singBox.rules to name. The
|
||||
built-in ones are `local`, `remote`, and `fakeip` when fakeIp is on.
|
||||
'';
|
||||
example = [
|
||||
{
|
||||
tag = "corp";
|
||||
type = "udp";
|
||||
server = "10.0.0.53";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
rules = mkOption {
|
||||
type = types.listOf types.attrs;
|
||||
default = [ ];
|
||||
description = ''
|
||||
sing-box DNS rules, as sing-box JSON, checked before the generated ones. Kept when the
|
||||
route mode is all-proxy or all-bypass, which drop the generated ones.
|
||||
'';
|
||||
example = [
|
||||
{
|
||||
domain_suffix = [ "corp.example" ];
|
||||
server = "corp";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -17,6 +17,20 @@ let
|
||||
inherit description example;
|
||||
};
|
||||
|
||||
detourOption =
|
||||
what:
|
||||
mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Tag of the outbound ${what} connects through: a proxy chain. Any outbound can be the hop,
|
||||
subscription entries, `warp`, `ssh-proxy` and AmneziaWG ones included. On hybrid, an
|
||||
outbound that runs on XRay can only chain through another XRay one. ShadowTLS works this
|
||||
way too: a `shadowtls` outbound in singBoxJson, and the shadowsocks one with detour naming it.
|
||||
'';
|
||||
example = "ru-vps";
|
||||
};
|
||||
|
||||
subscriptionType = types.submodule {
|
||||
options = {
|
||||
tag = mkOption {
|
||||
@@ -26,6 +40,7 @@ let
|
||||
};
|
||||
url = nullStr "Subscription URL. Ends up in the Nix store; prefer urlFile." "https://example.com/sub/token123";
|
||||
urlFile = nullStr "Runtime path to the subscription URL." "/run/secrets/proxy-subscription-url";
|
||||
detour = detourOption "every entry of this subscription";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -39,6 +54,7 @@ let
|
||||
|
||||
url = nullStr "Proxy URL. Ends up in the Nix store; prefer urlFile." "hy2://password@example.com:443?sni=example.com";
|
||||
urlFile = nullStr "Runtime path to the proxy URL." "/run/secrets/my-proxy-url";
|
||||
detour = detourOption "this one";
|
||||
|
||||
singBoxJson = nullAttrs "Raw sing-box outbound (sing-box backend); tag is overridden." {
|
||||
type = "vless";
|
||||
|
||||
Reference in new issue
Block a user