mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-07 03:56:55 +03:00
refactor: use get_first_outbound_section to determine outbound tag, remove SB_MAIN_OUTBOUND_TAG constant
This commit is contained in:
@@ -91,7 +91,7 @@ has_outbound_section() {
|
||||
config_get outbound_json "$section" "outbound_json"
|
||||
config_get urltest_proxy_links "$section" "urltest_proxy_links"
|
||||
|
||||
if [ -n "$proxy_string" ] || [ -n "$interface" ] || \
|
||||
if [ -n "$proxy_string" ] || [ -n "$interface" ] ||
|
||||
[ -n "$outbound_json" ] || [ -n "$urltest_proxy_links" ]; then
|
||||
section_exists=0
|
||||
fi
|
||||
@@ -751,9 +751,10 @@ sing_box_configure_route() {
|
||||
config=$(sing_box_cf_add_single_key_reject_rule "$config" "$SB_TPROXY_INBOUND_TAG" "protocol" "quic")
|
||||
fi
|
||||
|
||||
config=$(
|
||||
sing_box_cf_proxy_domain "$config" "$SB_TPROXY_INBOUND_TAG" "$CHECK_PROXY_IP_DOMAIN" "$SB_MAIN_OUTBOUND_TAG"
|
||||
)
|
||||
local first_outbound_section
|
||||
first_outbound_section="$(get_first_outbound_section)"
|
||||
first_outbound_tag="$(get_outbound_tag_by_section "$first_outbound_section")"
|
||||
config=$(sing_box_cf_proxy_domain "$config" "$SB_TPROXY_INBOUND_TAG" "$CHECK_PROXY_IP_DOMAIN" "$first_outbound_tag")
|
||||
config=$(sing_box_cf_override_domain_port "$config" "$FAKEIP_TEST_DOMAIN" 8443)
|
||||
|
||||
config_foreach include_source_ips_in_routing_handler "section"
|
||||
@@ -1392,6 +1393,25 @@ get_download_detour_tag() {
|
||||
fi
|
||||
}
|
||||
|
||||
_determine_first_outbound_section() {
|
||||
local section="$1"
|
||||
|
||||
local connection_type
|
||||
config_get connection_type "$section" "connection_type"
|
||||
|
||||
if [ "$connection_type" = "proxy" ] || [ "$connection_type" = "vpn" ]; then
|
||||
[ -z "$first_section" ] && first_section="$1"
|
||||
fi
|
||||
}
|
||||
|
||||
get_first_outbound_section() {
|
||||
local first_section=""
|
||||
|
||||
config_foreach _determine_first_outbound_section "section"
|
||||
|
||||
echo "$first_section"
|
||||
}
|
||||
|
||||
get_block_sections() {
|
||||
uci show podkop | grep "\.connection_type='block'" | cut -d'.' -f2
|
||||
}
|
||||
@@ -2048,8 +2068,8 @@ check_sing_box() {
|
||||
patch=$(echo "$version" | cut -d. -f3)
|
||||
|
||||
# Compare version: must be >= 1.12.4
|
||||
if [ "$major" -gt 1 ] || \
|
||||
[ "$major" -eq 1 ] && [ "$minor" -gt 12 ] || \
|
||||
if [ "$major" -gt 1 ] ||
|
||||
[ "$major" -eq 1 ] && [ "$minor" -gt 12 ] ||
|
||||
[ "$major" -eq 1 ] && [ "$minor" -eq 12 ] && [ "$patch" -ge 4 ]; then
|
||||
sing_box_version_ok=1
|
||||
fi
|
||||
@@ -2201,7 +2221,6 @@ clash_api() {
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
print_global() {
|
||||
local message="$1"
|
||||
echo "$message"
|
||||
|
||||
@@ -44,7 +44,6 @@ SB_SERVICE_MIXED_INBOUND_ADDRESS="127.0.0.1"
|
||||
SB_SERVICE_MIXED_INBOUND_PORT=4534
|
||||
# Outbounds
|
||||
SB_DIRECT_OUTBOUND_TAG="direct-out"
|
||||
SB_MAIN_OUTBOUND_TAG="main-out"
|
||||
# Route
|
||||
SB_REJECT_RULE_TAG="reject-rule-tag"
|
||||
# Experimental
|
||||
|
||||
Reference in New Issue
Block a user