forked from quic-go/quic-go
fix typo in UDP connection helper function in tests (#4970)
This commit is contained in:
@@ -15,7 +15,7 @@ func TestDial(t *testing.T) {
|
||||
t.Run("Dial", func(t *testing.T) {
|
||||
testDial(t,
|
||||
func(ctx context.Context, addr net.Addr) error {
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
_, err := Dial(ctx, conn, addr, &tls.Config{}, nil)
|
||||
return err
|
||||
},
|
||||
@@ -26,7 +26,7 @@ func TestDial(t *testing.T) {
|
||||
t.Run("DialEarly", func(t *testing.T) {
|
||||
testDial(t,
|
||||
func(ctx context.Context, addr net.Addr) error {
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
_, err := DialEarly(ctx, conn, addr, &tls.Config{}, nil)
|
||||
return err
|
||||
},
|
||||
@@ -59,7 +59,7 @@ func testDial(t *testing.T,
|
||||
dialFn func(context.Context, net.Addr) error,
|
||||
shouldCloseConn bool,
|
||||
) {
|
||||
server := newUPDConnLocalhost(t)
|
||||
server := newUDPConnLocalhost(t)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
errChan := make(chan error, 1)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
func BenchmarkHandshake(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
ln, err := quic.Listen(newUPDConnLocalhost(b), tlsConfig, nil)
|
||||
ln, err := quic.Listen(newUDPConnLocalhost(b), tlsConfig, nil)
|
||||
require.NoError(b, err)
|
||||
defer ln.Close()
|
||||
|
||||
@@ -28,7 +28,7 @@ func BenchmarkHandshake(b *testing.B) {
|
||||
}
|
||||
}()
|
||||
|
||||
tr := &quic.Transport{Conn: newUPDConnLocalhost(b)}
|
||||
tr := &quic.Transport{Conn: newUDPConnLocalhost(b)}
|
||||
defer tr.Close()
|
||||
|
||||
b.ResetTimer()
|
||||
@@ -44,13 +44,13 @@ func BenchmarkHandshake(b *testing.B) {
|
||||
func BenchmarkStreamChurn(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
ln, err := quic.Listen(newUPDConnLocalhost(b), tlsConfig, &quic.Config{MaxIncomingStreams: 1e10})
|
||||
ln, err := quic.Listen(newUDPConnLocalhost(b), tlsConfig, &quic.Config{MaxIncomingStreams: 1e10})
|
||||
require.NoError(b, err)
|
||||
defer ln.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(b), ln.Addr(), tlsClientConfig, nil)
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(b), ln.Addr(), tlsClientConfig, nil)
|
||||
require.NoError(b, err)
|
||||
defer conn.CloseWithError(0, "")
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ func testStreamCancellation(
|
||||
) {
|
||||
const numStreams = 80
|
||||
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
@@ -195,7 +195,7 @@ func testStreamCancellation(
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
server.Addr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 2}),
|
||||
@@ -325,7 +325,7 @@ func testStreamCancellation(
|
||||
func TestCancelAcceptStream(t *testing.T) {
|
||||
const numStreams = 30
|
||||
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
@@ -333,7 +333,7 @@ func TestCancelAcceptStream(t *testing.T) {
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
server.Addr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{MaxIncomingUniStreams: numStreams / 3}),
|
||||
@@ -419,13 +419,13 @@ func TestCancelOpenStreamSync(t *testing.T) {
|
||||
maxIncomingStreams = 4
|
||||
)
|
||||
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
conn, err := quic.Dial(
|
||||
context.Background(),
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
server.Addr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{MaxIncomingUniStreams: maxIncomingStreams}),
|
||||
@@ -508,7 +508,7 @@ func TestHeavyStreamCancellation(t *testing.T) {
|
||||
const maxIncomingStreams = 500
|
||||
|
||||
server, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{MaxIncomingStreams: maxIncomingStreams, MaxIdleTimeout: 10 * time.Second}),
|
||||
)
|
||||
@@ -520,7 +520,7 @@ func TestHeavyStreamCancellation(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
|
||||
serverConn, err := server.Accept(context.Background())
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
|
||||
func TestConnectionCloseRetransmission(t *testing.T) {
|
||||
server, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{DisablePathMTUDiscovery: true}),
|
||||
)
|
||||
@@ -28,7 +28,7 @@ func TestConnectionCloseRetransmission(t *testing.T) {
|
||||
var drop atomic.Bool
|
||||
dropped := make(chan []byte, 100)
|
||||
proxy := &quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: server.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration {
|
||||
return 5 * time.Millisecond // 10ms RTT
|
||||
@@ -46,7 +46,7 @@ func TestConnectionCloseRetransmission(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), proxy.LocalAddr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), proxy.LocalAddr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer conn.CloseWithError(0, "")
|
||||
|
||||
@@ -84,11 +84,11 @@ func TestConnectionCloseRetransmission(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDrainServerAcceptQueue(t *testing.T) {
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
dialer := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
dialer := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
defer dialer.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
@@ -158,21 +158,21 @@ func (c *brokenConn) Break(e error) {
|
||||
|
||||
func TestTransportClose(t *testing.T) {
|
||||
t.Run("Close", func(t *testing.T) {
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
testTransportClose(t, conn, func() { conn.Close() }, nil)
|
||||
})
|
||||
|
||||
t.Run("connection error", func(t *testing.T) {
|
||||
t.Setenv("QUIC_GO_DISABLE_RECEIVE_BUFFER_WARNING", "true")
|
||||
|
||||
bc := newBrokenConn(newUPDConnLocalhost(t))
|
||||
bc := newBrokenConn(newUDPConnLocalhost(t))
|
||||
testErr := errors.New("test error")
|
||||
testTransportClose(t, bc, func() { bc.Break(testErr) }, testErr)
|
||||
})
|
||||
}
|
||||
|
||||
func testTransportClose(t *testing.T, conn net.PacketConn, closeFn func(), expectedErr error) {
|
||||
server := newUPDConnLocalhost(t)
|
||||
server := newUDPConnLocalhost(t)
|
||||
tr := &quic.Transport{Conn: conn}
|
||||
|
||||
errChan := make(chan error, 1)
|
||||
|
||||
@@ -71,7 +71,7 @@ func testTransferWithConnectionIDs(
|
||||
|
||||
// setup server
|
||||
serverTr := &quic.Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ConnectionIDLength: serverConnIDLen,
|
||||
ConnectionIDGenerator: serverConnIDGenerator,
|
||||
}
|
||||
@@ -99,11 +99,11 @@ func testTransferWithConnectionIDs(
|
||||
},
|
||||
})
|
||||
if clientConnIDGenerator == nil && clientConnIDLen == 0 {
|
||||
conn, err = quic.Dial(ctx, newUPDConnLocalhost(t), ln.Addr(), getTLSClientConfig(), clientQUICConf)
|
||||
conn, err = quic.Dial(ctx, newUDPConnLocalhost(t), ln.Addr(), getTLSClientConfig(), clientQUICConf)
|
||||
require.NoError(t, err)
|
||||
} else {
|
||||
clientTr := &quic.Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ConnectionIDLength: clientConnIDLen,
|
||||
ConnectionIDGenerator: clientConnIDGenerator,
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestDatagramNegotiation(t *testing.T) {
|
||||
|
||||
func testDatagramNegotiation(t *testing.T, serverEnableDatagram, clientEnableDatagram bool) {
|
||||
server, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{EnableDatagrams: serverEnableDatagram}),
|
||||
)
|
||||
@@ -45,7 +45,7 @@ func testDatagramNegotiation(t *testing.T, serverEnableDatagram, clientEnableDat
|
||||
defer cancel()
|
||||
clientConn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
server.Addr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{EnableDatagrams: clientEnableDatagram}),
|
||||
@@ -87,7 +87,7 @@ func TestDatagramSizeLimit(t *testing.T) {
|
||||
t.Cleanup(func() { wire.MaxDatagramSize = originalMaxDatagramSize })
|
||||
|
||||
server, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{EnableDatagrams: true}),
|
||||
)
|
||||
@@ -98,7 +98,7 @@ func TestDatagramSizeLimit(t *testing.T) {
|
||||
defer cancel()
|
||||
clientConn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
server.Addr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{EnableDatagrams: true}),
|
||||
@@ -129,7 +129,7 @@ func TestDatagramLoss(t *testing.T) {
|
||||
const datagramSize = 500
|
||||
|
||||
server, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{EnableDatagrams: true}),
|
||||
)
|
||||
@@ -138,7 +138,7 @@ func TestDatagramLoss(t *testing.T) {
|
||||
|
||||
var droppedIncoming, droppedOutgoing, total atomic.Int32
|
||||
proxy := &quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: server.Addr().(*net.UDPAddr),
|
||||
DropPacket: func(dir quicproxy.Direction, _, _ net.Addr, packet []byte) bool {
|
||||
if wire.IsLongHeaderPacket(packet[0]) { // don't drop Long Header packets
|
||||
@@ -168,7 +168,7 @@ func TestDatagramLoss(t *testing.T) {
|
||||
defer cancel()
|
||||
clientConn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
proxy.LocalAddr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{EnableDatagrams: true}),
|
||||
|
||||
@@ -16,13 +16,13 @@ import (
|
||||
|
||||
func setupDeadlineTest(t *testing.T) (serverStr, clientStr quic.Stream) {
|
||||
t.Helper()
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { server.Close() })
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { conn.CloseWithError(0, "") })
|
||||
clientStr, err = conn.OpenStream()
|
||||
|
||||
@@ -28,13 +28,13 @@ func TestDropTests(t *testing.T) {
|
||||
t.Logf("dropping packets for %s, after a delay of %s", dropDuration, dropDelay)
|
||||
startTime := time.Now()
|
||||
|
||||
ln, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
ln, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer ln.Close()
|
||||
|
||||
var numDroppedPackets atomic.Int32
|
||||
proxy := &quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration { return rtt / 2 },
|
||||
DropPacket: func(d quicproxy.Direction, _, _ net.Addr, b []byte) bool {
|
||||
@@ -56,7 +56,7 @@ func TestDropTests(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), proxy.LocalAddr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), proxy.LocalAddr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer conn.CloseWithError(0, "")
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ import (
|
||||
|
||||
func TestEarlyData(t *testing.T) {
|
||||
const rtt = 80 * time.Millisecond
|
||||
ln, err := quic.ListenEarly(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
ln, err := quic.ListenEarly(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer ln.Close()
|
||||
|
||||
proxy := &quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration { return rtt / 2 },
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func TestEarlyData(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
clientConn, err := quic.Dial(ctx, newUPDConnLocalhost(t), proxy.LocalAddr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
clientConn, err := quic.Dial(ctx, newUDPConnLocalhost(t), proxy.LocalAddr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
|
||||
var serverConn quic.EarlyConnection
|
||||
|
||||
@@ -17,11 +17,11 @@ func TestHandshakeContextTimeout(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), scaleDuration(20*time.Millisecond))
|
||||
defer cancel()
|
||||
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
|
||||
errChan := make(chan error, 1)
|
||||
go func() {
|
||||
_, err := quic.Dial(ctx, newUPDConnLocalhost(t), conn.LocalAddr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
_, err := quic.Dial(ctx, newUDPConnLocalhost(t), conn.LocalAddr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
errChan <- err
|
||||
}()
|
||||
|
||||
@@ -31,9 +31,9 @@ func TestHandshakeContextTimeout(t *testing.T) {
|
||||
func TestHandshakeCancellationError(t *testing.T) {
|
||||
ctx, cancel := context.WithCancelCause(context.Background())
|
||||
errChan := make(chan error, 1)
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
go func() {
|
||||
_, err := quic.Dial(ctx, newUPDConnLocalhost(t), conn.LocalAddr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
_, err := quic.Dial(ctx, newUDPConnLocalhost(t), conn.LocalAddr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
errChan <- err
|
||||
}()
|
||||
|
||||
@@ -49,7 +49,7 @@ func TestConnContextOnServerSide(t *testing.T) {
|
||||
streamContextChan := make(chan context.Context, 1)
|
||||
|
||||
tr := &quic.Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ConnContext: func(ctx context.Context) context.Context {
|
||||
return context.WithValue(ctx, "foo", "bar") //nolint:staticcheck
|
||||
},
|
||||
@@ -80,7 +80,7 @@ func TestConnContextOnServerSide(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
c, err := quic.Dial(ctx, newUPDConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
c, err := quic.Dial(ctx, newUDPConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
|
||||
serverConn, err := server.Accept(ctx)
|
||||
@@ -135,7 +135,7 @@ func TestConnContextOnServerSide(t *testing.T) {
|
||||
// Users are not supposed to return a fresh context from ConnContext, but we should handle it gracefully.
|
||||
func TestConnContextFreshContext(t *testing.T) {
|
||||
tr := &quic.Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ConnContext: func(ctx context.Context) context.Context { return context.Background() },
|
||||
}
|
||||
defer tr.Close()
|
||||
@@ -155,7 +155,7 @@ func TestConnContextFreshContext(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
c, err := quic.Dial(ctx, newUPDConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
c, err := quic.Dial(ctx, newUDPConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
|
||||
select {
|
||||
@@ -170,7 +170,7 @@ func TestConnContextFreshContext(t *testing.T) {
|
||||
func TestContextOnClientSide(t *testing.T) {
|
||||
tlsServerConf := getTLSConfig()
|
||||
tlsServerConf.ClientAuth = tls.RequestClientCert
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), tlsServerConf, getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), tlsServerConf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
@@ -185,7 +185,7 @@ func TestContextOnClientSide(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.WithValue(context.Background(), "foo", "bar")) //nolint:staticcheck
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
server.Addr(),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{
|
||||
|
||||
@@ -35,7 +35,7 @@ func startDropTestListenerAndProxy(t *testing.T, rtt, timeout time.Duration, dro
|
||||
tlsConf = getTLSConfig()
|
||||
}
|
||||
tr := &quic.Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
VerifySourceAddress: func(net.Addr) bool { return doRetry },
|
||||
}
|
||||
t.Cleanup(func() { tr.Close() })
|
||||
@@ -44,7 +44,7 @@ func startDropTestListenerAndProxy(t *testing.T, rtt, timeout time.Duration, dro
|
||||
t.Cleanup(func() { ln.Close() })
|
||||
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DropPacket: dropCallback,
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration { return rtt / 2 },
|
||||
@@ -59,7 +59,7 @@ func dropTestProtocolClientSpeaksFirst(t *testing.T, ln *quic.Listener, addr net
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
addr,
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
@@ -95,7 +95,7 @@ func dropTestProtocolServerSpeaksFirst(t *testing.T, ln *quic.Listener, addr net
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
addr,
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
@@ -153,7 +153,7 @@ func dropTestProtocolNobodySpeaks(t *testing.T, ln *quic.Listener, addr net.Addr
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
addr,
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
|
||||
@@ -18,7 +18,7 @@ func handshakeWithRTT(t *testing.T, serverAddr net.Addr, tlsConf *tls.Config, qu
|
||||
t.Helper()
|
||||
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: serverAddr.(*net.UDPAddr),
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration { return rtt / 2 },
|
||||
}
|
||||
@@ -29,7 +29,7 @@ func handshakeWithRTT(t *testing.T, serverAddr net.Addr, tlsConf *tls.Config, qu
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
proxy.LocalAddr(),
|
||||
tlsConf,
|
||||
quicConf,
|
||||
@@ -40,7 +40,7 @@ func handshakeWithRTT(t *testing.T, serverAddr net.Addr, tlsConf *tls.Config, qu
|
||||
}
|
||||
|
||||
func TestHandshakeRTTWithoutRetry(t *testing.T) {
|
||||
ln, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
ln, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer ln.Close()
|
||||
|
||||
@@ -61,7 +61,7 @@ func TestHandshakeRTTWithoutRetry(t *testing.T) {
|
||||
|
||||
func TestHandshakeRTTWithRetry(t *testing.T) {
|
||||
tr := &quic.Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
VerifySourceAddress: func(net.Addr) bool { return true },
|
||||
}
|
||||
addTracer(tr)
|
||||
@@ -88,7 +88,7 @@ func TestHandshakeRTTWithHelloRetryRequest(t *testing.T) {
|
||||
tlsConf := getTLSConfig()
|
||||
tlsConf.CurvePreferences = []tls.CurveID{tls.CurveP384}
|
||||
|
||||
ln, err := quic.Listen(newUPDConnLocalhost(t), tlsConf, getQuicConfig(nil))
|
||||
ln, err := quic.Listen(newUDPConnLocalhost(t), tlsConf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer ln.Close()
|
||||
|
||||
@@ -117,7 +117,7 @@ func TestHandshakeRTTReceiveMessage(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("using Listen", func(t *testing.T) {
|
||||
ln, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
ln, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer ln.Close()
|
||||
|
||||
@@ -147,7 +147,7 @@ func TestHandshakeRTTReceiveMessage(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("using ListenEarly", func(t *testing.T) {
|
||||
ln, err := quic.ListenEarly(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
ln, err := quic.ListenEarly(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer ln.Close()
|
||||
|
||||
|
||||
@@ -76,13 +76,13 @@ func TestHandshake(t *testing.T) {
|
||||
{"long cert chain", getTLSConfigWithLongCertChain()},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), tt.conf, getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), tt.conf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer conn.CloseWithError(0, "")
|
||||
|
||||
@@ -94,7 +94,7 @@ func TestHandshake(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHandshakeServerMismatch(t *testing.T) {
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
@@ -102,7 +102,7 @@ func TestHandshakeServerMismatch(t *testing.T) {
|
||||
conf.ServerName = "foo.bar"
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
_, err = quic.Dial(ctx, newUPDConnLocalhost(t), server.Addr(), conf, getQuicConfig(nil))
|
||||
_, err = quic.Dial(ctx, newUDPConnLocalhost(t), server.Addr(), conf, getQuicConfig(nil))
|
||||
require.Error(t, err)
|
||||
var transportErr *quic.TransportError
|
||||
require.True(t, errors.As(err, &transportErr))
|
||||
@@ -122,13 +122,13 @@ func TestHandshakeCipherSuites(t *testing.T) {
|
||||
reset := qtls.SetCipherSuite(suiteID)
|
||||
defer reset()
|
||||
|
||||
ln, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
ln, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer ln.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer conn.CloseWithError(0, "")
|
||||
|
||||
@@ -156,7 +156,7 @@ func TestHandshakeCipherSuites(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTLSGetConfigForClientError(t *testing.T) {
|
||||
tr := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
addTracer(tr)
|
||||
defer tr.Close()
|
||||
|
||||
@@ -171,7 +171,7 @@ func TestTLSGetConfigForClientError(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
_, err = quic.Dial(ctx, newUPDConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
_, err = quic.Dial(ctx, newUDPConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
var transportErr *quic.TransportError
|
||||
require.ErrorAs(t, err, &transportErr)
|
||||
require.True(t, transportErr.ErrorCode.IsCryptoError())
|
||||
@@ -197,13 +197,13 @@ func TestTLSConfigGetConfigForClientAddresses(t *testing.T) {
|
||||
return conf, nil
|
||||
},
|
||||
}
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), tlsConf, getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), tlsConf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer conn.CloseWithError(0, "")
|
||||
|
||||
@@ -223,13 +223,13 @@ func TestHandshakeFailsWithoutClientCert(t *testing.T) {
|
||||
tlsConf := getTLSConfig()
|
||||
tlsConf.ClientAuth = tls.RequireAndVerifyClientCert
|
||||
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), tlsConf, getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), tlsConf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
|
||||
// Usually, the error will occur after the client already finished the handshake.
|
||||
// However, there's a race condition here. The server's CONNECTION_CLOSE might be
|
||||
@@ -256,10 +256,10 @@ func TestHandshakeFailsWithoutClientCert(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClosedConnectionsInAcceptQueue(t *testing.T) {
|
||||
dialer := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
dialer := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
defer dialer.Close()
|
||||
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
@@ -296,11 +296,11 @@ func TestClosedConnectionsInAcceptQueue(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestServerAcceptQueueOverflow(t *testing.T) {
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
dialer := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
dialer := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
defer dialer.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
@@ -340,7 +340,7 @@ func TestServerAcceptQueueOverflow(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHandshakingConnectionsClosedOnServerShutdown(t *testing.T) {
|
||||
tr := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
addTracer(tr)
|
||||
defer tr.Close()
|
||||
|
||||
@@ -360,7 +360,7 @@ func TestHandshakingConnectionsClosedOnServerShutdown(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration { return rtt / 2 },
|
||||
}
|
||||
@@ -371,7 +371,7 @@ func TestHandshakingConnectionsClosedOnServerShutdown(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
go func() {
|
||||
_, err := quic.Dial(ctx, newUPDConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
_, err := quic.Dial(ctx, newUDPConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
errChan <- err
|
||||
}()
|
||||
|
||||
@@ -389,7 +389,7 @@ func TestHandshakingConnectionsClosedOnServerShutdown(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestALPN(t *testing.T) {
|
||||
ln, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
ln, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer ln.Close()
|
||||
|
||||
@@ -406,7 +406,7 @@ func TestALPN(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), ln.Addr(), getTLSClientConfig(), nil)
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), ln.Addr(), getTLSClientConfig(), nil)
|
||||
require.NoError(t, err)
|
||||
cs := conn.ConnectionState()
|
||||
require.Equal(t, alpn, cs.TLS.NegotiatedProtocol)
|
||||
@@ -424,7 +424,7 @@ func TestALPN(t *testing.T) {
|
||||
tlsConf.NextProtos = []string{"foobar"}
|
||||
ctx, cancel = context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
_, err = quic.Dial(ctx, newUPDConnLocalhost(t), ln.Addr(), tlsConf, nil)
|
||||
_, err = quic.Dial(ctx, newUDPConnLocalhost(t), ln.Addr(), tlsConf, nil)
|
||||
require.Error(t, err)
|
||||
var transportErr *quic.TransportError
|
||||
require.ErrorAs(t, err, &transportErr)
|
||||
@@ -452,7 +452,7 @@ func testTokensFromNewTokenFrames(t *testing.T, maxTokenAge time.Duration, expec
|
||||
addrVerifiedChan <- info.AddrVerified
|
||||
return quicConf, nil
|
||||
}
|
||||
tr := &quic.Transport{Conn: newUPDConnLocalhost(t), MaxTokenAge: maxTokenAge}
|
||||
tr := &quic.Transport{Conn: newUDPConnLocalhost(t), MaxTokenAge: maxTokenAge}
|
||||
addTracer(tr)
|
||||
defer tr.Close()
|
||||
server, err := tr.Listen(getTLSConfig(), quicConf)
|
||||
@@ -473,7 +473,7 @@ func testTokensFromNewTokenFrames(t *testing.T, maxTokenAge time.Duration, expec
|
||||
ts := newTokenStore(gets, puts)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(&quic.Config{TokenStore: ts}))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(&quic.Config{TokenStore: ts}))
|
||||
require.NoError(t, err)
|
||||
|
||||
// verify token store was used
|
||||
@@ -502,7 +502,7 @@ func testTokensFromNewTokenFrames(t *testing.T, maxTokenAge time.Duration, expec
|
||||
require.NoError(t, conn.CloseWithError(0, ""))
|
||||
|
||||
time.Sleep(scaleDuration(5 * time.Millisecond))
|
||||
conn, err = quic.Dial(ctx, newUPDConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(&quic.Config{TokenStore: ts}))
|
||||
conn, err = quic.Dial(ctx, newUDPConnLocalhost(t), server.Addr(), getTLSClientConfig(), getQuicConfig(&quic.Config{TokenStore: ts}))
|
||||
require.NoError(t, err)
|
||||
defer conn.CloseWithError(0, "")
|
||||
|
||||
@@ -540,7 +540,7 @@ func TestInvalidToken(t *testing.T) {
|
||||
serverConfig := getQuicConfig(&quic.Config{HandshakeIdleTimeout: rtt / 5})
|
||||
|
||||
tr := &quic.Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
VerifySourceAddress: func(net.Addr) bool { return true },
|
||||
}
|
||||
addTracer(tr)
|
||||
@@ -551,7 +551,7 @@ func TestInvalidToken(t *testing.T) {
|
||||
defer server.Close()
|
||||
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: server.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration { return rtt / 2 },
|
||||
}
|
||||
@@ -560,7 +560,7 @@ func TestInvalidToken(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
_, err = quic.Dial(ctx, newUPDConnLocalhost(t), proxy.LocalAddr(), getTLSClientConfig(), nil)
|
||||
_, err = quic.Dial(ctx, newUDPConnLocalhost(t), proxy.LocalAddr(), getTLSClientConfig(), nil)
|
||||
require.Error(t, err)
|
||||
var transportErr *quic.TransportError
|
||||
require.ErrorAs(t, err, &transportErr)
|
||||
@@ -576,7 +576,7 @@ func TestGetConfigForClient(t *testing.T) {
|
||||
calledFrom = info.RemoteAddr
|
||||
return getQuicConfig(conf), nil
|
||||
}
|
||||
ln, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), serverConfig)
|
||||
ln, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), serverConfig)
|
||||
require.NoError(t, err)
|
||||
|
||||
acceptDone := make(chan struct{})
|
||||
@@ -588,7 +588,7 @@ func TestGetConfigForClient(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(&quic.Config{EnableDatagrams: true}))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(&quic.Config{EnableDatagrams: true}))
|
||||
require.NoError(t, err)
|
||||
defer conn.CloseWithError(0, "")
|
||||
|
||||
@@ -607,7 +607,7 @@ func TestGetConfigForClient(t *testing.T) {
|
||||
|
||||
func TestGetConfigForClientErrorsConnectionRejection(t *testing.T) {
|
||||
ln, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
GetConfigForClient: func(info *quic.ClientHelloInfo) (*quic.Config, error) {
|
||||
@@ -625,7 +625,7 @@ func TestGetConfigForClientErrorsConnectionRejection(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
_, err = quic.Dial(ctx, newUPDConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
_, err = quic.Dial(ctx, newUDPConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
var transportErr *quic.TransportError
|
||||
require.ErrorAs(t, err, &transportErr)
|
||||
require.Equal(t, qerr.ConnectionRefused, transportErr.ErrorCode)
|
||||
@@ -636,7 +636,7 @@ func TestGetConfigForClientErrorsConnectionRejection(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNoPacketsSentWhenClientHelloFails(t *testing.T) {
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
|
||||
packetChan := make(chan struct{}, 1)
|
||||
go func() {
|
||||
@@ -656,7 +656,7 @@ func TestNoPacketsSentWhenClientHelloFails(t *testing.T) {
|
||||
tlsConf.NextProtos = []string{""}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
_, err := quic.Dial(ctx, newUPDConnLocalhost(t), conn.LocalAddr(), tlsConf, getQuicConfig(nil))
|
||||
_, err := quic.Dial(ctx, newUDPConnLocalhost(t), conn.LocalAddr(), tlsConf, getQuicConfig(nil))
|
||||
|
||||
var transportErr *quic.TransportError
|
||||
require.ErrorAs(t, err, &transportErr)
|
||||
|
||||
@@ -78,7 +78,7 @@ func TestHTTP3ServerHotswap(t *testing.T) {
|
||||
}
|
||||
|
||||
tlsConf := http3.ConfigureTLSConfig(getTLSConfig())
|
||||
quicLn, err := quic.ListenEarly(newUPDConnLocalhost(t), tlsConf, getQuicConfig(nil))
|
||||
quicLn, err := quic.ListenEarly(newUDPConnLocalhost(t), tlsConf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
ln := &listenerWrapper{QUICEarlyListener: quicLn}
|
||||
port := strconv.Itoa(ln.Addr().(*net.UDPAddr).Port)
|
||||
|
||||
@@ -59,7 +59,7 @@ func startHTTPServer(t *testing.T, mux *http.ServeMux, opts ...func(*http3.Serve
|
||||
opt(server)
|
||||
}
|
||||
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer close(done)
|
||||
@@ -554,7 +554,7 @@ func TestHTTPDeadlines(t *testing.T) {
|
||||
func TestHTTPServeQUICConn(t *testing.T) {
|
||||
tlsConf := getTLSConfig()
|
||||
tlsConf.NextProtos = []string{http3.NextProtoH3}
|
||||
ln, err := quic.Listen(newUPDConnLocalhost(t), tlsConf, getQuicConfig(nil))
|
||||
ln, err := quic.Listen(newUDPConnLocalhost(t), tlsConf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer ln.Close()
|
||||
|
||||
@@ -593,7 +593,7 @@ func TestHTTPServeQUICConn(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHTTPContextFromQUIC(t *testing.T) {
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
tr := &quic.Transport{
|
||||
Conn: conn,
|
||||
ConnContext: func(ctx context.Context) context.Context {
|
||||
@@ -849,7 +849,7 @@ func TestHTTP0RTT(t *testing.T) {
|
||||
|
||||
var num0RTTPackets atomic.Uint32
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: port},
|
||||
DelayPacket: func(_ quicproxy.Direction, _, _ net.Addr, data []byte) time.Duration {
|
||||
if contains0RTTPacket(data) {
|
||||
@@ -927,7 +927,7 @@ func TestHTTPStreamer(t *testing.T) {
|
||||
tlsConf.NextProtos = []string{http3.NextProtoH3}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: port}, tlsConf, getQuicConfig(nil))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: port}, tlsConf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer conn.CloseWithError(0, "")
|
||||
tr := http3.Transport{}
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestKeyUpdates(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), nil)
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), nil)
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestKeyUpdates(t *testing.T) {
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
server.Addr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{Tracer: func(context.Context, logging.Perspective, quic.ConnectionID) *logging.ConnectionTracer {
|
||||
|
||||
@@ -26,14 +26,14 @@ const mitmTestConnIDLen = 6
|
||||
|
||||
func getTransportsForMITMTest(t *testing.T) (serverTransport, clientTransport *quic.Transport) {
|
||||
serverTransport = &quic.Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ConnectionIDLength: mitmTestConnIDLen,
|
||||
}
|
||||
addTracer(serverTransport)
|
||||
t.Cleanup(func() { serverTransport.Close() })
|
||||
|
||||
clientTransport = &quic.Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ConnectionIDLength: mitmTestConnIDLen,
|
||||
}
|
||||
addTracer(clientTransport)
|
||||
@@ -204,7 +204,7 @@ func runMITMTest(t *testing.T, serverTr, clientTr *quic.Transport, rtt time.Dura
|
||||
defer ln.Close()
|
||||
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration { return rtt / 2 },
|
||||
DropPacket: dropCb,
|
||||
@@ -413,7 +413,7 @@ func runMITMTestSuccessful(t *testing.T, serverTransport, clientTransport *quic.
|
||||
defer ln.Close()
|
||||
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DelayPacket: delayCb,
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ import (
|
||||
)
|
||||
|
||||
func TestInitialPacketSize(t *testing.T) {
|
||||
server := newUPDConnLocalhost(t)
|
||||
client := newUPDConnLocalhost(t)
|
||||
server := newUDPConnLocalhost(t)
|
||||
client := newUDPConnLocalhost(t)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
@@ -46,7 +46,7 @@ func TestPathMTUDiscovery(t *testing.T) {
|
||||
const mtu = 1400
|
||||
|
||||
ln, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
InitialPacketSize: 1234,
|
||||
@@ -80,7 +80,7 @@ func TestPathMTUDiscovery(t *testing.T) {
|
||||
var maxPacketSizeServer int
|
||||
var clientPacketSizes []int
|
||||
proxy := &quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration { return rtt / 2 },
|
||||
DropPacket: func(dir quicproxy.Direction, _, _ net.Addr, packet []byte) bool {
|
||||
@@ -105,7 +105,7 @@ func TestPathMTUDiscovery(t *testing.T) {
|
||||
|
||||
// Make sure to use v4-only socket here.
|
||||
// We can't reliably set the DF bit on dual-stack sockets on older versions of macOS (before Sequoia).
|
||||
tr := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
defer tr.Close()
|
||||
|
||||
var mtus []logging.ByteCount
|
||||
|
||||
@@ -59,12 +59,12 @@ func dialAndReceiveData(tr *quic.Transport, addr net.Addr) error {
|
||||
}
|
||||
|
||||
func TestMultiplexesConnectionsToSameServer(t *testing.T) {
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
go runMultiplexTestServer(t, server)
|
||||
|
||||
tr := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
addTracer(tr)
|
||||
defer tr.Close()
|
||||
|
||||
@@ -88,17 +88,17 @@ func TestMultiplexesConnectionsToSameServer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMultiplexingToDifferentServers(t *testing.T) {
|
||||
server1, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
server1, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server1.Close()
|
||||
go runMultiplexTestServer(t, server1)
|
||||
|
||||
server2, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
server2, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server2.Close()
|
||||
go runMultiplexTestServer(t, server2)
|
||||
|
||||
tr := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
addTracer(tr)
|
||||
defer tr.Close()
|
||||
|
||||
@@ -122,7 +122,7 @@ func TestMultiplexingToDifferentServers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMultiplexingConnectToSelf(t *testing.T) {
|
||||
tr := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
addTracer(tr)
|
||||
defer tr.Close()
|
||||
|
||||
@@ -147,14 +147,14 @@ func TestMultiplexingServerAndClientOnSameConn(t *testing.T) {
|
||||
t.Skip("This test requires setting of iptables rules on Linux, see https://stackoverflow.com/questions/23859164/linux-udp-socket-sendto-operation-not-permitted.")
|
||||
}
|
||||
|
||||
tr1 := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr1 := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
addTracer(tr1)
|
||||
defer tr1.Close()
|
||||
server1, err := tr1.Listen(getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server1.Close()
|
||||
|
||||
tr2 := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr2 := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
addTracer(tr2)
|
||||
defer tr2.Close()
|
||||
server2, err := tr2.Listen(getTLSConfig(), getQuicConfig(nil))
|
||||
@@ -188,14 +188,14 @@ func TestMultiplexingServerAndClientOnSameConn(t *testing.T) {
|
||||
func TestMultiplexingNonQUICPackets(t *testing.T) {
|
||||
const numPackets = 100
|
||||
|
||||
tr1 := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr1 := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
defer tr1.Close()
|
||||
addTracer(tr1)
|
||||
server, err := tr1.Listen(getTLSConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
tr2 := &quic.Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr2 := &quic.Transport{Conn: newUDPConnLocalhost(t)}
|
||||
defer tr2.Close()
|
||||
addTracer(tr2)
|
||||
|
||||
|
||||
@@ -25,21 +25,21 @@ func TestNATRebinding(t *testing.T) {
|
||||
defer f.Close()
|
||||
tlsConf.KeyLogWriter = f
|
||||
server, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{Tracer: newTracer(tracer)}),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
newPath := newUPDConnLocalhost(t)
|
||||
clientUDPConn := newUPDConnLocalhost(t)
|
||||
newPath := newUDPConnLocalhost(t)
|
||||
clientUDPConn := newUDPConnLocalhost(t)
|
||||
|
||||
oldPathRTT := scaleDuration(10 * time.Millisecond)
|
||||
newPathRTT := scaleDuration(20 * time.Millisecond)
|
||||
proxy := quicproxy.Proxy{
|
||||
ServerAddr: server.Addr().(*net.UDPAddr),
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
}
|
||||
var mx sync.Mutex
|
||||
var switchedPath bool
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestACKBundling(t *testing.T) {
|
||||
|
||||
serverCounter, serverTracer := newPacketTracer()
|
||||
server, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
DisablePathMTUDiscovery: true,
|
||||
@@ -35,7 +35,7 @@ func TestACKBundling(t *testing.T) {
|
||||
defer server.Close()
|
||||
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: server.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration {
|
||||
return 5 * time.Millisecond
|
||||
@@ -49,7 +49,7 @@ func TestACKBundling(t *testing.T) {
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
proxy.LocalAddr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
@@ -153,7 +153,7 @@ func testConnAndStreamDataBlocked(t *testing.T, limitStream, limitConn bool) {
|
||||
rtt := scaleDuration(5 * time.Millisecond)
|
||||
|
||||
ln, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
InitialStreamReceiveWindow: initialStreamWindow,
|
||||
@@ -164,7 +164,7 @@ func testConnAndStreamDataBlocked(t *testing.T, limitStream, limitConn bool) {
|
||||
defer ln.Close()
|
||||
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration {
|
||||
return rtt / 2
|
||||
@@ -178,7 +178,7 @@ func testConnAndStreamDataBlocked(t *testing.T, limitStream, limitConn bool) {
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
proxy.LocalAddr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestQlogDirEnvironmentVariable(t *testing.T) {
|
||||
|
||||
serverStopped := make(chan struct{})
|
||||
server, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
&quic.Config{
|
||||
Tracer: qlog.DefaultConnectionTracer,
|
||||
@@ -42,7 +42,7 @@ func TestQlogDirEnvironmentVariable(t *testing.T) {
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
server.Addr(),
|
||||
getTLSClientConfig(),
|
||||
&quic.Config{
|
||||
|
||||
@@ -66,7 +66,7 @@ func TestTLSSessionResumption(t *testing.T) {
|
||||
}
|
||||
|
||||
func handshakeWithSessionResumption(t *testing.T, serverTLSConf *tls.Config, expectSessionTicket bool) {
|
||||
server, err := quic.Listen(newUPDConnLocalhost(t), serverTLSConf, getQuicConfig(nil))
|
||||
server, err := quic.Listen(newUDPConnLocalhost(t), serverTLSConf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer server.Close()
|
||||
|
||||
@@ -79,7 +79,7 @@ func handshakeWithSessionResumption(t *testing.T, serverTLSConf *tls.Config, exp
|
||||
// first connection - doesn't use resumption
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn1, err := quic.Dial(ctx, newUPDConnLocalhost(t), server.Addr(), tlsConf, getQuicConfig(nil))
|
||||
conn1, err := quic.Dial(ctx, newUDPConnLocalhost(t), server.Addr(), tlsConf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer conn1.CloseWithError(0, "")
|
||||
require.False(t, conn1.ConnectionState().TLS.DidResume)
|
||||
@@ -101,7 +101,7 @@ func handshakeWithSessionResumption(t *testing.T, serverTLSConf *tls.Config, exp
|
||||
require.False(t, serverConn.ConnectionState().TLS.DidResume)
|
||||
|
||||
// second connection - will use resumption, if enabled
|
||||
conn2, err := quic.Dial(ctx, newUPDConnLocalhost(t), server.Addr(), tlsConf, getQuicConfig(nil))
|
||||
conn2, err := quic.Dial(ctx, newUDPConnLocalhost(t), server.Addr(), tlsConf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
defer conn2.CloseWithError(0, "")
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
func runServerForRTTTest(t *testing.T) (net.Addr, <-chan error) {
|
||||
ln, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(nil),
|
||||
)
|
||||
@@ -66,7 +66,7 @@ func TestDownloadWithFixedRTT(t *testing.T) {
|
||||
})
|
||||
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: addr.(*net.UDPAddr).Port},
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration { return rtt / 2 },
|
||||
}
|
||||
@@ -77,7 +77,7 @@ func TestDownloadWithFixedRTT(t *testing.T) {
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
proxy.LocalAddr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(nil),
|
||||
@@ -111,7 +111,7 @@ func TestDownloadWithReordering(t *testing.T) {
|
||||
})
|
||||
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: addr.(*net.UDPAddr).Port},
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration {
|
||||
return randomDuration(rtt/2, rtt*3/2) / 2
|
||||
@@ -124,7 +124,7 @@ func TestDownloadWithReordering(t *testing.T) {
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
proxy.LocalAddr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(nil),
|
||||
|
||||
@@ -153,7 +153,7 @@ func addTracer(tr *quic.Transport) {
|
||||
)
|
||||
}
|
||||
|
||||
func newUPDConnLocalhost(t testing.TB) *net.UDPConn {
|
||||
func newUDPConnLocalhost(t testing.TB) *net.UDPConn {
|
||||
t.Helper()
|
||||
conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -26,7 +26,7 @@ func testStatelessReset(t *testing.T, connIDLen int) {
|
||||
var statelessResetKey quic.StatelessResetKey
|
||||
rand.Read(statelessResetKey[:])
|
||||
|
||||
c := newUPDConnLocalhost(t)
|
||||
c := newUDPConnLocalhost(t)
|
||||
tr := &quic.Transport{
|
||||
Conn: c,
|
||||
StatelessResetKey: &statelessResetKey,
|
||||
@@ -58,7 +58,7 @@ func testStatelessReset(t *testing.T, connIDLen int) {
|
||||
|
||||
var drop atomic.Bool
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DropPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) bool { return drop.Load() },
|
||||
}
|
||||
@@ -66,7 +66,7 @@ func testStatelessReset(t *testing.T, connIDLen int) {
|
||||
defer proxy.Close()
|
||||
|
||||
cl := &quic.Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ConnectionIDLength: connIDLen,
|
||||
}
|
||||
defer cl.Close()
|
||||
|
||||
@@ -71,7 +71,7 @@ func TestBidirectionalStreamMultiplexing(t *testing.T) {
|
||||
|
||||
t.Run("client -> server", func(t *testing.T) {
|
||||
ln, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
MaxIncomingStreams: 10,
|
||||
@@ -86,7 +86,7 @@ func TestBidirectionalStreamMultiplexing(t *testing.T) {
|
||||
defer cancel()
|
||||
client, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
ln.Addr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{InitialConnectionReceiveWindow: 2000}),
|
||||
@@ -116,7 +116,7 @@ func TestBidirectionalStreamMultiplexing(t *testing.T) {
|
||||
|
||||
t.Run("client <-> server", func(t *testing.T) {
|
||||
ln, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
MaxIncomingStreams: 30,
|
||||
@@ -131,7 +131,7 @@ func TestBidirectionalStreamMultiplexing(t *testing.T) {
|
||||
defer cancel()
|
||||
client, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
ln.Addr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{InitialConnectionReceiveWindow: 2000}),
|
||||
@@ -214,7 +214,7 @@ func TestUnidirectionalStreams(t *testing.T) {
|
||||
|
||||
t.Run("client -> server", func(t *testing.T) {
|
||||
ln, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(nil),
|
||||
)
|
||||
@@ -223,7 +223,7 @@ func TestUnidirectionalStreams(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
client, err := quic.Dial(ctx, newUPDConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
client, err := quic.Dial(ctx, newUDPConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
|
||||
serverConn, err := ln.Accept(ctx)
|
||||
@@ -243,7 +243,7 @@ func TestUnidirectionalStreams(t *testing.T) {
|
||||
|
||||
t.Run("server -> client", func(t *testing.T) {
|
||||
ln, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(nil),
|
||||
)
|
||||
@@ -252,7 +252,7 @@ func TestUnidirectionalStreams(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
client, err := quic.Dial(ctx, newUPDConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
client, err := quic.Dial(ctx, newUDPConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
|
||||
serverConn, err := ln.Accept(ctx)
|
||||
@@ -273,7 +273,7 @@ func TestUnidirectionalStreams(t *testing.T) {
|
||||
|
||||
t.Run("client <-> server", func(t *testing.T) {
|
||||
ln, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(nil),
|
||||
)
|
||||
@@ -295,7 +295,7 @@ func TestUnidirectionalStreams(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
client, err := quic.Dial(ctx, newUPDConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
client, err := quic.Dial(ctx, newUDPConnLocalhost(t), ln.Addr(), getTLSClientConfig(), getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
|
||||
errChan3 := make(chan error, 1)
|
||||
|
||||
@@ -35,10 +35,10 @@ func requireIdleTimeoutError(t *testing.T, err error) {
|
||||
func TestHandshakeIdleTimeout(t *testing.T) {
|
||||
errChan := make(chan error, 1)
|
||||
go func() {
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
_, err := quic.Dial(
|
||||
context.Background(),
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
conn.LocalAddr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{HandshakeIdleTimeout: scaleDuration(50 * time.Millisecond)}),
|
||||
@@ -58,10 +58,10 @@ func TestHandshakeTimeoutContext(t *testing.T) {
|
||||
defer cancel()
|
||||
errChan := make(chan error)
|
||||
go func() {
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
_, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
conn.LocalAddr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(nil),
|
||||
@@ -81,10 +81,10 @@ func TestHandshakeTimeout0RTTContext(t *testing.T) {
|
||||
defer cancel()
|
||||
errChan := make(chan error)
|
||||
go func() {
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
_, err := quic.DialEarly(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
conn.LocalAddr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(nil),
|
||||
@@ -103,7 +103,7 @@ func TestIdleTimeout(t *testing.T) {
|
||||
idleTimeout := scaleDuration(200 * time.Millisecond)
|
||||
|
||||
server, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{DisablePathMTUDiscovery: true}),
|
||||
)
|
||||
@@ -112,7 +112,7 @@ func TestIdleTimeout(t *testing.T) {
|
||||
|
||||
var drop atomic.Bool
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: server.Addr().(*net.UDPAddr),
|
||||
DropPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) bool { return drop.Load() },
|
||||
}
|
||||
@@ -121,7 +121,7 @@ func TestIdleTimeout(t *testing.T) {
|
||||
|
||||
conn, err := quic.Dial(
|
||||
context.Background(),
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
proxy.LocalAddr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{DisablePathMTUDiscovery: true, MaxIdleTimeout: idleTimeout}),
|
||||
@@ -170,7 +170,7 @@ func TestKeepAlive(t *testing.T) {
|
||||
}
|
||||
|
||||
server, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{DisablePathMTUDiscovery: true}),
|
||||
)
|
||||
@@ -179,7 +179,7 @@ func TestKeepAlive(t *testing.T) {
|
||||
|
||||
var drop atomic.Bool
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: server.Addr().(*net.UDPAddr),
|
||||
DropPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) bool { return drop.Load() },
|
||||
}
|
||||
@@ -190,7 +190,7 @@ func TestKeepAlive(t *testing.T) {
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
proxy.LocalAddr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
@@ -239,7 +239,7 @@ func TestTimeoutAfterInactivity(t *testing.T) {
|
||||
}
|
||||
|
||||
server, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{DisablePathMTUDiscovery: true}),
|
||||
)
|
||||
@@ -251,7 +251,7 @@ func TestTimeoutAfterInactivity(t *testing.T) {
|
||||
counter, tr := newPacketTracer()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
server.Addr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{
|
||||
@@ -312,7 +312,7 @@ func TestTimeoutAfterSendingPacket(t *testing.T) {
|
||||
}
|
||||
|
||||
server, err := quic.Listen(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
getTLSConfig(),
|
||||
getQuicConfig(&quic.Config{DisablePathMTUDiscovery: true}),
|
||||
)
|
||||
@@ -321,7 +321,7 @@ func TestTimeoutAfterSendingPacket(t *testing.T) {
|
||||
|
||||
var drop atomic.Bool
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: server.Addr().(*net.UDPAddr),
|
||||
DropPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) bool { return drop.Load() },
|
||||
}
|
||||
@@ -332,7 +332,7 @@ func TestTimeoutAfterSendingPacket(t *testing.T) {
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
proxy.LocalAddr(),
|
||||
getTLSClientConfig(),
|
||||
getQuicConfig(&quic.Config{MaxIdleTimeout: idleTimeout, DisablePathMTUDiscovery: true}),
|
||||
@@ -435,8 +435,8 @@ func testFaultyPacketConn(t *testing.T, pers protocol.Perspective) {
|
||||
return conn.CloseWithError(0, "done")
|
||||
}
|
||||
|
||||
var cconn net.PacketConn = newUPDConnLocalhost(t)
|
||||
var sconn net.PacketConn = newUPDConnLocalhost(t)
|
||||
var cconn net.PacketConn = newUDPConnLocalhost(t)
|
||||
var sconn net.PacketConn = newUDPConnLocalhost(t)
|
||||
maxPackets := mrand.Int31n(25)
|
||||
t.Logf("blocking %s's connection after %d packets", pers, maxPackets)
|
||||
switch pers {
|
||||
|
||||
@@ -70,7 +70,7 @@ func TestTracerHandshake(t *testing.T) {
|
||||
quicClientConf := addTracers(protocol.PerspectiveClient, getQuicConfig(nil))
|
||||
quicServerConf := addTracers(protocol.PerspectiveServer, getQuicConfig(nil))
|
||||
|
||||
ln, err := quic.Listen(newUPDConnLocalhost(t), getTLSConfig(), quicServerConf)
|
||||
ln, err := quic.Listen(newUDPConnLocalhost(t), getTLSConfig(), quicServerConf)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { require.NoError(t, ln.Close()) })
|
||||
|
||||
@@ -81,7 +81,7 @@ func TestTracerHandshake(t *testing.T) {
|
||||
defer wg.Done()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), ln.Addr(), getTLSClientConfig(), quicClientConf)
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), ln.Addr(), getTLSClientConfig(), quicClientConf)
|
||||
require.NoError(t, err)
|
||||
defer conn.CloseWithError(0, "")
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ func runCountingProxyAndCount0RTTPackets(t *testing.T, serverPort int, rtt time.
|
||||
t.Helper()
|
||||
var num0RTTPackets atomic.Uint32
|
||||
proxy := &quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: serverPort},
|
||||
DelayPacket: func(_ quicproxy.Direction, _, _ net.Addr, data []byte) time.Duration {
|
||||
if contains0RTTPacket(data) {
|
||||
@@ -48,12 +48,12 @@ func dialAndReceiveTicket(
|
||||
) (clientTLSConf *tls.Config) {
|
||||
t.Helper()
|
||||
|
||||
ln, err := quic.ListenEarly(newUPDConnLocalhost(t), serverTLSConf, serverConf)
|
||||
ln, err := quic.ListenEarly(newUDPConnLocalhost(t), serverTLSConf, serverConf)
|
||||
require.NoError(t, err)
|
||||
defer ln.Close()
|
||||
|
||||
proxy := &quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration { return rtt / 2 },
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func dialAndReceiveTicket(
|
||||
clientTLSConf.ClientSessionCache = newClientSessionCache(cache, nil, puts)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), proxy.LocalAddr(), clientTLSConf, getQuicConfig(nil))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), proxy.LocalAddr(), clientTLSConf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
require.False(t, conn.ConnectionState().Used0RTT)
|
||||
|
||||
@@ -102,7 +102,7 @@ func transfer0RTTData(
|
||||
t.Helper()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.DialEarly(ctx, newUPDConnLocalhost(t), proxyAddr, clientTLSConf, clientConf)
|
||||
conn, err := quic.DialEarly(ctx, newUDPConnLocalhost(t), proxyAddr, clientTLSConf, clientConf)
|
||||
require.NoError(t, err)
|
||||
|
||||
errChan := make(chan error, 1)
|
||||
@@ -173,7 +173,7 @@ func Test0RTTTransfer(t *testing.T) {
|
||||
|
||||
counter, tracer := newPacketTracer()
|
||||
ln, err := quic.ListenEarly(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{Allow0RTT: true, Tracer: newTracer(tracer)}),
|
||||
)
|
||||
@@ -200,7 +200,7 @@ func Test0RTTDisabledOnDial(t *testing.T) {
|
||||
|
||||
counter, tracer := newPacketTracer()
|
||||
ln, err := quic.ListenEarly(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{Allow0RTT: true, Tracer: newTracer(tracer)}),
|
||||
)
|
||||
@@ -212,7 +212,7 @@ func Test0RTTDisabledOnDial(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.Dial(ctx, newUPDConnLocalhost(t), proxy.LocalAddr(), clientTLSConf, getQuicConfig(nil))
|
||||
conn, err := quic.Dial(ctx, newUDPConnLocalhost(t), proxy.LocalAddr(), clientTLSConf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
// session Resumption is enabled at the TLS layer, but not 0-RTT at the QUIC layer
|
||||
require.True(t, conn.ConnectionState().TLS.DidResume)
|
||||
@@ -233,7 +233,7 @@ func Test0RTTWaitForHandshakeCompletion(t *testing.T) {
|
||||
|
||||
counter, tracer := newPacketTracer()
|
||||
ln, err := quic.ListenEarly(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{
|
||||
Allow0RTT: true,
|
||||
@@ -285,7 +285,7 @@ func Test0RTTWaitForHandshakeCompletion(t *testing.T) {
|
||||
defer cancel()
|
||||
conn, err := quic.DialEarly(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
proxy.LocalAddr(),
|
||||
clientTLSConf,
|
||||
getQuicConfig(nil),
|
||||
@@ -355,7 +355,7 @@ func Test0RTTDataLoss(t *testing.T) {
|
||||
|
||||
counter, tracer := newPacketTracer()
|
||||
ln, err := quic.ListenEarly(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{Allow0RTT: true, Tracer: newTracer(tracer)}),
|
||||
)
|
||||
@@ -364,7 +364,7 @@ func Test0RTTDataLoss(t *testing.T) {
|
||||
|
||||
var num0RTTPackets, numDropped atomic.Uint32
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(quicproxy.Direction, net.Addr, net.Addr, []byte) time.Duration { return rtt / 2 },
|
||||
DropPacket: func(_ quicproxy.Direction, _, _ net.Addr, data []byte) bool {
|
||||
@@ -418,7 +418,7 @@ func Test0RTTRetransmitOnRetry(t *testing.T) {
|
||||
|
||||
counter, tracer := newPacketTracer()
|
||||
tr := &quic.Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
VerifySourceAddress: func(net.Addr) bool { return true },
|
||||
}
|
||||
addTracer(tr)
|
||||
@@ -434,7 +434,7 @@ func Test0RTTRetransmitOnRetry(t *testing.T) {
|
||||
var mutex sync.Mutex
|
||||
var connIDToCounter []*connIDCounter
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(dir quicproxy.Direction, _, _ net.Addr, data []byte) time.Duration {
|
||||
connID, err := wire.ParseConnectionID(data, 0)
|
||||
@@ -483,7 +483,7 @@ func Test0RTTWithIncreasedStreamLimit(t *testing.T) {
|
||||
clientConf := dialAndReceiveTicket(t, rtt, tlsConf, getQuicConfig(&quic.Config{Allow0RTT: true, MaxIncomingUniStreams: maxStreams}), nil)
|
||||
|
||||
ln, err := quic.ListenEarly(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{Allow0RTT: true, MaxIncomingUniStreams: maxStreams + 1}),
|
||||
)
|
||||
@@ -496,7 +496,7 @@ func Test0RTTWithIncreasedStreamLimit(t *testing.T) {
|
||||
defer cancel()
|
||||
conn, err := quic.DialEarly(
|
||||
ctx,
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
proxy.LocalAddr(),
|
||||
clientConf,
|
||||
getQuicConfig(nil),
|
||||
@@ -535,7 +535,7 @@ func check0RTTRejected(t *testing.T,
|
||||
) (clientConn, serverConn quic.Connection) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.DialEarly(ctx, newUPDConnLocalhost(t), addr, conf, getQuicConfig(nil))
|
||||
conn, err := quic.DialEarly(ctx, newUDPConnLocalhost(t), addr, conf, getQuicConfig(nil))
|
||||
require.NoError(t, err)
|
||||
require.False(t, conn.ConnectionState().TLS.HandshakeComplete)
|
||||
if sendData {
|
||||
@@ -597,7 +597,7 @@ func Test0RTTRejectedOnStreamLimitDecrease(t *testing.T) {
|
||||
|
||||
counter, tracer := newPacketTracer()
|
||||
ln, err := quic.ListenEarly(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{
|
||||
Allow0RTT: true,
|
||||
@@ -661,7 +661,7 @@ func Test0RTTRejectedOnConnectionWindowDecrease(t *testing.T) {
|
||||
)
|
||||
|
||||
ln, err := quic.ListenEarly(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{
|
||||
Allow0RTT: true,
|
||||
@@ -708,7 +708,7 @@ func Test0RTTRejectedOnALPNChanged(t *testing.T) {
|
||||
clientConf.NextProtos = append(clientConf.NextProtos, "new-alpn")
|
||||
counter, tracer := newPacketTracer()
|
||||
ln, err := quic.ListenEarly(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{
|
||||
Allow0RTT: true,
|
||||
@@ -740,7 +740,7 @@ func Test0RTTRejectedWhenDisabled(t *testing.T) {
|
||||
|
||||
counter, tracer := newPacketTracer()
|
||||
ln, err := quic.ListenEarly(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{
|
||||
Allow0RTT: false,
|
||||
@@ -769,7 +769,7 @@ func Test0RTTRejectedOnDatagramsDisabled(t *testing.T) {
|
||||
|
||||
counter, tracer := newPacketTracer()
|
||||
ln, err := quic.ListenEarly(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{
|
||||
Allow0RTT: true,
|
||||
@@ -852,7 +852,7 @@ func Test0RTTWithSessionTicketData(t *testing.T) {
|
||||
}
|
||||
clientConf := dialAndReceiveTicket(t, 0, tlsConf, getQuicConfig(&quic.Config{Allow0RTT: true}), nil)
|
||||
|
||||
ln, err := quic.ListenEarly(newUPDConnLocalhost(t), tlsConf, getQuicConfig(&quic.Config{Allow0RTT: true}))
|
||||
ln, err := quic.ListenEarly(newUDPConnLocalhost(t), tlsConf, getQuicConfig(&quic.Config{Allow0RTT: true}))
|
||||
require.NoError(t, err)
|
||||
defer ln.Close()
|
||||
|
||||
@@ -881,7 +881,7 @@ func Test0RTTWithSessionTicketData(t *testing.T) {
|
||||
},
|
||||
)
|
||||
|
||||
ln, err := quic.ListenEarly(newUPDConnLocalhost(t), tlsConf, getQuicConfig(&quic.Config{Allow0RTT: true}))
|
||||
ln, err := quic.ListenEarly(newUDPConnLocalhost(t), tlsConf, getQuicConfig(&quic.Config{Allow0RTT: true}))
|
||||
require.NoError(t, err)
|
||||
defer ln.Close()
|
||||
|
||||
@@ -902,7 +902,7 @@ func Test0RTTPacketQueueing(t *testing.T) {
|
||||
|
||||
counter, tracer := newPacketTracer()
|
||||
ln, err := quic.ListenEarly(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{Allow0RTT: true, Tracer: newTracer(tracer)}),
|
||||
)
|
||||
@@ -910,7 +910,7 @@ func Test0RTTPacketQueueing(t *testing.T) {
|
||||
defer ln.Close()
|
||||
|
||||
proxy := quicproxy.Proxy{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ServerAddr: ln.Addr().(*net.UDPAddr),
|
||||
DelayPacket: func(dir quicproxy.Direction, _, _ net.Addr, data []byte) time.Duration {
|
||||
// delay the client's Initial by 1 RTT
|
||||
@@ -956,7 +956,7 @@ func Test0RTTDatagrams(t *testing.T) {
|
||||
|
||||
counter, tracer := newPacketTracer()
|
||||
ln, err := quic.ListenEarly(
|
||||
newUPDConnLocalhost(t),
|
||||
newUDPConnLocalhost(t),
|
||||
tlsConf,
|
||||
getQuicConfig(&quic.Config{
|
||||
Allow0RTT: true,
|
||||
@@ -971,7 +971,7 @@ func Test0RTTDatagrams(t *testing.T) {
|
||||
msg := GeneratePRData(100)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
conn, err := quic.DialEarly(ctx, newUPDConnLocalhost(t), proxy.LocalAddr(), clientTLSConf, getQuicConfig(&quic.Config{EnableDatagrams: true}))
|
||||
conn, err := quic.DialEarly(ctx, newUDPConnLocalhost(t), proxy.LocalAddr(), clientTLSConf, getQuicConfig(&quic.Config{EnableDatagrams: true}))
|
||||
require.NoError(t, err)
|
||||
defer conn.CloseWithError(0, "")
|
||||
require.True(t, conn.ConnectionState().SupportsDatagrams)
|
||||
|
||||
@@ -48,7 +48,7 @@ func scaleDuration(t time.Duration) time.Duration {
|
||||
return time.Duration(scaleFactor) * t
|
||||
}
|
||||
|
||||
func newUPDConnLocalhost(t testing.TB) *net.UDPConn {
|
||||
func newUDPConnLocalhost(t testing.TB) *net.UDPConn {
|
||||
t.Helper()
|
||||
conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -101,11 +101,11 @@ func TestSendConnSendmsgFailures(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendConnRemoteAddrChange(t *testing.T) {
|
||||
ln1 := newUPDConnLocalhost(t)
|
||||
ln2 := newUPDConnLocalhost(t)
|
||||
ln1 := newUDPConnLocalhost(t)
|
||||
ln2 := newUDPConnLocalhost(t)
|
||||
|
||||
c := newSendConn(
|
||||
&basicConn{PacketConn: newUPDConnLocalhost(t)},
|
||||
&basicConn{PacketConn: newUDPConnLocalhost(t)},
|
||||
ln1.LocalAddr(),
|
||||
packetInfo{},
|
||||
utils.DefaultLogger,
|
||||
|
||||
@@ -297,7 +297,7 @@ func (c *mockBatchConn) ReadBatch(ms []ipv4.Message, _ int) (int, error) {
|
||||
func TestReadsMultipleMessagesInOneBatch(t *testing.T) {
|
||||
bc := &mockBatchConn{t: t, numMsgRead: batchSize/2 + 1}
|
||||
|
||||
udpConn := newUPDConnLocalhost(t)
|
||||
udpConn := newUDPConnLocalhost(t)
|
||||
oobConn, err := newConn(udpConn, true)
|
||||
require.NoError(t, err)
|
||||
oobConn.batchConn = bc
|
||||
|
||||
@@ -74,7 +74,7 @@ func TestTransportPacketHandling(t *testing.T) {
|
||||
phm := NewMockPacketHandlerManager(mockCtrl)
|
||||
|
||||
tr := &Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
handlerMap: phm,
|
||||
}
|
||||
tr.init(true)
|
||||
@@ -93,7 +93,7 @@ func TestTransportPacketHandling(t *testing.T) {
|
||||
conn2 := &mockPacketHandler{packets: connChan2}
|
||||
phm.EXPECT().Get(connID2).Return(conn2, true)
|
||||
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
_, err := conn.WriteTo(getPacket(t, connID1), tr.Conn.LocalAddr())
|
||||
require.NoError(t, err)
|
||||
_, err = conn.WriteTo(getPacket(t, connID2), tr.Conn.LocalAddr())
|
||||
@@ -120,7 +120,7 @@ func TestTransportPacketHandling(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTransportAndListenerConcurrentClose(t *testing.T) {
|
||||
tr := &Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr := &Transport{Conn: newUDPConnLocalhost(t)}
|
||||
ln, err := tr.Listen(&tls.Config{}, nil)
|
||||
require.NoError(t, err)
|
||||
// close transport and listener concurrently
|
||||
@@ -136,9 +136,9 @@ func TestTransportAndListenerConcurrentClose(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTransportAndDialConcurrentClose(t *testing.T) {
|
||||
server := newUPDConnLocalhost(t)
|
||||
server := newUDPConnLocalhost(t)
|
||||
|
||||
tr := &Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr := &Transport{Conn: newUDPConnLocalhost(t)}
|
||||
// close transport and dial concurrently
|
||||
errChan := make(chan error, 1)
|
||||
go func() { errChan <- tr.Close() }()
|
||||
@@ -193,7 +193,7 @@ func TestTransportStatelessResetReceiving(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
phm := NewMockPacketHandlerManager(mockCtrl)
|
||||
tr := &Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ConnectionIDLength: 4,
|
||||
handlerMap: phm,
|
||||
}
|
||||
@@ -217,7 +217,7 @@ func TestTransportStatelessResetReceiving(t *testing.T) {
|
||||
phm.EXPECT().GetByResetToken(token).Return(conn1, true),
|
||||
)
|
||||
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
_, err = conn.WriteTo(b, tr.Conn.LocalAddr())
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -234,7 +234,7 @@ func TestTransportStatelessResetSending(t *testing.T) {
|
||||
phm := NewMockPacketHandlerManager(mockCtrl)
|
||||
tracer, mockTracer := mocklogging.NewMockTracer(mockCtrl)
|
||||
tr := &Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ConnectionIDLength: 4,
|
||||
StatelessResetKey: &StatelessResetKey{1, 2, 3, 4},
|
||||
handlerMap: phm,
|
||||
@@ -255,7 +255,7 @@ func TestTransportStatelessResetSending(t *testing.T) {
|
||||
b, err := wire.AppendShortHeader(nil, connID, 1337, 2, protocol.KeyPhaseOne)
|
||||
require.NoError(t, err)
|
||||
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
|
||||
// no stateless reset sent for packets smaller than MinStatelessResetSize
|
||||
dropped := make(chan struct{})
|
||||
@@ -290,7 +290,7 @@ func TestTransportDropsUnparseableQUICPackets(t *testing.T) {
|
||||
mockCtrl := gomock.NewController(t)
|
||||
tracer, mockTracer := mocklogging.NewMockTracer(mockCtrl)
|
||||
tr := &Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ConnectionIDLength: 10,
|
||||
Tracer: tracer,
|
||||
}
|
||||
@@ -300,7 +300,7 @@ func TestTransportDropsUnparseableQUICPackets(t *testing.T) {
|
||||
tr.Close()
|
||||
}()
|
||||
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
|
||||
dropped := make(chan struct{})
|
||||
mockTracer.EXPECT().DroppedPacket(conn.LocalAddr(), logging.PacketTypeNotDetermined, protocol.ByteCount(4), logging.PacketDropHeaderParseError).Do(
|
||||
@@ -318,7 +318,7 @@ func TestTransportDropsUnparseableQUICPackets(t *testing.T) {
|
||||
func TestTransportListening(t *testing.T) {
|
||||
tracer, mockTracer := mocklogging.NewMockTracer(gomock.NewController(t))
|
||||
tr := &Transport{
|
||||
Conn: newUPDConnLocalhost(t),
|
||||
Conn: newUDPConnLocalhost(t),
|
||||
ConnectionIDLength: 5,
|
||||
Tracer: tracer,
|
||||
}
|
||||
@@ -328,7 +328,7 @@ func TestTransportListening(t *testing.T) {
|
||||
tr.Close()
|
||||
}()
|
||||
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
data := wire.ComposeVersionNegotiation([]byte{1, 2, 3, 4, 5}, []byte{6, 7, 8, 9, 10}, []protocol.Version{protocol.Version1})
|
||||
dropped := make(chan struct{}, 10)
|
||||
mockTracer.EXPECT().DroppedPacket(conn.LocalAddr(), logging.PacketTypeNotDetermined, protocol.ByteCount(len(data)), logging.PacketDropUnknownConnectionID).Do(
|
||||
@@ -379,7 +379,7 @@ func TestTransportListening(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTransportNonQUICPackets(t *testing.T) {
|
||||
tr := &Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr := &Transport{Conn: newUDPConnLocalhost(t)}
|
||||
defer tr.Close()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), scaleDuration(5*time.Millisecond))
|
||||
@@ -388,7 +388,7 @@ func TestTransportNonQUICPackets(t *testing.T) {
|
||||
require.Error(t, err)
|
||||
require.ErrorIs(t, err, context.DeadlineExceeded)
|
||||
|
||||
conn := newUPDConnLocalhost(t)
|
||||
conn := newUDPConnLocalhost(t)
|
||||
data := []byte{0 /* don't set the QUIC bit */, 1, 2, 3}
|
||||
_, err = conn.WriteTo(data, tr.Conn.LocalAddr())
|
||||
require.NoError(t, err)
|
||||
@@ -430,7 +430,7 @@ type faultySyscallConn struct{ net.PacketConn }
|
||||
func (c *faultySyscallConn) SyscallConn() (syscall.RawConn, error) { return nil, errors.New("mocked") }
|
||||
|
||||
func TestTransportFaultySyscallConn(t *testing.T) {
|
||||
syscallconn := &faultySyscallConn{PacketConn: newUPDConnLocalhost(t)}
|
||||
syscallconn := &faultySyscallConn{PacketConn: newUDPConnLocalhost(t)}
|
||||
|
||||
tr := &Transport{Conn: syscallconn}
|
||||
_, err := tr.Listen(&tls.Config{}, nil)
|
||||
@@ -527,7 +527,7 @@ func testTransportDial(t *testing.T, early bool) {
|
||||
return conn
|
||||
}
|
||||
|
||||
tr := &Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr := &Transport{Conn: newUDPConnLocalhost(t)}
|
||||
tr.init(true)
|
||||
defer tr.Close()
|
||||
|
||||
@@ -607,7 +607,7 @@ func TestTransportDialingVersionNegotiation(t *testing.T) {
|
||||
return conn2
|
||||
}
|
||||
|
||||
tr := &Transport{Conn: newUPDConnLocalhost(t)}
|
||||
tr := &Transport{Conn: newUDPConnLocalhost(t)}
|
||||
tr.init(true)
|
||||
defer tr.Close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user