other improvements
This commit is contained in:
11 files changed
+192
-26
No files matched your search
@@ -133,7 +133,7 @@ Usage: proxy-ctl <command> [args]
|
|||||||
Commands:
|
Commands:
|
||||||
help show this help message
|
help show this help message
|
||||||
status [--tray] show status of all proxy-suite services
|
status [--tray] show status of all proxy-suite services
|
||||||
proxy on|off enable/disable the core SOCKS proxy
|
proxy on|off enable/disable the sing-box proxy stack
|
||||||
tproxy on|off enable/disable TProxy transparent mode
|
tproxy on|off enable/disable TProxy transparent mode
|
||||||
tun on|off enable/disable TUN mode
|
tun on|off enable/disable TUN mode
|
||||||
zapret on|off enable/disable zapret-discord-youtube
|
zapret on|off enable/disable zapret-discord-youtube
|
||||||
@@ -144,6 +144,6 @@ Commands:
|
|||||||
apps list configured per-app routing profiles
|
apps list configured per-app routing profiles
|
||||||
wrap <profile> -- <cmd> run a command via a perAppRouting profile
|
wrap <profile> -- <cmd> run a command via a perAppRouting profile
|
||||||
subscription list show subscriptions, cache age, and proxy count
|
subscription list show subscriptions, cache age, and proxy count
|
||||||
subscription update force-refresh all subscription caches and restart
|
subscription update force-refresh all subscription caches and restart active sing-box services
|
||||||
```
|
```
|
||||||
<!-- proxy-ctl-help:end -->
|
<!-- proxy-ctl-help:end -->
|
||||||
+4
-1
@@ -2566,10 +2566,13 @@ Unique identifier for this subscription\.
|
|||||||
Used as a prefix for all outbound tags generated from its proxy list,
|
Used as a prefix for all outbound tags generated from its proxy list,
|
||||||
e\.g\. “my-sub” -> tags like “my-sub-Server-DE”\.
|
e\.g\. “my-sub” -> tags like “my-sub-Server-DE”\.
|
||||||
|
|
||||||
|
This value is also used as the subscription cache filename stem under
|
||||||
|
/var/lib/proxy-suite/subscriptions/, so it must be a safe identifier\.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*Type:*
|
*Type:*
|
||||||
string
|
string matching the pattern ^\[A-Za-z0-9]\[A-Za-z0-9\._-]\*$
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -76,11 +76,14 @@ let
|
|||||||
subscriptionType = types.submodule {
|
subscriptionType = types.submodule {
|
||||||
options = {
|
options = {
|
||||||
tag = mkOption {
|
tag = mkOption {
|
||||||
type = types.str;
|
type = types.strMatching "^[A-Za-z0-9][A-Za-z0-9._-]*$";
|
||||||
description = ''
|
description = ''
|
||||||
Unique identifier for this subscription.
|
Unique identifier for this subscription.
|
||||||
Used as a prefix for all outbound tags generated from its proxy list,
|
Used as a prefix for all outbound tags generated from its proxy list,
|
||||||
e.g. "my-sub" -> tags like "my-sub-Server-DE".
|
e.g. "my-sub" -> tags like "my-sub-Server-DE".
|
||||||
|
|
||||||
|
This value is also used as the subscription cache filename stem under
|
||||||
|
/var/lib/proxy-suite/subscriptions/, so it must be a safe identifier.
|
||||||
'';
|
'';
|
||||||
example = "community-list";
|
example = "community-list";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
perAppZapretCfg,
|
perAppZapretCfg,
|
||||||
builtinTags,
|
builtinTags,
|
||||||
outboundTags,
|
outboundTags,
|
||||||
|
subscriptionTags,
|
||||||
invalidRoutingTargets,
|
invalidRoutingTargets,
|
||||||
effectivePerAppRoutingProfileNames,
|
effectivePerAppRoutingProfileNames,
|
||||||
hasProxychainsProfiles,
|
hasProxychainsProfiles,
|
||||||
@@ -30,6 +31,10 @@ in
|
|||||||
assertion = !singBoxCfg.enable || builtins.length outboundTags == builtins.length (lib.unique outboundTags);
|
assertion = !singBoxCfg.enable || builtins.length outboundTags == builtins.length (lib.unique outboundTags);
|
||||||
message = "proxy-suite: outbound tags must be unique";
|
message = "proxy-suite: outbound tags must be unique";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
assertion = !singBoxCfg.enable || builtins.length subscriptionTags == builtins.length (lib.unique subscriptionTags);
|
||||||
|
message = "proxy-suite: subscription tags must be unique because they are used as cache keys and outbound tag prefixes";
|
||||||
|
}
|
||||||
{
|
{
|
||||||
assertion = !singBoxCfg.enable || builtins.all (tag: !builtins.elem tag builtinTags) outboundTags;
|
assertion = !singBoxCfg.enable || builtins.all (tag: !builtins.elem tag builtinTags) outboundTags;
|
||||||
message = "proxy-suite: outbound tags must not use reserved names: proxy, direct, block";
|
message = "proxy-suite: outbound tags must not use reserved names: proxy, direct, block";
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ let
|
|||||||
|
|
||||||
builtinTags = [ "proxy" "direct" "block" ];
|
builtinTags = [ "proxy" "direct" "block" ];
|
||||||
outboundTags = map (ob: ob.tag) singBoxCfg.outbounds;
|
outboundTags = map (ob: ob.tag) singBoxCfg.outbounds;
|
||||||
|
subscriptionTags = map (sub: sub.tag) singBoxCfg.subscriptions;
|
||||||
invalidRoutingTargets = lib.unique (
|
invalidRoutingTargets = lib.unique (
|
||||||
map (rule: rule.outbound) (
|
map (rule: rule.outbound) (
|
||||||
builtins.filter (rule: !builtins.elem rule.outbound (builtinTags ++ outboundTags)) singBoxCfg.routing.rules
|
builtins.filter (rule: !builtins.elem rule.outbound (builtinTags ++ outboundTags)) singBoxCfg.routing.rules
|
||||||
@@ -69,7 +70,7 @@ let
|
|||||||
control = import ./control.nix {
|
control = import ./control.nix {
|
||||||
inherit packages singBoxCfg perAppRoutingCfg perAppRoutingTun perAppRoutingTproxy perAppZapretCfg;
|
inherit packages singBoxCfg perAppRoutingCfg perAppRoutingTun perAppRoutingTproxy perAppZapretCfg;
|
||||||
zapretEnabled = cfg.zapret.enable;
|
zapretEnabled = cfg.zapret.enable;
|
||||||
inherit (scripts) subscriptionTagsList;
|
inherit (scripts) subscriptionTagsFile;
|
||||||
inherit (perAppRouting)
|
inherit (perAppRouting)
|
||||||
perAppRoutingProfilesFile
|
perAppRoutingProfilesFile
|
||||||
proxychainsConfigFile
|
proxychainsConfigFile
|
||||||
@@ -89,6 +90,7 @@ in
|
|||||||
userControlCfg
|
userControlCfg
|
||||||
builtinTags
|
builtinTags
|
||||||
outboundTags
|
outboundTags
|
||||||
|
subscriptionTags
|
||||||
invalidRoutingTargets
|
invalidRoutingTargets
|
||||||
polkit
|
polkit
|
||||||
scripts
|
scripts
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
perAppRoutingTproxy,
|
perAppRoutingTproxy,
|
||||||
perAppZapretCfg,
|
perAppZapretCfg,
|
||||||
zapretEnabled,
|
zapretEnabled,
|
||||||
subscriptionTagsList,
|
subscriptionTagsFile,
|
||||||
perAppRoutingProfilesFile,
|
perAppRoutingProfilesFile,
|
||||||
proxychainsConfigFile,
|
proxychainsConfigFile,
|
||||||
proxychainsQuietArg,
|
proxychainsQuietArg,
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
clashApi = "http://127.0.0.1:${toString singBoxCfg.clashApiPort}";
|
clashApi = "http://127.0.0.1:${toString singBoxCfg.clashApiPort}";
|
||||||
selection = singBoxCfg.selection;
|
selection = singBoxCfg.selection;
|
||||||
inherit
|
inherit
|
||||||
subscriptionTagsList
|
subscriptionTagsFile
|
||||||
perAppRoutingProfilesFile
|
perAppRoutingProfilesFile
|
||||||
proxychainsConfigFile
|
proxychainsConfigFile
|
||||||
proxychainsQuietArg
|
proxychainsQuietArg
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ let
|
|||||||
userControlCfg
|
userControlCfg
|
||||||
builtinTags
|
builtinTags
|
||||||
outboundTags
|
outboundTags
|
||||||
|
subscriptionTags
|
||||||
invalidRoutingTargets
|
invalidRoutingTargets
|
||||||
polkit
|
polkit
|
||||||
scripts
|
scripts
|
||||||
@@ -101,7 +102,7 @@ in
|
|||||||
inherit singBoxCfg perAppRoutingCfg perAppRoutingTun perAppRoutingTproxy;
|
inherit singBoxCfg perAppRoutingCfg perAppRoutingTun perAppRoutingTproxy;
|
||||||
perAppZapretCfg = perAppZapretCfg;
|
perAppZapretCfg = perAppZapretCfg;
|
||||||
tgWsProxyCfg = cfg.tgWsProxy;
|
tgWsProxyCfg = cfg.tgWsProxy;
|
||||||
inherit builtinTags outboundTags invalidRoutingTargets;
|
inherit builtinTags outboundTags subscriptionTags invalidRoutingTargets;
|
||||||
inherit (perAppRouting)
|
inherit (perAppRouting)
|
||||||
effectivePerAppRoutingProfileNames
|
effectivePerAppRoutingProfileNames
|
||||||
hasProxychainsProfiles
|
hasProxychainsProfiles
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
globalTproxy = singBoxCfg.tproxy;
|
globalTproxy = singBoxCfg.tproxy;
|
||||||
|
subscriptionCacheDir = "/var/lib/proxy-suite/subscriptions";
|
||||||
|
|
||||||
|
mkSubscriptionCacheFile = sub: "${subscriptionCacheDir}/${sub.tag}.json";
|
||||||
|
|
||||||
mkSubscriptionUrlSource =
|
mkSubscriptionUrlSource =
|
||||||
sub:
|
sub:
|
||||||
@@ -76,10 +79,13 @@ let
|
|||||||
# Fetches subscription into the cache on first run; subsequent starts use the cache.
|
# Fetches subscription into the cache on first run; subsequent starts use the cache.
|
||||||
mkSubscriptionBlock =
|
mkSubscriptionBlock =
|
||||||
sub: routingMark:
|
sub: routingMark:
|
||||||
|
let
|
||||||
|
cacheFile = mkSubscriptionCacheFile sub;
|
||||||
|
in
|
||||||
''
|
''
|
||||||
# subscription: ${sub.tag}
|
# subscription: ${sub.tag}
|
||||||
CACHE_DIR="/var/lib/proxy-suite/subscriptions"
|
CACHE_DIR="${subscriptionCacheDir}"
|
||||||
CACHE_FILE="$CACHE_DIR/${lib.escapeShellArg sub.tag}.json"
|
CACHE_FILE="${cacheFile}"
|
||||||
if [ ! -f "$CACHE_FILE" ]; then
|
if [ ! -f "$CACHE_FILE" ]; then
|
||||||
mkdir -p "$CACHE_DIR"
|
mkdir -p "$CACHE_DIR"
|
||||||
if ${mkSubscriptionFetchCommand sub} > "$CACHE_FILE.tmp"; then
|
if ${mkSubscriptionFetchCommand sub} > "$CACHE_FILE.tmp"; then
|
||||||
@@ -195,13 +201,15 @@ let
|
|||||||
# Shell code to fetch a single subscription into the cache (used in update service).
|
# Shell code to fetch a single subscription into the cache (used in update service).
|
||||||
mkSubscriptionFetchBlock =
|
mkSubscriptionFetchBlock =
|
||||||
sub:
|
sub:
|
||||||
|
let
|
||||||
|
cacheFile = mkSubscriptionCacheFile sub;
|
||||||
|
in
|
||||||
''
|
''
|
||||||
if ${mkSubscriptionFetchCommand sub} > "$CACHE_DIR/${lib.escapeShellArg sub.tag}.json.tmp"; then
|
if ${mkSubscriptionFetchCommand sub} > "${cacheFile}.tmp"; then
|
||||||
mv "$CACHE_DIR/${lib.escapeShellArg sub.tag}.json.tmp" \
|
mv "${cacheFile}.tmp" "${cacheFile}"
|
||||||
"$CACHE_DIR/${lib.escapeShellArg sub.tag}.json"
|
|
||||||
echo "Updated subscription: ${sub.tag}"
|
echo "Updated subscription: ${sub.tag}"
|
||||||
else
|
else
|
||||||
rm -f "$CACHE_DIR/${lib.escapeShellArg sub.tag}.json.tmp"
|
rm -f "${cacheFile}.tmp"
|
||||||
echo "proxy-suite: failed to update subscription '${sub.tag}'" >&2
|
echo "proxy-suite: failed to update subscription '${sub.tag}'" >&2
|
||||||
FAILED=1
|
FAILED=1
|
||||||
fi
|
fi
|
||||||
@@ -209,23 +217,39 @@ let
|
|||||||
|
|
||||||
subscriptionUpdateScript = pkgs.writeShellScript "proxy-suite-subscription-update" ''
|
subscriptionUpdateScript = pkgs.writeShellScript "proxy-suite-subscription-update" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
CACHE_DIR="/var/lib/proxy-suite/subscriptions"
|
CACHE_DIR="${subscriptionCacheDir}"
|
||||||
mkdir -p "$CACHE_DIR"
|
mkdir -p "$CACHE_DIR"
|
||||||
FAILED=0
|
FAILED=0
|
||||||
|
SOCKS_WAS_ACTIVE=0
|
||||||
|
TUN_WAS_ACTIVE=0
|
||||||
|
PER_APP_TUN_WAS_ACTIVE=0
|
||||||
|
|
||||||
|
systemctl is-active --quiet proxy-suite-socks && SOCKS_WAS_ACTIVE=1 || true
|
||||||
|
systemctl is-active --quiet proxy-suite-tun && TUN_WAS_ACTIVE=1 || true
|
||||||
|
systemctl is-active --quiet proxy-suite-per-app-tun && PER_APP_TUN_WAS_ACTIVE=1 || true
|
||||||
|
|
||||||
${lib.concatMapStrings mkSubscriptionFetchBlock singBoxCfg.subscriptions}
|
${lib.concatMapStrings mkSubscriptionFetchBlock singBoxCfg.subscriptions}
|
||||||
|
|
||||||
if [ "$FAILED" -eq 0 ]; then
|
if [ "$FAILED" -eq 0 ]; then
|
||||||
systemctl restart proxy-suite-socks
|
if [ "$SOCKS_WAS_ACTIVE" -eq 1 ]; then
|
||||||
systemctl is-active --quiet proxy-suite-tun && systemctl restart proxy-suite-tun || true
|
systemctl restart proxy-suite-socks
|
||||||
|
fi
|
||||||
|
if [ "$TUN_WAS_ACTIVE" -eq 1 ]; then
|
||||||
|
systemctl restart proxy-suite-tun
|
||||||
|
fi
|
||||||
|
if [ "$PER_APP_TUN_WAS_ACTIVE" -eq 1 ]; then
|
||||||
|
systemctl restart proxy-suite-per-app-tun
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
exit "$FAILED"
|
exit "$FAILED"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
hasSubscriptions = singBoxCfg.subscriptions != [ ];
|
hasSubscriptions = singBoxCfg.subscriptions != [ ];
|
||||||
subscriptionTagsList = lib.concatStringsSep " " (map (sub: lib.escapeShellArg sub.tag) singBoxCfg.subscriptions);
|
subscriptionTagsFile = pkgs.writeText "proxy-suite-subscription-tags.json" (
|
||||||
|
builtins.toJSON (map (sub: sub.tag) singBoxCfg.subscriptions)
|
||||||
|
);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit startSocks startTun startPerAppTun;
|
inherit startSocks startTun startPerAppTun;
|
||||||
inherit subscriptionUpdateScript hasSubscriptions subscriptionTagsList;
|
inherit subscriptionUpdateScript hasSubscriptions subscriptionTagsFile;
|
||||||
}
|
}
|
||||||
+125
@@ -641,6 +641,24 @@ let
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
subscriptionOnlyProxyCtl =
|
||||||
|
packageByPattern subscriptionOnlyFixture.config.environment.systemPackages ".*/[^/]*proxy-ctl(-[0-9.]+)?$";
|
||||||
|
subscriptionOnlyWrapper =
|
||||||
|
builtins.readFile "${subscriptionOnlyProxyCtl}/bin/proxy-ctl";
|
||||||
|
subscriptionOnlyScript =
|
||||||
|
subscriptionOnlyWrapper
|
||||||
|
+ "\n"
|
||||||
|
+ builtins.readFile "${subscriptionOnlyProxyCtl}/bin/.proxy-ctl-wrapped";
|
||||||
|
subscriptionOnlyTags =
|
||||||
|
builtins.fromJSON (
|
||||||
|
builtins.readFile (
|
||||||
|
shellValueByPrefix subscriptionOnlyWrapper "export SUB_TAGS_FILE="
|
||||||
|
)
|
||||||
|
);
|
||||||
|
subscriptionOnlyStartScript =
|
||||||
|
builtins.readFile subscriptionOnlyFixture.config.systemd.services."proxy-suite-socks".serviceConfig.ExecStart;
|
||||||
|
subscriptionOnlyUpdateScript =
|
||||||
|
builtins.readFile subscriptionOnlyFixture.config.systemd.services."proxy-suite-subscription-update".serviceConfig.ExecStart;
|
||||||
|
|
||||||
subscriptionWithStaticFixture = evalProxySuite [
|
subscriptionWithStaticFixture = evalProxySuite [
|
||||||
{
|
{
|
||||||
@@ -666,6 +684,43 @@ let
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
duplicateSubscriptionTags = forceEval (
|
||||||
|
(evalProxySuite [
|
||||||
|
{
|
||||||
|
system.stateVersion = "26.05";
|
||||||
|
services.proxy-suite = {
|
||||||
|
enable = true;
|
||||||
|
singBox.subscriptions = [
|
||||||
|
{
|
||||||
|
tag = "dup";
|
||||||
|
url = "https://example.com/sub/one";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
tag = "dup";
|
||||||
|
url = "https://example.com/sub/two";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]).config.system.build.toplevel.drvPath
|
||||||
|
);
|
||||||
|
|
||||||
|
unsafeSubscriptionTag = forceEval (
|
||||||
|
(evalProxySuite [
|
||||||
|
{
|
||||||
|
system.stateVersion = "26.05";
|
||||||
|
services.proxy-suite = {
|
||||||
|
enable = true;
|
||||||
|
singBox.subscriptions = [
|
||||||
|
{
|
||||||
|
tag = "bad/tag";
|
||||||
|
url = "https://example.com/sub/token";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]).config.system.build.toplevel.drvPath
|
||||||
|
);
|
||||||
|
|
||||||
# selection=first with subscriptions only – start script must rename first
|
# selection=first with subscriptions only – start script must rename first
|
||||||
# subscription outbound to "proxy" so routing rules resolve at runtime.
|
# subscription outbound to "proxy" so routing rules resolve at runtime.
|
||||||
@@ -686,6 +741,28 @@ let
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
subscriptionPerAppTunFixture = evalProxySuite [
|
||||||
|
{
|
||||||
|
system.stateVersion = "26.05";
|
||||||
|
services.proxy-suite = {
|
||||||
|
enable = true;
|
||||||
|
singBox = {
|
||||||
|
subscriptions = [
|
||||||
|
{
|
||||||
|
tag = "community";
|
||||||
|
url = "https://example.com/sub/token";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
tun.perApp.enable = true;
|
||||||
|
};
|
||||||
|
perAppRouting.enable = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
subscriptionPerAppTunUpdateScript =
|
||||||
|
builtins.readFile (
|
||||||
|
subscriptionPerAppTunFixture.config.systemd.services."proxy-suite-subscription-update".serviceConfig.ExecStart
|
||||||
|
);
|
||||||
|
|
||||||
subscriptionUrlFileFixture = evalProxySuite [
|
subscriptionUrlFileFixture = evalProxySuite [
|
||||||
{
|
{
|
||||||
@@ -1697,6 +1774,14 @@ let
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# -- subscription: wrapper exposes tags through a JSON file, not shell word splitting --
|
||||||
|
(
|
||||||
|
assert subscriptionOnlyTags == [ "community" ];
|
||||||
|
assert pkgs.lib.hasInfix "export SUB_TAGS_FILE=" subscriptionOnlyScript;
|
||||||
|
assert !(pkgs.lib.hasInfix "SUB_TAGS_RAW" subscriptionOnlyScript);
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
# -- subscription: update service is created when subscriptions are configured --
|
# -- subscription: update service is created when subscriptions are configured --
|
||||||
(
|
(
|
||||||
assert subscriptionOnlyFixture.config.systemd.services ? "proxy-suite-subscription-update";
|
assert subscriptionOnlyFixture.config.systemd.services ? "proxy-suite-subscription-update";
|
||||||
@@ -1725,6 +1810,18 @@ let
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# -- subscription: duplicate tags fail because they are cache keys and tag prefixes --
|
||||||
|
(
|
||||||
|
assert duplicateSubscriptionTags.success == false;
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
|
# -- subscription: tag must be a filesystem-safe identifier --
|
||||||
|
(
|
||||||
|
assert unsafeSubscriptionTag.success == false;
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
# -- subscription: selection=first renames first subscription outbound to "proxy" --
|
# -- subscription: selection=first renames first subscription outbound to "proxy" --
|
||||||
(
|
(
|
||||||
let
|
let
|
||||||
@@ -1758,6 +1855,32 @@ let
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# -- subscription/runtime: generated cache paths use the raw validated tag, not shell-escaped quotes --
|
||||||
|
(
|
||||||
|
assert pkgs.lib.hasInfix ''CACHE_FILE="/var/lib/proxy-suite/subscriptions/community.json"'' subscriptionOnlyStartScript;
|
||||||
|
assert pkgs.lib.hasInfix ''/var/lib/proxy-suite/subscriptions/community.json.tmp'' subscriptionOnlyUpdateScript;
|
||||||
|
assert !(pkgs.lib.hasInfix "subscriptions/'community'.json" subscriptionOnlyStartScript);
|
||||||
|
assert !(pkgs.lib.hasInfix "subscriptions/'community'.json" subscriptionOnlyUpdateScript);
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
|
# -- subscription/runtime: refresh only restarts sing-box units that were already active --
|
||||||
|
(
|
||||||
|
assert pkgs.lib.hasInfix ''SOCKS_WAS_ACTIVE=0'' subscriptionOnlyUpdateScript;
|
||||||
|
assert pkgs.lib.hasInfix ''if [ "$SOCKS_WAS_ACTIVE" -eq 1 ]; then'' subscriptionOnlyUpdateScript;
|
||||||
|
assert pkgs.lib.hasInfix ''if [ "$TUN_WAS_ACTIVE" -eq 1 ]; then'' subscriptionOnlyUpdateScript;
|
||||||
|
assert pkgs.lib.hasInfix ''systemctl restart proxy-suite-socks'' subscriptionOnlyUpdateScript;
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
|
# -- subscription/runtime: refresh also handles the per-app TUN sing-box service when present --
|
||||||
|
(
|
||||||
|
assert pkgs.lib.hasInfix ''PER_APP_TUN_WAS_ACTIVE=0'' subscriptionPerAppTunUpdateScript;
|
||||||
|
assert pkgs.lib.hasInfix ''systemctl is-active --quiet proxy-suite-per-app-tun'' subscriptionPerAppTunUpdateScript;
|
||||||
|
assert pkgs.lib.hasInfix ''systemctl restart proxy-suite-per-app-tun'' subscriptionPerAppTunUpdateScript;
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
# -- subscription: no update service/timer without subscriptions --
|
# -- subscription: no update service/timer without subscriptions --
|
||||||
(
|
(
|
||||||
assert !(minimal.config.systemd.services ? "proxy-suite-subscription-update");
|
assert !(minimal.config.systemd.services ? "proxy-suite-subscription-update");
|
||||||
@@ -1839,6 +1962,8 @@ let
|
|||||||
(
|
(
|
||||||
assert pkgs.lib.hasInfix "help)" perAppRoutingProxychainsScript;
|
assert pkgs.lib.hasInfix "help)" perAppRoutingProxychainsScript;
|
||||||
assert pkgs.lib.hasInfix "show this help message" perAppRoutingProxychainsScript;
|
assert pkgs.lib.hasInfix "show this help message" perAppRoutingProxychainsScript;
|
||||||
|
assert pkgs.lib.hasInfix "enable/disable the sing-box proxy stack" perAppRoutingProxychainsScript;
|
||||||
|
assert pkgs.lib.hasInfix "restart active sing-box services" perAppRoutingProxychainsScript;
|
||||||
assert pkgs.lib.hasInfix "wrap <profile> -- <cmd>" perAppRoutingProxychainsScript;
|
assert pkgs.lib.hasInfix "wrap <profile> -- <cmd>" perAppRoutingProxychainsScript;
|
||||||
assert pkgs.lib.hasInfix "apps" perAppRoutingProxychainsScript;
|
assert pkgs.lib.hasInfix "apps" perAppRoutingProxychainsScript;
|
||||||
true
|
true
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@
|
|||||||
{
|
{
|
||||||
clashApi,
|
clashApi,
|
||||||
selection,
|
selection,
|
||||||
subscriptionTagsList,
|
subscriptionTagsFile,
|
||||||
perAppRoutingEnabled,
|
perAppRoutingEnabled,
|
||||||
perAppRoutingProxychainsEnabled,
|
perAppRoutingProxychainsEnabled,
|
||||||
perAppRoutingTunEnabled,
|
perAppRoutingTunEnabled,
|
||||||
@@ -37,7 +37,7 @@ pkgs.symlinkJoin {
|
|||||||
]}" \
|
]}" \
|
||||||
--set CLASH_API ${lib.escapeShellArg clashApi} \
|
--set CLASH_API ${lib.escapeShellArg clashApi} \
|
||||||
--set SELECTION ${lib.escapeShellArg selection} \
|
--set SELECTION ${lib.escapeShellArg selection} \
|
||||||
--set SUB_TAGS_RAW ${lib.escapeShellArg subscriptionTagsList} \
|
--set SUB_TAGS_FILE ${lib.escapeShellArg (toString subscriptionTagsFile)} \
|
||||||
--set PER_APP_ROUTING_ENABLED ${lib.escapeShellArg perAppRoutingEnabled} \
|
--set PER_APP_ROUTING_ENABLED ${lib.escapeShellArg perAppRoutingEnabled} \
|
||||||
--set PER_APP_ROUTING_PROXYCHAINS_ENABLED ${lib.escapeShellArg perAppRoutingProxychainsEnabled} \
|
--set PER_APP_ROUTING_PROXYCHAINS_ENABLED ${lib.escapeShellArg perAppRoutingProxychainsEnabled} \
|
||||||
--set PER_APP_ROUTING_TUN_ENABLED ${lib.escapeShellArg perAppRoutingTunEnabled} \
|
--set PER_APP_ROUTING_TUN_ENABLED ${lib.escapeShellArg perAppRoutingTunEnabled} \
|
||||||
|
|||||||
+8
-5
@@ -1,10 +1,13 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Wrapped binary provides runtime config through env vars.
|
# Wrapped binary provides runtime config through env vars.
|
||||||
SUB_TAGS_RAW="${SUB_TAGS_RAW:-}"
|
SUB_TAGS_FILE="${SUB_TAGS_FILE:-}"
|
||||||
PROXYCHAINS_QUIET_ARG="${PROXYCHAINS_QUIET_ARG:-}"
|
PROXYCHAINS_QUIET_ARG="${PROXYCHAINS_QUIET_ARG:-}"
|
||||||
# shellcheck disable=SC2206
|
SUB_TAGS=()
|
||||||
SUB_TAGS=(${SUB_TAGS_RAW})
|
|
||||||
|
if [ -n "$SUB_TAGS_FILE" ] && [ -f "$SUB_TAGS_FILE" ]; then
|
||||||
|
mapfile -t SUB_TAGS < <(jq -r '.[]' "$SUB_TAGS_FILE")
|
||||||
|
fi
|
||||||
|
|
||||||
ALL_SERVICES=(
|
ALL_SERVICES=(
|
||||||
proxy-suite-socks
|
proxy-suite-socks
|
||||||
@@ -22,7 +25,7 @@ _usage() {
|
|||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo " help show this help message"
|
echo " help show this help message"
|
||||||
echo " status [--tray] show status of all proxy-suite services"
|
echo " status [--tray] show status of all proxy-suite services"
|
||||||
echo " proxy on|off enable/disable the core SOCKS proxy"
|
echo " proxy on|off enable/disable the sing-box proxy stack"
|
||||||
echo " tproxy on|off enable/disable TProxy transparent mode"
|
echo " tproxy on|off enable/disable TProxy transparent mode"
|
||||||
echo " tun on|off enable/disable TUN mode"
|
echo " tun on|off enable/disable TUN mode"
|
||||||
echo " zapret on|off enable/disable zapret-discord-youtube"
|
echo " zapret on|off enable/disable zapret-discord-youtube"
|
||||||
@@ -33,7 +36,7 @@ _usage() {
|
|||||||
echo " apps list configured per-app routing profiles"
|
echo " apps list configured per-app routing profiles"
|
||||||
echo " wrap <profile> -- <cmd> run a command via a perAppRouting profile"
|
echo " wrap <profile> -- <cmd> run a command via a perAppRouting profile"
|
||||||
echo " subscription list show subscriptions, cache age, and proxy count"
|
echo " subscription list show subscriptions, cache age, and proxy count"
|
||||||
echo " subscription update force-refresh all subscription caches and restart"
|
echo " subscription update force-refresh all subscription caches and restart active sing-box services"
|
||||||
exit "$status"
|
exit "$status"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user