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()) Expect(err).ToNot(HaveOccurred())
serverPort := ln.Addr().(*net.UDPAddr).Port 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), RemoteAddr: fmt.Sprintf("localhost:%d", serverPort),
DelayPacket: func(dir quicproxy.Direction, packetCount uint64) time.Duration { DelayPacket: func(dir quicproxy.Direction, packetCount uint64) time.Duration {
return 5 * time.Millisecond // 10ms RTT return 5 * time.Millisecond // 10ms RTT

View file

@ -41,7 +41,7 @@ var _ = Describe("Handshake drop tests", func() {
) )
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
serverPort := ln.Addr().(*net.UDPAddr).Port 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), RemoteAddr: fmt.Sprintf("localhost:%d", serverPort),
DropPacket: dropCallback, DropPacket: dropCallback,
}, },

View file

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

View file

@ -54,7 +54,7 @@ var _ = Describe("non-zero RTT", func() {
close(done) close(done)
}() }()
serverPort := ln.Addr().(*net.UDPAddr).Port 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), RemoteAddr: fmt.Sprintf("localhost:%d", serverPort),
DelayPacket: func(d quicproxy.Direction, p uint64) time.Duration { DelayPacket: func(d quicproxy.Direction, p uint64) time.Duration {
return rtt / 2 return rtt / 2

View file

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

View file

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