This commit is contained in:
itdoginfo
2025-05-07 00:22:04 +03:00
parent 96d661c49f
commit 6d1e4091e5
3 changed files with 96 additions and 21 deletions

View File

@@ -1212,6 +1212,11 @@ return view.extend({
o.rmempty = false; o.rmempty = false;
o.ucisection = 'main'; o.ucisection = 'main';
o = mainSection.taboption('additional', form.Flag, 'detour', _('Proxy download of lists'), _('Downloading all lists via main Proxy/VPN'));
o.default = '0';
o.rmempty = false;
o.ucisection = 'main';
// Extra IPs and exclusions (main section) // Extra IPs and exclusions (main section)
o = mainSection.taboption('basic', form.Flag, 'exclude_from_ip_enabled', _('IP for exclusion'), _('Specify local IP addresses that will never use the configured route')); o = mainSection.taboption('basic', form.Flag, 'exclude_from_ip_enabled', _('IP for exclusion'), _('Specify local IP addresses that will never use the configured route'));
o.default = '0'; o.default = '0';

View File

@@ -39,3 +39,4 @@ config main 'main'
option mon_restart_ifaces '0' option mon_restart_ifaces '0'
#list restart_ifaces 'wan' #list restart_ifaces 'wan'
option ss_uot '0' option ss_uot '0'
option detour '0'

View File

@@ -132,6 +132,12 @@ start_main() {
sing_box_quic_reject sing_box_quic_reject
fi fi
config_get_bool detour "main" "detour" "0"
if [ "$detour" -eq 1 ]; then
log "Detour mixed enable"
detour_mixed
fi
sing_box_config_check sing_box_config_check
/etc/init.d/sing-box start /etc/init.d/sing-box start
#/etc/init.d/sing-box enable #/etc/init.d/sing-box enable
@@ -564,10 +570,19 @@ list_update() {
fi fi
for i in $(seq 1 60); do for i in $(seq 1 60); do
config_get_bool detour "main" "detour" "0"
if [ "$detour" -eq 1 ]; then
if http_proxy="http://127.0.0.1:4534" https_proxy="http://127.0.0.1:4534" curl -s -m 3 https://github.com >/dev/null; then
log "GitHub is available"
break
fi
else
if curl -s -m 3 https://github.com >/dev/null; then if curl -s -m 3 https://github.com >/dev/null; then
log "GitHub is available" log "GitHub is available"
break break
fi fi
fi
log "GitHub is unavailable [$i/60]" log "GitHub is unavailable [$i/60]"
sleep 3 sleep 3
done done
@@ -1012,7 +1027,7 @@ sing_box_config_outbound_json() {
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
log "Outbound config updated successfully" log "Outbound config updated successfully"
else else
log "Error: Invalid JSON config generated" log "Error: Outbound invalid JSON config generated"
return 1 return 1
fi fi
} }
@@ -1073,9 +1088,9 @@ sing_box_config_shadowsocks() {
)' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG )' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
log "Config updated successfully" log "Config Shadowsocks updated successfully"
else else
log "Error: Invalid JSON config generated" log "Error: Shadowsocks invalid JSON config generated"
return 1 return 1
fi fi
} }
@@ -1200,9 +1215,9 @@ sing_box_config_vless() {
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
log "Config created successfully" log "Config VLESS created successfully"
else else
log "Error: Invalid JSON config generated" log "Error: VLESS invalid JSON config generated"
return 1 return 1
fi fi
} }
@@ -1356,6 +1371,7 @@ sing_box_ruleset_remote() {
local tag=$1 local tag=$1
local type=$2 local type=$2
local update_interval=$3 local update_interval=$3
local detour=$4
url="$SRS_MAIN_URL/$tag.srs" url="$SRS_MAIN_URL/$tag.srs"
@@ -1371,15 +1387,19 @@ sing_box_ruleset_remote() {
--arg type "$type" \ --arg type "$type" \
--arg url "$url" \ --arg url "$url" \
--arg update_interval "$update_interval" \ --arg update_interval "$update_interval" \
--arg detour "$detour" \
' '
.route.rule_set += [ .route.rule_set += [
(
{ {
"tag": $tag, "tag": $tag,
"type": $type, "type": $type,
"format": "binary", "format": "binary",
"url": $url, "url": $url,
"update_interval": $update_interval "update_interval": $update_interval
} } +
(if $detour == "1" then {"download_detour": "main"} else {} end)
)
]' "$SING_BOX_CONFIG" > /tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json "$SING_BOX_CONFIG" ]' "$SING_BOX_CONFIG" > /tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json "$SING_BOX_CONFIG"
log "Added new ruleset with tag $tag" log "Added new ruleset with tag $tag"
@@ -1414,7 +1434,13 @@ list_subnets_download() {
esac esac
local filename=$(basename "$URL") local filename=$(basename "$URL")
config_get_bool detour "main" "detour" "0"
if [ "$detour" -eq 1 ]; then
http_proxy="http://127.0.0.1:4534" https_proxy="http://127.0.0.1:4534" wget -O "/tmp/podkop/$filename" "$URL"
else
wget -O "/tmp/podkop/$filename" "$URL" wget -O "/tmp/podkop/$filename" "$URL"
fi
while IFS= read -r subnet; do while IFS= read -r subnet; do
if [ "$service" = "discord" ]; then if [ "$service" = "discord" ]; then
@@ -1476,8 +1502,9 @@ sing_box_quic_reject() {
process_remote_ruleset_srs() { process_remote_ruleset_srs() {
config_get_bool domain_list_enabled "$section" "domain_list_enabled" "0" config_get_bool domain_list_enabled "$section" "domain_list_enabled" "0"
if [ "$domain_list_enabled" -eq 1 ]; then if [ "$domain_list_enabled" -eq 1 ]; then
config_get_bool detour "main" "detour" "0"
log "Adding a srs list for $section" log "Adding a srs list for $section"
config_list_foreach "$section" domain_list "sing_box_ruleset_remote" "remote" "1d" config_list_foreach "$section" domain_list "sing_box_ruleset_remote" "remote" "1d" "$detour"
fi fi
} }
@@ -1544,7 +1571,12 @@ list_custom_url_domains_create() {
local URL="$1" local URL="$1"
local filename=$(basename "$URL") local filename=$(basename "$URL")
wget -q -O "/tmp/podkop/${filename}" "$URL" config_get_bool detour "main" "detour" "0"
if [ "$detour" -eq 1 ]; then
http_proxy="http://127.0.0.1:4534" https_proxy="http://127.0.0.1:4534" wget -O "/tmp/podkop/${filename}" "$URL"
else
wget -O "/tmp/podkop/${filename}" "$URL"
fi
while IFS= read -r domain; do while IFS= read -r domain; do
log "From downloaded file: $domain" log "From downloaded file: $domain"
@@ -1584,7 +1616,12 @@ list_custom_url_subnets_create() {
local URL="$1" local URL="$1"
local filename=$(basename "$URL") local filename=$(basename "$URL")
wget -q -O "/tmp/podkop/${filename}" "$URL" config_get_bool detour "main" "detour" "0"
if [ "$detour" -eq 1 ]; then
http_proxy="http://127.0.0.1:4534" https_proxy="http://127.0.0.1:4534" wget -O "/tmp/podkop/${filename}" "$URL"
else
wget -O "/tmp/podkop/${filename}" "$URL"
fi
while IFS= read -r subnet; do while IFS= read -r subnet; do
log "From local file: $subnet" log "From local file: $subnet"
@@ -1643,6 +1680,31 @@ sing_box_rules_source_ip_cidr() {
fi fi
} }
detour_mixed() {
local section="main"
local port="4534"
local tag="detour"
log "Adding detour Socks5 for $section on port $port"
jq \
--arg tag "$tag" \
--arg port "$port" \
--arg section "$section" \
'.inbounds += [{
"tag": $tag,
"type": "mixed",
"listen": "127.0.0.1",
"listen_port": ($port|tonumber),
"set_system_proxy": false
}] |
.route.rules += [{
"inbound": [$tag],
"outbound": $section,
"action": "route"
}]' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
}
## nftables ## nftables
list_all_traffic_from_ip() { list_all_traffic_from_ip() {
local ip="$1" local ip="$1"
@@ -1777,7 +1839,14 @@ check_github() {
for url in "$DOMAINS_RU_INSIDE" "$DOMAINS_RU_OUTSIDE" "$DOMAINS_UA" "$DOMAINS_YOUTUBE" \ for url in "$DOMAINS_RU_INSIDE" "$DOMAINS_RU_OUTSIDE" "$DOMAINS_UA" "$DOMAINS_YOUTUBE" \
"$SUBNETS_TWITTER" "$SUBNETS_META" "$SUBNETS_DISCORD"; do "$SUBNETS_TWITTER" "$SUBNETS_META" "$SUBNETS_DISCORD"; do
local list_name=$(basename "$url") local list_name=$(basename "$url")
config_get_bool detour "main" "detour" "0"
if [ "$detour" -eq 1 ]; then
http_proxy="http://127.0.0.1:4534" https_proxy="http://127.0.0.1:4534" wget -q -O /dev/null "$url"
else
wget -q -O /dev/null "$url" wget -q -O /dev/null "$url"
fi
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
nolog "- $list_name: available" nolog "- $list_name: available"
else else