mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-17 05:53:03 +08:00
40 lines
1.3 KiB
Bash
Executable File
40 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
tcp_cca="$(cat /proc/sys/net/ipv4/tcp_congestion_control 2>/dev/null)"
|
|
nat_mode="disabled"
|
|
hnat_available=false
|
|
[ -e /sys/kernel/debug/hnat/hook_toggle ] && hnat_available=true
|
|
ecm_available=false
|
|
[ -x /etc/init.d/qca-nss-ecm ] && [ -f /etc/config/ecm ] &&
|
|
[ -f /usr/share/ucitrack/qca-nss-ecm.json ] && ecm_available=true
|
|
|
|
ppe_bind_rate_available=false
|
|
if [ -f /etc/openwrt_release ]; then
|
|
. /etc/openwrt_release
|
|
case "$DISTRIB_TARGET" in
|
|
airoha/*) [ ! -e /sys/kernel/debug/ppe/bind_rate ] || ppe_bind_rate_available=true ;;
|
|
mediatek/mt798x|mediatek/mt79xx)
|
|
[ "$hnat_available" != true ] || [ ! -e /sys/kernel/debug/hnat/hnat_setting ] ||
|
|
ppe_bind_rate_available=true
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
rules="$(iptables-save -t nat 2>/dev/null)"
|
|
|
|
if printf '%s\n' "$rules" | grep -q -- '--mode fullcone'; then
|
|
nat_mode="nat1"
|
|
elif printf '%s\n' "$rules" | grep -q -- '-j FULLCONENAT'; then
|
|
nat_mode="fullcone"
|
|
else
|
|
rules="$(nft list ruleset 2>/dev/null)"
|
|
|
|
if printf '%s\n' "$rules" | grep -Eq 'masquerade[[:space:]]+fullcone'; then
|
|
nat_mode="nat1"
|
|
elif printf '%s\n' "$rules" | grep -Eq '(^|[[:space:]])fullcone([[:space:]]|$)'; then
|
|
nat_mode="fullcone"
|
|
fi
|
|
fi
|
|
|
|
printf '{"nat_mode":"%s","tcp_cca":"%s","hnat_available":%s,"ecm_available":%s,"ppe_bind_rate_available":%s}\n' "$nat_mode" "$tcp_cca" "$hnat_available" "$ecm_available" "$ppe_bind_rate_available"
|