返回归档

归档 2022

Shadowsocks Kcptun 调试过程

MacOS 连接自建 SS+kcptun 调试过程

翻墙ShadowsocksKcptun个人笔记Tools
本文目录3
  1. Kcptun 调试过程
  2. Mac 上 ShadowsocksX-NG(1.9.4) 自带的 kcptun 链接失败
  3. Reference

Kcptun 调试过程

Mac 上 ShadowsocksX-NG(1.9.4) 自带的 kcptun 链接失败

  1. 安卓上没有问题,参数如下
bash
# 安卓参数
mode=fast3;dscp=0;crypt=aes;parityshard=3;rcvwnd=512;key=very fast;sndwnd=512;mtu=1350;datashard=10
  1. Mac 调整填入参数为
bash
# Mac PC 端
--key="very fast" --crypt="aes" --mode="fast" --mtu=1350 --datashard=10 --parityshard=3 --rcvwnd=512 --sndwnd=512 --dscp=0
  1. 并修改 kcptun(v20190905_1) 输出日志,执行结果为
shell
-r IP:PORT -l 127.0.0.1:58627 --key "very fast" --crypt "aes" --mode "fast" --mtu 1350 --datashard 10 --parityshard 3 --rcvwnd=512 --sndwnd 512 --dscp 0
  1. 启动成功但是链接不成功
shell
-r IP:PORT -l 127.0.0.1:58627 --key "very fast" --crypt "aes" --mode "fast" --mtu 1350 --datashard 10 --parityshard 3 --rcvwnd=512 --sndwnd 512 --dscp 0
2022/02/24 14:00:45 version: 20190905
2022/02/24 14:00:45 initiating key derivation
2022/02/24 14:00:45 listening on: 127.0.0.1:58627
2022/02/24 14:00:45 encryption: aes
2022/02/24 14:00:45 nodelay parameters: 0 30 2 1
2022/02/24 14:00:45 remote address: IP:PORT
2022/02/24 14:00:45 sndwnd: 128 rcvwnd: 512
2022/02/24 14:00:45 compression: true
2022/02/24 14:00:45 mtu: 1350
2022/02/24 14:00:45 datashard: 10 parityshard: 3
2022/02/24 14:00:45 acknodelay: false
2022/02/24 14:00:45 dscp: 0
2022/02/24 14:00:45 sockbuf: 4194304
2022/02/24 14:00:45 smuxbuf: 4194304
2022/02/24 14:00:45 keepalive: 10
2022/02/24 14:00:45 conn: 1
2022/02/24 14:00:45 autoexpire: 0
2022/02/24 14:00:45 scavengettl: 600
2022/02/24 14:00:45 snmplog: 
2022/02/24 14:00:45 snmpperiod: 60
2022/02/24 14:00:45 quiet: false
2022/02/24 14:00:45 tcp: false
2022/02/24 14:00:45 connection: 0.0.0.0:49550 -> IP:PORT
2022/02/24 14:00:54 stream opened in: 127.0.0.1:58649 out: IP:PORT(3)
2022/02/24 14:00:56 stream opened in: 127.0.0.1:58660 out: IP:PORT(5)
2022/02/24 14:00:57 stream opened in: 127.0.0.1:58662 out: IP:PORT(7)
2022/02/24 14:00:57 stream opened in: 127.0.0.1:58666 out: IP:PORT(9)
2022/02/24 14:00:57 stream opened in: 127.0.0.1:58668 out: IP:PORT(11)
2022/02/24 14:00:57 stream opened in: 127.0.0.1:58669 out: IP:PORT(13)
2022/02/24 14:01:01 stream closed in: 127.0.0.1:58666 out: IP:PORT(9)
  1. 下载最新的 kcptun client

  2. 执行但是发现还是不行,查到相关 Issue,使用 kcptun 的 2017 版本

  3. 执行时报另一个错误

text
# ss-local
2022-02-24 12:10:38 INFO: plugin "plugins/kcptun" enabled
 2022-02-24 12:10:38 INFO: using tcp fast open
 2022-02-24 12:10:38 INFO: initializing ciphers... aes-256-cfb
 2022-02-24 12:10:38 INFO: listening at 127.0.0.1:1086
 2022-02-24 12:10:38 INFO: tcp port reuse enabled
fatal error: runtime: bsdthread_register error

runtime stack:
runtime.throw(0x1256855, 0x21)
	/home/max/Develop/go/src/runtime/panic.go:596 +0x95 fp=0x7ff7bfeff9b0 sp=0x7ff7bfeff990
runtime.goenvs()
	/home/max/Develop/go/src/runtime/os_darwin.go:108 +0xa0 fp=0x7ff7bfeff9e0 sp=0x7ff7bfeff9b0
runtime.schedinit()
	/home/max/Develop/go/src/runtime/proc.go:486 +0xa1 fp=0x7ff7bfeffa20 sp=0x7ff7bfeff9e0
runtime.rt0_go(0x7ff7bfeffa50, 0x2, 0x7ff7bfeffa50, 0x1000000, 0x2, 0x7ff7bfeffb68, 0x7ff7bfeffb77, 0x0, 0x7ff7bfeffb83, 0x7ff7bfeffc1f, ...)
	/home/max/Develop/go/src/runtime/asm_amd64.s:158 +0x183 fp=0x7ff7bfeffa28 sp=0x7ff7bfeffa20
 2022-02-24 12:10:38 ERROR: plugin service exit unexpectedly
  1. 查询后是编译的 Go 版本有问题,相关 Issue

  2. 后又发现是 kcptun 调用参数有问题,修改脚本后问题解决

bash
# /Users/jiyu/Library/Application Support/ShadowsocksX-NG/plugins/kcptun
#!/bin/bash

# A shadowsocks SIP003 adapter shell script.
#
# SIP003 Docucment: https://github.com/shadowsocks/shadowsocks-org/issues/28
#
# Created by Qiu Yuzhou on 2019-09-09
# Copyright © 2019 Qiu Yuzhou. All rights reserved.

# test data, Start
# SS_REMOTE_HOST=127.0.0.1
# SS_REMOTE_PORT=8088
# SS_LOCAL_HOST=192.168.1.1
# SS_LOCAL_PORT=888
# test data, End

SS_ENV_NAMES=(SS_REMOTE_HOST SS_REMOTE_PORT SS_LOCAL_HOST SS_LOCAL_PORT)

for i in "${SS_ENV_NAMES[@]}"; do
    if [ -z ${!i} ]
    then
        echo Not found env variable $i
        exit
    fi
done

PLUGIN_PATH="kcptun_v20190905_1/client"

CMD="$(dirname "${BASH_SOURCE[0]}")/../${PLUGIN_PATH}"

# Check if it is an IPv6 address
if  [[ $SS_REMOTE_HOST == *":"* ]]; then
    SS_REMOTE_ADDR="[${SS_REMOTE_HOST}]:${SS_REMOTE_PORT}"
else
    SS_REMOTE_ADDR="${SS_REMOTE_HOST}:${SS_REMOTE_PORT}"
fi

# Check if it is an IPv6 address
if  [[ $SS_LOCAL_HOST == *":"* ]]; then
    SS_LOCAL_ADDR="[${SS_LOCAL_HOST}]:${SS_LOCAL_PORT}"
else
    SS_LOCAL_ADDR="${SS_LOCAL_HOST}:${SS_LOCAL_PORT}"
fi

# Update this line when adapted other plugin.
echo "$CMD -r ${SS_REMOTE_ADDR} -l ${SS_LOCAL_ADDR} ${SS_PLUGIN_OPTIONS}"
eval "$CMD -r ${SS_REMOTE_ADDR} -l ${SS_LOCAL_ADDR} ${SS_PLUGIN_OPTIONS}"

Reference

Releases · shadowsocks/ShadowsocksX-NG

You can't perform that action at this time. https://github.com/shadowsocks/ShadowsocksX-NG/releases

Releases · xtaci/kcptun

You can't perform that action at this time. https://github.com/xtaci/kcptun/releases

kcptun插件选项不生效 · Issue #993 · shadowsocks/ShadowsocksX-NG

You can't perform that action at this time. https://github.com/shadowsocks/ShadowsocksX-NG/issues/993

返回首页
上一篇前端 NPM 多包项目 GIT 规范与发版流程思考下一篇TCP、UDP 调试命令

Discussion

留言与讨论

想法、补充和不同意见都欢迎。