Issue S99sing-box. Fixed repeat rulesset in sections

This commit is contained in:
itdoginfo
2025-02-15 11:52:31 +03:00
parent 543b66a6cc
commit c914d38ff2
2 changed files with 43 additions and 16 deletions

View File

@@ -147,6 +147,7 @@ Luci: Services/podkop
- [ ] Диагностика: Proxy check completed successfully предположительно не показывает IP, если вернулся это IPv6. - [ ] Диагностика: Proxy check completed successfully предположительно не показывает IP, если вернулся это IPv6.
- [ ] Диагностика: podkop_domains: 0 elements как проверять что доходят запросы при fakeip? Мб врубать логи dnsmasq и их чекать. - [ ] Диагностика: podkop_domains: 0 elements как проверять что доходят запросы при fakeip? Мб врубать логи dnsmasq и их чекать.
- [ ] Сделать галку запрещающую подкопу редачить dhcp. Допилить в исключение вместе с пустыми полями proxy и vpn - [ ] Сделать галку запрещающую подкопу редачить dhcp. Допилить в исключение вместе с пустыми полями proxy и vpn
- [ ] Валидации предустановленных значений. Если прописаны другие, то вывод в лог о неизвестной переменной и продолжение работы
Приоритет 2 Приоритет 2
- [x] Списки доменов и подсетей с роутера - [x] Списки доменов и подсетей с роутера

View File

@@ -46,6 +46,13 @@ start_service() {
migration migration
# S99sing-box issue
if sing-box -c $SING_BOX_CONFIG check >/dev/null 2>&1; then
/etc/init.d/sing-box start
fi
sleep 5
config_foreach wget_github config_foreach wget_github
mkdir -p /tmp/podkop mkdir -p /tmp/podkop
@@ -305,6 +312,11 @@ wget_github() {
if [ "$domain_list_enabled" -eq 1 ] || [ "$subnets_list_enabled" -eq 1 ] || if [ "$domain_list_enabled" -eq 1 ] || [ "$subnets_list_enabled" -eq 1 ] ||
[ "$custom_download_domains_list_enabled" -eq 1 ] || [ "$custom_download_subnets_list_enabled" -eq 1 ] ; then [ "$custom_download_domains_list_enabled" -eq 1 ] || [ "$custom_download_subnets_list_enabled" -eq 1 ] ; then
if ! nslookup google.com >/dev/null 2>&1; then
log "DNS not work"
exit 1
fi
while true; do while true; do
if ! curl -m 3 github.com; then if ! curl -m 3 github.com; then
log "GitHub is not available. Check the internet availability [$count sec]" log "GitHub is not available. Check the internet availability [$count sec]"
@@ -497,20 +509,24 @@ sing_box_dns_rule_fakeip() {
sing_box_dns_rule_fakeip_section() { sing_box_dns_rule_fakeip_section() {
local rule_set=$1 local rule_set=$1
echo $rule_set
log "Adding section to fakeip route rules in sing-box" log "Adding section to fakeip route rules in sing-box"
jq \ jq \
--arg rule_set "$rule_set" \ --arg rule_set "$rule_set" \
'.dns.rules |= map( '.dns.rules |= map(
if .server == "fakeip-server" then if .server == "fakeip-server" then
.rule_set += [$rule_set] if any(.rule_set[]?; . == $rule_set) then
.
else
.rule_set += [$rule_set]
end
else else
. .
end 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"
} }
sing_box_cache_file() { sing_box_cache_file() {
log "Configure cache.db in sing-box" log "Configure cache.db in sing-box"
jq \ jq \
@@ -531,7 +547,7 @@ sing_box_outdound() {
case "$mode" in case "$mode" in
"vpn") "vpn")
log "VPN mode" log "VPN mode"
log "You are using VPN mode, make sure you have installed all the necessary packages, configured, created the zone and forwarding." log "You are using VPN mode, make sure you have installed all the necessary packages and configured."
config_get interface "$section" "interface" config_get interface "$section" "interface"
sing_box_outbound_interface $section $interface sing_box_outbound_interface $section $interface
;; ;;
@@ -970,27 +986,37 @@ process_domains_for_section() {
} }
sing_box_ruleset_remote() { sing_box_ruleset_remote() {
log "Configure ruleset remote in sing-box"
local tag=$1 local tag=$1
local type=$2 local type=$2
local update_interval=$3 local update_interval=$3
url="$SRS_MAIN_URL/$tag.srs" url="$SRS_MAIN_URL/$tag.srs"
jq \ local tag_exists=$(jq -r --arg tag "$tag" '
--arg tag "$tag" \ .route.rule_set[]? | select(.tag == $tag) | .tag
--arg type "$type" \ ' "$SING_BOX_CONFIG")
--arg url "$url" \
--arg update_interval "$update_interval" \ if [[ -n "$tag_exists" ]]; then
'.route |= (if . == null then {rule_set: []} else . end) | log "Ruleset with tag $tag already exists. Skipping addition."
.route.rule_set += [{ else
jq \
--arg tag "$tag" \
--arg type "$type" \
--arg url "$url" \
--arg update_interval "$update_interval" \
'
.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
}]' $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"
fi
} }
list_subnets_download() { list_subnets_download() {