From d7ad1b6b9b5e54daf0dd22b90dd2eeaa017d1b5c Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 27 Mar 2022 10:13:02 +0100 Subject: [PATCH] rename the connection to rawConn --- packet_handler_map.go | 11 ++++++++++- send_conn.go | 8 ++++---- server.go | 2 +- sys_conn.go | 13 ++----------- sys_conn_no_oob.go | 2 +- sys_conn_oob.go | 2 +- sys_conn_windows.go | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/packet_handler_map.go b/packet_handler_map.go index 7feadff75b8..3156016ce8f 100644 --- a/packet_handler_map.go +++ b/packet_handler_map.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "hash" + "io" "log" "net" "os" @@ -48,6 +49,14 @@ func (h *zeroRTTQueue) Clear() { } } +// rawConn is a connection that allow reading of a receivedPacket. +type rawConn interface { + ReadPacket() (*receivedPacket, error) + WritePacket(b []byte, addr net.Addr, oob []byte) (int, error) + LocalAddr() net.Addr + io.Closer +} + type packetHandlerMapEntry struct { packetHandler packetHandler is0RTTQueue bool @@ -60,7 +69,7 @@ type packetHandlerMapEntry struct { type packetHandlerMap struct { mutex sync.Mutex - conn connection + conn rawConn connIDLen int handlers map[string] /* string(ConnectionID)*/ packetHandlerMapEntry diff --git a/send_conn.go b/send_conn.go index b276af11388..c53ebdfab1c 100644 --- a/send_conn.go +++ b/send_conn.go @@ -13,7 +13,7 @@ type sendConn interface { } type sconn struct { - connection + rawConn remoteAddr net.Addr info *packetInfo @@ -22,9 +22,9 @@ type sconn struct { var _ sendConn = &sconn{} -func newSendConn(c connection, remote net.Addr, info *packetInfo) sendConn { +func newSendConn(c rawConn, remote net.Addr, info *packetInfo) sendConn { return &sconn{ - connection: c, + rawConn: c, remoteAddr: remote, info: info, oob: info.OOB(), @@ -41,7 +41,7 @@ func (c *sconn) RemoteAddr() net.Addr { } func (c *sconn) LocalAddr() net.Addr { - addr := c.connection.LocalAddr() + addr := c.rawConn.LocalAddr() if c.info != nil { if udpAddr, ok := addr.(*net.UDPAddr); ok { addrCopy := *udpAddr diff --git a/server.go b/server.go index 429fbd27acd..fa70bf23242 100644 --- a/server.go +++ b/server.go @@ -61,7 +61,7 @@ type baseServer struct { tlsConf *tls.Config config *Config - conn connection + conn rawConn // If the server is started with ListenAddr, we create a packet conn. // If it is started with Listen, we take a packet conn as a parameter. createdPacketConn bool diff --git a/sys_conn.go b/sys_conn.go index 4b38b0634d4..d73b01d2341 100644 --- a/sys_conn.go +++ b/sys_conn.go @@ -1,7 +1,6 @@ package quic import ( - "io" "net" "syscall" "time" @@ -10,14 +9,6 @@ import ( "github.com/lucas-clemente/quic-go/internal/utils" ) -// connection is a connection that allow reading of a receivedPacket. -type connection interface { - ReadPacket() (*receivedPacket, error) - WritePacket(b []byte, addr net.Addr, oob []byte) (int, error) - LocalAddr() net.Addr - io.Closer -} - // OOBCapablePacketConn is a connection that allows the reading of ECN bits from the IP header. // If the PacketConn passed to Dial or Listen satisfies this interface, quic-go will use it. // In this case, ReadMsgUDP() will be used instead of ReadFrom() to read packets. @@ -30,7 +21,7 @@ type OOBCapablePacketConn interface { var _ OOBCapablePacketConn = &net.UDPConn{} -func wrapConn(pc net.PacketConn) (connection, error) { +func wrapConn(pc net.PacketConn) (rawConn, error) { conn, ok := pc.(interface { SyscallConn() (syscall.RawConn, error) }) @@ -61,7 +52,7 @@ type basicConn struct { net.PacketConn } -var _ connection = &basicConn{} +var _ rawConn = &basicConn{} func (c *basicConn) ReadPacket() (*receivedPacket, error) { buffer := getPacketBuffer() diff --git a/sys_conn_no_oob.go b/sys_conn_no_oob.go index a2a125c08e6..e3b0d11f685 100644 --- a/sys_conn_no_oob.go +++ b/sys_conn_no_oob.go @@ -5,7 +5,7 @@ package quic import "net" -func newConn(c net.PacketConn) (connection, error) { +func newConn(c net.PacketConn) (rawConn, error) { return &basicConn{PacketConn: c}, nil } diff --git a/sys_conn_oob.go b/sys_conn_oob.go index b46781377d2..acd74d023c1 100644 --- a/sys_conn_oob.go +++ b/sys_conn_oob.go @@ -64,7 +64,7 @@ type oobConn struct { buffers [batchSize]*packetBuffer } -var _ connection = &oobConn{} +var _ rawConn = &oobConn{} func newConn(c OOBCapablePacketConn) (*oobConn, error) { rawConn, err := c.SyscallConn() diff --git a/sys_conn_windows.go b/sys_conn_windows.go index 4869d67aaa2..f2cc22ab7c4 100644 --- a/sys_conn_windows.go +++ b/sys_conn_windows.go @@ -12,7 +12,7 @@ import ( "golang.org/x/sys/windows" ) -func newConn(c OOBCapablePacketConn) (connection, error) { +func newConn(c OOBCapablePacketConn) (rawConn, error) { return &basicConn{PacketConn: c}, nil }