mirror of
https://github.com/juewuy/ShellCrash.git
synced 2026-10-24 11:49:20 +00:00
feat: add optional UDP buffer limit tuning
This commit is contained in:
@@ -10,6 +10,7 @@ SET_MENU_SKIP_CERT="跳过证书验证:"
|
|||||||
SET_MENU_SNIFFER="启用域名嗅探:"
|
SET_MENU_SNIFFER="启用域名嗅探:"
|
||||||
SET_MENU_ADV_PORT="自定义端口及密钥"
|
SET_MENU_ADV_PORT="自定义端口及密钥"
|
||||||
SET_MENU_IPV6="IPv6设置: "
|
SET_MENU_IPV6="IPv6设置: "
|
||||||
|
SET_MENU_UDP_BUFFER="提高UDP缓冲上限(16 MiB):"
|
||||||
SET_MENU_RESET="重置/备份/还原脚本设置"
|
SET_MENU_RESET="重置/备份/还原脚本设置"
|
||||||
SET_MENU_LANG="多语言切换"
|
SET_MENU_LANG="多语言切换"
|
||||||
SET_MENU_UI="UI切换"
|
SET_MENU_UI="UI切换"
|
||||||
@@ -26,6 +27,9 @@ SET_SNIFFER_LOCKED="当前内核与DNS模式组合下,域名嗅探无法关闭
|
|||||||
|
|
||||||
SET_CORE_RUNNING="检测到服务正在运行,需要先停止服务!"
|
SET_CORE_RUNNING="检测到服务正在运行,需要先停止服务!"
|
||||||
SET_CORE_STOP_CONFIRM="是否确认停止服务?"
|
SET_CORE_STOP_CONFIRM="是否确认停止服务?"
|
||||||
|
SET_UDP_BUFFER_ON="已启用UDP缓冲上限优化!"
|
||||||
|
SET_UDP_BUFFER_OFF="已禁用UDP缓冲上限优化,现有系统值不会被降低。"
|
||||||
|
SET_UDP_BUFFER_RESTART="重启服务后对新连接生效。"
|
||||||
|
|
||||||
# =================================================
|
# =================================================
|
||||||
# Backup / Restore / Reset
|
# Backup / Restore / Reset
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ SET_MENU_SKIP_CERT="Skip Cert Verify:"
|
|||||||
SET_MENU_SNIFFER="Enable Sniff:"
|
SET_MENU_SNIFFER="Enable Sniff:"
|
||||||
SET_MENU_ADV_PORT="Custom Ports and Secrets"
|
SET_MENU_ADV_PORT="Custom Ports and Secrets"
|
||||||
SET_MENU_IPV6="IPv6 Settings:"
|
SET_MENU_IPV6="IPv6 Settings:"
|
||||||
|
SET_MENU_UDP_BUFFER="Raise UDP Buffer Limit (16 MiB):"
|
||||||
SET_MENU_RESET="Reset / Backup / Restore Script Settings"
|
SET_MENU_RESET="Reset / Backup / Restore Script Settings"
|
||||||
SET_MENU_LANG="Language"
|
SET_MENU_LANG="Language"
|
||||||
SET_MENU_UI="UI Switch"
|
SET_MENU_UI="UI Switch"
|
||||||
@@ -26,6 +27,9 @@ SET_SNIFFER_LOCKED="Domain sniffing cannot be disabled with the current core and
|
|||||||
|
|
||||||
SET_CORE_RUNNING="Service is currently running and must be stopped first!"
|
SET_CORE_RUNNING="Service is currently running and must be stopped first!"
|
||||||
SET_CORE_STOP_CONFIRM="Do you want to stop the service?"
|
SET_CORE_STOP_CONFIRM="Do you want to stop the service?"
|
||||||
|
SET_UDP_BUFFER_ON="UDP buffer limit optimization is now enabled!"
|
||||||
|
SET_UDP_BUFFER_OFF="UDP buffer limit optimization is now disabled. Existing system values will not be lowered."
|
||||||
|
SET_UDP_BUFFER_RESTART="Restart the service to apply it to new connections."
|
||||||
|
|
||||||
# =================================================
|
# =================================================
|
||||||
# Backup / Restore / Reset
|
# Backup / Restore / Reset
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ settings() {
|
|||||||
echo "$crashcore" | grep -q 'singbox' && sniffer=ON
|
echo "$crashcore" | grep -q 'singbox' && sniffer=ON
|
||||||
}
|
}
|
||||||
[ -z "$dns_mod" ] && dns_mod='redir_host'
|
[ -z "$dns_mod" ] && dns_mod='redir_host'
|
||||||
|
[ -z "$udp_buffer" ] && udp_buffer=OFF
|
||||||
|
|
||||||
comp_box "\033[30;47m$SET_MENU_TITLE\033[0m"
|
comp_box "\033[30;47m$SET_MENU_TITLE\033[0m"
|
||||||
content_line "1) $SET_MENU_REDIR\t\033[36m$redir_mod$MENU_MOD\033[0m"
|
content_line "1) $SET_MENU_REDIR\t\033[36m$redir_mod$MENU_MOD\033[0m"
|
||||||
@@ -27,6 +28,7 @@ settings() {
|
|||||||
content_line "6) $SET_MENU_ADV_PORT"
|
content_line "6) $SET_MENU_ADV_PORT"
|
||||||
}
|
}
|
||||||
content_line "7) $SET_MENU_IPV6\t\033[36m$ipv6_redir\033[0m"
|
content_line "7) $SET_MENU_IPV6\t\033[36m$ipv6_redir\033[0m"
|
||||||
|
content_line "8) $SET_MENU_UDP_BUFFER\t\033[36m$udp_buffer\033[0m"
|
||||||
btm_box "" \
|
btm_box "" \
|
||||||
"a) \033[31m$SET_MENU_RESET\033[0m" \
|
"a) \033[31m$SET_MENU_RESET\033[0m" \
|
||||||
"b) \033[36m$SET_MENU_LANG\033[0m" \
|
"b) \033[36m$SET_MENU_LANG\033[0m" \
|
||||||
@@ -143,6 +145,18 @@ settings() {
|
|||||||
7)
|
7)
|
||||||
set_ipv6
|
set_ipv6
|
||||||
;;
|
;;
|
||||||
|
8)
|
||||||
|
if [ "$udp_buffer" = "ON" ]; then
|
||||||
|
udp_buffer=OFF
|
||||||
|
msg_alert "\033[33m$SET_UDP_BUFFER_OFF\033[0m" \
|
||||||
|
"$SET_UDP_BUFFER_RESTART"
|
||||||
|
else
|
||||||
|
udp_buffer=ON
|
||||||
|
msg_alert "\033[32m$SET_UDP_BUFFER_ON\033[0m" \
|
||||||
|
"$SET_UDP_BUFFER_RESTART"
|
||||||
|
fi
|
||||||
|
setconfig udp_buffer "$udp_buffer"
|
||||||
|
;;
|
||||||
a)
|
a)
|
||||||
BACK_TAR="$CRASHDIR/configs.tar.gz"
|
BACK_TAR="$CRASHDIR/configs.tar.gz"
|
||||||
comp_box "1) $SET_BACKUP" \
|
comp_box "1) $SET_BACKUP" \
|
||||||
|
|||||||
@@ -23,6 +23,22 @@
|
|||||||
[ -z "$redir_mod" ] && firewall_area='4'
|
[ -z "$redir_mod" ] && firewall_area='4'
|
||||||
routing_mark=$((fwmark + 2))
|
routing_mark=$((fwmark + 2))
|
||||||
|
|
||||||
|
set_udp_buffer_limit() {
|
||||||
|
[ "$udp_buffer" = "ON" ] || return 0
|
||||||
|
|
||||||
|
udp_buffer_limit=16777216
|
||||||
|
for udp_buffer_file in /proc/sys/net/core/rmem_max /proc/sys/net/core/wmem_max; do
|
||||||
|
[ -w "$udp_buffer_file" ] || continue
|
||||||
|
udp_buffer_current=$(cat "$udp_buffer_file" 2>/dev/null)
|
||||||
|
case "$udp_buffer_current" in
|
||||||
|
'' | *[!0-9]*) continue ;;
|
||||||
|
esac
|
||||||
|
[ "$udp_buffer_current" -lt "$udp_buffer_limit" ] &&
|
||||||
|
printf '%s\n' "$udp_buffer_limit" >"$udp_buffer_file"
|
||||||
|
done
|
||||||
|
unset udp_buffer_limit udp_buffer_file udp_buffer_current
|
||||||
|
}
|
||||||
|
|
||||||
makehtml() { #生成面板跳转文件
|
makehtml() { #生成面板跳转文件
|
||||||
cat >"$BINDIR"/ui/index.html <<EOF
|
cat >"$BINDIR"/ui/index.html <<EOF
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -78,6 +94,8 @@ EOF
|
|||||||
[ "$network_check" != "OFF" ] && [ ! -f "$TMPDIR"/crash_start_time ] && ckcmd ping && . "$CRASHDIR"/starts/check_network.sh && check_network
|
[ "$network_check" != "OFF" ] && [ ! -f "$TMPDIR"/crash_start_time ] && ckcmd ping && . "$CRASHDIR"/starts/check_network.sh && check_network
|
||||||
[ ! -d "$BINDIR"/ui ] && mkdir -p "$BINDIR"/ui
|
[ ! -d "$BINDIR"/ui ] && mkdir -p "$BINDIR"/ui
|
||||||
[ -z "$crashcore" ] && crashcore=meta
|
[ -z "$crashcore" ] && crashcore=meta
|
||||||
|
#按需提高UDP套接字缓冲上限,改善Hysteria2等QUIC协议的吞吐
|
||||||
|
set_udp_buffer_limit
|
||||||
#执行条件任务
|
#执行条件任务
|
||||||
[ -s "$TASKCFGDIR"/bfstart ] && . "$TASKCFGDIR"/bfstart
|
[ -s "$TASKCFGDIR"/bfstart ] && . "$TASKCFGDIR"/bfstart
|
||||||
#检查内核配置文件
|
#检查内核配置文件
|
||||||
|
|||||||
Reference in New Issue
Block a user