refactor: rename all_traffic_ip to fully_routed_ips, remove all_traffic_from_ip_enabled flag, update handlers

This commit is contained in:
Andrey Petelin
2025-10-10 14:36:38 +05:00
committed by divocat
parent d3847db313
commit 9be0eb3e57
2 changed files with 9 additions and 21 deletions

View File

@@ -534,25 +534,13 @@ function createSectionContent(section) {
return validation.message; return validation.message;
}; };
o = section.option(
form.Flag,
'all_traffic_from_ip_enabled',
_('IP for full redirection'),
_(
'Specify local IP addresses whose traffic will always use the configured route',
),
);
o.default = '0';
o.rmempty = false;
o = section.option( o = section.option(
form.DynamicList, form.DynamicList,
'all_traffic_ip', 'fully_routed_ips',
_('Local IPs'), _('Fully Routed IPs'),
_('Enter valid IPv4 addresses'), _('Specify local IP addresses whose traffic will always be routed through the configured route'),
); );
o.placeholder = 'IP'; o.placeholder = 'IP';
o.depends('all_traffic_from_ip_enabled', '1');
o.rmempty = false; o.rmempty = false;
o.validate = function (section_id, value) { o.validate = function (section_id, value) {
// Optional // Optional
@@ -573,7 +561,7 @@ function createSectionContent(section) {
form.Flag, form.Flag,
'mixed_proxy_enabled', 'mixed_proxy_enabled',
_('Enable Mixed Proxy'), _('Enable Mixed Proxy'),
_('Enable the mixed proxy, allowing this section to route traffic through both HTTP and SOCKS proxies.'), _('Enable the mixed proxy, allowing this section to route traffic through both HTTP and SOCKS proxies'),
); );
o.default = '0'; o.default = '0';
o.rmempty = false; o.rmempty = false;
@@ -584,7 +572,7 @@ function createSectionContent(section) {
_('Mixed Proxy Port'), _('Mixed Proxy Port'),
_( _(
'Specify the port number on which the mixed proxy will run for this section. ' + 'Specify the port number on which the mixed proxy will run for this section. ' +
'Make sure the selected port is not used by another service.' 'Make sure the selected port is not used by another service'
), ),
); );
o.rmempty = false; o.rmempty = false;

View File

@@ -754,15 +754,15 @@ sing_box_configure_route() {
include_source_ips_in_routing_handler() { include_source_ips_in_routing_handler() {
local section="$1" local section="$1"
local all_traffic_from_ip_enabled rule_tag local fully_routed_ips rule_tag
config_get all_traffic_from_ip_enabled "$section" "all_traffic_from_ip_enabled" 0 config_get fully_routed_ips "$section" "fully_routed_ips"
if [ "$all_traffic_from_ip_enabled" -eq 1 ]; then if [ -n "$fully_routed_ips" ]; then
rule_tag="$(gen_id)" rule_tag="$(gen_id)"
config=$( config=$(
sing_box_cm_add_route_rule \ sing_box_cm_add_route_rule \
"$config" "$rule_tag" "$SB_TPROXY_INBOUND_TAG" "$(get_outbound_tag_by_section "$section")" "$config" "$rule_tag" "$SB_TPROXY_INBOUND_TAG" "$(get_outbound_tag_by_section "$section")"
) )
config_list_foreach "$section" "all_traffic_ip" include_source_ip_in_routing_handler "$rule_tag" config_list_foreach "$section" "fully_routed_ips" include_source_ip_in_routing_handler "$rule_tag"
fi fi
} }