Documentation ¶
Overview ¶
Wraps quic structures in standard net interfaces and improves context awareness. Conn instances created by this package may be multiplexed
Index ¶
- Constants
- Variables
- func DialUDPNetx(addr string) (net.PacketConn, *net.UDPAddr, error)
- func IsPeerGoingAway(err error) bool
- func Listen(pconn net.PacketConn, tlsConf *tls.Config, config *Config) (net.Listener, error)
- func ListenAddr(addr string, tlsConf *tls.Config, config *Config) (net.Listener, error)
- type Client
- type Config
- type Conn
- type QuicDialFn
- type UDPDialFn
Constants ¶
const ( // This the value represents HTTP/3 protocol (over quic v1). AlpnH3 = "h3" // This the value represents HTTP/3 protocol (over quic draft 29). AlpnH3_29 = "h3-29" )
Variables ¶
Functions ¶
func DialUDPNetx ¶
DialUDPNetx is a UDPDialFn that resolves addresses and obtains the net.PacketConn using the netx package.
func IsPeerGoingAway ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
NewClient returns a client that creates multiplexed QUIC connections in a single Session with the given address using the provided configuration.
The Session is created using the QuicDialFn given, but is not established until the first call to Dial(), DialContext() or Connect()
if dial is nil, the default quic dialer is used
func NewClientWithPinnedCert ¶
func NewClientWithPinnedCert(addr string, tlsConf *tls.Config, config *Config, dial QuicDialFn, cert *x509.Certificate) *Client
NewClientWithPinnedCert returns a new client configured as with NewClient, but accepting only a specific given certificate. If the certificate presented by the connected server does match the given certificate, the connection is rejected. This check is performed regardless of tls.Config settings (ie even if InsecureSkipVerify is true)
If a nil certificate is given, the check is not performed and any valid certificate according the tls.Config given is accepted (equivalent to NewClient behavior)
func (*Client) Close ¶
closes the session established by this client (and all multiplexed connections)
func (*Client) Connect ¶
Connect requests immediate handshaking regardless of whether any specific Dial has been initiated. It is called lazily on the first Dial if not otherwise called.
This can serve to pre-establish a multiplexed session, but will also initiate idle timeout tracking, keepalives etc. Returns any error encountered during handshake.
This may safely be called concurrently with Dial. The handshake is guaranteed to be completed when the call returns to any caller.
func (*Client) Dial ¶
Dial creates a new multiplexed QUIC connection to the server configured for the client.
func (*Client) DialContext ¶
DialContext creates a new multiplexed QUIC connection to the server configured in the client. The given Context governs cancellation / timeout. If initial handshaking is performed, the operation is additionally governed by HandshakeTimeout value given in the client Config.
type Conn ¶
wraps quic.Stream and other info to implement net.Conn
func (*Conn) PeerCertificates ¶
func (c *Conn) PeerCertificates() []*x509.Certificate
Returns certificates presented by peer
type QuicDialFn ¶
type QuicDialFn func(ctx context.Context, addr string, tlsConf *tls.Config, config *quic.Config) (quic.Connection, error)
a QuicDialFn is a function that may be used to establish a new QUIC Session
var ( DialWithNetx QuicDialFn = newDialerWithUDPDialer(DialUDPNetx) DialWithoutNetx QuicDialFn = quic.DialAddr )