From b736360b66f2129e8c2d937c2ca850605fdbaf26 Mon Sep 17 00:00:00 2001 From: Nikita Skryabin Date: Thu, 6 Mar 2025 21:55:40 +0300 Subject: [PATCH] fix: ensure routing rule for mixed-in is always applied --- podkop/files/usr/bin/podkop | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/podkop/files/usr/bin/podkop b/podkop/files/usr/bin/podkop index 89dd8de..5206e5a 100755 --- a/podkop/files/usr/bin/podkop +++ b/podkop/files/usr/bin/podkop @@ -464,24 +464,19 @@ process_socks5() { config_get_bool socks5 "main" "socks5" "0" if [ "$socks5" -eq 1 ]; then log "Socks5 local enable port 2080" - jq '.inbounds += [{ + jq \ + '.inbounds += [{ "tag": "mixed-in", "type": "mixed", "listen": "0.0.0.0", "listen_port": 2080, "set_system_proxy": false + }] | + .route.rules += [{ + "inbound": ["mixed-in"], + "outbound": "main", + "action": "route" }]' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG - - #local rule_exists=$(jq -r '.route.rules[] | select(.inbound[] == "mixed-in")' $SING_BOX_CONFIG) - local rule_exists=$(jq -r '.route.rules // [] | map(select(.inbound // [] | index("mixed-in"))) | length' $SING_BOX_CONFIG) - - if [ -z "$rule_exists" ]; then - jq '.route.rules += [{ - "inbound": ["mixed-in"], - "outbound": "main", - "action": "route" - }]' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG - fi fi }