fix: multiple fixes + cleanup and formatting
This commit is contained in:
59 files changed
+1357
-920
No files matched your search
@@ -25,13 +25,17 @@ lib.optionalString hybridEnabled ''
|
||||
local batch
|
||||
batch=$(${jq} -c \
|
||||
--argjson base "$XRAY_SIDECAR_NEXT_PORT" \
|
||||
--argjson mark ${if xraySidecarRoutingMark == null then "null" else toString xraySidecarRoutingMark} '
|
||||
--argjson mark ${
|
||||
if xraySidecarRoutingMark == null then "null" else toString xraySidecarRoutingMark
|
||||
} '
|
||||
to_entries | map(
|
||||
($base + .key) as $port
|
||||
| ("proxy-suite-xray-" + ($port | tostring)) as $auth
|
||||
| .value.tag as $tag
|
||||
| {outbound: (.value
|
||||
${lib.optionalString (xraySidecarRoutingMark != null) "| .streamSettings.sockopt.mark = $mark"}
|
||||
${lib.optionalString (
|
||||
xraySidecarRoutingMark != null
|
||||
) "| .streamSettings.sockopt.mark = $mark"}
|
||||
| .streamSettings.sockopt.domainStrategy = (.streamSettings.sockopt.domainStrategy // "UseIP")),
|
||||
inbound: {tag: ($tag + "-inbound"), listen: "127.0.0.1", port: $port, protocol: "socks",
|
||||
settings: {auth: "password", udp: true, accounts: [{user: $auth, pass: $auth}]}},
|
||||
|
||||
@@ -163,7 +163,9 @@ let
|
||||
|
||||
_proxy_suite_parse_xray_url() {
|
||||
${parse "--backend xray" (
|
||||
lib.optionalString (xraySidecarRoutingMark != null) " --routing-mark ${toString xraySidecarRoutingMark}"
|
||||
lib.optionalString (
|
||||
xraySidecarRoutingMark != null
|
||||
) " --routing-mark ${toString xraySidecarRoutingMark}"
|
||||
)}
|
||||
}
|
||||
''
|
||||
@@ -238,7 +240,11 @@ let
|
||||
|
||||
singBoxRawOutboundJson =
|
||||
ob: tag: routingMark:
|
||||
ob.singBoxJson // { inherit tag; } // lib.optionalAttrs (routingMark != null) { routing_mark = routingMark; };
|
||||
ob.singBoxJson
|
||||
// {
|
||||
inherit tag;
|
||||
}
|
||||
// lib.optionalAttrs (routingMark != null) { routing_mark = routingMark; };
|
||||
|
||||
mkHybridOutboundBlock =
|
||||
ob: routingMark: tag:
|
||||
@@ -435,7 +441,10 @@ let
|
||||
|
||||
# Declared detours, resolved once every outbound - subscription entries included - exists.
|
||||
detourMap =
|
||||
entries: lib.listToAttrs (map (e: lib.nameValuePair e.tag e.detour) (lib.filter (e: e.detour != null) entries));
|
||||
entries:
|
||||
lib.listToAttrs (
|
||||
map (e: lib.nameValuePair e.tag e.detour) (lib.filter (e: e.detour != null) entries)
|
||||
);
|
||||
detours = {
|
||||
outbounds = detourMap proxyCfg.outbounds;
|
||||
subscriptions = detourMap proxyCfg.subscriptions;
|
||||
@@ -645,9 +654,7 @@ let
|
||||
# Real exits for autoProxy, taken after the wrapper may have renamed one to
|
||||
# "proxy".
|
||||
exitTagsBlock = ''
|
||||
EXIT_TAGS_JSON=$(${jq} -c '[.[] | select(.type != "selector" and .type != "urltest"${
|
||||
lib.optionalString torOutboundEnabled " and (.tag | ltrimstr(\"proxy-suite-ob-\")) != \"tor\""
|
||||
}) | .tag]' <<< "$OUTBOUNDS_JSON")
|
||||
EXIT_TAGS_JSON=$(${jq} -c '[.[] | select(.type != "selector" and .type != "urltest"${lib.optionalString torOutboundEnabled " and (.tag | ltrimstr(\"proxy-suite-ob-\")) != \"tor\""}) | .tag]' <<< "$OUTBOUNDS_JSON")
|
||||
'';
|
||||
in
|
||||
mkUrlOutboundHelpersBlock routingMark
|
||||
|
||||
@@ -25,11 +25,7 @@ let
|
||||
subscriptionCacheDir = "${stateDir}/subscriptions/${backend}";
|
||||
|
||||
mkSubscriptionUrlSource =
|
||||
sub:
|
||||
if sub.urlFile != null then
|
||||
sub.urlFile
|
||||
else
|
||||
pkgs.writeText "proxy-suite-core" sub.url;
|
||||
sub: if sub.urlFile != null then sub.urlFile else pkgs.writeText "proxy-suite-core" sub.url;
|
||||
|
||||
# Defined in every script that touches a cache: the start scripts and the
|
||||
# update unit.
|
||||
@@ -145,14 +141,10 @@ let
|
||||
}
|
||||
'';
|
||||
|
||||
mkSubscriptionBlock =
|
||||
sub: _routingMark:
|
||||
''
|
||||
# subscription: ${sub.tag}
|
||||
_proxy_suite_load_subscription ${lib.escapeShellArg sub.tag} ${
|
||||
lib.escapeShellArg (mkSubscriptionUrlSource sub)
|
||||
}
|
||||
'';
|
||||
mkSubscriptionBlock = sub: _routingMark: ''
|
||||
# subscription: ${sub.tag}
|
||||
_proxy_suite_load_subscription ${lib.escapeShellArg sub.tag} ${lib.escapeShellArg (mkSubscriptionUrlSource sub)}
|
||||
'';
|
||||
|
||||
runtimeSubscriptionsBlock = ''
|
||||
# subscriptions added at runtime
|
||||
@@ -162,17 +154,13 @@ let
|
||||
done < <(_proxy_suite_runtime_subscriptions)
|
||||
'';
|
||||
|
||||
mkSubscriptionFetchBlock =
|
||||
sub:
|
||||
''
|
||||
if _proxy_suite_fetch_subscription ${lib.escapeShellArg sub.tag} ${
|
||||
lib.escapeShellArg (mkSubscriptionUrlSource sub)
|
||||
}; then
|
||||
echo "Updated subscription: ${sub.tag}"
|
||||
else
|
||||
FAILED=1
|
||||
fi
|
||||
'';
|
||||
mkSubscriptionFetchBlock = sub: ''
|
||||
if _proxy_suite_fetch_subscription ${lib.escapeShellArg sub.tag} ${lib.escapeShellArg (mkSubscriptionUrlSource sub)}; then
|
||||
echo "Updated subscription: ${sub.tag}"
|
||||
else
|
||||
FAILED=1
|
||||
fi
|
||||
'';
|
||||
|
||||
runtimeSubscriptionsFetchBlock = ''
|
||||
while IFS=$'\t' read -r RUNTIME_SUB_TAG RUNTIME_SUB_SRC; do
|
||||
|
||||
Reference in new issue
Block a user