1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-04 23:40:26 +08:00

add log to file option -l

This commit is contained in:
源文雨
2022-04-20 19:02:32 +08:00
parent 9f90cc456c
commit 6586b5dd10
5 changed files with 28 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
package tunnel
import (
"errors"
"io"
"net"
"github.com/sirupsen/logrus"
@@ -72,7 +72,7 @@ func (s *Tunnel) Read(p []byte) (int, error) {
return copy(p, d[:len(p)]), nil
}
}
return 0, errors.New("reading reaches nil")
return 0, io.EOF
}
func (s *Tunnel) Stop() {

View File

@@ -3,6 +3,7 @@ package tunnel
import (
"crypto/rand"
"encoding/hex"
"io"
"testing"
curve "github.com/fumiama/go-x25519"
@@ -84,6 +85,17 @@ func TestTunnel(t *testing.T) {
t.Fatal("error: recv 4096 bytes data")
}
sendb = make([]byte, 65535)
rand.Read(sendb)
n, _ := tunnme.Write(sendb)
t.Log("write", n, "bytes")
buf = make([]byte, 65535)
n, _ = io.ReadFull(&tunnpeer, buf)
t.Log("read", n, "bytes")
if string(sendb) != string(buf) {
t.Fatal("error: recv 65535 bytes data")
}
tunnme.Stop()
tunnpeer.Stop()
}