fix: jq double output with 2 outputs in sing-box config
This commit is contained in:
@@ -1124,31 +1124,28 @@ check_proxy() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! sing-box -c $SING_BOX_CONFIG check; then
|
nolog "Checking sing-box configuration..."
|
||||||
|
|
||||||
|
if ! sing-box -c $SING_BOX_CONFIG check >/dev/null; then
|
||||||
nolog "Invalid configuration"
|
nolog "Invalid configuration"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nolog "Checking sing-box configuration..."
|
|
||||||
|
|
||||||
jq '
|
jq '
|
||||||
.outbounds[].uuid |= "MASKED-UUID" |
|
.outbounds |= map(. + {
|
||||||
.outbounds[].server |= "MASKED-SERVER" |
|
uuid: "MASKED-UUID",
|
||||||
if .outbounds[].tls.reality.public_key then
|
server: "MASKED-SERVER",
|
||||||
.outbounds[].tls.reality.public_key |= "MASKED-PUBLIC-KEY"
|
tls: (if .tls.reality then .tls + {reality: (.reality + {public_key: "MASKED-PUBLIC-KEY"})} else .tls end)
|
||||||
else . end
|
})
|
||||||
' $SING_BOX_CONFIG
|
' $SING_BOX_CONFIG
|
||||||
|
|
||||||
nolog "Checking sing-box proxy connection..."
|
nolog "Checking proxy connection..."
|
||||||
|
|
||||||
for attempt in `seq 1 5`; do
|
for attempt in `seq 1 5`; do
|
||||||
response=$(sing-box tools fetch ifconfig.me -D /etc/sing-box)
|
response=$(sing-box tools fetch ifconfig.me -D /etc/sing-box 2>/dev/null)
|
||||||
if echo "$response" | grep -q "403 Forbidden"; then
|
if ! echo "$response" | grep -q "403 Forbidden"; then
|
||||||
:
|
|
||||||
else
|
|
||||||
nolog "Proxy check completed successfully"
|
nolog "Proxy check completed successfully"
|
||||||
masked_ip=$(echo "$response" | sed 's/\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)/XXX.\2.\3.\4/')
|
echo "$response" | sed 's/\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)\.\([0-9]\+\)/XXX.\2.\3.\4/'
|
||||||
echo "$masked_ip"
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user