Skip to content

Commit

Permalink
chore(client): refine routing port settings
Browse files Browse the repository at this point in the history
  • Loading branch information
1715173329 authored Sep 3, 2024
1 parent 1060b86 commit e4c3a5b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
7 changes: 2 additions & 5 deletions htdocs/luci-static/resources/view/homeproxy/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,11 @@ return view.extend({

o = s.taboption('routing', form.Value, 'routing_port', _('Routing ports'),
_('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.default = 'common';
o.rmempty = false;
o.validate = function(section_id, value) {
if (section_id && value !== 'all' && value !== 'common') {
if (!value)
return _('Expecting: %s').format(_('valid port value'));
if (section_id && value && value !== 'common') {

var ports = [];
for (var i of value.split(',')) {
Expand Down
12 changes: 6 additions & 6 deletions root/etc/homeproxy/scripts/firewall_post.ut
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if (routing_mode !== 'custom') {
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')
routing_port = uci.get(cfgname, 'infra', 'common_port') || '22,53,80,143,443,465,587,853,873,993,995,8080,8443,9418';

Expand Down Expand Up @@ -222,7 +222,7 @@ set homeproxy_wan_direct_addr_v6 {
}
{% endif /* ipv6_support */ %}

{% if (routing_port !== 'all'): %}
{% if (routing_port): %}
set homeproxy_routing_port {
type inet_service
flags interval
Expand All @@ -248,7 +248,7 @@ chain homeproxy_redirect_proxy {
}

chain homeproxy_redirect_proxy_port {
{% if (routing_port !== 'all'): %}
{% if (routing_port): %}
tcp dport != @homeproxy_routing_port counter return
{% endif %}
goto homeproxy_redirect_proxy
Expand Down Expand Up @@ -363,14 +363,14 @@ chain homeproxy_mangle_tproxy {
}

chain homeproxy_mangle_tproxy_port {
{% if (routing_port !== 'all'): %}
{% if (routing_port): %}
udp dport != @homeproxy_routing_port counter return
{% endif %}
goto homeproxy_mangle_tproxy
}

chain homeproxy_mangle_mark {
{% if (routing_port !== 'all'): %}
{% if (routing_port): %}
udp dport != @homeproxy_routing_port counter return
{% endif %}
meta l4proto udp mark set {{ tproxy_mark }} counter accept
Expand Down Expand Up @@ -557,7 +557,7 @@ chain homeproxy_mangle_lanac {
}

chain homeproxy_mangle_tun_mark {
{% if (routing_port !== 'all'): %}
{% if (routing_port): %}
{% if (proxy_mode === 'tun'): %}
tcp dport != @homeproxy_routing_port counter return
{% endif /* proxy_mode */ %}
Expand Down
5 changes: 5 additions & 0 deletions root/etc/uci-defaults/luci-homeproxy-migration
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ elif echo "$china_dns_server" | grep -q ","; then
uci -q add_list "homeproxy.config.china_dns_server"="$dns"
done
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"

exit 0

0 comments on commit e4c3a5b

Please sign in to comment.