From 7bb8f19b90ce7737cf7613e5d05f831b63984a07 Mon Sep 17 00:00:00 2001 From: "arraykeys@gmail.com" Date: Fri, 9 Mar 2018 16:02:05 +0800 Subject: [PATCH] Signed-off-by: arraykeys@gmail.com --- README.md | 16 ++++++++-------- README_ZH.md | 16 ++++++++-------- services/mux_bridge.go | 5 +++++ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 66b689b..c3a9e5c 100644 --- a/README.md +++ b/README.md @@ -281,13 +281,13 @@ Local HTTP (S) proxy use 28080 port,excute: `./proxy http -T ssh -P "2.2.2.2:22" -u user -S user.key -t tcp -p ":28080"` #### **1.8.KCP protocol transmission** -The KCP protocol requires a -B parameter to set a password which can encrypt and decrypt data. +The KCP protocol requires a --kcp-key parameter to set a password which can encrypt and decrypt data. Http first level proxy(VPS,IP:22.22.22.22) -`./proxy http -t kcp -p ":38080" -B mypassword` +`./proxy http -t kcp -p ":38080" --kcp-key mypassword` Http second level proxy(os is Linux) -`./proxy http -t tcp -p ":8080" -T kcp -P "22.22.22.22:38080" -B mypassword` +`./proxy http -t tcp -p ":8080" -T kcp -P "22.22.22.22:38080" --kcp-key mypassword` Then access to the local 8080 port is access to the proxy's port 38080 on the VPS, and the data is transmitted through the KCP protocol. #### **1.9.HTTP reverse proxy** Proxy supports not only set up a proxy through in other software, to provide services for other software, but support the request directly to the website domain to proxy monitor IP when proxy monitors 80 and 443 ports, then proxy will automatically access to the HTTP proxy access website for you.   @@ -657,13 +657,13 @@ ip: user's IP, for example: 192.168.1.200 If there is no -a or -F or --auth-url parameters, it means to turn off the authentication. #### **5.8.KCP protocol transmission** -The KCP protocol requires a -B parameter which can set a password to encrypt and decrypt data.   +The KCP protocol requires a --kcp-key parameter which can set a password to encrypt and decrypt data.   HTTP first level proxy(VPS,IP:22.22.22.22) -`./proxy socks -t kcp -p ":38080" -B mypassword` +`./proxy socks -t kcp -p ":38080" --kcp-key mypassword` HTTP two level proxy(local os is Linux) -`./proxy socks -t tcp -p ":8080" -T kcp -P "22.22.22.22:38080" -B mypassword` +`./proxy socks -t tcp -p ":8080" -T kcp -P "22.22.22.22:38080" --kcp-key mypassword` Then access to the local 8080 port is access to the proxy port 38080 on the VPS, and the data is transmitted through the KCP protocol. #### **5.9.Custom DNS** @@ -692,7 +692,7 @@ command: Suppose there is a KCP HTTP (s) proxy (password: demo123): 127.0.0.1:8080. Now we turn it into a common proxy that supports HTTP (s) and Socks5 at the same time. The local port after transformation is 18080. command: -`./proxy sps -S http -T kcp -P 127.0.0.1:8080 -t tcp -p :18080 -B demo123` +`./proxy sps -S http -T kcp -P 127.0.0.1:8080 -t tcp -p :18080 --kcp-key demo123` #### **6.3.SOCKS5 to HTTP(S) + SOCKS5** Suppose there is a common Socks5 proxy: 127.0.0.1:8080, now we turn it into a common proxy that supports HTTP (s) and Socks5 at the same time, and the local port after transformation is 18080. @@ -705,7 +705,7 @@ command: Suppose there is a KCP Socks5 proxy (password: demo123): 127.0.0.1:8080, now we turn it into a common proxy that support HTTP (s) and Socks5 at the same time, and the local port after transformation is 18080. command: -`./proxy sps -S socks -T kcp -P 127.0.0.1:8080 -t tcp -p :18080 -B demo123`   +`./proxy sps -S socks -T kcp -P 127.0.0.1:8080 -t tcp -p :18080 --kcp-key demo123`   #### **6.4.Chain style connection** It is mentioned above that multiple SPS nodes can be connected to build encrypted channels, assuming you have the following VPS and a PC. diff --git a/README_ZH.md b/README_ZH.md index 5eab06e..e3e2974 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -281,13 +281,13 @@ target:用户访问的URL,比如:http://demo.com:80/1.html或https://www.baidu.c `./proxy http -T ssh -P "2.2.2.2:22" -u user -S user.key -t tcp -p ":28080"` #### **1.8.KCP协议传输** -KCP协议需要-B参数设置一个密码用于加密解密数据 +KCP协议需要--kcp-key参数设置一个密码用于加密解密数据 一级HTTP代理(VPS,IP:22.22.22.22) -`./proxy http -t kcp -p ":38080" -B mypassword` +`./proxy http -t kcp -p ":38080" --kcp-key mypassword` 二级HTTP代理(本地Linux) -`./proxy http -t tcp -p ":8080" -T kcp -P "22.22.22.22:38080" -B mypassword` +`./proxy http -t tcp -p ":8080" -T kcp -P "22.22.22.22:38080" --kcp-key mypassword` 那么访问本地的8080端口就是访问VPS上面的代理端口38080,数据通过kcp协议传输. #### **1.9 HTTP(S)反向代理** @@ -661,13 +661,13 @@ ip:用户的IP,比如:192.168.1.200 如果没有-a或-F或--auth-url参数,就是关闭认证. #### **5.8.KCP协议传输** -KCP协议需要-B参数设置一个密码用于加密解密数据 +KCP协议需要--kcp-key参数设置一个密码用于加密解密数据 一级HTTP代理(VPS,IP:22.22.22.22) -`./proxy socks -t kcp -p ":38080" -B mypassword` +`./proxy socks -t kcp -p ":38080" --kcp-key mypassword` 二级HTTP代理(本地Linux) -`./proxy socks -t tcp -p ":8080" -T kcp -P "22.22.22.22:38080" -B mypassword` +`./proxy socks -t tcp -p ":8080" -T kcp -P "22.22.22.22:38080" --kcp-key mypassword` 那么访问本地的8080端口就是访问VPS上面的代理端口38080,数据通过kcp协议传输. #### **5.9.自定义DNS** @@ -695,7 +695,7 @@ KCP协议需要-B参数设置一个密码用于加密解密数据 假设已经存在一个kcp的http(s)代理(密码是:demo123):127.0.0.1:8080,现在我们把它转为同时支持http(s)和socks5的普通代理,转换后的本地端口为18080。 命令如下: -`./proxy sps -S http -T kcp -P 127.0.0.1:8080 -t tcp -p :18080 -B demo123` +`./proxy sps -S http -T kcp -P 127.0.0.1:8080 -t tcp -p :18080 --kcp-key demo123` #### **6.3 SOCKS5转HTTP(S)+SOCKS5** 假设已经存在一个普通的socks5代理:127.0.0.1:8080,现在我们把它转为同时支持http(s)和socks5的普通代理,转换后的本地端口为18080。 @@ -708,7 +708,7 @@ KCP协议需要-B参数设置一个密码用于加密解密数据 假设已经存在一个kcp的socks5代理(密码是:demo123):127.0.0.1:8080,现在我们把它转为同时支持http(s)和socks5的普通代理,转换后的本地端口为18080。 命令如下: -`./proxy sps -S socks -T kcp -P 127.0.0.1:8080 -t tcp -p :18080 -B demo123` +`./proxy sps -S socks -T kcp -P 127.0.0.1:8080 -t tcp -p :18080 --kcp-key demo123` #### **6.4 链式连接** 上面提过多个sps结点可以层级连接构建加密通道,假设有如下vps和家里的pc电脑。 diff --git a/services/mux_bridge.go b/services/mux_bridge.go index f452b48..0b097ce 100644 --- a/services/mux_bridge.go +++ b/services/mux_bridge.go @@ -93,6 +93,11 @@ func (s *MuxBridge) Start(args interface{}) (err error) { return } keyInfo := strings.Split(key, "-") + if len(keyInfo) != 2 { + utils.CloseConn(&inConn) + log.Printf("client key format error,key:%s", key) + return + } groupKey := keyInfo[0] index := keyInfo[1] if !s.clientControlConns.Has(groupKey) {