mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
clean up dial functions
* add a context to all Dial functions * remove the explicit Dial{*}Context functions
This commit is contained in:
parent
d683b841c4
commit
aee7706d5d
32 changed files with 106 additions and 59 deletions
42
client.go
42
client.go
|
@ -46,24 +46,14 @@ var generateConnectionIDForInitial = protocol.GenerateConnectionIDForInitial
|
||||||
|
|
||||||
// DialAddr establishes a new QUIC connection to a server.
|
// DialAddr establishes a new QUIC connection to a server.
|
||||||
// It uses a new UDP connection and closes this connection when the QUIC connection is closed.
|
// It uses a new UDP connection and closes this connection when the QUIC connection is closed.
|
||||||
func DialAddr(addr string, tlsConf *tls.Config, config *Config) (Connection, error) {
|
// The hostname for SNI is taken from the given address.
|
||||||
return DialAddrContext(context.Background(), addr, tlsConf, config)
|
func DialAddr(ctx context.Context, addr string, tlsConf *tls.Config, config *Config) (Connection, error) {
|
||||||
|
return dialAddrContext(ctx, addr, tlsConf, config, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DialAddrEarly establishes a new 0-RTT QUIC connection to a server.
|
// DialAddrEarly establishes a new 0-RTT QUIC connection to a server.
|
||||||
// It uses a new UDP connection and closes this connection when the QUIC connection is closed.
|
// It uses a new UDP connection and closes this connection when the QUIC connection is closed.
|
||||||
func DialAddrEarly(addr string, tlsConf *tls.Config, config *Config) (EarlyConnection, error) {
|
func DialAddrEarly(ctx context.Context, addr string, tlsConf *tls.Config, config *Config) (EarlyConnection, error) {
|
||||||
return DialAddrEarlyContext(context.Background(), addr, tlsConf, config)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DialAddrEarlyContext establishes a new 0-RTT QUIC connection to a server using provided context.
|
|
||||||
// See DialAddrEarly for details
|
|
||||||
func DialAddrEarlyContext(
|
|
||||||
ctx context.Context,
|
|
||||||
addr string,
|
|
||||||
tlsConf *tls.Config,
|
|
||||||
config *Config,
|
|
||||||
) (EarlyConnection, error) {
|
|
||||||
conn, err := dialAddrContext(ctx, addr, tlsConf, config, true)
|
conn, err := dialAddrContext(ctx, addr, tlsConf, config, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -72,12 +62,6 @@ func DialAddrEarlyContext(
|
||||||
return conn, nil
|
return conn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DialAddrContext establishes a new QUIC connection to a server using the provided context.
|
|
||||||
// See DialAddr for details.
|
|
||||||
func DialAddrContext(ctx context.Context, addr string, tlsConf *tls.Config, config *Config) (Connection, error) {
|
|
||||||
return dialAddrContext(ctx, addr, tlsConf, config, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func dialAddrContext(ctx context.Context, addr string, tlsConf *tls.Config, config *Config, use0RTT bool) (quicConn, error) {
|
func dialAddrContext(ctx context.Context, addr string, tlsConf *tls.Config, config *Config, use0RTT bool) (quicConn, error) {
|
||||||
udpAddr, err := net.ResolveUDPAddr("udp", addr)
|
udpAddr, err := net.ResolveUDPAddr("udp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -98,30 +82,18 @@ func dialAddrContext(ctx context.Context, addr string, tlsConf *tls.Config, conf
|
||||||
// The same PacketConn can be used for multiple calls to Dial and Listen.
|
// The same PacketConn can be used for multiple calls to Dial and Listen.
|
||||||
// QUIC connection IDs are used for demultiplexing the different connections.
|
// QUIC connection IDs are used for demultiplexing the different connections.
|
||||||
// The tls.Config must define an application protocol (using NextProtos).
|
// The tls.Config must define an application protocol (using NextProtos).
|
||||||
func Dial(pconn net.PacketConn, addr net.Addr, tlsConf *tls.Config, config *Config) (Connection, error) {
|
func Dial(ctx context.Context, pconn net.PacketConn, addr net.Addr, tlsConf *tls.Config, config *Config) (Connection, error) {
|
||||||
return dialContext(context.Background(), pconn, addr, tlsConf, config, false, false)
|
return dialContext(ctx, pconn, addr, tlsConf, config, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DialEarly establishes a new 0-RTT QUIC connection to a server using a net.PacketConn.
|
// DialEarly establishes a new 0-RTT QUIC connection to a server using a net.PacketConn.
|
||||||
// The same PacketConn can be used for multiple calls to Dial and Listen,
|
// The same PacketConn can be used for multiple calls to Dial and Listen,
|
||||||
// QUIC connection IDs are used for demultiplexing the different connections.
|
// QUIC connection IDs are used for demultiplexing the different connections.
|
||||||
// The tls.Config must define an application protocol (using NextProtos).
|
// The tls.Config must define an application protocol (using NextProtos).
|
||||||
func DialEarly(pconn net.PacketConn, addr net.Addr, tlsConf *tls.Config, config *Config) (EarlyConnection, error) {
|
func DialEarly(ctx context.Context, pconn net.PacketConn, addr net.Addr, tlsConf *tls.Config, config *Config) (EarlyConnection, error) {
|
||||||
return DialEarlyContext(context.Background(), pconn, addr, tlsConf, config)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DialEarlyContext establishes a new 0-RTT QUIC connection to a server using a net.PacketConn using the provided context.
|
|
||||||
// See DialEarly for details.
|
|
||||||
func DialEarlyContext(ctx context.Context, pconn net.PacketConn, addr net.Addr, tlsConf *tls.Config, config *Config) (EarlyConnection, error) {
|
|
||||||
return dialContext(ctx, pconn, addr, tlsConf, config, true, false)
|
return dialContext(ctx, pconn, addr, tlsConf, config, true, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DialContext establishes a new QUIC connection to a server using a net.PacketConn using the provided context.
|
|
||||||
// See Dial for details.
|
|
||||||
func DialContext(ctx context.Context, pconn net.PacketConn, addr net.Addr, tlsConf *tls.Config, config *Config) (Connection, error) {
|
|
||||||
return dialContext(ctx, pconn, addr, tlsConf, config, false, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func dialContext(ctx context.Context, pconn net.PacketConn, addr net.Addr, tlsConf *tls.Config, config *Config, use0RTT bool, createdPacketConn bool) (quicConn, error) {
|
func dialContext(ctx context.Context, pconn net.PacketConn, addr net.Addr, tlsConf *tls.Config, config *Config, use0RTT bool, createdPacketConn bool) (quicConn, error) {
|
||||||
if tlsConf == nil {
|
if tlsConf == nil {
|
||||||
return nil, errors.New("quic: tls.Config not set")
|
return nil, errors.New("quic: tls.Config not set")
|
||||||
|
|
|
@ -128,7 +128,7 @@ var _ = Describe("Client", func() {
|
||||||
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
|
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
|
||||||
return conn
|
return conn
|
||||||
}
|
}
|
||||||
_, err := DialAddr("localhost:17890", tlsConf, &Config{HandshakeIdleTimeout: time.Millisecond})
|
_, err := DialAddr(context.Background(), "localhost:17890", tlsConf, &Config{HandshakeIdleTimeout: time.Millisecond})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Eventually(remoteAddrChan).Should(Receive(Equal("127.0.0.1:17890")))
|
Eventually(remoteAddrChan).Should(Receive(Equal("127.0.0.1:17890")))
|
||||||
})
|
})
|
||||||
|
@ -163,7 +163,7 @@ var _ = Describe("Client", func() {
|
||||||
return conn
|
return conn
|
||||||
}
|
}
|
||||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
s, err := Dial(packetConn, addr, tlsConf, config)
|
s, err := Dial(context.Background(), packetConn, addr, tlsConf, config)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(s).ToNot(BeNil())
|
Expect(s).ToNot(BeNil())
|
||||||
Eventually(run).Should(BeClosed())
|
Eventually(run).Should(BeClosed())
|
||||||
|
@ -203,7 +203,7 @@ var _ = Describe("Client", func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
defer close(done)
|
defer close(done)
|
||||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
s, err := DialEarly(packetConn, addr, tlsConf, config)
|
s, err := DialEarly(context.Background(), packetConn, addr, tlsConf, config)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(s).ToNot(BeNil())
|
Expect(s).ToNot(BeNil())
|
||||||
}()
|
}()
|
||||||
|
@ -239,7 +239,7 @@ var _ = Describe("Client", func() {
|
||||||
return conn
|
return conn
|
||||||
}
|
}
|
||||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
_, err := Dial(packetConn, addr, tlsConf, config)
|
_, err := Dial(context.Background(), packetConn, addr, tlsConf, config)
|
||||||
Expect(err).To(MatchError(testErr))
|
Expect(err).To(MatchError(testErr))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ var _ = Describe("Client", func() {
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
_, err := DialContext(ctx, packetConn, addr, tlsConf, config)
|
_, err := Dial(ctx, packetConn, addr, tlsConf, config)
|
||||||
Expect(err).To(MatchError(context.Canceled))
|
Expect(err).To(MatchError(context.Canceled))
|
||||||
close(dialed)
|
close(dialed)
|
||||||
}()
|
}()
|
||||||
|
@ -323,7 +323,7 @@ var _ = Describe("Client", func() {
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
_, err := DialAddr("localhost:1337", tlsConf, nil)
|
_, err := DialAddr(context.Background(), "localhost:1337", tlsConf, nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
close(done)
|
close(done)
|
||||||
}()
|
}()
|
||||||
|
@ -370,7 +370,7 @@ var _ = Describe("Client", func() {
|
||||||
mockMultiplexer.EXPECT().AddConn(packetConn, gomock.Any(), gomock.Any(), gomock.Any()).Return(manager, nil)
|
mockMultiplexer.EXPECT().AddConn(packetConn, gomock.Any(), gomock.Any(), gomock.Any()).Return(manager, nil)
|
||||||
|
|
||||||
version := protocol.VersionNumber(0x1234)
|
version := protocol.VersionNumber(0x1234)
|
||||||
_, err := Dial(packetConn, nil, tlsConf, &Config{Versions: []protocol.VersionNumber{version}})
|
_, err := Dial(context.Background(), packetConn, nil, tlsConf, &Config{Versions: []protocol.VersionNumber{version}})
|
||||||
Expect(err).To(MatchError("0x1234 is not a valid QUIC version"))
|
Expect(err).To(MatchError("0x1234 is not a valid QUIC version"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ var _ = Describe("Client", func() {
|
||||||
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
|
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
|
||||||
return conn
|
return conn
|
||||||
}
|
}
|
||||||
_, err := Dial(packetConn, addr, tlsConf, config)
|
_, err := Dial(context.Background(), packetConn, addr, tlsConf, config)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Eventually(c).Should(BeClosed())
|
Eventually(c).Should(BeClosed())
|
||||||
Expect(cconn.(*spconn).PacketConn).To(Equal(packetConn))
|
Expect(cconn.(*spconn).PacketConn).To(Equal(packetConn))
|
||||||
|
@ -492,7 +492,7 @@ var _ = Describe("Client", func() {
|
||||||
|
|
||||||
config := &Config{Tracer: config.Tracer, Versions: []protocol.VersionNumber{protocol.Version1}, ConnectionIDGenerator: &mockConnIDGenerator{ConnID: connID}}
|
config := &Config{Tracer: config.Tracer, Versions: []protocol.VersionNumber{protocol.Version1}, ConnectionIDGenerator: &mockConnIDGenerator{ConnID: connID}}
|
||||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
_, err := DialAddr("localhost:7890", tlsConf, config)
|
_, err := DialAddr(context.Background(), "localhost:7890", tlsConf, config)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(counter).To(Equal(2))
|
Expect(counter).To(Equal(2))
|
||||||
})
|
})
|
||||||
|
|
|
@ -54,7 +54,7 @@ func clientMain() error {
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
NextProtos: []string{"quic-echo-example"},
|
NextProtos: []string{"quic-echo-example"},
|
||||||
}
|
}
|
||||||
conn, err := quic.DialAddr(addr, tlsConf, nil)
|
conn, err := quic.DialAddr(context.Background(), addr, tlsConf, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ var defaultQuicConfig = &quic.Config{
|
||||||
|
|
||||||
type dialFunc func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error)
|
type dialFunc func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error)
|
||||||
|
|
||||||
var dialAddr = quic.DialAddrEarlyContext
|
var dialAddr dialFunc = quic.DialAddrEarly
|
||||||
|
|
||||||
type roundTripperOpts struct {
|
type roundTripperOpts struct {
|
||||||
DisableCompression bool
|
DisableCompression bool
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// declare this as a variable, such that we can it mock it in the tests
|
// declare this as a variable, such that we can it mock it in the tests
|
||||||
var quicDialer = quic.DialEarlyContext
|
var quicDialer = quic.DialEarly
|
||||||
|
|
||||||
type roundTripCloser interface {
|
type roundTripCloser interface {
|
||||||
RoundTripOpt(*http.Request, RoundTripOpt) (*http.Response, error)
|
RoundTripOpt(*http.Request, RoundTripOpt) (*http.Response, error)
|
||||||
|
|
|
@ -932,7 +932,7 @@ var _ = Describe("Server", func() {
|
||||||
ln, err := quic.ListenAddr("localhost:0", conf, &quic.Config{Versions: []quic.VersionNumber{quic.Version1}})
|
ln, err := quic.ListenAddr("localhost:0", conf, &quic.Config{Versions: []quic.VersionNumber{quic.Version1}})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer ln.Close()
|
defer ln.Close()
|
||||||
c, err := quic.DialAddr(ln.Addr().String(), &tls.Config{InsecureSkipVerify: true, NextProtos: []string{NextProtoH3}}, nil)
|
c, err := quic.DialAddr(context.Background(), ln.Addr().String(), &tls.Config{InsecureSkipVerify: true, NextProtos: []string{NextProtoH3}}, nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer c.CloseWithError(0, "")
|
defer c.CloseWithError(0, "")
|
||||||
Expect(c.ConnectionState().TLS.ConnectionState.NegotiatedProtocol).To(Equal(NextProtoH3))
|
Expect(c.ConnectionState().TLS.ConnectionState.NegotiatedProtocol).To(Equal(NextProtoH3))
|
||||||
|
@ -943,7 +943,7 @@ var _ = Describe("Server", func() {
|
||||||
ln, err := quic.ListenAddr("localhost:0", conf, &quic.Config{Versions: []quic.VersionNumber{quic.VersionDraft29}})
|
ln, err := quic.ListenAddr("localhost:0", conf, &quic.Config{Versions: []quic.VersionNumber{quic.VersionDraft29}})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer ln.Close()
|
defer ln.Close()
|
||||||
c, err := quic.DialAddr(ln.Addr().String(), &tls.Config{InsecureSkipVerify: true, NextProtos: []string{NextProtoH3Draft29}}, nil)
|
c, err := quic.DialAddr(context.Background(), ln.Addr().String(), &tls.Config{InsecureSkipVerify: true, NextProtos: []string{NextProtoH3Draft29}}, nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer c.CloseWithError(0, "")
|
defer c.CloseWithError(0, "")
|
||||||
Expect(c.ConnectionState().TLS.ConnectionState.NegotiatedProtocol).To(Equal(NextProtoH3Draft29))
|
Expect(c.ConnectionState().TLS.ConnectionState.NegotiatedProtocol).To(Equal(NextProtoH3Draft29))
|
||||||
|
@ -971,7 +971,7 @@ var _ = Describe("Server", func() {
|
||||||
ln, err := quic.ListenAddr("localhost:0", ConfigureTLSConfig(tlsConf), &quic.Config{Versions: []quic.VersionNumber{quic.Version1}})
|
ln, err := quic.ListenAddr("localhost:0", ConfigureTLSConfig(tlsConf), &quic.Config{Versions: []quic.VersionNumber{quic.Version1}})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer ln.Close()
|
defer ln.Close()
|
||||||
c, err := quic.DialAddr(ln.Addr().String(), &tls.Config{InsecureSkipVerify: true, NextProtos: []string{NextProtoH3}}, nil)
|
c, err := quic.DialAddr(context.Background(), ln.Addr().String(), &tls.Config{InsecureSkipVerify: true, NextProtos: []string{NextProtoH3}}, nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer c.CloseWithError(0, "")
|
defer c.CloseWithError(0, "")
|
||||||
Expect(c.ConnectionState().TLS.ConnectionState.NegotiatedProtocol).To(Equal(NextProtoH3))
|
Expect(c.ConnectionState().TLS.ConnectionState.NegotiatedProtocol).To(Equal(NextProtoH3))
|
||||||
|
@ -984,7 +984,7 @@ var _ = Describe("Server", func() {
|
||||||
ln, err := quic.ListenAddr("localhost:0", ConfigureTLSConfig(tlsConf), &quic.Config{Versions: []quic.VersionNumber{quic.Version1}})
|
ln, err := quic.ListenAddr("localhost:0", ConfigureTLSConfig(tlsConf), &quic.Config{Versions: []quic.VersionNumber{quic.Version1}})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer ln.Close()
|
defer ln.Close()
|
||||||
c, err := quic.DialAddr(ln.Addr().String(), &tls.Config{InsecureSkipVerify: true, NextProtos: []string{NextProtoH3}}, nil)
|
c, err := quic.DialAddr(context.Background(), ln.Addr().String(), &tls.Config{InsecureSkipVerify: true, NextProtos: []string{NextProtoH3}}, nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer c.CloseWithError(0, "")
|
defer c.CloseWithError(0, "")
|
||||||
Expect(c.ConnectionState().TLS.ConnectionState.NegotiatedProtocol).To(Equal(NextProtoH3))
|
Expect(c.ConnectionState().TLS.ConnectionState.NegotiatedProtocol).To(Equal(NextProtoH3))
|
||||||
|
@ -1002,7 +1002,7 @@ var _ = Describe("Server", func() {
|
||||||
ln, err := quic.ListenAddr("localhost:0", ConfigureTLSConfig(tlsConf), &quic.Config{Versions: []quic.VersionNumber{quic.Version1}})
|
ln, err := quic.ListenAddr("localhost:0", ConfigureTLSConfig(tlsConf), &quic.Config{Versions: []quic.VersionNumber{quic.Version1}})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer ln.Close()
|
defer ln.Close()
|
||||||
c, err := quic.DialAddr(ln.Addr().String(), &tls.Config{InsecureSkipVerify: true, NextProtos: []string{NextProtoH3}}, nil)
|
c, err := quic.DialAddr(context.Background(), ln.Addr().String(), &tls.Config{InsecureSkipVerify: true, NextProtos: []string{NextProtoH3}}, nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
defer c.CloseWithError(0, "")
|
defer c.CloseWithError(0, "")
|
||||||
Expect(c.ConnectionState().TLS.ConnectionState.NegotiatedProtocol).To(Equal(NextProtoH3))
|
Expect(c.ConnectionState().TLS.ConnectionState.NegotiatedProtocol).To(Equal(NextProtoH3))
|
||||||
|
|
|
@ -36,7 +36,7 @@ func BenchmarkHandshake(b *testing.B) {
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
c, err := quic.Dial(conn, ln.Addr(), tlsClientConfig, nil)
|
c, err := quic.Dial(context.Background(), conn, ln.Addr(), tlsClientConfig, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ func BenchmarkStreamChurn(b *testing.B) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
c, err := quic.DialAddr(fmt.Sprintf("localhost:%d", ln.Addr().(*net.UDPAddr).Port), tlsClientConfig, nil)
|
c, err := quic.DialAddr(context.Background(), fmt.Sprintf("localhost:%d", ln.Addr().(*net.UDPAddr).Port), tlsClientConfig, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ var _ = Describe("Stream Cancellations", func() {
|
||||||
It("downloads when the client immediately cancels most streams", func() {
|
It("downloads when the client immediately cancels most streams", func() {
|
||||||
serverCanceledCounterChan := runServer(PRData)
|
serverCanceledCounterChan := runServer(PRData)
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
||||||
|
@ -124,6 +125,7 @@ var _ = Describe("Stream Cancellations", func() {
|
||||||
serverCanceledCounterChan := runServer(PRData)
|
serverCanceledCounterChan := runServer(PRData)
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
||||||
|
@ -174,6 +176,7 @@ var _ = Describe("Stream Cancellations", func() {
|
||||||
serverCanceledCounterChan := runServer(make([]byte, 100)) // make sure the FIN is sent with the STREAM frame
|
serverCanceledCounterChan := runServer(make([]byte, 100)) // make sure the FIN is sent with the STREAM frame
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
||||||
|
@ -221,6 +224,7 @@ var _ = Describe("Stream Cancellations", func() {
|
||||||
Context("canceling the write side", func() {
|
Context("canceling the write side", func() {
|
||||||
runClient := func(server quic.Listener) int32 /* number of canceled streams */ {
|
runClient := func(server quic.Listener) int32 /* number of canceled streams */ {
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
||||||
|
@ -366,6 +370,7 @@ var _ = Describe("Stream Cancellations", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
||||||
|
@ -451,6 +456,7 @@ var _ = Describe("Stream Cancellations", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
||||||
|
@ -529,6 +535,7 @@ var _ = Describe("Stream Cancellations", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 3}),
|
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 3}),
|
||||||
|
@ -614,6 +621,7 @@ var _ = Describe("Stream Cancellations", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{MaxIncomingUniStreams: maxIncomingStreams}),
|
getQuicConfig(&quic.Config{MaxIncomingUniStreams: maxIncomingStreams}),
|
||||||
|
@ -707,6 +715,7 @@ var _ = Describe("Stream Cancellations", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{}),
|
getQuicConfig(&quic.Config{}),
|
||||||
|
|
|
@ -44,6 +44,7 @@ var _ = Describe("Connection ID lengths tests", func() {
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
|
|
@ -61,6 +61,7 @@ var _ = Describe("Connection ID lengths tests", func() {
|
||||||
runClient := func(addr net.Addr, conf *quic.Config) {
|
runClient := func(addr net.Addr, conf *quic.Config) {
|
||||||
GinkgoWriter.Write([]byte(fmt.Sprintf("Using %d byte connection ID for the client\n", conf.ConnectionIDLength)))
|
GinkgoWriter.Write([]byte(fmt.Sprintf("Using %d byte connection ID for the client\n", conf.ConnectionIDLength)))
|
||||||
cl, err := quic.DialAddr(
|
cl, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", addr.(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", addr.(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
conf,
|
conf,
|
||||||
|
|
|
@ -105,6 +105,7 @@ var _ = Describe("Datagram test", func() {
|
||||||
raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", proxy.LocalPort()))
|
raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", proxy.LocalPort()))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
conn, err := quic.Dial(
|
conn, err := quic.Dial(
|
||||||
|
context.Background(),
|
||||||
clientConn,
|
clientConn,
|
||||||
raddr,
|
raddr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
|
@ -140,6 +141,7 @@ var _ = Describe("Datagram test", func() {
|
||||||
raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", proxy.LocalPort()))
|
raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", proxy.LocalPort()))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
conn, err := quic.Dial(
|
conn, err := quic.Dial(
|
||||||
|
context.Background(),
|
||||||
clientConn,
|
clientConn,
|
||||||
raddr,
|
raddr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
|
@ -157,6 +159,7 @@ var _ = Describe("Datagram test", func() {
|
||||||
raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", proxy.LocalPort()))
|
raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", proxy.LocalPort()))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
conn, err := quic.Dial(
|
conn, err := quic.Dial(
|
||||||
|
context.Background(),
|
||||||
clientConn,
|
clientConn,
|
||||||
raddr,
|
raddr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
|
|
|
@ -30,6 +30,7 @@ var _ = Describe("Stream deadline tests", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
|
|
@ -97,6 +97,7 @@ var _ = Describe("Drop Tests", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
|
|
@ -50,6 +50,7 @@ var _ = Describe("early data", func() {
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
|
|
@ -81,6 +81,7 @@ var _ = Describe("Handshake drop tests", func() {
|
||||||
serverConnChan <- conn
|
serverConnChan <- conn
|
||||||
}()
|
}()
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{
|
getQuicConfig(&quic.Config{
|
||||||
|
@ -118,6 +119,7 @@ var _ = Describe("Handshake drop tests", func() {
|
||||||
serverConnChan <- conn
|
serverConnChan <- conn
|
||||||
}()
|
}()
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{
|
getQuicConfig(&quic.Config{
|
||||||
|
@ -150,6 +152,7 @@ var _ = Describe("Handshake drop tests", func() {
|
||||||
serverConnChan <- conn
|
serverConnChan <- conn
|
||||||
}()
|
}()
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{
|
getQuicConfig(&quic.Config{
|
||||||
|
|
|
@ -63,6 +63,7 @@ var _ = Describe("Handshake RTT tests", func() {
|
||||||
runProxy(ln.Addr())
|
runProxy(ln.Addr())
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
_, err = quic.DialAddr(
|
_, err = quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -79,6 +80,7 @@ var _ = Describe("Handshake RTT tests", func() {
|
||||||
runProxy(ln.Addr())
|
runProxy(ln.Addr())
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
_, err = quic.DialAddr(
|
_, err = quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -96,6 +98,7 @@ var _ = Describe("Handshake RTT tests", func() {
|
||||||
runProxy(ln.Addr())
|
runProxy(ln.Addr())
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
_, err = quic.DialAddr(
|
_, err = quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -122,6 +125,7 @@ var _ = Describe("Handshake RTT tests", func() {
|
||||||
runProxy(ln.Addr())
|
runProxy(ln.Addr())
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -156,6 +160,7 @@ var _ = Describe("Handshake RTT tests", func() {
|
||||||
runProxy(ln.Addr())
|
runProxy(ln.Addr())
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", proxy.LocalAddr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
|
|
@ -111,6 +111,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", ln.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", ln.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
nil,
|
nil,
|
||||||
|
@ -131,6 +132,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
It("accepts the certificate", func() {
|
It("accepts the certificate", func() {
|
||||||
runServer(getTLSConfig())
|
runServer(getTLSConfig())
|
||||||
_, err := quic.DialAddr(
|
_, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -141,6 +143,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
It("works with a long certificate chain", func() {
|
It("works with a long certificate chain", func() {
|
||||||
runServer(getTLSConfigWithLongCertChain())
|
runServer(getTLSConfigWithLongCertChain())
|
||||||
_, err := quic.DialAddr(
|
_, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -155,6 +158,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
conf := getTLSClientConfig()
|
conf := getTLSClientConfig()
|
||||||
conf.ServerName = "foo.bar"
|
conf.ServerName = "foo.bar"
|
||||||
_, err = quic.Dial(
|
_, err = quic.Dial(
|
||||||
|
context.Background(),
|
||||||
conn,
|
conn,
|
||||||
server.Addr(),
|
server.Addr(),
|
||||||
conf,
|
conf,
|
||||||
|
@ -173,6 +177,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
runServer(tlsConf)
|
runServer(tlsConf)
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -201,6 +206,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
tlsConf := getTLSClientConfig()
|
tlsConf := getTLSClientConfig()
|
||||||
tlsConf.ServerName = "foo.bar"
|
tlsConf.ServerName = "foo.bar"
|
||||||
_, err := quic.DialAddr(
|
_, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
tlsConf,
|
tlsConf,
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -223,7 +229,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
remoteAddr := fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port)
|
remoteAddr := fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port)
|
||||||
raddr, err := net.ResolveUDPAddr("udp", remoteAddr)
|
raddr, err := net.ResolveUDPAddr("udp", remoteAddr)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
return quic.Dial(pconn, raddr, getTLSClientConfig(), nil)
|
return quic.Dial(context.Background(), pconn, raddr, getTLSClientConfig(), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
|
@ -324,6 +330,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", ln.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", ln.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
nil,
|
nil,
|
||||||
|
@ -342,6 +349,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
tlsConf := getTLSClientConfig()
|
tlsConf := getTLSClientConfig()
|
||||||
tlsConf.NextProtos = []string{"foobar"}
|
tlsConf.NextProtos = []string{"foobar"}
|
||||||
_, err := quic.DialAddr(
|
_, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
tlsConf,
|
tlsConf,
|
||||||
nil,
|
nil,
|
||||||
|
@ -371,6 +379,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
tokenStore := newTokenStore(gets, puts)
|
tokenStore := newTokenStore(gets, puts)
|
||||||
quicConf := getQuicConfig(&quic.Config{TokenStore: tokenStore})
|
quicConf := getQuicConfig(&quic.Config{TokenStore: tokenStore})
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
quicConf,
|
quicConf,
|
||||||
|
@ -390,6 +399,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}()
|
}()
|
||||||
conn, err = quic.DialAddr(
|
conn, err = quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
quicConf,
|
quicConf,
|
||||||
|
@ -410,6 +420,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
_, err = quic.DialAddr(
|
_, err = quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
nil,
|
nil,
|
||||||
|
@ -441,6 +452,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
tlsConf := getTLSClientConfig()
|
tlsConf := getTLSClientConfig()
|
||||||
tlsConf.NextProtos = []string{""}
|
tlsConf.NextProtos = []string{""}
|
||||||
_, err = quic.DialAddr(
|
_, err = quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", ln.LocalAddr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", ln.LocalAddr().(*net.UDPAddr).Port),
|
||||||
tlsConf,
|
tlsConf,
|
||||||
nil,
|
nil,
|
||||||
|
|
|
@ -72,6 +72,7 @@ var _ = Describe("Key Update tests", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{Tracer: newTracer(func() logging.ConnectionTracer { return &keyUpdateConnTracer{} })}),
|
getQuicConfig(&quic.Config{Tracer: newTracer(func() logging.ConnectionTracer { return &keyUpdateConnTracer{} })}),
|
||||||
|
|
|
@ -147,6 +147,7 @@ var _ = Describe("MITM test", func() {
|
||||||
raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", proxyPort))
|
raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", proxyPort))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
conn, err := quic.Dial(
|
conn, err := quic.Dial(
|
||||||
|
context.Background(),
|
||||||
clientUDPConn,
|
clientUDPConn,
|
||||||
raddr,
|
raddr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
|
@ -190,6 +191,7 @@ var _ = Describe("MITM test", func() {
|
||||||
raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", proxyPort))
|
raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", proxyPort))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
conn, err := quic.Dial(
|
conn, err := quic.Dial(
|
||||||
|
context.Background(),
|
||||||
clientUDPConn,
|
clientUDPConn,
|
||||||
raddr,
|
raddr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
|
@ -304,6 +306,7 @@ var _ = Describe("MITM test", func() {
|
||||||
raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", proxyPort))
|
raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("localhost:%d", proxyPort))
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
_, err = quic.Dial(
|
_, err = quic.Dial(
|
||||||
|
context.Background(),
|
||||||
clientUDPConn,
|
clientUDPConn,
|
||||||
raddr,
|
raddr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
|
|
|
@ -36,6 +36,7 @@ var _ = Describe("Multiplexing", func() {
|
||||||
|
|
||||||
dial := func(pconn net.PacketConn, addr net.Addr) {
|
dial := func(pconn net.PacketConn, addr net.Addr) {
|
||||||
conn, err := quic.Dial(
|
conn, err := quic.Dial(
|
||||||
|
context.Background(),
|
||||||
pconn,
|
pconn,
|
||||||
addr,
|
addr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
|
|
|
@ -45,6 +45,7 @@ var _ = Describe("Packetization", func() {
|
||||||
|
|
||||||
clientTracer := newPacketTracer()
|
clientTracer := newPacketTracer()
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{
|
getQuicConfig(&quic.Config{
|
||||||
|
|
|
@ -58,6 +58,7 @@ var _ = Describe("TLS session resumption", func() {
|
||||||
tlsConf := getTLSClientConfig()
|
tlsConf := getTLSClientConfig()
|
||||||
tlsConf.ClientSessionCache = cache
|
tlsConf.ClientSessionCache = cache
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
tlsConf,
|
tlsConf,
|
||||||
nil,
|
nil,
|
||||||
|
@ -72,6 +73,7 @@ var _ = Describe("TLS session resumption", func() {
|
||||||
Expect(serverConn.ConnectionState().TLS.DidResume).To(BeFalse())
|
Expect(serverConn.ConnectionState().TLS.DidResume).To(BeFalse())
|
||||||
|
|
||||||
conn, err = quic.DialAddr(
|
conn, err = quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
tlsConf,
|
tlsConf,
|
||||||
nil,
|
nil,
|
||||||
|
@ -98,6 +100,7 @@ var _ = Describe("TLS session resumption", func() {
|
||||||
tlsConf := getTLSClientConfig()
|
tlsConf := getTLSClientConfig()
|
||||||
tlsConf.ClientSessionCache = cache
|
tlsConf.ClientSessionCache = cache
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
tlsConf,
|
tlsConf,
|
||||||
nil,
|
nil,
|
||||||
|
@ -111,6 +114,7 @@ var _ = Describe("TLS session resumption", func() {
|
||||||
Expect(serverConn.ConnectionState().TLS.DidResume).To(BeFalse())
|
Expect(serverConn.ConnectionState().TLS.DidResume).To(BeFalse())
|
||||||
|
|
||||||
conn, err = quic.DialAddr(
|
conn, err = quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
tlsConf,
|
tlsConf,
|
||||||
nil,
|
nil,
|
||||||
|
|
|
@ -37,6 +37,7 @@ var _ = Describe("non-zero RTT", func() {
|
||||||
|
|
||||||
downloadFile := func(port int) {
|
downloadFile := func(port int) {
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", port),
|
fmt.Sprintf("localhost:%d", port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -72,6 +73,7 @@ var _ = Describe("non-zero RTT", func() {
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
|
|
@ -56,6 +56,7 @@ var _ = Describe("Stateless Resets", func() {
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{
|
getQuicConfig(&quic.Config{
|
||||||
|
|
|
@ -87,6 +87,7 @@ var _ = Describe("Bidirectional streams", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(
|
client, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
serverAddr,
|
serverAddr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -105,6 +106,7 @@ var _ = Describe("Bidirectional streams", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(
|
client, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
serverAddr,
|
serverAddr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -132,6 +134,7 @@ var _ = Describe("Bidirectional streams", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(
|
client, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
serverAddr,
|
serverAddr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
|
|
@ -54,6 +54,7 @@ var _ = Describe("Timeout tests", func() {
|
||||||
errChan := make(chan error)
|
errChan := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
_, err := quic.DialAddr(
|
_, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
"localhost:12345",
|
"localhost:12345",
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{HandshakeIdleTimeout: 10 * time.Millisecond}),
|
getQuicConfig(&quic.Config{HandshakeIdleTimeout: 10 * time.Millisecond}),
|
||||||
|
@ -70,7 +71,7 @@ var _ = Describe("Timeout tests", func() {
|
||||||
defer cancel()
|
defer cancel()
|
||||||
errChan := make(chan error)
|
errChan := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
_, err := quic.DialAddrContext(
|
_, err := quic.DialAddr(
|
||||||
ctx,
|
ctx,
|
||||||
"localhost:12345",
|
"localhost:12345",
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
|
@ -89,7 +90,7 @@ var _ = Describe("Timeout tests", func() {
|
||||||
defer cancel()
|
defer cancel()
|
||||||
errChan := make(chan error)
|
errChan := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
_, err := quic.DialAddrEarlyContext(
|
_, err := quic.DialAddrEarly(
|
||||||
ctx,
|
ctx,
|
||||||
"localhost:12345",
|
"localhost:12345",
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
|
@ -135,6 +136,7 @@ var _ = Describe("Timeout tests", func() {
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{DisablePathMTUDiscovery: true, MaxIdleTimeout: idleTimeout}),
|
getQuicConfig(&quic.Config{DisablePathMTUDiscovery: true, MaxIdleTimeout: idleTimeout}),
|
||||||
|
@ -194,6 +196,7 @@ var _ = Describe("Timeout tests", func() {
|
||||||
|
|
||||||
tr := newPacketTracer()
|
tr := newPacketTracer()
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{
|
getQuicConfig(&quic.Config{
|
||||||
|
@ -273,6 +276,7 @@ var _ = Describe("Timeout tests", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{MaxIdleTimeout: idleTimeout, DisablePathMTUDiscovery: true}),
|
getQuicConfig(&quic.Config{MaxIdleTimeout: idleTimeout, DisablePathMTUDiscovery: true}),
|
||||||
|
@ -341,6 +345,7 @@ var _ = Describe("Timeout tests", func() {
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{
|
getQuicConfig(&quic.Config{
|
||||||
|
@ -423,6 +428,7 @@ var _ = Describe("Timeout tests", func() {
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", ln.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", ln.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(&quic.Config{
|
getQuicConfig(&quic.Config{
|
||||||
|
@ -484,6 +490,7 @@ var _ = Describe("Timeout tests", func() {
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
conn, err := quic.Dial(
|
conn, err := quic.Dial(
|
||||||
|
context.Background(),
|
||||||
&faultyConn{PacketConn: conn, MaxPackets: maxPackets},
|
&faultyConn{PacketConn: conn, MaxPackets: maxPackets},
|
||||||
ln.Addr(),
|
ln.Addr(),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
|
|
|
@ -80,6 +80,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
defer ln.Close()
|
defer ln.Close()
|
||||||
|
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", ln.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", ln.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
quicClientConf,
|
quicClientConf,
|
||||||
|
|
|
@ -77,6 +77,7 @@ var _ = Describe("Unidirectional Streams", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(
|
client, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
serverAddr,
|
serverAddr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -95,6 +96,7 @@ var _ = Describe("Unidirectional Streams", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(
|
client, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
serverAddr,
|
serverAddr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -121,6 +123,7 @@ var _ = Describe("Unidirectional Streams", func() {
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(
|
client, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
serverAddr,
|
serverAddr,
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
|
|
@ -86,6 +86,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
puts := make(chan string, 100)
|
puts := make(chan string, 100)
|
||||||
clientConf.ClientSessionCache = newClientSessionCache(gets, puts)
|
clientConf.ClientSessionCache = newClientSessionCache(gets, puts)
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
clientConf,
|
clientConf,
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -126,6 +127,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
clientConf = getQuicConfig(nil)
|
clientConf = getQuicConfig(nil)
|
||||||
}
|
}
|
||||||
conn, err := quic.DialAddrEarly(
|
conn, err := quic.DialAddrEarly(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxyPort),
|
fmt.Sprintf("localhost:%d", proxyPort),
|
||||||
clientTLSConf,
|
clientTLSConf,
|
||||||
clientConf,
|
clientConf,
|
||||||
|
@ -151,6 +153,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
clientConf *tls.Config,
|
clientConf *tls.Config,
|
||||||
) {
|
) {
|
||||||
conn, err := quic.DialAddrEarly(
|
conn, err := quic.DialAddrEarly(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxyPort),
|
fmt.Sprintf("localhost:%d", proxyPort),
|
||||||
clientConf,
|
clientConf,
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -280,6 +283,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
|
|
||||||
conn, err := quic.DialAddrEarly(
|
conn, err := quic.DialAddrEarly(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
clientConf,
|
clientConf,
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -479,6 +483,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
|
|
||||||
conn, err := quic.DialAddrEarly(
|
conn, err := quic.DialAddrEarly(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
clientConf,
|
clientConf,
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -609,6 +614,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
|
|
||||||
conn, err := quic.DialAddrEarly(
|
conn, err := quic.DialAddrEarly(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
clientConf,
|
clientConf,
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
@ -680,6 +686,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
|
|
||||||
conn, err := quic.DialAddrEarly(
|
conn, err := quic.DialAddrEarly(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
clientConf,
|
clientConf,
|
||||||
getQuicConfig(nil),
|
getQuicConfig(nil),
|
||||||
|
|
|
@ -69,7 +69,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
var supportedVersions []protocol.VersionNumber
|
var supportedVersions []protocol.VersionNumber
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
supportedVersions = protocol.SupportedVersions
|
supportedVersions = append([]quic.VersionNumber{}, protocol.SupportedVersions...)
|
||||||
protocol.SupportedVersions = append(protocol.SupportedVersions, []protocol.VersionNumber{7, 8, 9, 10}...)
|
protocol.SupportedVersions = append(protocol.SupportedVersions, []protocol.VersionNumber{7, 8, 9, 10}...)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -90,6 +90,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
defer cl()
|
defer cl()
|
||||||
clientTracer := &versionNegotiationTracer{}
|
clientTracer := &versionNegotiationTracer{}
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
maybeAddQlogTracer(&quic.Config{Tracer: newTracer(func() logging.ConnectionTracer { return clientTracer })}),
|
maybeAddQlogTracer(&quic.Config{Tracer: newTracer(func() logging.ConnectionTracer { return clientTracer })}),
|
||||||
|
@ -119,6 +120,7 @@ var _ = Describe("Handshake tests", func() {
|
||||||
clientVersions := []protocol.VersionNumber{7, 8, 9, protocol.SupportedVersions[0], 10}
|
clientVersions := []protocol.VersionNumber{7, 8, 9, protocol.SupportedVersions[0], 10}
|
||||||
clientTracer := &versionNegotiationTracer{}
|
clientTracer := &versionNegotiationTracer{}
|
||||||
conn, err := quic.DialAddr(
|
conn, err := quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
maybeAddQlogTracer(&quic.Config{
|
maybeAddQlogTracer(&quic.Config{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package versionnegotiation
|
package versionnegotiation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/quic-go/quic-go"
|
"github.com/quic-go/quic-go"
|
||||||
|
@ -43,6 +44,7 @@ var _ = Describe("Handshake RTT tests", func() {
|
||||||
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
_, err = quic.DialAddr(
|
_, err = quic.DialAddr(
|
||||||
|
context.Background(),
|
||||||
proxy.LocalAddr().String(),
|
proxy.LocalAddr().String(),
|
||||||
getTLSClientConfig(),
|
getTLSClientConfig(),
|
||||||
maybeAddQlogTracer(&quic.Config{Versions: protocol.SupportedVersions[1:2]}),
|
maybeAddQlogTracer(&quic.Config{Versions: protocol.SupportedVersions[1:2]}),
|
||||||
|
|
|
@ -90,7 +90,7 @@ type client struct {
|
||||||
|
|
||||||
func (c *client) RoundTrip(req *http.Request) (*http.Response, error) {
|
func (c *client) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
c.once.Do(func() {
|
c.once.Do(func() {
|
||||||
c.conn, c.dialErr = quic.DialAddrEarly(c.hostname, c.tlsConf, c.quicConf)
|
c.conn, c.dialErr = quic.DialAddrEarly(context.Background(), c.hostname, c.tlsConf, c.quicConf)
|
||||||
})
|
})
|
||||||
if c.dialErr != nil {
|
if c.dialErr != nil {
|
||||||
return nil, c.dialErr
|
return nil, c.dialErr
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue