mirror of
https://github.com/libp2p/go-libp2p.git
synced 2025-09-26 20:21:26 +08:00

This introduces a new GatedMaListener type which gates conns accepted from a manet.Listener with a gater and creates the rcmgr scope for it. Explicitly passing the scope allows for many guardrails that the previous interface assertion didn't. This breaks the previous responsibility of the upgradeListener method into two, one gating the connection initially, and the other upgrading the connection with a security and muxer selection. This split makes it easy to gate the connection with the resource manager as early as possible. This is especially true for websocket because we want to gate the connection just after the TCP connection is established, and not after the tls handshake + websocket upgrade is completed.
20 lines
508 B
Go
20 lines
508 B
Go
// riscv64 see: https://github.com/marten-seemann/tcp/pull/1
|
|
|
|
//go:build windows || riscv64 || loong64
|
|
|
|
package tcp
|
|
|
|
import (
|
|
"github.com/libp2p/go-libp2p/core/transport"
|
|
manet "github.com/multiformats/go-multiaddr/net"
|
|
)
|
|
|
|
type aggregatingCollector struct{}
|
|
|
|
func newTracingConn(c manet.Conn, collector *aggregatingCollector, isClient bool) (manet.Conn, error) {
|
|
return c, nil
|
|
}
|
|
func newTracingListener(l transport.GatedMaListener, collector *aggregatingCollector) transport.GatedMaListener {
|
|
return l
|
|
}
|