Skip to content

Commit

Permalink
webrtc: remove the streams limit
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Oct 23, 2023
1 parent b7c04f8 commit 851d1be
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions p2p/transport/webrtc/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ var _ tpt.CapableConn = &connection{}
// maxAcceptQueueLen is the number of waiting streams.
const maxAcceptQueueLen = 256

const maxDataChannelID = 1 << 10

type errConnectionTimeout struct{}

var _ net.Error = &errConnectionTimeout{}
Expand Down Expand Up @@ -195,12 +193,6 @@ func (c *connection) OpenStream(ctx context.Context) (network.MuxedStream, error
if id > math.MaxUint16 {
return nil, errors.New("exhausted stream ID space")
}
// Limit the number of streams, since we're not able to actually properly close them.
// See https://github.com/libp2p/specs/issues/575 for details.
if id > maxDataChannelID {
c.Close()
return c.OpenStream(ctx)
}

streamID := uint16(id)
dc, err := c.pc.CreateDataChannel("", &webrtc.DataChannelInit{ID: &streamID})
Expand Down Expand Up @@ -329,12 +321,6 @@ func (c *connection) setRemotePublicKey(key ic.PubKey) {
func SetupDataChannelQueue(pc *webrtc.PeerConnection, queueLen int) chan DetachedDataChannel {
queue := make(chan DetachedDataChannel, queueLen)
pc.OnDataChannel(func(dc *webrtc.DataChannel) {
// Limit the number of streams, since we're not able to actually properly close them.
// See https://github.com/libp2p/specs/issues/575 for details.
if *dc.ID() > maxDataChannelID {
dc.Close()
return
}
dc.OnOpen(func() {
rwc, err := dc.Detach()
if err != nil {
Expand Down

0 comments on commit 851d1be

Please sign in to comment.