forked from quic-go/quic-go
pass the raw packet to the Drop- and Delay callbacks of the proxy
This commit is contained in:
@@ -39,7 +39,7 @@ var _ = Describe("Drop Tests", func() {
|
||||
serverPort := ln.Addr().(*net.UDPAddr).Port
|
||||
proxy, err = quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
|
||||
RemoteAddr: fmt.Sprintf("localhost:%d", serverPort),
|
||||
DelayPacket: func(dir quicproxy.Direction, packetCount uint64) time.Duration {
|
||||
DelayPacket: func(dir quicproxy.Direction, _ []byte) time.Duration {
|
||||
return 5 * time.Millisecond // 10ms RTT
|
||||
},
|
||||
DropPacket: dropCallback,
|
||||
@@ -75,7 +75,7 @@ var _ = Describe("Drop Tests", func() {
|
||||
startTime := time.Now()
|
||||
|
||||
var numDroppedPackets int32
|
||||
startListenerAndProxy(func(d quicproxy.Direction, p uint64) bool {
|
||||
startListenerAndProxy(func(d quicproxy.Direction, _ []byte) bool {
|
||||
if !d.Is(direction) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
mrand "math/rand"
|
||||
"net"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
quic "github.com/lucas-clemente/quic-go"
|
||||
@@ -161,21 +162,37 @@ var _ = Describe("Handshake drop tests", func() {
|
||||
|
||||
Context(app.name, func() {
|
||||
It(fmt.Sprintf("establishes a connection when the first packet is lost in %s direction", d), func() {
|
||||
startListenerAndProxy(func(d quicproxy.Direction, p uint64) bool {
|
||||
var incoming, outgoing int32
|
||||
startListenerAndProxy(func(d quicproxy.Direction, _ []byte) bool {
|
||||
var p int32
|
||||
switch d {
|
||||
case quicproxy.DirectionIncoming:
|
||||
p = atomic.AddInt32(&incoming, 1)
|
||||
case quicproxy.DirectionOutgoing:
|
||||
p = atomic.AddInt32(&outgoing, 1)
|
||||
}
|
||||
return p == 1 && d.Is(direction)
|
||||
}, version)
|
||||
app.run(version)
|
||||
})
|
||||
|
||||
It(fmt.Sprintf("establishes a connection when the second packet is lost in %s direction", d), func() {
|
||||
startListenerAndProxy(func(d quicproxy.Direction, p uint64) bool {
|
||||
var incoming, outgoing int32
|
||||
startListenerAndProxy(func(d quicproxy.Direction, _ []byte) bool {
|
||||
var p int32
|
||||
switch d {
|
||||
case quicproxy.DirectionIncoming:
|
||||
p = atomic.AddInt32(&incoming, 1)
|
||||
case quicproxy.DirectionOutgoing:
|
||||
p = atomic.AddInt32(&outgoing, 1)
|
||||
}
|
||||
return p == 2 && d.Is(direction)
|
||||
}, version)
|
||||
app.run(version)
|
||||
})
|
||||
|
||||
It(fmt.Sprintf("establishes a connection when 1/5 of the packets are lost in %s direction", d), func() {
|
||||
startListenerAndProxy(func(d quicproxy.Direction, p uint64) bool {
|
||||
startListenerAndProxy(func(d quicproxy.Direction, _ []byte) bool {
|
||||
return d.Is(direction) && stochasticDropper(5)
|
||||
}, version)
|
||||
app.run(version)
|
||||
|
||||
@@ -47,7 +47,7 @@ var _ = Describe("Handshake RTT tests", func() {
|
||||
// start the proxy
|
||||
proxy, err = quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
|
||||
RemoteAddr: server.Addr().String(),
|
||||
DelayPacket: func(_ quicproxy.Direction, _ uint64) time.Duration { return rtt / 2 },
|
||||
DelayPacket: func(_ quicproxy.Direction, _ []byte) time.Duration { return rtt / 2 },
|
||||
})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ var _ = Describe("non-zero RTT", func() {
|
||||
serverPort := ln.Addr().(*net.UDPAddr).Port
|
||||
proxy, err := quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
|
||||
RemoteAddr: fmt.Sprintf("localhost:%d", serverPort),
|
||||
DelayPacket: func(d quicproxy.Direction, p uint64) time.Duration {
|
||||
DelayPacket: func(quicproxy.Direction, []byte) time.Duration {
|
||||
return rtt / 2
|
||||
},
|
||||
})
|
||||
|
||||
@@ -48,7 +48,7 @@ var _ = Describe("Stateless Resets", func() {
|
||||
|
||||
proxy, err := quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
|
||||
RemoteAddr: fmt.Sprintf("localhost:%d", serverPort),
|
||||
DropPacket: func(d quicproxy.Direction, p uint64) bool {
|
||||
DropPacket: func(quicproxy.Direction, []byte) bool {
|
||||
return drop.Get()
|
||||
},
|
||||
})
|
||||
|
||||
@@ -82,7 +82,7 @@ var _ = Describe("Timeout tests", func() {
|
||||
|
||||
proxy, err := quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
|
||||
RemoteAddr: fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||
DropPacket: func(d quicproxy.Direction, p uint64) bool {
|
||||
DropPacket: func(quicproxy.Direction, []byte) bool {
|
||||
return drop.Get()
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user