mirror of
https://github.com/xtaci/kcptun.git
synced 2024-04-21 12:32:32 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03f27ec53d | ||
|
|
b2390a5dd3 |
@@ -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
@@ -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
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user