mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-08 04:26:55 +03:00
refactor: use list presence instead of *_enabled flags, simplify UI texts/placeholders, remove mixed inbound tag
This commit is contained in:
@@ -42,8 +42,7 @@ function createSectionContent(section) {
|
|||||||
o.textarea = true;
|
o.textarea = true;
|
||||||
o.rmempty = false;
|
o.rmempty = false;
|
||||||
o.sectionDescriptions = new Map();
|
o.sectionDescriptions = new Map();
|
||||||
o.placeholder =
|
o.placeholder = 'vless://uuid@server:port?type=tcp&security=tls#main\n// backup ss://method:pass@server:port\n// backup2 vless://uuid@server:port?type=grpc&security=reality#alt\n// backup3 trojan://04agAQapcl@127.0.0.1:33641?type=tcp&security=none#trojan-tcp-none';
|
||||||
'vless://uuid@server:port?type=tcp&security=tls#main\n// backup ss://method:pass@server:port\n// backup2 vless://uuid@server:port?type=grpc&security=reality#alt\n// backup3 trojan://04agAQapcl@127.0.0.1:33641?type=tcp&security=none#trojan-tcp-none';
|
|
||||||
o.validate = function (section_id, value) {
|
o.validate = function (section_id, value) {
|
||||||
// Optional
|
// Optional
|
||||||
if (!value || value.length === 0) {
|
if (!value || value.length === 0) {
|
||||||
@@ -54,15 +53,11 @@ function createSectionContent(section) {
|
|||||||
const activeConfigs = main.splitProxyString(value);
|
const activeConfigs = main.splitProxyString(value);
|
||||||
|
|
||||||
if (!activeConfigs.length) {
|
if (!activeConfigs.length) {
|
||||||
return _(
|
return _('No active configuration found. One configuration is required.');
|
||||||
'No active configuration found. One configuration is required.',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeConfigs.length > 1) {
|
if (activeConfigs.length > 1) {
|
||||||
return _(
|
return _('Multiply active configurations found. Please leave one configuration.');
|
||||||
'Multiply active configurations found. Please leave one configuration.',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const validation = main.validateProxyUrl(activeConfigs[0]);
|
const validation = main.validateProxyUrl(activeConfigs[0]);
|
||||||
@@ -224,33 +219,24 @@ function createSectionContent(section) {
|
|||||||
return validation.message;
|
return validation.message;
|
||||||
};
|
};
|
||||||
|
|
||||||
o = section.option(
|
|
||||||
form.Flag,
|
|
||||||
'community_lists_enabled',
|
|
||||||
_('Community Lists'),
|
|
||||||
);
|
|
||||||
o.default = '0';
|
|
||||||
o.rmempty = false;
|
|
||||||
|
|
||||||
o = section.option(
|
o = section.option(
|
||||||
form.DynamicList,
|
form.DynamicList,
|
||||||
'community_lists',
|
'community_lists',
|
||||||
_('Service List'),
|
_('Community Lists'),
|
||||||
_('Select predefined service for routing') +
|
_('Select a predefined list for routing') +
|
||||||
' <a href="https://github.com/itdoginfo/allow-domains" target="_blank">github.com/itdoginfo/allow-domains</a>',
|
' <a href="https://github.com/itdoginfo/allow-domains" target="_blank">github.com/itdoginfo/allow-domains</a>',
|
||||||
);
|
);
|
||||||
o.placeholder = 'Service list';
|
o.placeholder = 'Service list';
|
||||||
Object.entries(main.DOMAIN_LIST_OPTIONS).forEach(([key, label]) => {
|
Object.entries(main.DOMAIN_LIST_OPTIONS).forEach(([key, label]) => {
|
||||||
o.value(key, _(label));
|
o.value(key, _(label));
|
||||||
});
|
});
|
||||||
o.depends('community_lists_enabled', '1');
|
o.rmempty = true;
|
||||||
o.rmempty = false;
|
|
||||||
|
|
||||||
o = section.option(
|
o = section.option(
|
||||||
form.ListValue,
|
form.ListValue,
|
||||||
'user_domain_list_type',
|
'user_domain_list_type',
|
||||||
_('User Domain List Type'),
|
_('User Domain List Type'),
|
||||||
_('Select how to add your custom domains'),
|
_('Select the list type for adding custom domains'),
|
||||||
);
|
);
|
||||||
o.value('disabled', _('Disabled'));
|
o.value('disabled', _('Disabled'));
|
||||||
o.value('dynamic', _('Dynamic List'));
|
o.value('dynamic', _('Dynamic List'));
|
||||||
@@ -262,9 +248,7 @@ function createSectionContent(section) {
|
|||||||
form.DynamicList,
|
form.DynamicList,
|
||||||
'user_domains',
|
'user_domains',
|
||||||
_('User Domains'),
|
_('User Domains'),
|
||||||
_(
|
_('Enter domain names without protocols, e.g. example.com or sub.example.com'),
|
||||||
'Enter domain names without protocols (example: sub.example.com or example.com)',
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
o.placeholder = 'Domains list';
|
o.placeholder = 'Domains list';
|
||||||
o.depends('user_domain_list_type', 'dynamic');
|
o.depends('user_domain_list_type', 'dynamic');
|
||||||
@@ -288,12 +272,9 @@ function createSectionContent(section) {
|
|||||||
form.TextValue,
|
form.TextValue,
|
||||||
'user_domains_text',
|
'user_domains_text',
|
||||||
_('User Domains List'),
|
_('User Domains List'),
|
||||||
_(
|
_('Enter domain names separated by commas, spaces, or newlines. You can add comments using //'),
|
||||||
'Enter domain names separated by comma, space or newline. You can add comments after //',
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
o.placeholder =
|
o.placeholder = 'example.com, sub.example.com\n// Social networks\ndomain.com test.com // personal domains';
|
||||||
'example.com, sub.example.com\n// Social networks\ndomain.com test.com // personal domains';
|
|
||||||
o.depends('user_domain_list_type', 'text');
|
o.depends('user_domain_list_type', 'text');
|
||||||
o.rows = 8;
|
o.rows = 8;
|
||||||
o.rmempty = false;
|
o.rmempty = false;
|
||||||
@@ -306,9 +287,7 @@ function createSectionContent(section) {
|
|||||||
const domains = main.parseValueList(value);
|
const domains = main.parseValueList(value);
|
||||||
|
|
||||||
if (!domains.length) {
|
if (!domains.length) {
|
||||||
return _(
|
return _('At least one valid domain must be specified. Comments-only content is not allowed.');
|
||||||
'At least one valid domain must be specified. Comments-only content is not allowed.',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const {valid, results} = main.bulkValidate(domains, row => main.validateDomain(row, true));
|
const {valid, results} = main.bulkValidate(domains, row => main.validateDomain(row, true));
|
||||||
@@ -324,110 +303,11 @@ function createSectionContent(section) {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
o = section.option(
|
|
||||||
form.Flag,
|
|
||||||
'local_domain_lists_enabled',
|
|
||||||
_('Local Domain Lists'),
|
|
||||||
_('Use the list from the router filesystem'),
|
|
||||||
);
|
|
||||||
o.default = '0';
|
|
||||||
o.rmempty = false;
|
|
||||||
|
|
||||||
o = section.option(
|
|
||||||
form.DynamicList,
|
|
||||||
'local_domain_lists',
|
|
||||||
_('Local Domain List Paths'),
|
|
||||||
_('Enter the list file path'),
|
|
||||||
);
|
|
||||||
o.placeholder = '/path/file.lst';
|
|
||||||
o.depends('local_domain_lists_enabled', '1');
|
|
||||||
o.rmempty = false;
|
|
||||||
o.validate = function (section_id, value) {
|
|
||||||
// Optional
|
|
||||||
if (!value || value.length === 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const validation = main.validatePath(value);
|
|
||||||
|
|
||||||
if (validation.valid) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return validation.message;
|
|
||||||
};
|
|
||||||
|
|
||||||
o = section.option(
|
|
||||||
form.Flag,
|
|
||||||
'remote_domain_lists_enabled',
|
|
||||||
_('Remote Domain Lists'),
|
|
||||||
_('Download and use domain lists from remote URLs'),
|
|
||||||
);
|
|
||||||
o.default = '0';
|
|
||||||
o.rmempty = false;
|
|
||||||
|
|
||||||
o = section.option(
|
|
||||||
form.DynamicList,
|
|
||||||
'remote_domain_lists',
|
|
||||||
_('Remote Domain URLs'),
|
|
||||||
_('Enter full URLs starting with http:// or https://'),
|
|
||||||
);
|
|
||||||
o.placeholder = 'URL';
|
|
||||||
o.depends('remote_domain_lists_enabled', '1');
|
|
||||||
o.rmempty = false;
|
|
||||||
o.validate = function (section_id, value) {
|
|
||||||
// Optional
|
|
||||||
if (!value || value.length === 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const validation = main.validateUrl(value);
|
|
||||||
|
|
||||||
if (validation.valid) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return validation.message;
|
|
||||||
};
|
|
||||||
|
|
||||||
o = section.option(
|
|
||||||
form.Flag,
|
|
||||||
'local_subnet_lists_enabled',
|
|
||||||
_('Local Subnet Lists'),
|
|
||||||
_('Use the list from the router filesystem'),
|
|
||||||
);
|
|
||||||
o.default = '0';
|
|
||||||
o.rmempty = false;
|
|
||||||
|
|
||||||
o = section.option(
|
|
||||||
form.DynamicList,
|
|
||||||
'local_subnet_lists',
|
|
||||||
_('Local Subnet List Paths'),
|
|
||||||
_('Enter the list file path'),
|
|
||||||
);
|
|
||||||
o.placeholder = '/path/file.lst';
|
|
||||||
o.depends('local_subnet_lists_enabled', '1');
|
|
||||||
o.rmempty = false;
|
|
||||||
o.validate = function (section_id, value) {
|
|
||||||
// Optional
|
|
||||||
if (!value || value.length === 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const validation = main.validatePath(value);
|
|
||||||
|
|
||||||
if (validation.valid) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return validation.message;
|
|
||||||
};
|
|
||||||
|
|
||||||
o = section.option(
|
o = section.option(
|
||||||
form.ListValue,
|
form.ListValue,
|
||||||
'user_subnet_list_type',
|
'user_subnet_list_type',
|
||||||
_('User Subnet List Type'),
|
_('User Subnet List Type'),
|
||||||
_('Select how to add your custom subnets'),
|
_('Select the list type for adding custom subnets'),
|
||||||
);
|
);
|
||||||
o.value('disabled', _('Disabled'));
|
o.value('disabled', _('Disabled'));
|
||||||
o.value('dynamic', _('Dynamic List'));
|
o.value('dynamic', _('Dynamic List'));
|
||||||
@@ -439,9 +319,7 @@ function createSectionContent(section) {
|
|||||||
form.DynamicList,
|
form.DynamicList,
|
||||||
'user_subnets',
|
'user_subnets',
|
||||||
_('User Subnets'),
|
_('User Subnets'),
|
||||||
_(
|
_('Enter subnets in CIDR notation (e.g. 103.21.244.0/22) or single IP addresses'),
|
||||||
'Enter subnets in CIDR notation (example: 103.21.244.0/22) or single IP addresses',
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
o.placeholder = 'IP or subnet';
|
o.placeholder = 'IP or subnet';
|
||||||
o.depends('user_subnet_list_type', 'dynamic');
|
o.depends('user_subnet_list_type', 'dynamic');
|
||||||
@@ -466,7 +344,8 @@ function createSectionContent(section) {
|
|||||||
'user_subnets_text',
|
'user_subnets_text',
|
||||||
_('User Subnets List'),
|
_('User Subnets List'),
|
||||||
_(
|
_(
|
||||||
'Enter subnets in CIDR notation or single IP addresses, separated by comma, space or newline. You can add comments after //',
|
'Enter subnets in CIDR notation or single IP addresses, separated by commas, spaces, or newlines. ' +
|
||||||
|
'You can add comments using //'
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
o.placeholder =
|
o.placeholder =
|
||||||
@@ -483,9 +362,7 @@ function createSectionContent(section) {
|
|||||||
const subnets = main.parseValueList(value);
|
const subnets = main.parseValueList(value);
|
||||||
|
|
||||||
if (!subnets.length) {
|
if (!subnets.length) {
|
||||||
return _(
|
return _('At least one valid subnet or IP must be specified. Comments-only content is not allowed.');
|
||||||
'At least one valid subnet or IP must be specified. Comments-only content is not allowed.',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const {valid, results} = main.bulkValidate(subnets, main.validateSubnet);
|
const {valid, results} = main.bulkValidate(subnets, main.validateSubnet);
|
||||||
@@ -502,23 +379,82 @@ function createSectionContent(section) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
o = section.option(
|
o = section.option(
|
||||||
form.Flag,
|
form.DynamicList,
|
||||||
'remote_subnet_lists_enabled',
|
'local_domain_lists',
|
||||||
_('Remote Subnet Lists'),
|
_('Local Domain Lists'),
|
||||||
_('Download and use subnet lists from remote URLs'),
|
_('Specify the path to the list file located on the router filesystem'),
|
||||||
);
|
);
|
||||||
o.default = '0';
|
o.placeholder = '/path/file.lst';
|
||||||
o.rmempty = false;
|
o.rmempty = true;
|
||||||
|
o.validate = function (section_id, value) {
|
||||||
|
// Optional
|
||||||
|
if (!value || value.length === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const validation = main.validatePath(value);
|
||||||
|
|
||||||
|
if (validation.valid) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return validation.message;
|
||||||
|
};
|
||||||
|
|
||||||
|
o = section.option(
|
||||||
|
form.DynamicList,
|
||||||
|
'local_subnet_lists',
|
||||||
|
_('Local Subnet Lists'),
|
||||||
|
_('Specify the path to the list file located on the router filesystem'),
|
||||||
|
);
|
||||||
|
o.placeholder = '/path/file.lst';
|
||||||
|
o.rmempty = true;
|
||||||
|
o.validate = function (section_id, value) {
|
||||||
|
// Optional
|
||||||
|
if (!value || value.length === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const validation = main.validatePath(value);
|
||||||
|
|
||||||
|
if (validation.valid) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return validation.message;
|
||||||
|
};
|
||||||
|
|
||||||
|
o = section.option(
|
||||||
|
form.DynamicList,
|
||||||
|
'remote_domain_lists',
|
||||||
|
_('Remote Domain Lists'),
|
||||||
|
_('Specify remote URLs to download and use domain lists'),
|
||||||
|
);
|
||||||
|
o.placeholder = 'https://example.com/domains.srs';
|
||||||
|
o.rmempty = true;
|
||||||
|
o.validate = function (section_id, value) {
|
||||||
|
// Optional
|
||||||
|
if (!value || value.length === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const validation = main.validateUrl(value);
|
||||||
|
|
||||||
|
if (validation.valid) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return validation.message;
|
||||||
|
};
|
||||||
|
|
||||||
o = section.option(
|
o = section.option(
|
||||||
form.DynamicList,
|
form.DynamicList,
|
||||||
'remote_subnet_lists',
|
'remote_subnet_lists',
|
||||||
_('Remote Subnet URLs'),
|
_('Remote Subnet Lists'),
|
||||||
_('Enter full URLs starting with http:// or https://'),
|
_('Specify remote URLs to download and use subnet lists'),
|
||||||
);
|
);
|
||||||
o.placeholder = 'URL';
|
o.placeholder = 'https://example.com/subnets.srs';
|
||||||
o.depends('remote_subnet_lists_enabled', '1');
|
o.rmempty = true;
|
||||||
o.rmempty = false;
|
|
||||||
o.validate = function (section_id, value) {
|
o.validate = function (section_id, value) {
|
||||||
// Optional
|
// Optional
|
||||||
if (!value || value.length === 0) {
|
if (!value || value.length === 0) {
|
||||||
@@ -538,10 +474,10 @@ function createSectionContent(section) {
|
|||||||
form.DynamicList,
|
form.DynamicList,
|
||||||
'fully_routed_ips',
|
'fully_routed_ips',
|
||||||
_('Fully Routed IPs'),
|
_('Fully Routed IPs'),
|
||||||
_('Specify local IP addresses whose traffic will always be routed through the configured route'),
|
_('Specify local IP addresses or subnets whose traffic will always be routed through the configured route'),
|
||||||
);
|
);
|
||||||
o.placeholder = 'IP';
|
o.placeholder = '192.168.1.2 or 192.168.1.0/24';
|
||||||
o.rmempty = false;
|
o.rmempty = true;
|
||||||
o.validate = function (section_id, value) {
|
o.validate = function (section_id, value) {
|
||||||
// Optional
|
// Optional
|
||||||
if (!value || value.length === 0) {
|
if (!value || value.length === 0) {
|
||||||
|
|||||||
@@ -211,9 +211,10 @@ validate_service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
process_validate_service() {
|
process_validate_service() {
|
||||||
local community_lists_enabled
|
local section="$1"
|
||||||
config_get_bool community_lists_enabled "$section" "community_lists_enabled" 0
|
local community_lists
|
||||||
if [ "$community_lists_enabled" -eq 1 ]; then
|
config_get community_lists "$section" "community_lists"
|
||||||
|
if [ -n "$community_lists" ]; then
|
||||||
config_list_foreach "$section" "community_lists" validate_service
|
config_list_foreach "$section" "community_lists" validate_service
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -404,10 +405,10 @@ dnsmasq_restore() {
|
|||||||
|
|
||||||
add_cron_job() {
|
add_cron_job() {
|
||||||
## Future: make a check so that it doesn't recreate many times
|
## Future: make a check so that it doesn't recreate many times
|
||||||
local community_lists_enabled remote_domain_lists_enabled remote_subnet_lists_enabled update_interval
|
local community_lists remote_domain_lists remote_subnet_lists update_interval
|
||||||
config_get community_lists_enabled "$section" "community_lists_enabled"
|
config_get community_lists "$section" "community_lists"
|
||||||
config_get remote_domain_lists_enabled "$section" "remote_domain_lists_enabled"
|
config_get remote_domain_lists "$section" "remote_domain_lists"
|
||||||
config_get remote_subnet_lists_enabled "$section" "remote_subnet_lists_enabled"
|
config_get remote_subnet_lists "$section" "remote_subnet_lists"
|
||||||
config_get update_interval "settings" "update_interval"
|
config_get update_interval "settings" "update_interval"
|
||||||
|
|
||||||
case "$update_interval" in
|
case "$update_interval" in
|
||||||
@@ -432,9 +433,9 @@ add_cron_job() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "$community_lists_enabled" -eq 1 ] ||
|
if [ -n "$community_lists" ] ||
|
||||||
[ "$remote_domain_lists_enabled" -eq 1 ] ||
|
[ -n "$remote_domain_lists" ] ||
|
||||||
[ "$remote_subnet_lists_enabled" -eq 1 ]; then
|
[ -n "$remote_subnet_lists" ]; then
|
||||||
remove_cron_job
|
remove_cron_job
|
||||||
crontab -l | {
|
crontab -l | {
|
||||||
cat
|
cat
|
||||||
@@ -720,7 +721,7 @@ sing_box_configure_route() {
|
|||||||
config=$(sing_box_cm_configure_route "$config" "$SB_DIRECT_OUTBOUND_TAG" true "$SB_DNS_SERVER_TAG")
|
config=$(sing_box_cm_configure_route "$config" "$SB_DIRECT_OUTBOUND_TAG" true "$SB_DNS_SERVER_TAG")
|
||||||
|
|
||||||
local sniff_inbounds
|
local sniff_inbounds
|
||||||
sniff_inbounds=$(comma_string_to_json_array "$SB_TPROXY_INBOUND_TAG,$SB_DNS_INBOUND_TAG,$SB_MIXED_INBOUND_TAG")
|
sniff_inbounds=$(comma_string_to_json_array "$SB_TPROXY_INBOUND_TAG,$SB_DNS_INBOUND_TAG")
|
||||||
config=$(sing_box_cm_sniff_route_rule "$config" "inbound" "$sniff_inbounds")
|
config=$(sing_box_cm_sniff_route_rule "$config" "inbound" "$sniff_inbounds")
|
||||||
|
|
||||||
config=$(sing_box_cm_add_hijack_dns_route_rule "$config" "protocol" "dns")
|
config=$(sing_box_cm_add_hijack_dns_route_rule "$config" "protocol" "dns")
|
||||||
@@ -803,20 +804,21 @@ exclude_source_ip_from_routing_handler() {
|
|||||||
configure_routing_for_section_lists() {
|
configure_routing_for_section_lists() {
|
||||||
local section="$1"
|
local section="$1"
|
||||||
|
|
||||||
|
log "Configuring routing for '$section' section"
|
||||||
if ! section_has_enabled_lists "$section"; then
|
if ! section_has_enabled_lists "$section"; then
|
||||||
log "Section '$section' does not have any enabled list, skipping..." "warn"
|
log "Section '$section' does not have any enabled list, skipping..." "warn"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local community_lists_enabled user_domain_list_type local_domain_lists_enabled remote_domain_lists_enabled \
|
local community_lists user_domain_list_type user_subnet_list_type local_domain_lists local_subnet_lists \
|
||||||
user_subnet_list_type local_subnet_lists_enabled remote_subnet_lists_enabled section_mode_type route_rule_tag
|
remote_domain_lists remote_subnet_lists section_mode_type route_rule_tag
|
||||||
config_get_bool community_lists_enabled "$section" "community_lists_enabled" 0
|
config_get_bool community_lists "$section" "community_lists"
|
||||||
config_get user_domain_list_type "$section" "user_domain_list_type" "disabled"
|
config_get user_domain_list_type "$section" "user_domain_list_type" "disabled"
|
||||||
config_get_bool local_domain_lists_enabled "$section" "local_domain_lists_enabled" 0
|
|
||||||
config_get_bool remote_domain_lists_enabled "$section" "remote_domain_lists_enabled" 0
|
|
||||||
config_get user_subnet_list_type "$section" "user_subnet_list_type" "disabled"
|
config_get user_subnet_list_type "$section" "user_subnet_list_type" "disabled"
|
||||||
config_get_bool local_subnet_lists_enabled "$section" "local_subnet_lists_enabled" 0
|
config_get_bool local_domain_lists "$section" "local_domain_lists"
|
||||||
config_get_bool remote_subnet_lists_enabled "$section" "remote_subnet_lists_enabled" 0
|
config_get_bool local_subnet_lists "$section" "local_subnet_lists"
|
||||||
|
config_get_bool remote_domain_lists "$section" "remote_domain_lists"
|
||||||
|
config_get_bool remote_subnet_lists "$section" "remote_subnet_lists"
|
||||||
config_get section_mode_type "$section" "mode"
|
config_get section_mode_type "$section" "mode"
|
||||||
|
|
||||||
if [ "$section_mode_type" = "block" ]; then
|
if [ "$section_mode_type" = "block" ]; then
|
||||||
@@ -827,7 +829,7 @@ configure_routing_for_section_lists() {
|
|||||||
config=$(sing_box_cm_add_route_rule "$config" "$route_rule_tag" "$SB_TPROXY_INBOUND_TAG" "$outbound_tag")
|
config=$(sing_box_cm_add_route_rule "$config" "$route_rule_tag" "$SB_TPROXY_INBOUND_TAG" "$outbound_tag")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$community_lists_enabled" -eq 1 ]; then
|
if [ -n "$community_lists" ]; then
|
||||||
log "Processing community list routing rules for '$section' section"
|
log "Processing community list routing rules for '$section' section"
|
||||||
config_list_foreach "$section" "community_lists" configure_community_list_handler "$section" "$route_rule_tag"
|
config_list_foreach "$section" "community_lists" configure_community_list_handler "$section" "$route_rule_tag"
|
||||||
fi
|
fi
|
||||||
@@ -838,30 +840,30 @@ configure_routing_for_section_lists() {
|
|||||||
configure_user_domain_or_subnets_list "$section" "domains" "$route_rule_tag"
|
configure_user_domain_or_subnets_list "$section" "domains" "$route_rule_tag"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$local_domain_lists_enabled" -eq 1 ]; then
|
|
||||||
log "Processing local domains routing rules for '$section' section"
|
|
||||||
configure_local_domain_or_subnet_lists "$section" "domains" "$route_rule_tag"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$remote_domain_lists_enabled" -eq 1 ]; then
|
|
||||||
log "Processing remote domains routing rules for '$section' section"
|
|
||||||
prepare_common_ruleset "$section" "domains" "$route_rule_tag"
|
|
||||||
config_list_foreach "$section" "remote_domain_lists" configure_remote_domain_or_subnet_list_handler \
|
|
||||||
"domains" "$section" "$route_rule_tag"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$user_subnet_list_type" != "disabled" ]; then
|
if [ "$user_subnet_list_type" != "disabled" ]; then
|
||||||
log "Processing user subnets routing rules for '$section' section"
|
log "Processing user subnets routing rules for '$section' section"
|
||||||
prepare_common_ruleset "$section" "subnets" "$route_rule_tag"
|
prepare_common_ruleset "$section" "subnets" "$route_rule_tag"
|
||||||
configure_user_domain_or_subnets_list "$section" "subnets" "$route_rule_tag"
|
configure_user_domain_or_subnets_list "$section" "subnets" "$route_rule_tag"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$local_subnet_lists_enabled" -eq 1 ]; then
|
if [ -n "$local_domain_lists" ]; then
|
||||||
|
log "Processing local domains routing rules for '$section' section"
|
||||||
|
configure_local_domain_or_subnet_lists "$section" "domains" "$route_rule_tag"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$local_subnet_lists" ]; then
|
||||||
log "Processing local subnets routing rules for '$section' section"
|
log "Processing local subnets routing rules for '$section' section"
|
||||||
configure_local_domain_or_subnet_lists "$section" "subnets" "$route_rule_tag"
|
configure_local_domain_or_subnet_lists "$section" "subnets" "$route_rule_tag"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$remote_subnet_lists_enabled" -eq 1 ]; then
|
if [ -n "$remote_domain_lists" ]; then
|
||||||
|
log "Processing remote domains routing rules for '$section' section"
|
||||||
|
prepare_common_ruleset "$section" "domains" "$route_rule_tag"
|
||||||
|
config_list_foreach "$section" "remote_domain_lists" configure_remote_domain_or_subnet_list_handler \
|
||||||
|
"domains" "$section" "$route_rule_tag"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$remote_subnet_lists" ]; then
|
||||||
log "Processing remote subnets routing rules for '$section' section"
|
log "Processing remote subnets routing rules for '$section' section"
|
||||||
prepare_common_ruleset "$section" "subnets" "$route_rule_tag"
|
prepare_common_ruleset "$section" "subnets" "$route_rule_tag"
|
||||||
config_list_foreach "$section" "remote_subnet_lists" configure_remote_domain_or_subnet_list_handler \
|
config_list_foreach "$section" "remote_subnet_lists" configure_remote_domain_or_subnet_list_handler \
|
||||||
@@ -1130,9 +1132,9 @@ sing_box_config_check() {
|
|||||||
|
|
||||||
import_community_subnet_lists() {
|
import_community_subnet_lists() {
|
||||||
local section="$1"
|
local section="$1"
|
||||||
local community_lists_enabled
|
local community_lists
|
||||||
config_get_bool community_lists_enabled "$section" "community_lists_enabled" 0
|
config_get community_lists "$section" "community_lists"
|
||||||
if [ "$community_lists_enabled" -eq 1 ]; then
|
if [ -n "$community_lists" ]; then
|
||||||
log "Importing community subnet lists for '$section' section"
|
log "Importing community subnet lists for '$section' section"
|
||||||
config_list_foreach "$section" "community_lists" import_community_service_subnet_list_handler
|
config_list_foreach "$section" "community_lists" import_community_service_subnet_list_handler
|
||||||
fi
|
fi
|
||||||
@@ -1198,9 +1200,9 @@ import_community_service_subnet_list_handler() {
|
|||||||
|
|
||||||
import_domains_from_remote_domain_lists() {
|
import_domains_from_remote_domain_lists() {
|
||||||
local section="$1"
|
local section="$1"
|
||||||
local remote_domain_lists_enabled
|
local remote_domain_lists
|
||||||
config_get remote_domain_lists_enabled "$section" "remote_domain_lists_enabled"
|
config_get remote_domain_lists "$section" "remote_domain_lists"
|
||||||
if [ "$remote_domain_lists_enabled" -eq 1 ]; then
|
if [ -n "$remote_domain_lists" ]; then
|
||||||
log "Importing domains from remote domain lists for '$section' section"
|
log "Importing domains from remote domain lists for '$section' section"
|
||||||
config_list_foreach "$section" "remote_domain_lists" import_domains_from_remote_domain_list_handler "$section"
|
config_list_foreach "$section" "remote_domain_lists" import_domains_from_remote_domain_list_handler "$section"
|
||||||
fi
|
fi
|
||||||
@@ -1227,9 +1229,9 @@ import_domains_from_remote_domain_list_handler() {
|
|||||||
|
|
||||||
import_subnets_from_remote_subnet_lists() {
|
import_subnets_from_remote_subnet_lists() {
|
||||||
local section="$1"
|
local section="$1"
|
||||||
|
local remote_subnet_lists
|
||||||
config_get remote_subnet_lists_enabled "$section" "remote_subnet_lists_enabled"
|
config_get remote_subnet_lists "$section" "remote_subnet_lists"
|
||||||
if [ "$remote_subnet_lists_enabled" -eq 1 ]; then
|
if [ -n "$remote_subnet_lists" ]; then
|
||||||
log "Importing subnets from remote subnet lists for '$section' section"
|
log "Importing subnets from remote subnet lists for '$section' section"
|
||||||
config_list_foreach "$section" "remote_subnet_lists" import_subnets_from_remote_subnet_list_handler "$section"
|
config_list_foreach "$section" "remote_subnet_lists" import_subnets_from_remote_subnet_list_handler "$section"
|
||||||
fi
|
fi
|
||||||
@@ -1375,24 +1377,24 @@ block_section_exists() {
|
|||||||
|
|
||||||
section_has_enabled_lists() {
|
section_has_enabled_lists() {
|
||||||
local section="$1"
|
local section="$1"
|
||||||
local community_lists_enabled user_domain_list_type local_domain_lists_enabled remote_domain_lists_enabled \
|
local community_lists user_domain_list_type user_subnet_list_type local_domain_lists local_subnet_lists \
|
||||||
user_subnet_list_type local_subnet_lists_enabled remote_subnet_lists_enabled
|
remote_domain_lists remote_subnet_lists
|
||||||
|
|
||||||
config_get_bool community_lists_enabled "$section" "community_lists_enabled" 0
|
config_get_bool community_lists "$section" "community_lists"
|
||||||
config_get user_domain_list_type "$section" "user_domain_list_type" "disabled"
|
config_get user_domain_list_type "$section" "user_domain_list_type" "disabled"
|
||||||
config_get_bool local_domain_lists_enabled "$section" "local_domain_lists_enabled" 0
|
|
||||||
config_get_bool remote_domain_lists_enabled "$section" "remote_domain_lists_enabled" 0
|
|
||||||
config_get user_subnet_list_type "$section" "user_subnet_list_type" "disabled"
|
config_get user_subnet_list_type "$section" "user_subnet_list_type" "disabled"
|
||||||
config_get_bool local_subnet_lists_enabled "$section" "local_subnet_lists_enabled" 0
|
config_get_bool local_domain_lists "$section" "local_domain_lists"
|
||||||
config_get_bool remote_subnet_lists_enabled "$section" "remote_subnet_lists_enabled" 0
|
config_get_bool local_subnet_lists "$section" "local_subnet_lists"
|
||||||
|
config_get_bool remote_domain_lists "$section" "remote_domain_lists"
|
||||||
|
config_get_bool remote_subnet_lists "$section" "remote_subnet_lists"
|
||||||
|
|
||||||
if [ "$community_lists_enabled" -ne 0 ] ||
|
if [ -n "$community_lists" ] ||
|
||||||
[ "$user_domain_list_type" != "disabled" ] ||
|
[ "$user_domain_list_type" != "disabled" ] ||
|
||||||
[ "$local_domain_lists_enabled" -ne 0 ] ||
|
|
||||||
[ "$remote_domain_lists_enabled" -ne 0 ] ||
|
|
||||||
[ "$user_subnet_list_type" != "disabled" ] ||
|
[ "$user_subnet_list_type" != "disabled" ] ||
|
||||||
[ "$local_subnet_lists_enabled" -ne 0 ] ||
|
[ -n "$local_domain_lists" ] ||
|
||||||
[ "$remote_subnet_lists_enabled" -ne 0 ]; then
|
[ -n "$local_subnet_lists" ] ||
|
||||||
|
[ -n "$remote_domain_lists" ] ||
|
||||||
|
[ -n "$remote_subnet_lists" ]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -38,9 +38,7 @@ SB_TPROXY_INBOUND_PORT=1602
|
|||||||
SB_DNS_INBOUND_TAG="dns-in"
|
SB_DNS_INBOUND_TAG="dns-in"
|
||||||
SB_DNS_INBOUND_ADDRESS="127.0.0.42"
|
SB_DNS_INBOUND_ADDRESS="127.0.0.42"
|
||||||
SB_DNS_INBOUND_PORT=53
|
SB_DNS_INBOUND_PORT=53
|
||||||
SB_MIXED_INBOUND_TAG="mixed-in"
|
|
||||||
SB_MIXED_INBOUND_ADDRESS="0.0.0.0" # TODO(ampetelin): maybe to determine address?
|
SB_MIXED_INBOUND_ADDRESS="0.0.0.0" # TODO(ampetelin): maybe to determine address?
|
||||||
SB_MIXED_INBOUND_PORT=2080
|
|
||||||
SB_SERVICE_MIXED_INBOUND_TAG="service-mixed-in"
|
SB_SERVICE_MIXED_INBOUND_TAG="service-mixed-in"
|
||||||
SB_SERVICE_MIXED_INBOUND_ADDRESS="127.0.0.1"
|
SB_SERVICE_MIXED_INBOUND_ADDRESS="127.0.0.1"
|
||||||
SB_SERVICE_MIXED_INBOUND_PORT=4534
|
SB_SERVICE_MIXED_INBOUND_PORT=4534
|
||||||
|
|||||||
Reference in New Issue
Block a user