remove unneeded version parameter from proxy constructor

This commit is contained in:
Marten Seemann 2019-01-05 11:04:39 +07:00
parent 8ac77be934
commit 2367ab35bb
6 changed files with 10 additions and 13 deletions

View file

@ -38,7 +38,7 @@ var _ = Describe("Drop Tests", func() {
)
Expect(err).ToNot(HaveOccurred())
serverPort := ln.Addr().(*net.UDPAddr).Port
proxy, err = quicproxy.NewQuicProxy("localhost:0", version, &quicproxy.Opts{
proxy, err = quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
RemoteAddr: fmt.Sprintf("localhost:%d", serverPort),
DelayPacket: func(dir quicproxy.Direction, packetCount uint64) time.Duration {
return 5 * time.Millisecond // 10ms RTT

View file

@ -41,7 +41,7 @@ var _ = Describe("Handshake drop tests", func() {
)
Expect(err).ToNot(HaveOccurred())
serverPort := ln.Addr().(*net.UDPAddr).Port
proxy, err = quicproxy.NewQuicProxy("localhost:0", version, &quicproxy.Opts{
proxy, err = quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
RemoteAddr: fmt.Sprintf("localhost:%d", serverPort),
DropPacket: dropCallback,
},

View file

@ -43,7 +43,7 @@ var _ = Describe("Handshake RTT tests", func() {
server, err = quic.ListenAddr("localhost:0", testdata.GetTLSConfig(), serverConfig)
Expect(err).ToNot(HaveOccurred())
// start the proxy
proxy, err = quicproxy.NewQuicProxy("localhost:0", protocol.VersionWhatever, &quicproxy.Opts{
proxy, err = quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
RemoteAddr: server.Addr().String(),
DelayPacket: func(_ quicproxy.Direction, _ uint64) time.Duration { return rtt / 2 },
})

View file

@ -54,7 +54,7 @@ var _ = Describe("non-zero RTT", func() {
close(done)
}()
serverPort := ln.Addr().(*net.UDPAddr).Port
proxy, err := quicproxy.NewQuicProxy("localhost:0", version, &quicproxy.Opts{
proxy, err := quicproxy.NewQuicProxy("localhost:0", &quicproxy.Opts{
RemoteAddr: fmt.Sprintf("localhost:%d", serverPort),
DelayPacket: func(d quicproxy.Direction, p uint64) time.Duration {
return rtt / 2

View file

@ -85,8 +85,6 @@ type Opts struct {
type QuicProxy struct {
mutex sync.Mutex
version protocol.VersionNumber
conn *net.UDPConn
serverAddr *net.UDPAddr
@ -100,7 +98,7 @@ type QuicProxy struct {
}
// NewQuicProxy creates a new UDP proxy
func NewQuicProxy(local string, version protocol.VersionNumber, opts *Opts) (*QuicProxy, error) {
func NewQuicProxy(local string, opts *Opts) (*QuicProxy, error) {
if opts == nil {
opts = &Opts{}
}
@ -133,7 +131,6 @@ func NewQuicProxy(local string, version protocol.VersionNumber, opts *Opts) (*Qu
serverAddr: raddr,
dropPacket: packetDropper,
delayPacket: packetDelayer,
version: version,
logger: utils.DefaultLogger.WithPrefix("proxy"),
}

View file

@ -38,7 +38,7 @@ var _ = Describe("QUIC Proxy", func() {
Context("Proxy setup and teardown", func() {
It("sets up the UDPProxy", func() {
proxy, err := NewQuicProxy("localhost:0", protocol.VersionWhatever, nil)
proxy, err := NewQuicProxy("localhost:0", nil)
Expect(err).ToNot(HaveOccurred())
Expect(proxy.clientDict).To(HaveLen(0))
@ -57,7 +57,7 @@ var _ = Describe("QUIC Proxy", func() {
return strings.Contains(b.String(), "proxy.(*QuicProxy).runProxy")
}
proxy, err := NewQuicProxy("localhost:0", protocol.VersionWhatever, nil)
proxy, err := NewQuicProxy("localhost:0", nil)
Expect(err).ToNot(HaveOccurred())
port := proxy.LocalPort()
Expect(isProxyRunning()).To(BeTrue())
@ -92,7 +92,7 @@ var _ = Describe("QUIC Proxy", func() {
Expect(err).ToNot(HaveOccurred())
defer serverConn.Close()
proxy, err := NewQuicProxy("localhost:0", protocol.VersionWhatever, &Opts{RemoteAddr: serverConn.LocalAddr().String()})
proxy, err := NewQuicProxy("localhost:0", &Opts{RemoteAddr: serverConn.LocalAddr().String()})
Expect(err).ToNot(HaveOccurred())
Expect(isConnRunning()).To(BeFalse())
@ -107,7 +107,7 @@ var _ = Describe("QUIC Proxy", func() {
})
It("has the correct LocalAddr and LocalPort", func() {
proxy, err := NewQuicProxy("localhost:0", protocol.VersionWhatever, nil)
proxy, err := NewQuicProxy("localhost:0", nil)
Expect(err).ToNot(HaveOccurred())
Expect(proxy.LocalAddr().String()).To(Equal("127.0.0.1:" + strconv.Itoa(proxy.LocalPort())))
@ -128,7 +128,7 @@ var _ = Describe("QUIC Proxy", func() {
startProxy := func(opts *Opts) {
var err error
proxy, err = NewQuicProxy("localhost:0", protocol.VersionWhatever, opts)
proxy, err = NewQuicProxy("localhost:0", opts)
Expect(err).ToNot(HaveOccurred())
clientConn, err = net.DialUDP("udp", nil, proxy.LocalAddr().(*net.UDPAddr))
Expect(err).ToNot(HaveOccurred())