1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-29 07:10:25 +08:00

fix: async wait

This commit is contained in:
源文雨
2023-08-05 13:53:09 +08:00
parent a3ae280a7f
commit 1caf27dfa9
9 changed files with 252 additions and 156 deletions

View File

@@ -1,6 +1,7 @@
package tunnel
import (
"encoding/hex"
"io"
"net"
@@ -82,7 +83,13 @@ func (s *Tunnel) Stop() {
func (s *Tunnel) handleWrite() {
for b := range s.in {
logrus.Debugln("[tunnel] write recv", b)
end := 64
endl := "..."
if len(b) < 64 {
end = len(b)
endl = "."
}
logrus.Debugln("[tunnel] write send", hex.EncodeToString(b[:end]), endl)
if b == nil {
logrus.Errorln("[tunnel] write recv nil")
break
@@ -114,7 +121,13 @@ func (s *Tunnel) handleRead() {
logrus.Errorln("[tunnel] read recv nil")
break
}
logrus.Debugln("[tunnel] read recv", p.Data)
end := 64
endl := "..."
if len(p.Data) < 64 {
end = len(p.Data)
endl = "."
}
logrus.Debugln("[tunnel] read recv", hex.EncodeToString(p.Data[:end]), endl)
s.out <- p.Data
p.Put()
}