diff --git a/htdocs/luci-static/resources/view/homeproxy/client.js b/htdocs/luci-static/resources/view/homeproxy/client.js index acc1c164..a28af144 100644 --- a/htdocs/luci-static/resources/view/homeproxy/client.js +++ b/htdocs/luci-static/resources/view/homeproxy/client.js @@ -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. 300 is used by default.')); + so.datatype = 'uinteger'; + so.placeholder = '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; diff --git a/htdocs/luci-static/resources/view/homeproxy/server.js b/htdocs/luci-static/resources/view/homeproxy/server.js index 21bb3f92..6897915c 100644 --- a/htdocs/luci-static/resources/view/homeproxy/server.js +++ b/htdocs/luci-static/resources/view/homeproxy/server.js @@ -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. 300 is used by default.')); + o.datatype = 'uinteger'; + o.placeholder = '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; diff --git a/root/etc/config/homeproxy b/root/etc/config/homeproxy index d8438f0a..f607cda1 100644 --- a/root/etc/config/homeproxy +++ b/root/etc/config/homeproxy @@ -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' diff --git a/root/etc/homeproxy/scripts/generate_client.uc b/root/etc/homeproxy/scripts/generate_client.uc index bd72628d..8958435e 100755 --- a/root/etc/homeproxy/scripts/generate_client.uc +++ b/root/etc/homeproxy/scripts/generate_client.uc @@ -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'; @@ -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 @@ -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') }); @@ -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'), diff --git a/root/etc/homeproxy/scripts/generate_server.uc b/root/etc/homeproxy/scripts/generate_server.uc index 077f6898..7e9b735b 100755 --- a/root/etc/homeproxy/scripts/generate_server.uc +++ b/root/etc/homeproxy/scripts/generate_server.uc @@ -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,