package quicreuse

Import Path
	github.com/libp2p/go-libp2p/p2p/transport/quicreuse (on go.dev)

Dependency Relation
	imports 25 packages, and imported by 4 packages

Involved Source Files config.go Package quicreuse provides `quicreuse.ConnManager`, which provides functionality for reusing QUIC transports for various purposes, like listening & dialing, having multiple QUIC listeners on the same address with different ALPNs, and sharing the same address with non QUIC transports like WebRTC. listener.go nonquic_packetconn.go options.go quic_multiaddr.go reuse.go tracer.go
Package-Level Type Names (total 7)
/* sort by: | */
ConnManager enables QUIC and WebTransport transports to listen on the same port, reusing listen addresses for dialing, and provides a PacketConn for sharing the listen address with other protocols like WebRTC. Reusing the listen address for dialing helps with address discovery and hole punching. For details of the reuse logic see `ListenQUICAndAssociate` and `DialQUIC`. If reuseport is disabled using the `DisableReuseport` option, listen addresses are not used for dialing. (*ConnManager) ClientConfig() *quic.Config (*ConnManager) Close() error DialQUIC dials `raddr`. Use `WithAssociation` to select a specific transport that was previously used for listening. see the documentation for `ListenQUICAndAssociate` for details on associate. The priority order for reusing the transport is as follows: - Listening transport with the same association - Any other listening transport - Any transport previously used for dialing If none of these are available, it'll create a new transport. LendTransport is an advanced method used to lend an existing QUICTransport to the ConnManager. The ConnManager will close the returned channel when it is done with the transport, so that the owner may safely close the transport. ListenQUIC listens for quic connections with the provided `tlsConf.NextProtos` ALPNs on `addr`. The same addr can be shared between different ALPNs. ListenQUICAndAssociate listens for quic connections with the provided `tlsConf.NextProtos` ALPNs on `addr`. The same addr can be shared between different ALPNs. The QUIC Transport used for listening is tagged with the `association`. Any subsequent `TransportWithAssociationForDial`, or `DialQUIC` calls with the same `association` will reuse the QUIC Transport used by this method. A common use of associations is to ensure /quic dials use the quic listening address and /webtransport dials use the WebTransport listening address. Protocols returns the supported QUIC protocols. The only supported protocol at the moment is /quic-v1. SharedNonQUICPacketConn returns a `net.PacketConn` for `laddr` for non QUIC uses. TransportForDial returns a transport for dialing `raddr`. If reuseport is enabled, it attempts to reuse the QUIC Transport used for previous listens or dials. TransportWithAssociationForDial returns a transport for dialing `raddr`. If reuseport is enabled, it attempts to reuse the QUIC Transport previously used for listening with `ListenQuicAndAssociate` with the same `association`. If it fails to do so, it uses any other previously used transport. *ConnManager : github.com/prometheus/common/expfmt.Closer *ConnManager : io.Closer func NewConnManager(statelessResetKey quic.StatelessResetKey, tokenKey quic.TokenGeneratorKey, opts ...Option) (*ConnManager, error) func github.com/libp2p/go-libp2p/p2p/transport/quic.NewTransport(key ic.PrivKey, connManager *ConnManager, psk pnet.PSK, gater connmgr.ConnectionGater, rcmgr network.ResourceManager) (tpt.Transport, error) func github.com/libp2p/go-libp2p/p2p/transport/webtransport.New(key ic.PrivKey, psk pnet.PSK, connManager *ConnManager, gater connmgr.ConnectionGater, rcmgr network.ResourceManager, opts ...libp2pwebtransport.Option) (tpt.Transport, error)
( Listener) Accept(context.Context) (quic.Connection, error) ( Listener) Addr() net.Addr ( Listener) Close() error ( Listener) Multiaddrs() []ma.Multiaddr Listener : QUICListener Listener : github.com/prometheus/common/expfmt.Closer Listener : io.Closer func (*ConnManager).ListenQUIC(addr ma.Multiaddr, tlsConf *tls.Config, allowWindowIncrease func(conn quic.Connection, delta uint64) bool) (Listener, error) func (*ConnManager).ListenQUICAndAssociate(association any, addr ma.Multiaddr, tlsConf *tls.Config, allowWindowIncrease func(conn quic.Connection, delta uint64) bool) (Listener, error)
func ConnContext(f func(ctx context.Context, clientInfo *quic.ClientInfo) (context.Context, error)) Option func DisableReuseport() Option func EnableMetrics(reg prometheus.Registerer) Option func OverrideListenUDP(f listenUDP) Option func OverrideSourceIPSelector(f func() (SourceIPSelector, error)) Option func VerifySourceAddress(f func(addr net.Addr) bool) Option func NewConnManager(statelessResetKey quic.StatelessResetKey, tokenKey quic.TokenGeneratorKey, opts ...Option) (*ConnManager, error) func github.com/libp2p/go-libp2p.QUICReuse(constructor interface{}, opts ...Option) libp2p.Option
( QUICListener) Accept(ctx context.Context) (quic.Connection, error) ( QUICListener) Addr() net.Addr ( QUICListener) Close() error Listener (interface) *github.com/quic-go/quic-go.Listener QUICListener : github.com/prometheus/common/expfmt.Closer QUICListener : io.Closer func QUICTransport.Listen(tlsConf *tls.Config, conf *quic.Config) (QUICListener, error) func RefCountedQUICTransport.Listen(tlsConf *tls.Config, conf *quic.Config) (QUICListener, error)
( QUICTransport) Close() error ( QUICTransport) Dial(ctx context.Context, addr net.Addr, tlsConf *tls.Config, conf *quic.Config) (quic.Connection, error) ( QUICTransport) Listen(tlsConf *tls.Config, conf *quic.Config) (QUICListener, error) ( QUICTransport) ReadNonQUICPacket(ctx context.Context, b []byte) (int, net.Addr, error) ( QUICTransport) WriteTo(b []byte, addr net.Addr) (int, error) QUICTransport : github.com/prometheus/common/expfmt.Closer QUICTransport : io.Closer func (*ConnManager).LendTransport(network string, tr QUICTransport, conn net.PacketConn) (<-chan struct{}, error)
( RefCountedQUICTransport) Close() error count transport reference ( RefCountedQUICTransport) Dial(ctx context.Context, addr net.Addr, tlsConf *tls.Config, conf *quic.Config) (quic.Connection, error) ( RefCountedQUICTransport) IncreaseCount() ( RefCountedQUICTransport) Listen(tlsConf *tls.Config, conf *quic.Config) (QUICListener, error) ( RefCountedQUICTransport) LocalAddr() net.Addr Used to send packets directly around QUIC. Useful for hole punching. RefCountedQUICTransport : github.com/prometheus/common/expfmt.Closer RefCountedQUICTransport : io.Closer func (*ConnManager).TransportForDial(network string, raddr *net.UDPAddr) (RefCountedQUICTransport, error) func (*ConnManager).TransportWithAssociationForDial(association any, network string, raddr *net.UDPAddr) (RefCountedQUICTransport, error)
( SourceIPSelector) PreferredSourceIPForDestination(dst *net.UDPAddr) (net.IP, error)
Package-Level Functions (total 10)
ConnContext sets the context for all connections accepted by listeners. This doesn't affect the context for dialed connections. To reject a connection, return a non nil error.
EnableMetrics enables Prometheus metrics collection. If reg is nil, prometheus.DefaultRegisterer will be used as the registerer.
NewConnManager returns a new ConnManager
VerifySourceAddress returns whether to verify the source address for incoming connection requests. For more details see: `quic.Transport.VerifySourceAddress`
WithAssociation returns a new context with the given association. Used in DialQUIC to prefer a transport that has the given association.