client.go | 11 +++++------ torrent.go | 3 ++- diff --git a/client.go b/client.go index 735d58cad063f8e8c75332d87cd9d030af34742a..416453677c14b6d5a4dfa4ddb82f7d5a7f6b8067 100644 --- a/client.go +++ b/client.go @@ -658,18 +658,17 @@ } // Performs initiator handshakes and returns a connection. Returns nil *connection if no connection // for valid reasons. -func (cl *Client) handshakesConnection( +func (cl *Client) initiateProtocolHandshakes( ctx context.Context, nc net.Conn, t *Torrent, - encryptHeader bool, + outgoing, encryptHeader bool, remoteAddr net.Addr, - network, - connString string, + network, connString string, ) ( c *PeerConn, err error, ) { - c = cl.newConnection(nc, true, remoteAddr, network, connString) + c = cl.newConnection(nc, outgoing, remoteAddr, network, connString) c.headerEncrypted = encryptHeader ctx, cancel := context.WithTimeout(ctx, cl.config.HandshakesTimeout) defer cancel() @@ -701,7 +700,7 @@ return nil, xerrors.Errorf("dialing: %w", dialCtx.Err()) } return nil, errors.New("dial failed") } - c, err := cl.handshakesConnection(context.Background(), nc, t, obfuscatedHeader, addr, dr.Network, regularConnString(nc)) + c, err := cl.initiateProtocolHandshakes(context.Background(), nc, t, true, obfuscatedHeader, addr, dr.Network, regularConnString(nc)) if err != nil { nc.Close() } diff --git a/torrent.go b/torrent.go index b4d1764807b473c1d098c6e386d8c12e02f93f82..0a8cfe4b6a6a7f15a94a6c1b3670676d27497ed2 100644 --- a/torrent.go +++ b/torrent.go @@ -1287,10 +1287,11 @@ c datachannel.ReadWriteCloser, dcc webtorrent.DataChannelContext, ) { defer c.Close() - pc, err := t.cl.handshakesConnection( + pc, err := t.cl.initiateProtocolHandshakes( context.Background(), webrtcNetConn{c, dcc}, t, + dcc.LocalOffered, false, webrtcNetAddr{dcc.Remote}, webrtcNetwork,