Compare commits

..
2 Commits
Author SHA1 Message Date
xtaci bf1d0d6419 passive tunnel termination 2018-03-05 16:38:28 +08:00
xtaciandGitHub 834cc5d596 Update README.md 2017-12-03 21:59:22 +08:00
3 changed files with 17 additions and 29 deletions
+3 -5
View File
@@ -293,10 +293,8 @@ The parameters below **MUST** be **IDENTICAL** on **BOTH** side:
1. https://en.wikipedia.org/wiki/Noisy-channel_coding_theorem -- Noisy channel coding theorem
1. https://play.google.com/store/apps/details?id=com.k17game.k3 -- Battle Zone - Earth 2048, an online strategy game using kcp.
Donate via ETH:
### Donate via Ethereum(ETH)
Address: 0x2e4b43ab3d0983da282592571eef61ae5e60f726
Address: 0x2e4b43ab3d0983da282592571eef61ae5e60f726 , Or scan here:
QR Code:
![ETH](0x2e4b43ab3d0983da282592571eef61ae5e60f726.png)
<img src="0x2e4b43ab3d0983da282592571eef61ae5e60f726.png" alt="kcptun" height="100px" />
+7 -12
View File
@@ -9,6 +9,7 @@ import (
"math/rand"
"net"
"os"
"sync"
"time"
"golang.org/x/crypto/pbkdf2"
@@ -68,18 +69,12 @@ func handleClient(sess *smux.Session, p1 io.ReadWriteCloser, quiet bool) {
}
defer p2.Close()
// 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:
}
// 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()
}
func checkError(err error) {
+7 -12
View File
@@ -11,6 +11,7 @@ import (
"net/http"
_ "net/http/pprof"
"os"
"sync"
"time"
"golang.org/x/crypto/pbkdf2"
@@ -93,18 +94,12 @@ func handleClient(p1, p2 io.ReadWriteCloser, quiet bool) {
defer p1.Close()
defer p2.Close()
// 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:
}
// 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()
}
func checkError(err error) {