Skip to content

Commit

Permalink
feat: add TCP Brutal support
Browse files Browse the repository at this point in the history
  • Loading branch information
1715173329 authored Dec 2, 2023
1 parent 2819190 commit de5058d
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 3 deletions.
18 changes: 18 additions & 0 deletions htdocs/luci-static/resources/view/homeproxy/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,24 @@ return view.extend({
so.default = so.disabled;
so.depends('multiplex', '1');
so.modalonly = true;

so = ss.option(form.Flag, 'multiplex_brutal', _('Enable TCP Brutal'),
_('Enable TCP Brutal congestion control algorithm'));
so.default = so.disabled;
so.depends('multiplex', '1');
so.modalonly = true;

so = ss.option(form.Value, 'multiplex_brutal_down', _('Download bandwidth'),
_('Download bandwidth in Mbps.'));
so.datatype = 'uinteger';
so.depends('multiplex_brutal', '1');
so.modalonly = true;

so = ss.option(form.Value, 'multiplex_brutal_up', _('Upload bandwidth'),
_('Upload bandwidth in Mbps.'));
so.datatype = 'uinteger';
so.depends('multiplex_brutal', '1');
so.modalonly = true;
/* Mux config end */

/* TLS config start */
Expand Down
35 changes: 35 additions & 0 deletions htdocs/luci-static/resources/view/homeproxy/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,41 @@ return view.extend({

/* Transport config end */

/* Mux config start */
o = s.option(form.Flag, 'multiplex', _('Multiplex'));
o.default = o.disabled;
o.depends('type', 'shadowsocks');
o.depends('type', 'trojan');
o.depends('type', 'vless');
o.depends('type', 'vmess');
o.modalonly = true;

o = s.option(form.Flag, 'multiplex_padding', _('Enable padding'));
o.default = o.disabled;
o.depends('multiplex', '1');
o.modalonly = true;

if (features.hp_has_tcp_brutal) {
o = s.option(form.Flag, 'multiplex_brutal', _('Enable TCP Brutal'),
_('Enable TCP Brutal congestion control algorithm'));
o.default = o.disabled;
o.depends('multiplex', '1');
o.modalonly = true;

o = s.option(form.Value, 'multiplex_brutal_down', _('Download bandwidth'),
_('Download bandwidth in Mbps.'));
o.datatype = 'uinteger';
o.depends('multiplex_brutal', '1');
o.modalonly = true;

o = s.option(form.Value, 'multiplex_brutal_up', _('Upload bandwidth'),
_('Upload bandwidth in Mbps.'));
o.datatype = 'uinteger';
o.depends('multiplex_brutal', '1');
o.modalonly = true;
}
/* Mux config end */

/* TLS config start */
o = s.option(form.Flag, 'tls', _('TLS'));
o.default = o.disabled;
Expand Down
7 changes: 6 additions & 1 deletion root/etc/homeproxy/scripts/generate_client.uc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ function generate_outbound(node) {
max_connections: strToInt(node.multiplex_max_connections),
min_streams: strToInt(node.multiplex_min_streams),
max_streams: strToInt(node.multiplex_max_streams),
padding: (node.multiplex_padding === '1')
padding: (node.multiplex_padding === '1'),
brutal: (node.multiplex_brutal === '1') ? {
enabled: true,
up_mbps: node.multiplex_brutal_down,
down_mbps: node.multiplex_brutal_up
} : null
} : null,
tls: (node.tls === '1') ? {
enabled: true,
Expand Down
10 changes: 10 additions & 0 deletions root/etc/homeproxy/scripts/generate_server.uc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ uci.foreach(uciconfig, uciserver, (cfg) => {
}
] : null,

multiplex: (cfg.multiplex === '1') ? {
enabled: true,
padding: (cfg.multiplex_padding === '1'),
brutal: (cfg.multiplex_brutal === '1') ? {
enabled: true,
up_mbps: cfg.multiplex_brutal_down,
down_mbps: cfg.multiplex_brutal_up
} : null
} : null,

tls: (cfg.tls === '1') ? {
enabled: true,
server_name: cfg.tls_sni,
Expand Down
9 changes: 7 additions & 2 deletions root/usr/share/rpcd/ucode/luci.homeproxy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ function shellquote(s) {
return `'${replace(s, "'", "'\\''")}'`;
}

function hasKernelModule(kmod) {
return (system(sprintf('[ -e "/lib/modules/$(uname -r)"/%s ]', shellquote(kmod))) === 0);
}

const HP_DIR = '/etc/homeproxy';
const RUN_DIR = '/var/run/homeproxy';

Expand Down Expand Up @@ -173,8 +177,9 @@ const methods = {

features.hp_has_chinadns_ng = access('/usr/bin/chinadns-ng');
features.hp_has_ip_full = access('/usr/libexec/ip-full');
features.hp_has_tproxy = access('/etc/modules.d/nft-tproxy');
features.hp_has_tun = access('/etc/modules.d/30-tun');
features.hp_has_tcp_brutal = hasKernelModule('brutal.ko');
features.hp_has_tproxy = hasKernelModule('nft_tproxy.ko') || access('/etc/modules.d/nft-tproxy');
features.hp_has_tun = hasKernelModule('tun.ko') || access('/etc/modules.d/30-tun');

return features;
}
Expand Down

0 comments on commit de5058d

Please sign in to comment.