fix: multiple fixes
This commit is contained in:
22 files changed
+107
-92
No files matched your search
@@ -18,18 +18,18 @@ let
|
||||
systemctl = "${pkgs.systemd}/bin/systemctl";
|
||||
curl = "${pkgs.curl}/bin/curl";
|
||||
|
||||
restartActiveConfigConsumersBlock =
|
||||
lib.concatMapStrings
|
||||
(svc: ''
|
||||
if ${systemctl} is-active --quiet ${svc}; then
|
||||
${systemctl} restart ${svc}
|
||||
fi
|
||||
'')
|
||||
[
|
||||
"proxy-suite-socks"
|
||||
"proxy-suite-tun"
|
||||
"proxy-suite-per-app-tun"
|
||||
];
|
||||
restartActiveBlock = lib.concatMapStrings (svc: ''
|
||||
if ${systemctl} is-active --quiet ${svc}; then
|
||||
${systemctl} restart ${svc}
|
||||
fi
|
||||
'');
|
||||
|
||||
# The TUN backends are sing-box instances of their own, without a Clash API.
|
||||
tunConsumers = [
|
||||
"proxy-suite-tun"
|
||||
"proxy-suite-per-app-tun"
|
||||
];
|
||||
restartActiveConfigConsumersBlock = restartActiveBlock ([ "proxy-suite-socks" ] ++ tunConsumers);
|
||||
|
||||
subscriptionUpdateScript = pkgs.writeShellScript "proxy-suite-core" ''
|
||||
set -euo pipefail
|
||||
@@ -102,6 +102,7 @@ let
|
||||
if ${curl} -sf -X PUT "${clashApi}/proxies/proxy" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$(${jq} -cn --arg name "$tag" '{name:$name}')" >/dev/null 2>&1; then
|
||||
${restartActiveBlock tunConsumers}
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -46,7 +46,7 @@ let
|
||||
cgroup_level=$(printf '%s' "$cgroup_path" | ${awk} -F/ '{ print NF }')
|
||||
|
||||
handles=$(${nft} -a list chain ${nftFamily} ${nftTable} ${nftChain} 2>/dev/null \
|
||||
| ${grepBin} -F "comment \"$rule_comment_prefix" \
|
||||
| ${grepBin} -F "comment \"$rule_comment_prefix-mark\"" \
|
||||
| ${awk} '{ print $NF }' || true)
|
||||
if [ -n "$handles" ]; then
|
||||
while IFS= read -r handle; do
|
||||
@@ -72,7 +72,7 @@ let
|
||||
uid="$1"
|
||||
rule_comment_prefix="proxy-suite-${name}-user-$uid"
|
||||
handles=$(${nft} -a list chain ${nftFamily} ${nftTable} ${nftChain} 2>/dev/null \
|
||||
| ${grepBin} -F "comment \"$rule_comment_prefix" \
|
||||
| ${grepBin} -F "comment \"$rule_comment_prefix-mark\"" \
|
||||
| ${awk} '{ print $NF }' || true)
|
||||
if [ -n "$handles" ]; then
|
||||
while IFS= read -r handle; do
|
||||
|
||||
@@ -354,9 +354,10 @@ let
|
||||
|
||||
${singBox} run -c "$RUNTIME_DIR/config.json" &
|
||||
SING_BOX_PID="$!"
|
||||
# Either one going away breaks the outbounds: exit, and let systemd restart both.
|
||||
SING_BOX_STATUS=0
|
||||
wait "$SING_BOX_PID" || SING_BOX_STATUS="$?"
|
||||
exit "$SING_BOX_STATUS"
|
||||
wait -n "$XRAY_SIDECAR_PID" "$SING_BOX_PID" || SING_BOX_STATUS="$?"
|
||||
exit "$(( SING_BOX_STATUS == 0 ? 1 : SING_BOX_STATUS ))"
|
||||
fi
|
||||
|
||||
exec ${singBox} run -c "$RUNTIME_DIR/config.json"
|
||||
|
||||
@@ -229,6 +229,8 @@ let
|
||||
wants = [ "network-online.target" ];
|
||||
execStart = scripts.subscriptionUpdateScript;
|
||||
stateDirectory = "proxy-suite";
|
||||
# Run by a timer and by `proxy subs update`: a unit left "active" would never run again.
|
||||
extraServiceConfig.RemainAfterExit = false;
|
||||
};
|
||||
}
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user