Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typo and add some options #160

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>300</code> is used by default.'));
so.datatype = 'uinteger';
so.default = '300';
muink marked this conversation as resolved.
Show resolved Hide resolved
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
12 changes: 12 additions & 0 deletions htdocs/luci-static/resources/view/homeproxy/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,18 @@ function renderNodeSettings(section, data, features, main_node, routing_mode) {
o.datatype = 'port';
o.depends('type', 'direct');

o = s.option(form.Flag, 'proxy_protocol', _('Proxy protocol'),
_('Write proxy protocol in the connection header.'));
o.depends('type', 'direct');
o.modalonly = true;

o = s.option(form.ListValue, 'proxy_protocol_version', _('Proxy protocol version'));
o.value('1', _('v1'));
o.value('2', _('v2'));
o.default = '2';
o.depends('proxy_protocol', '1');
o.modalonly = true;

/* Hysteria (2) config start */
o = s.option(form.ListValue, 'hysteria_protocol', _('Protocol'));
o.value('udp');
Expand Down
9 changes: 8 additions & 1 deletion htdocs/luci-static/resources/view/homeproxy/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ return view.extend({
o.depends('type', 'tuic');
o.modalonly = true;

o = s.option(form.ListValue, 'tuic_auth_timeout', _('Auth timeout'),
o = s.option(form.Value, 'tuic_auth_timeout', _('Auth timeout'),
_('How long the server should wait for the client to send the authentication command (in seconds).'));
o.datatype = 'uinteger';
o.default = '3';
Expand Down 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>300</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 ''
option tun_name 'singtun0'
option tun_addr4 '172.19.0.1/30'
option tun_addr6 'fdfe:dcba:9876::1/126'
Expand Down
12 changes: 11 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');
if (routing_mode === 'custom')
udp_timeout = uci.get(uciconfig, uciroutingsetting, 'udp_timeout');
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 @@ -160,6 +163,10 @@ function generate_outbound(node) {
/* Direct */
override_address: node.override_address,
override_port: strToInt(node.override_port),
proxy_protocol: (node.proxy_protocol === '1') ? {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm according to the documentation this field aceepts a int value instead of a object, do i miss anything?
https://sing-box.sagernet.org/configuration/outbound/direct/#structure

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I made a mistake. The new patch has been committed
410c10e

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for quick fix

enabled: true,
version: strToInt(node.proxy_protocol_version)
} : null,
/* Hysteria (2) */
up_mbps: strToInt(node.hysteria_up_mbps),
down_mbps: strToInt(node.hysteria_down_mbps),
Expand Down Expand Up @@ -482,6 +489,7 @@ push(config.inbounds, {
tag: 'mixed-in',
listen: '::',
listen_port: int(mixed_port),
udp_timeout: udp_timeout ? (udp_timeout + 's') : null,
sniff: true,
sniff_override_destination: (sniff_override === '1'),
set_system_proxy: false
Expand All @@ -505,6 +513,7 @@ if (match(proxy_mode, /tproxy/))
listen: '::',
listen_port: int(tproxy_port),
network: 'udp',
udp_timeout: udp_timeout ? (udp_timeout + 's') : null,
sniff: true,
sniff_override_destination: (sniff_override === '1')
});
Expand All @@ -520,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 ? (udp_timeout + 's') : null,
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