diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/section.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/section.js index dc619bc..7dc8ccb 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/section.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/section.js @@ -683,6 +683,17 @@ function createSectionContent(section) { ); o.rmempty = false; o.depends("mixed_proxy_enabled", "1"); + + o = section.option( + form.Flag, + "resolve_real_ip_for_routing", + _("Resolve real IP for routing"), + _("Enable DNS resolve to get real IP when routing"), + ); + o.default = "0"; + o.rmempty = false; + o.depends("connection_type", "proxy"); + o.depends("connection_type", "vpn"); } const EntryPoint = { diff --git a/luci-app-podkop/po/ru/podkop.po b/luci-app-podkop/po/ru/podkop.po index 5afebc4..e96ab25 100644 --- a/luci-app-podkop/po/ru/podkop.po +++ b/luci-app-podkop/po/ru/podkop.po @@ -431,6 +431,12 @@ msgstr "Использование памяти" msgid "Mixed Proxy Port" msgstr "Порт смешанного прокси" +msgid "Resolve real IP for routing" +msgstr "Получать реальный IP при роутинге" + +msgid "Enable DNS resolve to get real IP when routing" +msgstr "Включить разрешение DNS вне FakeIP для получения реальных IP-адресов при маршрутизации" + msgid "Monitored Interfaces" msgstr "Наблюдаемые интерфейсы" diff --git a/luci-app-podkop/po/templates/podkop.pot b/luci-app-podkop/po/templates/podkop.pot index 4bd7f77..d138f11 100644 --- a/luci-app-podkop/po/templates/podkop.pot +++ b/luci-app-podkop/po/templates/podkop.pot @@ -283,6 +283,14 @@ msgstr "" msgid "Enable the mixed proxy, allowing this section to route traffic through both HTTP and SOCKS proxies" msgstr "" +#: ../luci-app-podkop/htdocs/luci-static/resources/view/podkop/section.js:678 +msgid "Resolve real IP for routing" +msgstr "" + +#: ../luci-app-podkop/htdocs/luci-static/resources/view/podkop/section.js:679 +msgid "Enable DNS resolve to get real IP when routing" +msgstr "" + #: ../luci-app-podkop/htdocs/luci-static/resources/view/podkop/settings.js:237 msgid "Enable YACD" msgstr "" diff --git a/podkop/files/usr/bin/podkop b/podkop/files/usr/bin/podkop index e26164a..418ea73 100755 --- a/podkop/files/usr/bin/podkop +++ b/podkop/files/usr/bin/podkop @@ -918,7 +918,7 @@ configure_routing_for_section_lists() { fi local community_lists user_domain_list_type user_subnet_list_type local_domain_lists local_subnet_lists \ - remote_domain_lists remote_subnet_lists section_connection_type route_rule_tag + remote_domain_lists remote_subnet_lists section_connection_type route_rule_tag resolve_real_ip_for_routing config_get community_lists "$section" "community_lists" config_get user_domain_list_type "$section" "user_domain_list_type" "disabled" config_get user_subnet_list_type "$section" "user_subnet_list_type" "disabled" @@ -927,6 +927,7 @@ configure_routing_for_section_lists() { config_get remote_domain_lists "$section" "remote_domain_lists" config_get remote_subnet_lists "$section" "remote_subnet_lists" config_get section_connection_type "$section" "connection_type" + config_get_bool resolve_real_ip_for_routing "$section" "resolve_real_ip_for_routing" 0 case "$section_connection_type" in proxy | vpn) @@ -982,6 +983,11 @@ configure_routing_for_section_lists() { config_list_foreach "$section" "remote_subnet_lists" configure_remote_domain_or_subnet_list_handler \ "subnets" "$section" "$route_rule_tag" fi + + if [ "$resolve_real_ip_for_routing" -eq 1 ]; then + config=$(sing_box_cm_add_resolve_rule "$config" "$route_rule_tag" "$(gen_id)" "$SB_DNS_SERVER_TAG") + log "Added resolve rule for '$section' section" "debug" + fi } configure_community_list_handler() { diff --git a/podkop/files/usr/lib/sing_box_config_manager.sh b/podkop/files/usr/lib/sing_box_config_manager.sh index 9a0af62..782550f 100644 --- a/podkop/files/usr/lib/sing_box_config_manager.sh +++ b/podkop/files/usr/lib/sing_box_config_manager.sh @@ -1090,6 +1090,42 @@ sing_box_cm_add_route_rule() { }]' } +####################################### +# Insert a resolve rule immediately before a route rule. +# Copies rule_set from the target route rule. +# Arguments: +# config: string (JSON), sing-box configuration to modify +# route_rule_tag: string, tag of the route rule to precede +# resolve_rule_tag: string, tag for the new resolve rule +# server: string, DNS server tag (optional, default: "dns-server") +# Outputs: +# Updated JSON config to stdout +####################################### +sing_box_cm_add_resolve_rule() { + local config="$1" + local route_rule_tag="$2" + local resolve_rule_tag="$3" + local server="${4:-dns-server}" + + echo "$config" | jq \ + --arg service_tag "$SERVICE_TAG" \ + --arg route_tag "$route_rule_tag" \ + --arg resolve_tag "$resolve_rule_tag" \ + --arg server "$server" \ + '.route.rules |= [ + .[] | + if .[$service_tag] == $route_tag then + { + action: "resolve", + rule_set: (.rule_set // []), + server: $server, + ($service_tag): $resolve_tag + }, . + else . + end + ]' +} + ####################################### # Patch a routing rule in the route section of a sing-box JSON configuration. # Arguments: