Skip to content

Commit e697f94

Browse files
committed
# Conflicts: # server/main.go
2 parents 5698338 + d374f93 commit e697f94

23 files changed

+400
-475
lines changed

.github/ISSUE_TEMPLATE

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
问问题前先搜索ISSUE,并搞清楚下面的问题:
22

33
1. 检查 ```-key xxx``` 至少三遍, ***保证***两边一致。
4-
2. 保证```-nocomp, -datashard, -parityshard, -key, -crypt```两边一致。
4+
2. 保证```-nocomp, -datashard, -parityshard, -key, -crypt, -smuxver```两边一致。
55
3. 是否在服务器端,正确设定了转发的目标服务器地址 ***--target***。
6-
4. 如果第3条不确定,尝试在服务器上telnet target port试试。
7-
5. 防火墙是否关闭了UDP通信。
8-
6. 两端的版本是否一致?
9-
7. 是不是最新版本?
10-
8. 两端分别是什么操作系统?
11-
9. 两端的输出日志是什么?
6+
4. 是否在客户端,正确的连接到了 client的监听端口。
7+
5. 如果第3条不确定,尝试在服务器上telnet target port试试。
8+
6. 防火墙是否关闭了UDP通信,或者设置了UDP的最大发包速率?
9+
7. 两端的版本是否一致?
10+
8. 是不是最新版本?
11+
9. 两端分别是什么操作系统?
12+
10. 两端的输出日志是什么?
1213

1314
Before firing issue, make sure you figured out the following common questions.
1415

1516
PLEASE DO SEARCH FIRST.
1617

1718
1. Check your ```-key xxx``` for at least 3 times, ***MAKE SURE*** both sides share the same secret.
18-
2. ```-nocomp, -datashard, -parityshard, -key, -crypt``` ***must be the same*** on both side.
19+
2. ```-nocomp, -datashard, -parityshard, -key, -crypt, -smuxver``` ***must be the same*** on both side.
1920
3. Did you correctly set the ***-target*** on the server side?
20-
4. ***MAKE SURE*** ```telnet target port``` on your server successful(don't ask me why couldn't).
21-
5. Does your ***firewall allows UDP*** communications? (including your ISP Cable-Modem)
22-
6. Are you using the **same version** for both client & server
23-
7. Are you using the **latest release**?
24-
8. Which **OS** do you use?
25-
9. Which end for this issue related to, **client or server**?
21+
4. Did you correctly connected to the listening port on client side?
22+
5. ***MAKE SURE*** ```telnet target port``` on your server successful(don't ask me why couldn't).
23+
6. Does your ***firewall allows UDP*** communications? (including your ISP Cable-Modem)
24+
7. Are you using the **same version** for both client & server
25+
8. Are you using the **latest release**?
26+
9. Which **OS** do you use?
27+
10. Which end for this issue related to, **client or server**?
2628

2729

.travis.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
language: go
22
go:
3-
- 1.10.x
43
- 1.11.x
54
- 1.12.x
5+
- 1.13.x
66
before_install:
77
- go get github.com/mattn/goveralls
88
- go get golang.org/x/tools/cmd/cover
99
install:
10-
- go get github.com/xtaci/kcptun/client
11-
- go get github.com/xtaci/kcptun/server
10+
- env GO111MODULE=on go get github.com/xtaci/kcptun/client
11+
- env GO111MODULE=on go get github.com/xtaci/kcptun/server
1212
before_script:
1313
script:
1414
- cd $HOME/gopath/src/github.com/xtaci/kcptun/client
15-
- $HOME/gopath/bin/goveralls -service=travis-ci
15+
- env GO111MODULE=on $HOME/gopath/bin/goveralls -service=travis-ci
1616
- cd $HOME/gopath/src/github.com/xtaci/kcptun/server
17-
- $HOME/gopath/bin/goveralls -service=travis-ci
17+
- env GO111MODULE=on $HOME/gopath/bin/goveralls -service=travis-ci
1818
- exit 0

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM golang:alpine as builder
22
MAINTAINER xtaci <[email protected]>
3+
ENV GO111MODULE=on
34
RUN apk update && \
45
apk upgrade && \
56
apk add git gcc libc-dev linux-headers

README.md

+33-23
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
[4]: https://travis-ci.org/xtaci/kcptun
99
[5]: https://goreportcard.com/badge/github.com/xtaci/kcptun
1010
[6]: https://goreportcard.com/report/github.com/xtaci/kcptun
11-
[7]: https://img.shields.io/badge/license-MIT-blue.svg
12-
[8]: https://raw.githubusercontent.com/xtaci/kcptun/master/LICENSE.md
13-
[11]: https://img.shields.io/badge/license-MIT-blue.svg
11+
[11]: https://img.shields.io/github/license/xtaci/kcptun
1412
[12]: LICENSE.md
15-
[13]: https://img.shields.io/github/release/xtaci/kcptun.svg
13+
[13]: https://img.shields.io/github/v/release/xtaci/kcptun?color=orange
1614
[14]: https://github.com/xtaci/kcptun/releases/latest
17-
[15]: https://img.shields.io/github/downloads/xtaci/kcptun/total.svg?maxAge=1800
15+
[15]: https://img.shields.io/github/downloads/xtaci/kcptun/total.svg?maxAge=1800&color=red
1816
[16]: https://github.com/xtaci/kcptun/releases
1917
[17]: https://img.shields.io/badge/KCP-Powered-blue.svg
2018
[18]: https://github.com/skywind3000/kcp
@@ -23,6 +21,15 @@
2321

2422
> *Disclaimer: kcptun maintains a single website — [github.com/xtaci/kcptun](https://github.com/xtaci/kcptun). Any websites other than [github.com/xtaci/kcptun](https://github.com/xtaci/kcptun) are not endorsed by xtaci.*
2523
24+
### Requirements
25+
26+
| Target | Minimum | Recommended |
27+
| --- | --- | --- |
28+
| System | aix darwin dragonfly freebsd linux netbsd openbsd solaris windows | linux |
29+
| Memory | >20MB | >32MB |
30+
| CPU | ANY | amd64 with AES-NI & AVX2 |
31+
32+
2633
### QuickStart
2734

2835
Increase the number of open files on your server, as:
@@ -59,10 +66,13 @@ which tunnels the original connection:
5966

6067
> Application -> Target Server(8388/tcp)
6168
62-
### Install from source
69+
### Build from source
6370

6471
```
65-
$go get -u github.com/xtaci/kcptun/...
72+
$ git clone https://github.com/xtaci/kcptun.git
73+
$ cd kcptun
74+
$ ./build-release.sh
75+
$ cd build
6676
```
6777

6878
All precompiled releases are genereated from `build-release.sh` script.
@@ -105,6 +115,8 @@ All precompiled releases are genereated from `build-release.sh` script.
105115
Since streams are multiplexed into a single physical channel, head of line blocking may appear under certain circumstances, by
106116
increasing `-smuxbuf` to a larger value (default 4MB) may mitigate this problem, obviously this will costs more memory.
107117

118+
For versions >= v20190924, you can switch to smux version 2, smux v2 has options to limit per-stream memory usage, now set `-smuxver 2` to enable smux v2, and adjust `-streambuf` to limit per-stream memory usage, eg: `-streambuf 2097152` can limit per-stream memory usage to 2MB. By limiting stream buffer on the receiver side, a back-pressure will be conducted to the sender and limits reading, and finally prevent source from sending too much data to occupy every bits of buffer along the link. (Setting -smuxver **MUST** be **IDENTICAL** on both side, default is 1. )
119+
108120
#### Slow Devices
109121

110122
kcptun made use of **ReedSolomon-Codes** to recover lost packets, which requires massive amount of computation, a low-end ARM device cannot satisfy kcptun well. To unleash the full potential of kcptun, a multi-core x86 homeserver CPU like AMD Opteron is recommended.
@@ -119,18 +131,18 @@ If you insist on running under some ARM routers, you'd better turn off `FEC` and
119131
#### Usage
120132

121133
```
122-
xtaci@gw:~$ ./client_linux_amd64 -h
134+
➜ ~ ./client_linux_amd64 -h
123135
NAME:
124136
kcptun - client(with SMUX)
125137
126138
USAGE:
127139
client_linux_amd64 [global options] command [command options] [arguments...]
128140
129141
VERSION:
130-
20190409
142+
20190924
131143
132144
COMMANDS:
133-
help, h Shows a list of commands or help for one command
145+
help, h Shows a list of commands or help for one command
134146
135147
GLOBAL OPTIONS:
136148
--localaddr value, -l value local listen address (default: ":12948")
@@ -149,32 +161,35 @@ GLOBAL OPTIONS:
149161
--dscp value set DSCP(6bit) (default: 0)
150162
--nocomp disable compression
151163
--sockbuf value per-socket buffer in bytes (default: 4194304)
164+
--smuxver value specify smux version, available 1,2 (default: 1)
152165
--smuxbuf value the overall de-mux buffer in bytes (default: 4194304)
166+
--streambuf value per stream receive buffer in bytes, smux v2+ (default: 2097152)
153167
--keepalive value seconds between heartbeats (default: 10)
154168
--snmplog value collect snmp to file, aware of timeformat in golang, like: ./snmp-20060102.log
155169
--snmpperiod value snmp collect period, in seconds (default: 60)
156170
--log value specify a log file to output, default goes to stderr
157171
--quiet to suppress the 'stream open/close' messages
172+
--tcp to emulate a TCP connection(linux)
158173
-c value config from json file, which will override the command from shell
159174
--help, -h show help
160175
--version, -v print the version
161176
162-
xtaci@gw:~$ ./server_linux_amd64 -h
177+
➜ ~ ./server_linux_amd64 -h
163178
NAME:
164179
kcptun - server(with SMUX)
165180
166181
USAGE:
167182
server_linux_amd64 [global options] command [command options] [arguments...]
168183
169184
VERSION:
170-
20190409
185+
20190924
171186
172187
COMMANDS:
173-
help, h Shows a list of commands or help for one command
188+
help, h Shows a list of commands or help for one command
174189
175190
GLOBAL OPTIONS:
176191
--listen value, -l value kcp server listen address (default: ":29900")
177-
--target value, -t value target server address (default: "127.0.0.1:12948")
192+
--target value, -t value target server address, or path/to/unix_socket (default: "127.0.0.1:12948")
178193
--key value pre-shared secret between client and server (default: "it's a secrect") [$KCPTUN_KEY]
179194
--crypt value aes, aes-128, aes-192, salsa20, blowfish, twofish, cast5, 3des, tea, xtea, xor, sm4, none (default: "aes")
180195
--mode value profiles: fast3, fast2, fast, normal, manual (default: "fast")
@@ -186,13 +201,16 @@ GLOBAL OPTIONS:
186201
--dscp value set DSCP(6bit) (default: 0)
187202
--nocomp disable compression
188203
--sockbuf value per-socket buffer in bytes (default: 4194304)
204+
--smuxver value specify smux version, available 1,2 (default: 1)
189205
--smuxbuf value the overall de-mux buffer in bytes (default: 4194304)
206+
--streambuf value per stream receive buffer in bytes, smux v2+ (default: 2097152)
190207
--keepalive value seconds between heartbeats (default: 10)
191208
--snmplog value collect snmp to file, aware of timeformat in golang, like: ./snmp-20060102.log
192209
--snmpperiod value snmp collect period, in seconds (default: 60)
193210
--pprof start profiling server on :6060
194211
--log value specify a log file to output, default goes to stderr
195212
--quiet to suppress the 'stream open/close' messages
213+
--tcp to emulate a TCP connection(linux)
196214
-c value config from json file, which will override the command from shell
197215
--help, -h show help
198216
--version, -v print the version
@@ -346,6 +364,7 @@ The parameters below **MUST** be **IDENTICAL** on **BOTH** side:
346364
1. -nocomp
347365
1. -datashard
348366
1. -parityshard
367+
1. -smuxver
349368

350369
### References
351370

@@ -366,14 +385,5 @@ The parameters below **MUST** be **IDENTICAL** on **BOTH** side:
366385
1. https://en.wikipedia.org/wiki/Noisy-channel_coding_theorem -- Noisy channel coding theorem
367386
1. https://zhuanlan.zhihu.com/p/53849089 -- kcptun开发小记
368387

369-
### Donate
370-
371-
via Ethereum(ETH): Address: 0x2e4b43ab3d0983da282592571eef61ae5e60f726 , Or scan here:
372-
373-
<img src="0x2e4b43ab3d0983da282592571eef61ae5e60f726.png" alt="kcptun" height="120px" />
374-
375-
via WeChat
376-
377-
<img src="wechat_donate.jpg" alt="kcptun" height="120px" />
378388

379389
(注意:我没有任何社交网站的账号,请小心骗子。)

build-release.sh

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ cd $BUILD_DIR
66

77
sum="sha1sum"
88

9-
if [ "$GO111MODULE" != "on" ]; then
10-
echo "GO111MODULE is off"
11-
else
12-
echo "GO111MODULE is on"
13-
fi
9+
export GO111MODULE=on
10+
echo "Setting GO111MODULE to" $GO111MODULE
1411

1512
if ! hash sha1sum 2>/dev/null; then
1613
if ! hash shasum 2>/dev/null; then

client/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ type Config struct {
2828
Resend int `json:"resend"`
2929
NoCongestion int `json:"nc"`
3030
SockBuf int `json:"sockbuf"`
31+
SmuxVer int `json:"smuxver"`
3132
SmuxBuf int `json:"smuxbuf"`
33+
StreamBuf int `json:"streambuf"`
3234
KeepAlive int `json:"keepalive"`
3335
Log string `json:"log"`
3436
SnmpLog string `json:"snmplog"`

client/dial.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"github.com/pkg/errors"
5-
kcp "github.com/xtaci/kcp-go"
5+
kcp "github.com/xtaci/kcp-go/v5"
66
"github.com/xtaci/tcpraw"
77
)
88

0 commit comments

Comments
 (0)