From cd07e61968763b8be710bb692b08c9e2f6441e20 Mon Sep 17 00:00:00 2001 From: Tuuz <24893075+tobycroft@users.noreply.github.com> Date: Wed, 26 Oct 2022 14:52:14 +0800 Subject: [PATCH 01/19] Update kcptun.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit socket_buf的 expr计算,需要使用 \* 来做乘法,否则会报 expr错误 --- kcptun/kcptun.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index eb3cd9f..f40039c 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -1945,7 +1945,7 @@ set_hidden_parameters() { continue fi - sockbuf=$(expr $input * 1024 * 1024) + sockbuf=$(expr $input \* 1024 \* 1024) fi break done @@ -1970,7 +1970,7 @@ set_hidden_parameters() { continue fi - smuxbuf=$(expr $input * 1024 * 1024) + smuxbuf=$(expr $input \* 1024 \* 1024) fi break done From a128392efe5952df690651d8b1cf807c5a22543f Mon Sep 17 00:00:00 2001 From: tuuz Date: Sat, 29 Jun 2024 13:09:26 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E6=96=B0=E5=A2=9ESMUXVer=E5=92=8CSTEAMBU?= =?UTF-8?q?F=E6=96=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kcptun/kcptun.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index f40039c..65fd2f5 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -68,9 +68,13 @@ D_NODELAY=1 D_INTERVAL=20 D_RESEND=2 D_NC=1 -D_SOCKBUF=4194304 -D_SMUXBUF=4194304 +D_SOCKBUF=16777217 +D_SMUXBUF=16777217 D_KEEPALIVE=10 + +# KCP新版支持 +D_SMUXVER=1 +D_STREAMBUF=4194304 # ====================== # 当前选择的实例 ID @@ -1701,6 +1705,8 @@ set_kcptun_config() { sockbuf="" smuxbuf="" keepalive="" + streambuf="" + smuxver="" cat >&1 <<-EOF --------------------------- 不配置隐藏参数 @@ -2005,6 +2011,54 @@ set_hidden_parameters() { keepalive = ${keepalive} --------------------------- EOF + + [ -z "$smuxver" ] && smuxver="$D_SMUXVER" + while true + do + cat >&1 <<-'EOF' + 请设置 smux 的版本 + EOF + read -p "(1,2, 默认值: ${smuxver}, 老版本默认1,新版本默认2): " input + if [ -n "$input" ]; then + if ! is_number "$input" || [ $input -le 0 ]; then + echo "输入有误, 请输入大于0的数字!" + continue + fi + + smuxver=$input + fi + break + done + + cat >&1 <<-EOF + --------------------------- + keepalive = ${keepalive} + --------------------------- + EOF + + [ -z "$keepalive" ] && keepalive="$D_KEEPALIVE" + while true + do + cat >&1 <<-'EOF' + 请设置 Keepalive 的间隔时间 + EOF + read -p "(单位: s, 默认值: ${keepalive}, 前值: 5): " input + if [ -n "$input" ]; then + if ! is_number "$input" || [ $input -le 0 ]; then + echo "输入有误, 请输入大于0的数字!" + continue + fi + + keepalive=$input + fi + break + done + + cat >&1 <<-EOF + --------------------------- + keepalive = ${keepalive} + --------------------------- + EOF } # 生成 Kcptun 服务端配置文件 @@ -2331,7 +2385,7 @@ show_current_instance_info() { show_configs "key" "crypt" "mode" "mtu" "sndwnd" "rcvwnd" "datashard" \ "parityshard" "dscp" "nocomp" "quiet" "tcp" "nodelay" "interval" "resend" \ - "nc" "acknodelay" "sockbuf" "smuxbuf" "keepalive" + "nc" "acknodelay" "sockbuf" "smuxbuf" "keepalive" "streambuf" "smuxver" show_version_and_client_url @@ -2373,7 +2427,7 @@ show_current_instance_info() { gen_client_configs "crypt" "mode" "mtu" "sndwnd" "rcvwnd" "datashard" \ "parityshard" "dscp" "nocomp" "quiet" "tcp" "nodelay" "interval" "resend" \ - "nc" "acknodelay" "sockbuf" "smuxbuf" "keepalive" + "nc" "acknodelay" "sockbuf" "smuxbuf" "keepalive" "streambuf" "smuxver" cat >&1 <<-EOF @@ -2407,7 +2461,7 @@ show_current_instance_info() { gen_mobile_configs "crypt" "mode" "mtu" "sndwnd" "rcvwnd" "datashard" \ "parityshard" "dscp" "nocomp" "quiet" "tcp" "nodelay" "interval" "resend" \ - "nc" "acknodelay" "sockbuf" "smuxbuf" "keepalive" + "nc" "acknodelay" "sockbuf" "smuxbuf" "keepalive" "streambuf" "smuxver" cat >&1 <<-EOF From 3b5682e987c523d475f0e38a513f3147707b8aef Mon Sep 17 00:00:00 2001 From: tuuz Date: Sat, 29 Jun 2024 13:09:39 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E6=96=B0=E5=A2=9ESMUXVer=E5=92=8CSTEAMBU?= =?UTF-8?q?F=E6=96=B0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 ++++++++ .idea/UniappTool.xml | 10 ++++++++++ .idea/misc.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/shell-scripts.iml | 9 +++++++++ .idea/vcs.xml | 6 ++++++ 6 files changed, 47 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/UniappTool.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/shell-scripts.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/UniappTool.xml b/.idea/UniappTool.xml new file mode 100644 index 0000000..f7328e8 --- /dev/null +++ b/.idea/UniappTool.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6f29fee --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8bc72c3 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/shell-scripts.iml b/.idea/shell-scripts.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/shell-scripts.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 289b192805033960ec9604e93b27cb54ecccfe64 Mon Sep 17 00:00:00 2001 From: tuuz Date: Sat, 29 Jun 2024 13:13:10 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9Esmuxver=202.=E6=96=B0?= =?UTF-8?q?=E5=A2=9Estreambuf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kcptun/kcptun.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index 65fd2f5..5daa3a3 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -2032,31 +2032,31 @@ set_hidden_parameters() { cat >&1 <<-EOF --------------------------- - keepalive = ${keepalive} + $smuxver = ${smuxver} --------------------------- EOF - [ -z "$keepalive" ] && keepalive="$D_KEEPALIVE" + [ -z "$streambuf" ] && streambuf="$D_STREAMBUF" while true do cat >&1 <<-'EOF' - 请设置 Keepalive 的间隔时间 + 请设置 streambuf 大小,官方文档介绍本值不宜过大 EOF - read -p "(单位: s, 默认值: ${keepalive}, 前值: 5): " input + read -p "(单位: MB, 默认: $(expr ${smuxbuf} / 1024 / 1024)): " input if [ -n "$input" ]; then if ! is_number "$input" || [ $input -le 0 ]; then echo "输入有误, 请输入大于0的数字!" continue fi - keepalive=$input + smuxbuf=$(expr $input \* 1024 \* 1024) fi break done cat >&1 <<-EOF --------------------------- - keepalive = ${keepalive} + streambuf = ${streambuf} --------------------------- EOF } From 09533647312b2ee62cc2a54809e04e3c8853bbcd Mon Sep 17 00:00:00 2001 From: tuuz Date: Sat, 29 Jun 2024 13:17:51 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9Esmuxver=202.=E6=96=B0?= =?UTF-8?q?=E5=A2=9Estreambuf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kcptun/kcptun.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index 5daa3a3..771c58e 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -2143,7 +2143,7 @@ gen_kcptun_config() { } write_configs_to_file "snmplog" "snmpperiod" "pprof" "acknodelay" "nodelay" \ - "interval" "resend" "nc" "sockbuf" "smuxbuf" "keepalive" + "interval" "resend" "nc" "sockbuf" "smuxbuf" "keepalive" "streambuf" "smuxver" if ! grep -q "^${run_user}:" '/etc/passwd'; then ( From af65e5fd62b9ef638488e82a6fcc19a747afcc38 Mon Sep 17 00:00:00 2001 From: tuuz Date: Fri, 2 Aug 2024 13:37:55 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9Esmuxver=202.=E6=96=B0?= =?UTF-8?q?=E5=A2=9Estreambuf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复: 1.streambuf设定不正确的故障 --- kcptun/kcptun.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index 771c58e..f5538b0 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -74,7 +74,7 @@ D_KEEPALIVE=10 # KCP新版支持 D_SMUXVER=1 -D_STREAMBUF=4194304 +D_STREAMBUF=16777217 # ====================== # 当前选择的实例 ID @@ -2042,14 +2042,14 @@ set_hidden_parameters() { cat >&1 <<-'EOF' 请设置 streambuf 大小,官方文档介绍本值不宜过大 EOF - read -p "(单位: MB, 默认: $(expr ${smuxbuf} / 1024 / 1024)): " input + read -p "(单位: MB, 默认: $(expr ${streambuf} / 1024 / 1024)): " input if [ -n "$input" ]; then if ! is_number "$input" || [ $input -le 0 ]; then echo "输入有误, 请输入大于0的数字!" continue fi - smuxbuf=$(expr $input \* 1024 \* 1024) + streambuf=$(expr $input \* 1024 \* 1024) fi break done From 0e66301ab28f3b8e28867543b5ad96898dd202c7 Mon Sep 17 00:00:00 2001 From: tuuz Date: Fri, 2 Aug 2024 13:40:09 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9Esmuxver=202.=E6=96=B0?= =?UTF-8?q?=E5=A2=9Estreambuf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复: 1.streambuf设定不正确的故障 配置: 1.streambuf大小由4改为16M --- kcptun/kcptun.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index f5538b0..934f94e 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -72,7 +72,7 @@ D_SOCKBUF=16777217 D_SMUXBUF=16777217 D_KEEPALIVE=10 -# KCP新版支持 +# KCP新版支持,SMux默认为2,BUF大小改为16M D_SMUXVER=1 D_STREAMBUF=16777217 # ====================== From c5fdc6ed4dc54db410e79fe9b4908a847838dcda Mon Sep 17 00:00:00 2001 From: tuuz Date: Fri, 2 Aug 2024 13:52:12 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9Esmuxver=202.=E6=96=B0?= =?UTF-8?q?=E5=A2=9Estreambuf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复: 1.streambuf设定不正确的故障 配置: 1.streambuf大小由4改为16M --- .idea/.gitignore | 8 -------- .idea/UniappTool.xml | 10 ---------- .idea/misc.xml | 6 ------ .idea/modules.xml | 8 -------- .idea/shell-scripts.iml | 9 --------- .idea/vcs.xml | 6 ------ 6 files changed, 47 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/UniappTool.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/shell-scripts.iml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/UniappTool.xml b/.idea/UniappTool.xml deleted file mode 100644 index f7328e8..0000000 --- a/.idea/UniappTool.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 6f29fee..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 8bc72c3..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/shell-scripts.iml b/.idea/shell-scripts.iml deleted file mode 100644 index d6ebd48..0000000 --- a/.idea/shell-scripts.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 2a9c117cc7327a31f4b7dc29a20f17d3fce9934e Mon Sep 17 00:00:00 2001 From: tuuz Date: Fri, 2 Aug 2024 14:11:04 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9E=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88=E7=AB=AF=E5=8F=A3=E6=AE=B5=E9=98=B2=E6=AD=A2=E5=B0=81?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kcptun/kcptun.sh | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index 934f94e..eb0620b 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -1201,22 +1201,32 @@ set_kcptun_config() { cat >&1 <<-'EOF' 请输入 Kcptun 服务端运行端口 [1~65535] 这个端口就是 Kcptun 客户端连接的端口 + 新版支持端口范围,可输入[30000-35000]来开启端口范围3w-3w5 EOF read -p "(默认: ${listen_port}): " input - if [ -n "$input" ]; then - if is_port "$input"; then - listen_port="$input" - else - echo "输入有误, 请输入 1~65535 之间的数字!" - continue - fi - fi - - if port_using "$listen_port" && \ - [ "$listen_port" != "$current_listen_port" ]; then - echo "端口已被占用, 请重新输入!" - continue - fi + if [ -n "$input" ]; then + if echo "$input" | grep -qE '^[0-9]+-[0-9]+$'; then + range_start=$(echo "$input" | cut -d'-' -f1) + range_end=$(echo "$input" | cut -d'-' -f2) + if [ "$range_start" -le "$current_listen_port" ] && [ "$current_listen_port" -le "$range_end" ]; then + #echo "current_listen_port 在输入的范围内" + listen_port="$input" + else + echo "current_listen_port 不在输入的范围内, 请重新输入!" + continue + fi + elif is_port "$input"; then + listen_port="$input" + else + echo "输入有误, 请输入 1~65535 之间的数字或有效的端口范围!" + continue + fi + fi + + if port_using "$listen_port" && [ "$listen_port" != "$current_listen_port" ]; then + echo "端口已被占用, 请重新输入!" + continue + fi break done From 727751400ec3f77bb59233bcf709acaf17c52c41 Mon Sep 17 00:00:00 2001 From: tuuz Date: Fri, 2 Aug 2024 14:14:15 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9E=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88=E7=AB=AF=E5=8F=A3=E6=AE=B5=E9=98=B2=E6=AD=A2=E5=B0=81?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kcptun/kcptun.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index eb0620b..dbb8cb7 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -1208,11 +1208,16 @@ set_kcptun_config() { if echo "$input" | grep -qE '^[0-9]+-[0-9]+$'; then range_start=$(echo "$input" | cut -d'-' -f1) range_end=$(echo "$input" | cut -d'-' -f2) - if [ "$range_start" -le "$current_listen_port" ] && [ "$current_listen_port" -le "$range_end" ]; then - #echo "current_listen_port 在输入的范围内" - listen_port="$input" + if [ "$range_start" -ge 1 ] && [ "$range_start" -le 65535 ] && [ "$range_end" -ge 1 ] && [ "$range_end" -le 65535 ] && [ "$range_start" -le "$range_end" ]; then + if [ "$range_start" -le "$current_listen_port" ] && [ "$current_listen_port" -le "$range_end" ]; then + echo "current_listen_port 在输入的范围内" + listen_port="$input" + else + echo "current_listen_port 不在输入的范围内, 请重新输入!" + continue + fi else - echo "current_listen_port 不在输入的范围内, 请重新输入!" + echo "端口范围无效, 请输入类似 3000-5000 的有效端口范围!" continue fi elif is_port "$input"; then From fc70576d104ef67a9527217f10a79c1b7374271a Mon Sep 17 00:00:00 2001 From: tuuz Date: Fri, 2 Aug 2024 14:15:05 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9E=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88=E7=AB=AF=E5=8F=A3=E6=AE=B5=E9=98=B2=E6=AD=A2=E5=B0=81?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kcptun/kcptun.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index dbb8cb7..d505e3c 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -1201,7 +1201,7 @@ set_kcptun_config() { cat >&1 <<-'EOF' 请输入 Kcptun 服务端运行端口 [1~65535] 这个端口就是 Kcptun 客户端连接的端口 - 新版支持端口范围,可输入[30000-35000]来开启端口范围3w-3w5 + 新版支持端口范围,可输入[30000-35000]来开启端口范围 EOF read -p "(默认: ${listen_port}): " input if [ -n "$input" ]; then From 5b9d1042029791c2f94ed63bef809923895284b2 Mon Sep 17 00:00:00 2001 From: tuuz Date: Fri, 2 Aug 2024 14:30:32 +0800 Subject: [PATCH 12/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9E=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88=E7=AB=AF=E5=8F=A3=E6=AE=B5=E9=98=B2=E6=AD=A2=E5=B0=81?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modify: 1.修改root执行判断逻辑 --- kcptun/kcptun.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index d505e3c..3f55ac9 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -1747,9 +1747,22 @@ set_kcptun_config() { unset_hidden_parameters fi - if [ $listen_port -le 1024 ]; then - run_user="root" - fi + if echo "$input" | grep -qE '^[0-9]+-[0-9]+$'; then + range_start=$(echo "$input" | cut -d'-' -f1) + range_end=$(echo "$input" | cut -d'-' -f2) + if [ "$range_start" -ge 1 ] && [ "$range_start" -le 65535 ] && [ "$range_end" -ge 1 ] && [ "$range_end" -le 65535 ] && [ "$range_start" -le "$range_end" ]; then + # 新增端口段检测逻辑 + if [ "$range_start" -le 1024 ] || [ "$range_end" -le 1024 ]; then + run_user="root" + fi + fi + elif is_port "$input"; then + listen_port="$input" + # 端口检测逻辑 + if [ "$listen_port" -le 1024 ]; then + run_user="root" + fi + fi echo "配置完成。" any_key_to_continue From f7844060d1e2902397a5140b718520a45338c22c Mon Sep 17 00:00:00 2001 From: tuuz Date: Fri, 2 Aug 2024 15:38:03 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9E=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88=E7=AB=AF=E5=8F=A3=E6=AE=B5=E9=98=B2=E6=AD=A2=E5=B0=81?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modify: 1.修改root执行判断逻辑 2.nocomp选项由默认关改为默认开,避免封端口 --- kcptun/kcptun.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index 3f55ac9..9bf343e 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -56,7 +56,7 @@ D_RCVWND=512 D_DATASHARD=10 D_PARITYSHARD=3 D_DSCP=0 -D_NOCOMP='false' +D_NOCOMP='true' D_QUIET='false' D_TCP='false' D_SNMPPERIOD=60 From 9937f18892fcc14da4c0d794f9c3b6d00d8f98d3 Mon Sep 17 00:00:00 2001 From: tuuz Date: Fri, 2 Aug 2024 18:53:32 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9E=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88=E7=AB=AF=E5=8F=A3=E6=AE=B5=E9=98=B2=E6=AD=A2=E5=B0=81?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 2.修复如果全新配置可能出现“数字不合法”的提示 Modify: 1.修改root执行判断逻辑 2.nocomp选项由默认关改为默认开 --- kcptun/kcptun.sh | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index 9bf343e..487003d 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -1209,19 +1209,38 @@ set_kcptun_config() { range_start=$(echo "$input" | cut -d'-' -f1) range_end=$(echo "$input" | cut -d'-' -f2) if [ "$range_start" -ge 1 ] && [ "$range_start" -le 65535 ] && [ "$range_end" -ge 1 ] && [ "$range_end" -le 65535 ] && [ "$range_start" -le "$range_end" ]; then - if [ "$range_start" -le "$current_listen_port" ] && [ "$current_listen_port" -le "$range_end" ]; then - echo "current_listen_port 在输入的范围内" - listen_port="$input" + echo "$current_listen_port" + if echo "$current_listen_port" | grep -qE '^[0-9]+-[0-9]+$'; then + current_range_start=$(echo "$current_listen_port" | cut -d'-' -f1) + current_range_end=$(echo "$current_listen_port" | cut -d'-' -f2) + if [ "$range_start" -le "$current_range_end" ] && [ "$range_end" -ge "$current_range_start" ]; then + # echo "current_listen_port 在输入的范围内" + listen_port="$input" + else + echo "current_listen_port 不在输入的范围内, 请重新输入!" + continue + fi else - echo "current_listen_port 不在输入的范围内, 请重新输入!" - continue + listen_port="$input" fi else echo "端口范围无效, 请输入类似 3000-5000 的有效端口范围!" continue fi elif is_port "$input"; then - listen_port="$input" + if echo "$current_listen_port" | grep -qE '^[0-9]+-[0-9]+$'; then + current_range_start=$(echo "$current_listen_port" | cut -d'-' -f1) + current_range_end=$(echo "$current_listen_port" | cut -d'-' -f2) + if [ "$input" -ge "$current_range_start" ] && [ "$input" -le "$current_range_end" ]; then + # echo "current_listen_port 在输入的范围内" + listen_port="$input" + else + echo "current_listen_port 不在输入的范围内, 请重新输入!" + continue + fi + else + listen_port="$input" + fi else echo "输入有误, 请输入 1~65535 之间的数字或有效的端口范围!" continue @@ -1563,6 +1582,9 @@ set_kcptun_config() { do cat >&1 <<-'EOF' 是否关闭数据压缩? + 对CPU性能有损耗 + 如果是文本类数据,可设手动开启 + 如果是数据套壳,则默认保持关闭直接 EOF read -p "(默认: ${nocomp}) [y/n]: " yn if [ -n "$yn" ]; then From 8d62bb1ddd7c121056f7cb6dfa74f0b58ba99bf3 Mon Sep 17 00:00:00 2001 From: tuuz Date: Fri, 2 Aug 2024 19:34:41 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9E=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88=E7=AB=AF=E5=8F=A3=E6=AE=B5=E9=98=B2=E6=AD=A2=E5=B0=81?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 2.修复如果全新配置可能出现“数字不合法”的提示 Modify: 1.修改root执行判断逻辑 2.nocomp选项由默认关改为默认开 --- kcptun/kcptun.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index 487003d..11596ce 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -1209,7 +1209,6 @@ set_kcptun_config() { range_start=$(echo "$input" | cut -d'-' -f1) range_end=$(echo "$input" | cut -d'-' -f2) if [ "$range_start" -ge 1 ] && [ "$range_start" -le 65535 ] && [ "$range_end" -ge 1 ] && [ "$range_end" -le 65535 ] && [ "$range_start" -le "$range_end" ]; then - echo "$current_listen_port" if echo "$current_listen_port" | grep -qE '^[0-9]+-[0-9]+$'; then current_range_start=$(echo "$current_listen_port" | cut -d'-' -f1) current_range_end=$(echo "$current_listen_port" | cut -d'-' -f2) From fd46e10d52056f175d7f31bf371f7bfaeadc1aa4 Mon Sep 17 00:00:00 2001 From: tuuz Date: Sun, 4 Aug 2024 21:55:04 +0800 Subject: [PATCH 16/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9E=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88=E7=AB=AF=E5=8F=A3=E6=AE=B5=E9=98=B2=E6=AD=A2=E5=B0=81?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 1.修复如果全新配置可能出现“数字不合法”的提示 2.修复echo输出问题 Modify: 1.修改root执行判断逻辑 2.nocomp选项由默认关改为默认开(配合新R协议) 3.ReadMe加入Ubuntu前置命令,减少使用中可能出错的风险 --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03a1a7e..2661056 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,15 @@ $ tree ## Kcptun 一键安装脚本 -* 安装命令: +* Ubuntu: +```sh +apt install python-is-python3 -y +wget --no-check-certificate -O kcptun.sh https://github.com/kuoruan/shell-scripts/raw/master/kcptun/kcptun.sh +sh kcptun.sh +``` + +* 其他Linux安装命令: ```sh wget --no-check-certificate -O kcptun.sh https://github.com/kuoruan/shell-scripts/raw/master/kcptun/kcptun.sh sh kcptun.sh From 6bbe194927d2882fb3c522049ee0a785331e7e9a Mon Sep 17 00:00:00 2001 From: tuuz Date: Mon, 5 Aug 2024 11:03:56 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=9A=201.=E6=96=B0=E5=A2=9E=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88=E7=AB=AF=E5=8F=A3=E6=AE=B5=E9=98=B2=E6=AD=A2=E5=B0=81?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 1.修复如果全新配置可能出现“数字不合法”的提示 2.修复echo输出问题 Modify: 1.修改root执行判断逻辑 2.nocomp选项由默认关改为默认开(配合新R协议) 3.ReadMe加入Ubuntu前置命令,减少使用中可能出错的风险 --- kcptun/kcptun.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index 11596ce..6746ad3 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -68,12 +68,13 @@ D_NODELAY=1 D_INTERVAL=20 D_RESEND=2 D_NC=1 -D_SOCKBUF=16777217 -D_SMUXBUF=16777217 +# SMUX提高到64M提高SreamBuf效果 +D_SOCKBUF=67108868 +D_SMUXBUF=67108868 D_KEEPALIVE=10 # KCP新版支持,SMux默认为2,BUF大小改为16M -D_SMUXVER=1 +D_SMUXVER=2 D_STREAMBUF=16777217 # ====================== From 4978e0527768a30fb77494830531d9fe2be8479b Mon Sep 17 00:00:00 2001 From: Tuuz <2539@tuuz.cn> Date: Fri, 15 May 2026 21:51:28 +0800 Subject: [PATCH 18/19] Update kcptun version and fix installation issues --- kcptun/kcptun.sh | 4 ++-- kcptun/version.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index 6746ad3..fbd115c 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -24,9 +24,9 @@ INIT_VERSION=3 KCPTUN_INSTALL_DIR='/usr/local/kcptun' KCPTUN_LOG_DIR='/var/log/kcptun' -KCPTUN_RELEASES_URL='https://api.github.com/repos/xtaci/kcptun/releases' +KCPTUN_RELEASES_URL='https://api.github.com/repos/tobycroft/kcptun/releases' KCPTUN_LATEST_RELEASE_URL="${KCPTUN_RELEASES_URL}/latest" -KCPTUN_TAGS_URL='https://github.com/xtaci/kcptun/tags' +KCPTUN_TAGS_URL='https://github.com/tobycroft/kcptun/tags' BASE_URL='https://github.com/kuoruan/shell-scripts/raw/master/kcptun' SHELL_VERSION_INFO_URL="${BASE_URL}/version.json" diff --git a/kcptun/version.json b/kcptun/version.json index 6fe8078..8c42f39 100644 --- a/kcptun/version.json +++ b/kcptun/version.json @@ -1,9 +1,9 @@ { - "shell_version": 25, + "shell_version": 26, "shell_url": "https://github.com/kuoruan/shell-scripts/raw/master/kcptun/kcptun.sh", "change_log": "1. 添加 TCP 参数支持", "config_version": 6, - "config_change_log": "1.支持 snmp 和 pprof 参数;\n2.输出新版手机端参数", + "config_change_log": "1.修复kcptun安装问题", "init_version": 3, "init_change_log": "1.修复 CentOS 上找不到 Supervisor 执行文件的问题;\n2.由于 Supervisor 的版本不同, 执行文件的目录可能不一样, 如果你出现无法安装或启动失败的问题, 请及时联系我" } From 66d1b6c52dd7574486613440360429c98b6fdd47 Mon Sep 17 00:00:00 2001 From: Tuuz <2539@tuuz.cn> Date: Fri, 15 May 2026 21:55:00 +0800 Subject: [PATCH 19/19] Update kcptun repository URLs to tobycroft fork --- kcptun/kcptun.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kcptun/kcptun.sh b/kcptun/kcptun.sh index a2062bd..20f7fef 100755 --- a/kcptun/kcptun.sh +++ b/kcptun/kcptun.sh @@ -24,9 +24,9 @@ INIT_VERSION=3 KCPTUN_INSTALL_DIR='/usr/local/kcptun' KCPTUN_LOG_DIR='/var/log/kcptun' -KCPTUN_RELEASES_URL='https://api.github.com/repos/xtaci/kcptun/releases' +KCPTUN_RELEASES_URL='https://api.github.com/repos/tobycroft/kcptun/releases' KCPTUN_LATEST_RELEASE_URL="${KCPTUN_RELEASES_URL}/latest" -KCPTUN_TAGS_URL='https://github.com/xtaci/kcptun/tags' +KCPTUN_TAGS_URL='https://github.com/tobycroft/kcptun/tags' BASE_URL='https://github.com/kuoruan/shell-scripts/raw/master/kcptun' SHELL_VERSION_INFO_URL="${BASE_URL}/version.json"