Skip to content

Commit

Permalink
webrtc: add missing call to ConnectionGater.InterceptSecured
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jun 13, 2023
1 parent 6ee6784 commit affee88
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion p2p/transport/webrtc/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ func (l *listener) handleCandidate(ctx context.Context, addr *candidateAddr) (tp
scope.Done()
return nil, err
}
if l.transport.gater != nil && !l.transport.gater.InterceptSecured(network.DirInbound, conn.RemotePeer(), conn) {
conn.Close()
return nil, errors.New("connection gated")
}
return conn, nil
}

Expand Down Expand Up @@ -262,6 +266,8 @@ func (l *listener) setupConnection(
return nil, err
}

localMultiaddrWithoutCerthash, _ := ma.SplitFunc(l.localMultiaddr, func(c ma.Component) bool { return c.Protocol().Code == ma.P_CERTHASH })

handshakeChannel := newStream(nil, rawDatachannel, rwc, l.localAddr, addr.raddr)
// The connection is instantiated before performing the Noise handshake. This is
// to handle the case where the remote is faster and attempts to initiate a stream
Expand All @@ -272,7 +278,7 @@ func (l *listener) setupConnection(
l.transport,
scope,
l.transport.localPeerId,
l.localMultiaddr,
localMultiaddrWithoutCerthash,
"", // remotePeer
nil, // remoteKey
remoteMultiaddr,
Expand Down

0 comments on commit affee88

Please sign in to comment.