feat: tor support
This commit is contained in:
42 files changed
+1853
-69
No files matched your search
@@ -4,6 +4,7 @@
|
||||
lib,
|
||||
proxyInboundsCfg,
|
||||
proxyInbounds,
|
||||
proxyInboundsRouteOnion,
|
||||
zapretDirectRules,
|
||||
}:
|
||||
|
||||
@@ -17,6 +18,18 @@ let
|
||||
# A blocked listener stays blocked: neither serverAddress nor the proxy exceptions open it.
|
||||
exceptionInboundTags = map (ib: ib.tag) (builtins.filter (ib: ib.via != "block") proxyInbounds);
|
||||
|
||||
# Only Tor reaches .onion: to the local proxy, whose own rule sends it there. First, so no
|
||||
# IP rule before it has XRay look the name up, which would leak it to a resolver.
|
||||
onionRule = lib.optional proxyInboundsRouteOnion {
|
||||
type = "field";
|
||||
ruleTag = "inbound-tor-onion";
|
||||
domain = [ "domain:onion" ];
|
||||
inboundTag = map (ib: ib.tag) (
|
||||
builtins.filter (ib: ib.via != "block" && ib.listener.type != "amneziawg") proxyInbounds
|
||||
);
|
||||
outboundTag = "proxy";
|
||||
};
|
||||
|
||||
blockPrivateRule = lib.optional proxyInboundsCfg.routing.blockPrivate {
|
||||
type = "field";
|
||||
ruleTag = "inbound-block-private";
|
||||
@@ -147,7 +160,8 @@ let
|
||||
# Explicit proxy exceptions beat blockRu: RU-geolocated ranges (Telegram's,
|
||||
# at times) would otherwise swallow them.
|
||||
xrayInboundRules =
|
||||
blockPrivateRule
|
||||
onionRule
|
||||
++ blockPrivateRule
|
||||
++ serverAddressRule
|
||||
++ proxyDomainRule
|
||||
++ proxyIpRule
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
tgWsProxyCfg,
|
||||
customRules,
|
||||
customRuleCategory,
|
||||
onionOutbound,
|
||||
geodata,
|
||||
}:
|
||||
|
||||
@@ -60,7 +61,11 @@ let
|
||||
action = "hijack-dns";
|
||||
}
|
||||
{ action = "sniff"; }
|
||||
];
|
||||
]
|
||||
++ lib.optional (onionOutbound != null) {
|
||||
domain_suffix = [ "onion" ];
|
||||
outbound = onionOutbound;
|
||||
};
|
||||
|
||||
customRouteRules = map (rule: {
|
||||
category = customRuleCategory rule.outbound;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
tgWsProxyCfg,
|
||||
customRules,
|
||||
customRuleCategory,
|
||||
onionOutbound,
|
||||
selectionMode,
|
||||
}:
|
||||
|
||||
@@ -116,8 +117,14 @@ let
|
||||
(xrayGeoIPRules "proxy-geoip" "proxy" r.proxy.geoips)
|
||||
];
|
||||
|
||||
# Kept by every route mode, like sing-box's common rules.
|
||||
xrayCommonRules = lib.optional (onionOutbound != null) (
|
||||
mkXrayRule "tor-onion" { domain = [ "domain:onion" ]; } onionOutbound
|
||||
);
|
||||
|
||||
xrayRoutingRules =
|
||||
lib.concatMap (item: item.entries) xrayCustomRouteRules
|
||||
xrayCommonRules
|
||||
++ lib.concatMap (item: item.entries) xrayCustomRouteRules
|
||||
++ xrayProxyPrimaryRules
|
||||
++ xrayDirectRules
|
||||
++ xraySafetyDirectRules
|
||||
@@ -125,7 +132,7 @@ let
|
||||
++ xrayBlockRules;
|
||||
|
||||
xrayRouteModeRules = {
|
||||
common = [ ];
|
||||
common = xrayCommonRules;
|
||||
custom = xrayCustomRouteRules;
|
||||
proxyPrimary = xrayProxyPrimaryRules;
|
||||
direct = xrayDirectRules;
|
||||
|
||||
Reference in new issue
Block a user