lib: Close underlying conn in protocol (fixes #7165) (#7212)

This commit is contained in:
Simon Frei
2020-12-21 11:40:51 +01:00
committed by GitHub
parent 4a787986cd
commit c845e245a1
11 changed files with 106 additions and 124 deletions
+47
View File
@@ -8,6 +8,7 @@ package testutils
import (
"errors"
"net"
"sync"
)
@@ -52,3 +53,49 @@ func (rw *NoopRW) Read(p []byte) (n int, err error) {
func (rw *NoopRW) Write(p []byte) (n int, err error) {
return len(p), nil
}
type NoopCloser struct{}
func (NoopCloser) Close() error {
return nil
}
// FakeConnectionInfo implements the methods of protocol.Connection that are
// not implemented by protocol.Connection
type FakeConnectionInfo struct {
Name string
}
func (f *FakeConnectionInfo) RemoteAddr() net.Addr {
return &FakeAddr{}
}
func (f *FakeConnectionInfo) Type() string {
return "fake"
}
func (f *FakeConnectionInfo) Crypto() string {
return "fake"
}
func (f *FakeConnectionInfo) Transport() string {
return "fake"
}
func (f *FakeConnectionInfo) Priority() int {
return 9000
}
func (f *FakeConnectionInfo) String() string {
return ""
}
type FakeAddr struct{}
func (FakeAddr) Network() string {
return "network"
}
func (FakeAddr) String() string {
return "address"
}