+func (t *Torrent) onWebRtcConn(
+ c datachannel.ReadWriteCloser,
+ initiatedLocally bool, // Whether we offered first, or they did.
+) {
+ defer c.Close()
+ pc, err := t.cl.handshakesConnection(context.Background(), webrtcNetConn{c}, t, false, nil, "webrtc")
+ if err != nil {
+ t.logger.Printf("error in handshaking webrtc connection: %v", err)
+ }
+ if initiatedLocally {
+ pc.Discovery = PeerSourceTracker
+ } else {
+ pc.Discovery = PeerSourceIncoming
+ }
+ t.cl.lock()
+ defer t.cl.unlock()
+ t.cl.runHandshookConn(pc, t)
+}
+