Commit d8a6d25b authored by Jeromy's avatar Jeromy
Browse files

add a read deadline for the multistream select on dial

Showing with 5 additions and 0 deletions
+5 -0
......@@ -4,6 +4,7 @@ import (
"fmt"
"math/rand"
"strings"
"time"
addrutil "github.com/ipfs/go-libp2p/p2p/net/swarm/addr"
transport "gx/ipfs/QmRHqYZs3Diy8YC3bW16zvs8VDDwS2ARKBuKwALxEMqibc/go-libp2p-transport"
......@@ -68,12 +69,16 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
cryptoProtoChoice = NoEncryptionTag
}
maconn.SetReadDeadline(time.Now().Add(NegotiateReadTimeout))
err = msmux.SelectProtoOrFail(cryptoProtoChoice, maconn)
if err != nil {
errOut = err
return
}
maconn.SetReadDeadline(time.Time{})
c, err := newSingleConn(ctx, d.LocalPeer, remote, maconn)
if err != nil {
maconn.Close()
......
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