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.
- [ ] Диагностика: podkop_domains: 0 elements как проверять что доходят запросы при fakeip? Мб врубать логи dnsmasq и их чекать.
- [ ] Сделать галку запрещающую подкопу редачить dhcp. Допилить в исключение вместе с пустыми полями proxy и vpn
- [ ] Валидации предустановленных значений. Если прописаны другие, то вывод в лог о неизвестной переменной и продолжение работы
Приоритет 2
- [x] Списки доменов и подсетей с роутера

View File

@@ -46,6 +46,13 @@ start_service() {
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
mkdir -p /tmp/podkop
@@ -305,6 +312,11 @@ wget_github() {
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
if ! nslookup google.com >/dev/null 2>&1; then
log "DNS not work"
exit 1
fi
while true; do
if ! curl -m 3 github.com; then
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() {
local rule_set=$1
echo $rule_set
log "Adding section to fakeip route rules in sing-box"
jq \
--arg rule_set "$rule_set" \
'.dns.rules |= map(
if .server == "fakeip-server" then
if any(.rule_set[]?; . == $rule_set) then
.
else
.rule_set += [$rule_set]
end
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"
}
sing_box_cache_file() {
log "Configure cache.db in sing-box"
jq \
@@ -531,7 +547,7 @@ sing_box_outdound() {
case "$mode" in
"vpn")
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"
sing_box_outbound_interface $section $interface
;;
@@ -970,27 +986,37 @@ process_domains_for_section() {
}
sing_box_ruleset_remote() {
log "Configure ruleset remote in sing-box"
local tag=$1
local type=$2
local update_interval=$3
url="$SRS_MAIN_URL/$tag.srs"
local tag_exists=$(jq -r --arg tag "$tag" '
.route.rule_set[]? | select(.tag == $tag) | .tag
' "$SING_BOX_CONFIG")
if [[ -n "$tag_exists" ]]; then
log "Ruleset with tag $tag already exists. Skipping addition."
else
jq \
--arg tag "$tag" \
--arg type "$type" \
--arg url "$url" \
--arg update_interval "$update_interval" \
'.route |= (if . == null then {rule_set: []} else . end) |
.route.rule_set += [{
'
.route.rule_set += [
{
"tag": $tag,
"type": $type,
"format": "binary",
"url": $url,
"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() {