per-app tproxy
This commit is contained in:
5 files changed
+482
-26
No files matched your search
+168
@@ -822,6 +822,51 @@ let
|
||||
]).config.system.build.toplevel.drvPath
|
||||
);
|
||||
|
||||
appRoutingTproxyFixture = evalProxySuite [
|
||||
baseModule
|
||||
{
|
||||
services.proxy-suite.appRouting = {
|
||||
enable = true;
|
||||
createDefaultProfiles = true;
|
||||
backends.tproxy.enable = true;
|
||||
};
|
||||
}
|
||||
];
|
||||
appRoutingTproxyScript =
|
||||
builtins.readFile (
|
||||
"${packageByPattern appRoutingTproxyFixture.config.environment.systemPackages
|
||||
".*/[^/]*proxy-ctl(-[0-9.]+)?$"}/bin/proxy-ctl"
|
||||
);
|
||||
appRoutingTproxyProfiles =
|
||||
builtins.fromJSON (
|
||||
builtins.readFile (
|
||||
quotedValueByPrefix appRoutingTproxyScript "APP_ROUTING_PROFILES_FILE=\""
|
||||
)
|
||||
);
|
||||
appRoutingTproxyStartScript =
|
||||
builtins.readFile appRoutingTproxyFixture.config.systemd.services."proxy-suite-app-tproxy".serviceConfig.ExecStart;
|
||||
appRoutingTproxyUserStartExec =
|
||||
appRoutingTproxyFixture.config.systemd.services."proxy-suite-app-tproxy-user@".serviceConfig.ExecStart;
|
||||
appRoutingTproxyUserStartScript =
|
||||
builtins.readFile (builtins.head (pkgs.lib.splitString " " appRoutingTproxyUserStartExec));
|
||||
|
||||
appRoutingTproxyWithoutEnable = forceEval (
|
||||
(evalProxySuite [
|
||||
baseModule
|
||||
{
|
||||
services.proxy-suite.appRouting = {
|
||||
enable = true;
|
||||
profiles = [
|
||||
{
|
||||
name = "browser";
|
||||
route = "tproxy";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
]).config.system.build.toplevel.drvPath
|
||||
);
|
||||
|
||||
duplicateAppRoutingProfiles = forceEval (
|
||||
(evalProxySuite [
|
||||
baseModule
|
||||
@@ -884,6 +929,66 @@ let
|
||||
]).config.system.build.toplevel.drvPath
|
||||
);
|
||||
|
||||
appRoutingTproxyFwmarkCollision = forceEval (
|
||||
(evalProxySuite [
|
||||
baseModule
|
||||
{
|
||||
services.proxy-suite = {
|
||||
singBox.proxyMark = 17;
|
||||
appRouting = {
|
||||
enable = true;
|
||||
backends.tproxy = {
|
||||
enable = true;
|
||||
fwmark = 17;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
]).config.system.build.toplevel.drvPath
|
||||
);
|
||||
|
||||
appRoutingTunTproxyFwmarkCollision = forceEval (
|
||||
(evalProxySuite [
|
||||
baseModule
|
||||
{
|
||||
services.proxy-suite.appRouting = {
|
||||
enable = true;
|
||||
backends = {
|
||||
tun = {
|
||||
enable = true;
|
||||
fwmark = 23;
|
||||
};
|
||||
tproxy = {
|
||||
enable = true;
|
||||
fwmark = 23;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
]).config.system.build.toplevel.drvPath
|
||||
);
|
||||
|
||||
appRoutingTunTproxyRouteTableCollision = forceEval (
|
||||
(evalProxySuite [
|
||||
baseModule
|
||||
{
|
||||
services.proxy-suite.appRouting = {
|
||||
enable = true;
|
||||
backends = {
|
||||
tun = {
|
||||
enable = true;
|
||||
routeTable = 123;
|
||||
};
|
||||
tproxy = {
|
||||
enable = true;
|
||||
routeTable = 123;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
]).config.system.build.toplevel.drvPath
|
||||
);
|
||||
|
||||
# Validation failures
|
||||
subscriptionBothSources = forceEval (
|
||||
(evalProxySuite [
|
||||
@@ -1347,6 +1452,13 @@ let
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: createDefaultProfiles injects curated tproxy profile when backend is enabled --
|
||||
(
|
||||
assert builtins.length appRoutingTproxyProfiles == 2;
|
||||
assert builtins.any (profile: profile.name == "tproxy" && profile.route == "tproxy") appRoutingTproxyProfiles;
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: proxy-ctl script embeds wrap/apps commands --
|
||||
(
|
||||
assert pkgs.lib.hasInfix "wrap <profile> -- <cmd>" appRoutingProxychainsScript;
|
||||
@@ -1376,6 +1488,14 @@ let
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: generated proxy-ctl script dispatches tproxy profiles through systemd slices --
|
||||
(
|
||||
assert pkgs.lib.hasInfix "APP_ROUTING_TPROXY_ENABLED" appRoutingTproxyScript;
|
||||
assert pkgs.lib.hasInfix "proxy-suite-app-tproxy-user@$uid.service" appRoutingTproxyScript;
|
||||
assert pkgs.lib.hasInfix "proxy-suite-app-tproxy-$profile-$$" appRoutingTproxyScript;
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: user mark script installs fwmark + conntrack mark rules --
|
||||
(
|
||||
assert pkgs.lib.hasInfix "meta mark set" appRoutingTunUserStartScript;
|
||||
@@ -1430,6 +1550,14 @@ let
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: app TProxy service and helper units are created --
|
||||
(
|
||||
assert appRoutingTproxyFixture.config.systemd.services ? "proxy-suite-app-tproxy";
|
||||
assert appRoutingTproxyFixture.config.systemd.services ? "proxy-suite-app-tproxy-user@";
|
||||
assert appRoutingTproxyFixture.config.systemd.user.services ? "proxy-suite-app-tproxy-anchor";
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: app TUN enables nftables and user control group --
|
||||
(
|
||||
assert appRoutingTunFixture.config.networking.nftables.enable;
|
||||
@@ -1437,6 +1565,22 @@ let
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: app TProxy helper installs socket cgroup mark rules --
|
||||
(
|
||||
assert pkgs.lib.hasInfix "socket cgroupv2" appRoutingTproxyUserStartScript;
|
||||
assert pkgs.lib.hasInfix "meta mark set" appRoutingTproxyUserStartScript;
|
||||
assert pkgs.lib.hasInfix "ct mark set" appRoutingTproxyUserStartScript;
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: app TProxy startup installs nftables and loopback policy route --
|
||||
(
|
||||
assert pkgs.lib.hasInfix "proxy_suite_app_tproxy" appRoutingTproxyStartScript;
|
||||
assert pkgs.lib.hasInfix "route replace local default dev lo table 102" appRoutingTproxyStartScript;
|
||||
assert pkgs.lib.hasInfix "rule add fwmark 17 table 102" appRoutingTproxyStartScript;
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: route=proxychains requires proxychains.enable --
|
||||
(
|
||||
assert appRoutingProxychainsWithoutEnable.success == false;
|
||||
@@ -1461,6 +1605,12 @@ let
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: route=tproxy requires appRouting.backends.tproxy.enable --
|
||||
(
|
||||
assert appRoutingTproxyWithoutEnable.success == false;
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: profile names must be unique --
|
||||
(
|
||||
assert duplicateAppRoutingProfiles.success == false;
|
||||
@@ -1473,6 +1623,24 @@ let
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: app TProxy fwmark must differ from sing-box proxyMark --
|
||||
(
|
||||
assert appRoutingTproxyFwmarkCollision.success == false;
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: app TUN and app TProxy fwmarks must differ --
|
||||
(
|
||||
assert appRoutingTunTproxyFwmarkCollision.success == false;
|
||||
true
|
||||
)
|
||||
|
||||
# -- appRouting: app TUN and app TProxy route tables must differ --
|
||||
(
|
||||
assert appRoutingTunTproxyRouteTableCollision.success == false;
|
||||
true
|
||||
)
|
||||
|
||||
# -- subscription: no outbounds + no subscriptions fails --
|
||||
(
|
||||
assert noOutboundsNoSubscriptions.success == false;
|
||||
|
||||
Reference in new issue
Block a user