Commit b9c1a08d authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

WrapNetConn: err on nil input

License: MIT
Signed-off-by: default avatarJuan Batiz-Benet <juan@benet.ai>
parent 62d4c740
...@@ -26,6 +26,9 @@ type Conn interface { ...@@ -26,6 +26,9 @@ type Conn interface {
// WrapNetConn wraps a net.Conn object with a Multiaddr // WrapNetConn wraps a net.Conn object with a Multiaddr
// friendly Conn. // friendly Conn.
func WrapNetConn(nconn net.Conn) (Conn, error) { func WrapNetConn(nconn net.Conn) (Conn, error) {
if nconn == nil {
return nil, fmt.Errorf("failed to convert nconn.LocalAddr: nil")
}
laddr, err := FromNetAddr(nconn.LocalAddr()) laddr, err := FromNetAddr(nconn.LocalAddr())
if err != nil { if err != nil {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment