parent
be3eb92ab4
commit
7e10e34ee1
@ -106,6 +106,17 @@ return view.extend({
|
|||||||
var features = data[1],
|
var features = data[1],
|
||||||
hosts = data[2]?.hosts;
|
hosts = data[2]?.hosts;
|
||||||
|
|
||||||
|
/* Cache all configured proxy nodes, they will be called multiple times */
|
||||||
|
var proxy_nodes = {};
|
||||||
|
uci.sections(data[0], 'node', (res) => {
|
||||||
|
var nodeaddr = ((res.type === 'direct') ? res.override_address : res.address) || '',
|
||||||
|
nodeport = ((res.type === 'direct') ? res.override_port : res.port) || '';
|
||||||
|
|
||||||
|
proxy_nodes[res['.name']] =
|
||||||
|
String.format('[%s] %s', res.type, res.label || ((stubValidator.apply('ip6addr', nodeaddr) ?
|
||||||
|
String.format('[%s]', nodeaddr) : nodeaddr) + ':' + nodeport));
|
||||||
|
});
|
||||||
|
|
||||||
m = new form.Map('homeproxy', _('HomeProxy'),
|
m = new form.Map('homeproxy', _('HomeProxy'),
|
||||||
_('The modern OpenWrt proxy platform for ARM64/AMD64.'));
|
_('The modern OpenWrt proxy platform for ARM64/AMD64.'));
|
||||||
|
|
||||||
@ -123,17 +134,6 @@ return view.extend({
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cache all configured proxy nodes, they will be called multiple times */
|
|
||||||
var proxy_nodes = {};
|
|
||||||
uci.sections(data[0], 'node', (res) => {
|
|
||||||
var nodeaddr = ((res.type === 'direct') ? res.override_address : res.address) || '',
|
|
||||||
nodeport = ((res.type === 'direct') ? res.override_port : res.port) || '';
|
|
||||||
|
|
||||||
proxy_nodes[res['.name']] =
|
|
||||||
String.format('[%s] %s', res.type, res.label || ((stubValidator.apply('ip6addr', nodeaddr) ?
|
|
||||||
String.format('[%s]', nodeaddr) : nodeaddr) + ':' + nodeport));
|
|
||||||
});
|
|
||||||
|
|
||||||
s = m.section(form.NamedSection, 'config', 'homeproxy');
|
s = m.section(form.NamedSection, 'config', 'homeproxy');
|
||||||
|
|
||||||
s.tab('routing', _('Routing Settings'));
|
s.tab('routing', _('Routing Settings'));
|
||||||
@ -234,14 +234,11 @@ return view.extend({
|
|||||||
|
|
||||||
o = s.taboption('routing', form.Value, 'routing_port', _('Routing ports'),
|
o = s.taboption('routing', form.Value, 'routing_port', _('Routing ports'),
|
||||||
_('Specify target ports to be proxied. Multiple ports must be separated by commas.'));
|
_('Specify target ports to be proxied. Multiple ports must be separated by commas.'));
|
||||||
o.value('all', _('All ports'));
|
o.value('', _('All ports'));
|
||||||
o.value('common', _('Common ports only (bypass P2P traffic)'));
|
o.value('common', _('Common ports only (bypass P2P traffic)'));
|
||||||
o.default = 'common';
|
o.default = 'common';
|
||||||
o.rmempty = false;
|
|
||||||
o.validate = function(section_id, value) {
|
o.validate = function(section_id, value) {
|
||||||
if (section_id && value !== 'all' && value !== 'common') {
|
if (section_id && value && value !== 'common') {
|
||||||
if (!value)
|
|
||||||
return _('Expecting: %s').format(_('valid port value'));
|
|
||||||
|
|
||||||
var ports = [];
|
var ports = [];
|
||||||
for (var i of value.split(',')) {
|
for (var i of value.split(',')) {
|
||||||
@ -383,7 +380,7 @@ return view.extend({
|
|||||||
so.editable = true;
|
so.editable = true;
|
||||||
|
|
||||||
so = ss.option(form.ListValue, 'domain_strategy', _('Domain strategy'),
|
so = ss.option(form.ListValue, 'domain_strategy', _('Domain strategy'),
|
||||||
_('If set, the server domain name will be resolved to IP before connecting.<br/>dns.strategy will be used if empty.'));
|
_('If set, the server domain name will be resolved to IP before connecting.<br/>'));
|
||||||
for (var i in hp.dns_strategy)
|
for (var i in hp.dns_strategy)
|
||||||
so.value(i, hp.dns_strategy[i]);
|
so.value(i, hp.dns_strategy[i]);
|
||||||
so.modalonly = true;
|
so.modalonly = true;
|
||||||
@ -725,7 +722,7 @@ return view.extend({
|
|||||||
so.modalonly = true;
|
so.modalonly = true;
|
||||||
|
|
||||||
so = ss.option(form.ListValue, 'address_strategy', _('Address strategy'),
|
so = ss.option(form.ListValue, 'address_strategy', _('Address strategy'),
|
||||||
_('The domain strategy for resolving the domain name in the address. dns.strategy will be used if empty.'));
|
_('The domain strategy for resolving the domain name in the address.'));
|
||||||
for (var i in hp.dns_strategy)
|
for (var i in hp.dns_strategy)
|
||||||
so.value(i, hp.dns_strategy[i]);
|
so.value(i, hp.dns_strategy[i]);
|
||||||
so.modalonly = true;
|
so.modalonly = true;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0-only
|
/*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-only
|
||||||
*
|
*
|
||||||
* Copyright (C) 2022-2023 ImmortalWrt.org
|
* Copyright (C) 2022-2023 ImmortalWrt.org
|
||||||
*/
|
*/
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -50,7 +50,7 @@ if (routing_mode !== 'custom') {
|
|||||||
bypass_cn_traffic = uci.get(cfgname, 'routing', 'bypass_cn_traffic') || '0';
|
bypass_cn_traffic = uci.get(cfgname, 'routing', 'bypass_cn_traffic') || '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
let routing_port = uci.get(cfgname, 'config', 'routing_port') || 'common';
|
let routing_port = uci.get(cfgname, 'config', 'routing_port');
|
||||||
if (routing_port === 'common')
|
if (routing_port === 'common')
|
||||||
routing_port = uci.get(cfgname, 'infra', 'common_port') || '22,53,80,143,443,465,587,853,873,993,995,8080,8443,9418';
|
routing_port = uci.get(cfgname, 'infra', 'common_port') || '22,53,80,143,443,465,587,853,873,993,995,8080,8443,9418';
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ set homeproxy_wan_direct_addr_v6 {
|
|||||||
}
|
}
|
||||||
{% endif /* ipv6_support */ %}
|
{% endif /* ipv6_support */ %}
|
||||||
|
|
||||||
{% if (routing_port !== 'all'): %}
|
{% if (routing_port): %}
|
||||||
set homeproxy_routing_port {
|
set homeproxy_routing_port {
|
||||||
type inet_service
|
type inet_service
|
||||||
flags interval
|
flags interval
|
||||||
@ -248,7 +248,7 @@ chain homeproxy_redirect_proxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
chain homeproxy_redirect_proxy_port {
|
chain homeproxy_redirect_proxy_port {
|
||||||
{% if (routing_port !== 'all'): %}
|
{% if (routing_port): %}
|
||||||
tcp dport != @homeproxy_routing_port counter return
|
tcp dport != @homeproxy_routing_port counter return
|
||||||
{% endif %}
|
{% endif %}
|
||||||
goto homeproxy_redirect_proxy
|
goto homeproxy_redirect_proxy
|
||||||
@ -363,14 +363,14 @@ chain homeproxy_mangle_tproxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
chain homeproxy_mangle_tproxy_port {
|
chain homeproxy_mangle_tproxy_port {
|
||||||
{% if (routing_port !== 'all'): %}
|
{% if (routing_port): %}
|
||||||
udp dport != @homeproxy_routing_port counter return
|
udp dport != @homeproxy_routing_port counter return
|
||||||
{% endif %}
|
{% endif %}
|
||||||
goto homeproxy_mangle_tproxy
|
goto homeproxy_mangle_tproxy
|
||||||
}
|
}
|
||||||
|
|
||||||
chain homeproxy_mangle_mark {
|
chain homeproxy_mangle_mark {
|
||||||
{% if (routing_port !== 'all'): %}
|
{% if (routing_port): %}
|
||||||
udp dport != @homeproxy_routing_port counter return
|
udp dport != @homeproxy_routing_port counter return
|
||||||
{% endif %}
|
{% endif %}
|
||||||
meta l4proto udp mark set {{ tproxy_mark }} counter accept
|
meta l4proto udp mark set {{ tproxy_mark }} counter accept
|
||||||
@ -557,7 +557,7 @@ chain homeproxy_mangle_lanac {
|
|||||||
}
|
}
|
||||||
|
|
||||||
chain homeproxy_mangle_tun_mark {
|
chain homeproxy_mangle_tun_mark {
|
||||||
{% if (routing_port !== 'all'): %}
|
{% if (routing_port): %}
|
||||||
{% if (proxy_mode === 'tun'): %}
|
{% if (proxy_mode === 'tun'): %}
|
||||||
tcp dport != @homeproxy_routing_port counter return
|
tcp dport != @homeproxy_routing_port counter return
|
||||||
{% endif /* proxy_mode */ %}
|
{% endif /* proxy_mode */ %}
|
||||||
|
@ -543,7 +543,10 @@ function main() {
|
|||||||
log(sprintf('Removing node: %s.', cfg.label || cfg['name']));
|
log(sprintf('Removing node: %s.', cfg.label || cfg['name']));
|
||||||
} else {
|
} else {
|
||||||
map(keys(node_cache[cfg.grouphash][cfg['.name']]), (v) => {
|
map(keys(node_cache[cfg.grouphash][cfg['.name']]), (v) => {
|
||||||
uci.set(uciconfig, cfg['.name'], v, node_cache[cfg.grouphash][cfg['.name']][v]);
|
if (v in node_cache[cfg.grouphash][cfg['.name']])
|
||||||
|
uci.set(uciconfig, cfg['.name'], v, node_cache[cfg.grouphash][cfg['.name']][v]);
|
||||||
|
else
|
||||||
|
uci.delete(uciconfig, cfg['.name'], v);
|
||||||
});
|
});
|
||||||
node_cache[cfg.grouphash][cfg['.name']].isExisting = true;
|
node_cache[cfg.grouphash][cfg['.name']].isExisting = true;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,11 @@ elif echo "$china_dns_server" | grep -q ","; then
|
|||||||
uci -q add_list "homeproxy.config.china_dns_server"="$dns"
|
uci -q add_list "homeproxy.config.china_dns_server"="$dns"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$(uci -q get homeproxy.config.routing_port)" = "all" ]; then
|
||||||
|
uci -q delete "homeproxy.config.routing_port"
|
||||||
|
fi
|
||||||
|
|
||||||
[ -z "$(uci -q changes "homeproxy")" ] || uci -q commit "homeproxy"
|
[ -z "$(uci -q changes "homeproxy")" ] || uci -q commit "homeproxy"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user