turboacc: support setting ap mode

This commit is contained in:
padavanonly 2025-03-29 12:49:19 +08:00
parent a68b5be912
commit bc90209e19
8 changed files with 72 additions and 44 deletions

View File

@ -158,13 +158,6 @@ return view.extend({
]);
}
/* Mark user edited */
s = m.section(form.NamedSection, 'global', 'turboacc');
o = s.option(form.HiddenValue, 'set');
o.load = (/* ... */) => { return 1 };
o.readonly = true;
o.rmempty = false;
s = m.section(form.NamedSection, 'config', 'turboacc');
o = s.option(form.ListValue, 'fastpath', _('Fastpath engine'),
@ -226,10 +219,9 @@ return view.extend({
o.rmempty = false;
o.depends('fastpath_mh_eth_hnat', '1');
o = s.option(form.Flag, 'fastpath_mh_eth_hnat_macvlan', _('Enable ethernet HNAT for MACVLAN WAN device'),
_('Enable hardware offloading for macvlan.'));
o.default = o.disabled;
o.rmempty = false;
o = s.option(form.Value, 'fastpath_mh_eth_hnat_ap', _('Enable AP Mode'),
_('Fill in ip to enable AP Mode(reboot needed)'));
o.optional = true;
o.depends('fastpath_mh_eth_hnat', '1');
o = s.option(form.Value, 'fastpath_mh_eth_hnat_bind_rate', _('HNAT bind rate threshold (pps)'),
@ -260,7 +252,7 @@ return view.extend({
o.value(i);
o.default = 'cubic';
o.rmempty = false;
return m.render();
}
});

View File

@ -33,11 +33,11 @@ msgid "Enable IPv6 Acceleration."
msgstr ""
#: applications/luci-app-turboacc/htdocs/luci-static/resources/view/turboacc.js:177
msgid "Enable ethernet HNAT for MACVLAN WAN device"
msgid "Enable AP Mode"
msgstr ""
#: applications/luci-app-turboacc/htdocs/luci-static/resources/view/turboacc.js:178
msgid "Enable hardware offloading for macvlan (sing wan only)."
msgid "Fill in ip to enable AP Mode(reboot needed)"
msgstr ""
#: applications/luci-app-turboacc/htdocs/luci-static/resources/view/turboacc.js:183

View File

@ -58,12 +58,12 @@ msgid "Enable hardware offloading for wired IPv6 connections."
msgstr "为有线 IPv6 连接启用硬件加速。"
#: applications/luci-app-turboacc/htdocs/luci-static/resources/view/turboacc.js:177
msgid "Enable ethernet HNAT for MACVLAN WAN device"
msgstr "启用MACVLAN WAN 设备 HNAT"
msgid "Enable AP Mode"
msgstr "启用AP模式"
#: applications/luci-app-turboacc/htdocs/luci-static/resources/view/turboacc.js:178
msgid "Enable hardware offloading for macvlan."
msgstr "为MACVLAN 连接启用硬件加速。"
msgid "Fill in ip to enable AP Mode(reboot needed)"
msgstr "填写IP将启动AP模式同网段不重复ip,需重启后生效.对于无线桥接请桥接完成后再启用AP模式)"
#: applications/luci-app-turboacc/htdocs/luci-static/resources/view/turboacc.js:183
msgid "HNAT bind rate threshold (pps)"

View File

@ -1,6 +1,2 @@
config turboacc 'global'
option set '0'
config turboacc 'config'

View File

@ -4,8 +4,8 @@
START=90
STOP=10
start() {
USE_PROCD=1
start_service() {
config_load "turboacc"
local fastpath
@ -50,7 +50,7 @@ start() {
echo "$fastpath_mh_eth_hnat" > "$hnat_path/hook_toggle"
if [ "$fastpath_mh_eth_hnat" -eq "1" ]; then
local fastpath_mh_eth_hnat_v6 fastpath_mh_eth_hnat_macvlan fastpath_mh_eth_hnat_bind_rate
local fastpath_mh_eth_hnat_v6 fastpath_mh_eth_hnat_ap fastpath_mh_eth_hnat_bind_rate
config_get_bool "fastpath_mh_eth_hnat_v6" "config" "fastpath_mh_eth_hnat_v6" "1"
echo "8 $fastpath_mh_eth_hnat_v6" > "$hnat_path/hnat_setting"
@ -58,14 +58,13 @@ start() {
config_get "fastpath_mh_eth_hnat_bind_rate" "config" "fastpath_mh_eth_hnat_bind_rate" "30"
echo "11 $fastpath_mh_eth_hnat_bind_rate" > "$hnat_path/hnat_setting"
config_get_bool "fastpath_mh_eth_hnat_macvlan" "config" "fastpath_mh_eth_hnat_macvlan" "0"
echo "12 $fastpath_mh_eth_hnat_macvlan" > "$hnat_path/hnat_setting"
config_get "fastpath_mh_eth_hnat_ap" "config" "fastpath_mh_eth_hnat_ap" ""
fi
;;
esac
local fullcone
config_get "fullcone" "config" "fullcone" "0"
config_get "fullcone" "config" "fullcone" "2"
echo "$fullcone" > /proc/sys/net/netfilter/nf_conntrack_nat_mode
local tcpcca
@ -74,4 +73,55 @@ start() {
uci -q commit "firewall"
/etc/init.d/firewall restart >"/dev/null" 2>&1
available_interfaces=""
for iface in eth0 eth1 wan; do
if ifconfig $iface 2>&1 | grep -qv "error fetching interface information"; then
echo "$iface interface detected."
available_interfaces="$available_interfaces $iface"
else
echo "$iface interface not found."
fi
done
if echo "$fastpath_mh_eth_hnat_ap" | grep -qE '^([0-9]{1,3}\.){3}[0-9]{1,3}$'; then
echo "Valid IPv4 address detected: $fastpath_mh_eth_hnat_ap"
uci delete network.wan
uci delete network.wwan
uci delete network.wan6
current_ports=$(uci get network.@device[0].ports)
echo "Current bridge ports: $current_ports"
new_ports="$current_ports"
for port in $available_interfaces; do
if echo "$current_ports" | grep -qw "$port"; then
echo "Port $port is already part of the bridge"
else
echo "Adding port $port to the bridge"
new_ports="$new_ports $port"
fi
done
uci set network.@device[0].ports="$new_ports"
uci set dhcp.lan.ignore=1
uci set network.lan.ipaddr="$fastpath_mh_eth_hnat_ap"
uci set wireless.wifinet1.network='lan'
uci set wireless.wifinet2.network='lan'
echo "Committing changes"
uci commit
else
echo "Invalid IPv4 address: $fastpath_mh_eth_hnat_ap"
fi
}
reload_service() {
start
}
stop_service() {
stop
}
service_triggers() {
procd_add_reload_trigger "turboacc"
}

View File

@ -1,16 +1,5 @@
#!/bin/sh
[ "$(uci -q get "turboacc.global.set")" -eq "1" ] && exit 0
cat <<-EOF > "/etc/config/turboacc"
config turboacc 'global'
option set '0'
config turboacc 'config'
option tcpcca 'cubic'
EOF
kernel_ver="$(uname -r)"
@ -42,8 +31,7 @@ uci -q commit "turboacc"
uci -q batch <<-EOF >"/dev/null"
delete ucitrack.@turboacc[-1]
add ucitrack turboacc
set ucitrack.@turboacc[-1].init=turboacc
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0

View File

@ -306,7 +306,9 @@ parse_rule_nat(struct nftnl_expr *e, rule_t *r)
/* destination address */
r->nat_addr = (in_addr_t)*reg_val_ptr;
/* destination port */
if (proto_min_reg == NFT_REG_1 || proto_min_reg == NFT_REG_2) {
r->nat_port = proto_min_val;
}
} else {
syslog(LOG_ERR, "%s: invalid addr_min_reg %u", "parse_rule_nat", addr_min_reg);
}

View File

@ -120,19 +120,19 @@
};
cpu_trip_hot: hot {
temperature = <80000>;
temperature = <55000>;
hysteresis = <2000>;
type = "hot";
};
cpu_trip_active: active {
temperature = <60000>;
temperature = <40000>;
hysteresis = <2000>;
type = "active";
};
cpu_trip_passive: passive {
temperature = <40000>;
temperature = <30000>;
hysteresis = <2000>;
type = "passive";
};