Compare commits

...
2 Commits
Author SHA1 Message Date
xtaci 03f27ec53d Revert "passive tunnel termination"
This reverts commit bf1d0d6419.
2018-03-16 13:44:44 +08:00
xtaciandGitHub b2390a5dd3 Update README.md 2018-03-16 13:30:53 +08:00
3 changed files with 28 additions and 14 deletions
+4
View File
@@ -27,6 +27,10 @@
### QuickStart
Increase number of open files on your server, as:
`ulimit -n 65535`, or write it in `~/.bashrc`.
Download precompiled [Releases](https://github.com/xtaci/kcptun/releases).
```
+12 -7
View File
@@ -9,7 +9,6 @@ import (
"math/rand"
"net"
"os"
"sync"
"time"
"golang.org/x/crypto/pbkdf2"
@@ -69,12 +68,18 @@ func handleClient(sess *smux.Session, p1 io.ReadWriteCloser, quiet bool) {
}
defer p2.Close()
// tunnel setup
var wg sync.WaitGroup
wg.Add(2)
go func() { io.Copy(p1, p2); wg.Done() }()
go func() { io.Copy(p2, p1); wg.Done() }()
wg.Wait()
// start tunnel
p1die := make(chan struct{})
go func() { io.Copy(p1, p2); close(p1die) }()
p2die := make(chan struct{})
go func() { io.Copy(p2, p1); close(p2die) }()
// wait for tunnel termination
select {
case <-p1die:
case <-p2die:
}
}
func checkError(err error) {
+12 -7
View File
@@ -11,7 +11,6 @@ import (
"net/http"
_ "net/http/pprof"
"os"
"sync"
"time"
"golang.org/x/crypto/pbkdf2"
@@ -94,12 +93,18 @@ func handleClient(p1, p2 io.ReadWriteCloser, quiet bool) {
defer p1.Close()
defer p2.Close()
// tunnel setup
var wg sync.WaitGroup
wg.Add(2)
go func() { io.Copy(p1, p2); wg.Done() }()
go func() { io.Copy(p2, p1); wg.Done() }()
wg.Wait()
// start tunnel
p1die := make(chan struct{})
go func() { io.Copy(p1, p2); close(p1die) }()
p2die := make(chan struct{})
go func() { io.Copy(p2, p1); close(p2die) }()
// wait for tunnel termination
select {
case <-p1die:
case <-p2die:
}
}
func checkError(err error) {