fix: ensure routing rule for mixed-in is always applied

This commit is contained in:
Nikita Skryabin
2025-03-06 21:55:40 +03:00
parent 3b2a7ba8af
commit b736360b66

View File

@@ -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
}