|
|
|
|
@@ -24,8 +24,6 @@ EXTRA_HELP=" list_update Updating domain and subnet lists
|
|
|
|
|
show_system_info Show OpenWrt version and device model
|
|
|
|
|
get_sing_box_status Get sing-box status"
|
|
|
|
|
|
|
|
|
|
[ ! -L /usr/sbin/podkop ] && ln -s /etc/init.d/podkop /usr/sbin/podkop
|
|
|
|
|
|
|
|
|
|
GITHUB_RAW_URL="https://raw.githubusercontent.com/itdoginfo/allow-domains/main"
|
|
|
|
|
SRS_MAIN_URL="https://github.com/itdoginfo/allow-domains/releases/latest/download"
|
|
|
|
|
DOMAINS_RU_INSIDE="${GITHUB_RAW_URL}/Russia/inside-dnsmasq-nfset.lst"
|
|
|
|
|
@@ -1235,7 +1233,7 @@ list_subnets_download() {
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
local filename=$(basename "$URL")
|
|
|
|
|
wget -q -O "/tmp/podkop/$filename" "$URL"
|
|
|
|
|
wget -O "/tmp/podkop/$filename" "$URL"
|
|
|
|
|
|
|
|
|
|
while IFS= read -r subnet; do
|
|
|
|
|
if [ "$service" = "discord" ]; then
|
|
|
|
|
@@ -1308,10 +1306,16 @@ sing_box_rule_preset() {
|
|
|
|
|
config_get custom_subnets_list_enabled "$section" "custom_subnets_list_enabled"
|
|
|
|
|
config_get custom_local_domains_list_enabled "$section" "custom_local_domains_list_enabled"
|
|
|
|
|
config_get custom_download_domains_list_enabled "$section" "custom_download_domains_list_enabled"
|
|
|
|
|
config_get custom_download_subnets_list_enabled "$section" "custom_download_subnets_list_enabled"
|
|
|
|
|
|
|
|
|
|
if [ "$custom_domains_list_type" != "disabled" ] || [ "$custom_subnets_list_enabled" != "disabled" ] ||
|
|
|
|
|
[ "$custom_local_domains_list_enabled" = "1" ] || [ "$custom_download_domains_list_enabled" = "1" ]; then
|
|
|
|
|
[ "$custom_local_domains_list_enabled" = "1" ] || [ "$custom_download_domains_list_enabled" = "1" ] ||
|
|
|
|
|
[ "$custom_download_subnets_list_enabled" = "1" ]; then
|
|
|
|
|
sing_box_rules "$section" "$section"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$custom_domains_list_type" != "disabled" ] || [ "$custom_local_domains_list_enabled" = "1" ] ||
|
|
|
|
|
[ "$custom_download_domains_list_enabled" = "1" ]; then
|
|
|
|
|
sing_box_dns_rule_fakeip_section "$section" "$section"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
@@ -1419,22 +1423,23 @@ process_all_traffic_for_section() {
|
|
|
|
|
if [ "$all_traffic_from_ip_enabled" -eq "1" ]; then
|
|
|
|
|
log "Adding an IP to redirect all traffic"
|
|
|
|
|
config_list_foreach $section all_traffic_ip list_all_traffic_from_ip
|
|
|
|
|
config_list_foreach $section all_traffic_ip sing_box_rules_source_ip_cidr "$section" "$all_traffic_ip"
|
|
|
|
|
config_list_foreach $section all_traffic_ip sing_box_rules_source_ip_cidr $all_traffic_ip $section
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sing_box_rules_source_ip_cidr() {
|
|
|
|
|
log "Configure source_ip_cidr rule in sing-box"
|
|
|
|
|
local outbound="$2"
|
|
|
|
|
local source_ip_cidr="$1"
|
|
|
|
|
local outbound="$2"
|
|
|
|
|
|
|
|
|
|
local current_source_ip_cidr=$(jq -r '.route.rules[] | select(.outbound == "'"$outbound"'" and .action == "route" and (.rule_set | not))' $SING_BOX_CONFIG)
|
|
|
|
|
|
|
|
|
|
local current_source_ip_cidr=$(jq -r ".route.rules[] | select(.outbound == \"$outbound\" and .source_ip_cidr) | .rule_set" $SING_BOX_CONFIG)
|
|
|
|
|
|
|
|
|
|
if [[ -n "$current_source_ip_cidr" ]]; then
|
|
|
|
|
jq \
|
|
|
|
|
--arg source_ip_cidr "$source_ip_cidr" \
|
|
|
|
|
--arg outbound "$outbound" \
|
|
|
|
|
'(.route.rules[] | select(.outbound == $outbound) | .source_ip_cidr) += [$source_ip_cidr]' \
|
|
|
|
|
'(.route.rules[] | select(.outbound == $outbound and .action == "route" and (.rule_set | not)) | .source_ip_cidr) += [$source_ip_cidr]' \
|
|
|
|
|
$SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
|
|
|
|
else
|
|
|
|
|
jq \
|
|
|
|
|
@@ -1444,7 +1449,8 @@ sing_box_rules_source_ip_cidr() {
|
|
|
|
|
{
|
|
|
|
|
"inbound": ["tproxy-in"],
|
|
|
|
|
"source_ip_cidr": [$source_ip_cidr],
|
|
|
|
|
"outbound": $outbound
|
|
|
|
|
"outbound": $outbound,
|
|
|
|
|
"action": "route"
|
|
|
|
|
}
|
|
|
|
|
] + .route.rules' $SING_BOX_CONFIG >/tmp/sing-box-config-tmp.json && mv /tmp/sing-box-config-tmp.json $SING_BOX_CONFIG
|
|
|
|
|
fi
|
|
|
|
|
|