Skip to content

Commit

Permalink
feat(generator): add udp_timeout option
Browse files Browse the repository at this point in the history
  • Loading branch information
muink committed Aug 22, 2024
1 parent 345911e commit 5991527
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions htdocs/luci-static/resources/view/homeproxy/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@ return view.extend({
so.depends('tcpip_stack', 'gvisor');
so.rmempty = false;

so = ss.option(form.Value, 'udp_timeout', _('UDP NAT expiration time'),
_('In seconds. <code>5m</code> is used by default.'));
so.datatype = 'uinteger';
so.default = '300';
so.depends('homeproxy.config.proxy_mode', 'redirect_tproxy');
so.depends('homeproxy.config.proxy_mode', 'redirect_tun');
so.depends('homeproxy.config.proxy_mode', 'tun');
so.rmempty = false;

so = ss.option(form.Flag, 'bypass_cn_traffic', _('Bypass CN traffic'),
_('Bypass mainland China traffic via firewall rules by default.'));
so.default = so.disabled;
Expand Down
7 changes: 7 additions & 0 deletions htdocs/luci-static/resources/view/homeproxy/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,13 @@ return view.extend({
o.depends({'network': 'tcp', '!reverse': true});
o.modalonly = true;

o = s.option(form.Value, 'udp_timeout', _('UDP NAT expiration time'),
_('In seconds. <code>5m</code> is used by default.'));
o.datatype = 'uinteger';
o.default = '300';
o.depends({'network': 'tcp', '!reverse': true});
o.modalonly = true;

o = s.option(form.Flag, 'sniff_override', _('Override destination'),
_('Override the connection destination address with the sniffed domain.'));
o.rmempty = false;
Expand Down
1 change: 1 addition & 0 deletions root/etc/config/homeproxy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ config homeproxy 'infra'
option tproxy_port '5332'
option dns_port '5333'
option china_dns_port '5334'
option udp_timeout '300'
option tun_name 'singtun0'
option tun_addr4 '172.19.0.1/30'
option tun_addr6 'fdfe:dcba:9876::1/126'
Expand Down
8 changes: 7 additions & 1 deletion root/etc/homeproxy/scripts/generate_client.uc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ const cache_file_store_rdrc = uci.get(uciconfig, uciexp, 'cache_file_store_rdrc'
const mixed_port = uci.get(uciconfig, uciinfra, 'mixed_port') || '5330';
let self_mark, redirect_port, tproxy_port,
tun_name, tun_addr4, tun_addr6, tun_mtu, tun_gso,
tcpip_stack, endpoint_independent_nat;
tcpip_stack, endpoint_independent_nat, udp_timeout;
udp_timeout = uci.get(uciconfig, 'infra', 'udp_timeout') || '300';
if (routing_mode === 'custom')
udp_timeout = uci.get(uciconfig, uciroutingsetting, 'udp_timeout') || '300';
if (match(proxy_mode, /redirect/)) {
self_mark = uci.get(uciconfig, 'infra', 'self_mark') || '100';
redirect_port = uci.get(uciconfig, 'infra', 'redirect_port') || '5331';
Expand Down Expand Up @@ -486,6 +489,7 @@ push(config.inbounds, {
tag: 'mixed-in',
listen: '::',
listen_port: int(mixed_port),
udp_timeout: udp_timeout + 's',
sniff: true,
sniff_override_destination: (sniff_override === '1'),
set_system_proxy: false
Expand All @@ -509,6 +513,7 @@ if (match(proxy_mode, /tproxy/))
listen: '::',
listen_port: int(tproxy_port),
network: 'udp',
udp_timeout: udp_timeout + 's',
sniff: true,
sniff_override_destination: (sniff_override === '1')
});
Expand All @@ -524,6 +529,7 @@ if (match(proxy_mode, /tun/))
gso: (tun_gso === '1'),
auto_route: false,
endpoint_independent_nat: strToBool(endpoint_independent_nat),
udp_timeout: udp_timeout + 's',
stack: tcpip_stack,
sniff: true,
sniff_override_destination: (sniff_override === '1'),
Expand Down
1 change: 1 addition & 0 deletions root/etc/homeproxy/scripts/generate_server.uc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ uci.foreach(uciconfig, uciserver, (cfg) => {
tcp_fast_open: strToBool(cfg.tcp_fast_open),
tcp_multi_path: strToBool(cfg.tcp_multi_path),
udp_fragment: strToBool(cfg.udp_fragment),
udp_timeout: cfg.udp_timeout ? (cfg.udp_timeout + 's') : null,
sniff: true,
sniff_override_destination: (cfg.sniff_override === '1'),
domain_strategy: cfg.domain_strategy,
Expand Down

0 comments on commit 5991527

Please sign in to comment.