mirror of
https://github.com/xtaci/kcptun.git
synced 2024-04-21 12:32:32 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf1d0d6419 | ||
|
|
834cc5d596 |
@@ -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:
|
||||
|
||||

|
||||
<img src="0x2e4b43ab3d0983da282592571eef61ae5e60f726.png" alt="kcptun" height="100px" />
|
||||
|
||||
+7
-12
@@ -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
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user