Involved Source Filesconfig.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.gononquic_packetconn.gooptions.goquic_multiaddr.goreuse.gotracer.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)
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.
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.
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.