package quicimport ()// make it possible to mock connection ID for initial generation in the testsvar generateConnectionIDForInitial = protocol.GenerateConnectionIDForInitial// DialAddr establishes a new QUIC connection to a server.// It resolves the address, and then creates a new UDP connection to dial the QUIC server.// When the QUIC connection is closed, this UDP connection is closed.// See [Dial] for more details.func ( context.Context, string, *tls.Config, *Config) (*Conn, error) { , := net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4zero, Port: 0})if != nil {returnnil, } , := net.ResolveUDPAddr("udp", )if != nil {returnnil, } , := setupTransport(, , true)if != nil {returnnil, } , := .dial(, , , , , false)if != nil { .Close()returnnil, }return , nil}// DialAddrEarly establishes a new 0-RTT QUIC connection to a server.// See [DialAddr] for more details.func ( context.Context, string, *tls.Config, *Config) (*Conn, error) { , := net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4zero, Port: 0})if != nil {returnnil, } , := net.ResolveUDPAddr("udp", )if != nil {returnnil, } , := setupTransport(, , true)if != nil {returnnil, } , := .dial(, , , , , true)if != nil { .Close()returnnil, }return , nil}// DialEarly establishes a new 0-RTT QUIC connection to a server using a net.PacketConn.// See [Dial] for more details.func ( context.Context, net.PacketConn, net.Addr, *tls.Config, *Config) (*Conn, error) { , := setupTransport(, , false)if != nil {returnnil, } , := .DialEarly(, , , )if != nil { .Close()returnnil, }return , nil}// Dial establishes a new QUIC connection to a server using a net.PacketConn.// If the PacketConn satisfies the [OOBCapablePacketConn] interface (as a [net.UDPConn] does),// ECN and packet info support will be enabled. In this case, ReadMsgUDP and WriteMsgUDP// will be used instead of ReadFrom and WriteTo to read/write packets.// The [tls.Config] must define an application protocol (using tls.Config.NextProtos).//// This is a convenience function. More advanced use cases should instantiate a [Transport],// which offers configuration options for a more fine-grained control of the connection establishment,// including reusing the underlying UDP socket for multiple QUIC connections.func ( context.Context, net.PacketConn, net.Addr, *tls.Config, *Config) (*Conn, error) { , := setupTransport(, , false)if != nil {returnnil, } , := .Dial(, , , )if != nil { .Close()returnnil, }return , nil}func setupTransport( net.PacketConn, *tls.Config, bool) (*Transport, error) {if == nil {returnnil, errors.New("quic: tls.Config not set") }return &Transport{Conn: ,createdConn: ,isSingleUse: true, }, nil}
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.