mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-05 07:50:24 +08:00
add log to file option -l
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user