mirror of
https://github.com/padavanonly/immortalwrt-mt798x.git
synced 2025-12-16 08:44:03 +00:00
hqos:using hash seeting to replace comments
This commit is contained in:
parent
77d57566c4
commit
2970fcfdea
@ -49,7 +49,7 @@ return view.extend({
|
||||
|
||||
|
||||
|
||||
s = m.section(form.TableSection, 'device', _('Speed limit and route choose based on IP address(using unique comment less than 32 will enable hardware QOS)'));
|
||||
s = m.section(form.TableSection, 'device', _('Speed limit and route choose based on IP address(Auto use hardware QOS)'));
|
||||
s.addremove = true;
|
||||
s.anonymous = true;
|
||||
s.sortable = true;
|
||||
@ -85,8 +85,7 @@ return view.extend({
|
||||
o.rmempty = false;
|
||||
|
||||
o = s.option(form.Value, 'comment', _('Comment'));
|
||||
o.datatype = 'and(uinteger,min(1))';
|
||||
o.rmempty = false;
|
||||
o.rmempty = true;
|
||||
|
||||
o = s.option(form.Value, 'interfacename', _('InterfaceName(start from 0)'));
|
||||
o.datatype = 'and(uinteger,min(0))';
|
||||
|
||||
@ -40,7 +40,7 @@ msgid "Load balance"
|
||||
msgstr "负载均衡"
|
||||
|
||||
msgid "Please set a different gateway hop for each network interface before filling in the network interface name. Fill in PPPOE-WAN for dialing and eth1 for DHCP. Leaving it blank to disable it.Please use commas as interface name separators. Example: pppoe-wan,eth1"
|
||||
msgstr "请先为每个网络接口设置不同的网关跃点后,再填写网络接口名。拨号填写PPPOE-WAN,DHCP则填写eth1。留空则不启用.请使用逗号作为接口名分隔符.例子:pppoe-wan, eth1"
|
||||
msgstr "请先为每个网络接口设置不同的网关跃点后,再填写网络接口名。拨号填写pppoe-wan,DHCP则填写eth1。留空则不启用.请使用逗号作为接口名分隔符.例子:pppoe-wan, eth1"
|
||||
|
||||
#: applications/luci-app-eqos/root/usr/share/rpcd/acl.d/luci-app-eqos.json:3
|
||||
msgid "Grant UCI access for luci-app-eqos"
|
||||
@ -66,8 +66,8 @@ msgid "Network speed control service.(Compatiable with Mediatek HNAT)"
|
||||
msgstr "网速控制服务(未设置限速主机可正常使用硬件加速)。"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:38
|
||||
msgid "Speed limit and route choose based on IP address(using unique comment less than 32 will enable hardware QOS)"
|
||||
msgstr "基于 IP 分流限速(设置小于32唯一编号将启用硬件QOS.速度设置为0则取消限速)"
|
||||
msgid "Speed limit and route choose based on IP address(Auto use hardware QOS)"
|
||||
msgstr "基于 IP 分流限速(自动启用硬件QOS.速度设置为0则取消限速)"
|
||||
|
||||
#: applications/luci-app-eqos/htdocs/luci-static/resources/view/eqos.js:29
|
||||
msgid "Total download bandwidth."
|
||||
|
||||
@ -88,7 +88,7 @@ process_existing_leases() {
|
||||
iptables -t mangle -A eqos -s $IP -j DSCP --set-dscp ${MARK_VALUE}
|
||||
iptables -t mangle -A eqos -d $IP -j DSCP --set-dscp ${idpair}
|
||||
ip6tables -t mangle -A eqos -m mac --mac-source $MAC -j MARK --set-mark ${MARK_VALUE}
|
||||
ebtables -t nat -D eqos -A ipv6 -d $MAC -j mark --mark-set ${idpair}
|
||||
ebtables -t nat -A eqos -A ipv6 -d $MAC -j mark --mark-set ${idpair}
|
||||
done < "$LEASE_FILE"
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
dev=br-lan
|
||||
hash_file="/tmp/hash_records.txt"
|
||||
|
||||
generate_index() {
|
||||
local input="$1"
|
||||
local hash_value=$(echo -n "$input" | md5sum | cut -d' ' -f1)
|
||||
local decimal_value=$((0x${hash_value:0:8}))
|
||||
local index=$((decimal_value % 31 + 1))
|
||||
echo $index
|
||||
}
|
||||
|
||||
find_available_index() {
|
||||
local base_index=$(generate_index "$1")
|
||||
local index=$base_index
|
||||
|
||||
while true; do
|
||||
if grep -q "^$index$" "$hash_file"; then
|
||||
index=$((index % 31 + 1))
|
||||
if [[ $index -eq $base_index ]]; then
|
||||
echo "All slots are full. Returning 0."
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
echo $index >> "$hash_file"
|
||||
echo $index
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
}
|
||||
stop_qos() {
|
||||
tc qdisc del dev $dev root 2>/dev/null
|
||||
tc qdisc del dev $dev ingress 2>/dev/null
|
||||
@ -12,7 +39,8 @@ stop_qos() {
|
||||
start_qos() {
|
||||
local dl=$1
|
||||
local up=$2
|
||||
|
||||
rm /tmp/hash_records.txt
|
||||
touch "$hash_file"
|
||||
tc qdisc add dev $dev root handle 1: htb
|
||||
tc class add dev $dev parent 1: classid 1:1 htb rate ${dl}mbit
|
||||
|
||||
@ -97,11 +125,16 @@ case "$1" in
|
||||
ip="$2"
|
||||
dl="$3"
|
||||
up="$4"
|
||||
id="$5" idpair=$((id+32))
|
||||
macaddr="$6"
|
||||
cnt=$(tc class show dev $dev | wc -l)
|
||||
|
||||
interface="$7"
|
||||
if [ -n "$ip" ]; then
|
||||
id="$(find_available_index "$ip")"
|
||||
elif [ -n "$macaddr" ]; then
|
||||
id="$(find_available_index "$macaddr")"
|
||||
fi
|
||||
idpair=$((id+32))
|
||||
if [ $id -lt 32 ]; then
|
||||
iptables -t mangle -D eqos -s $ip -j DSCP --set-dscp ${id}
|
||||
iptables -t mangle -D eqos -d $ip -j DSCP --set-dscp ${idpair}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user