Skip to content

Commit

Permalink
rename the connection to rawConn
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Mar 27, 2022
1 parent 3126062 commit d7ad1b6
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
11 changes: 10 additions & 1 deletion packet_handler_map.go
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"hash"
"io"
"log"
"net"
"os"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions send_conn.go
Expand Up @@ -13,7 +13,7 @@ type sendConn interface {
}

type sconn struct {
connection
rawConn

remoteAddr net.Addr
info *packetInfo
Expand All @@ -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(),
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server.go
Expand Up @@ -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
Expand Down
13 changes: 2 additions & 11 deletions sys_conn.go
@@ -1,7 +1,6 @@
package quic

import (
"io"
"net"
"syscall"
"time"
Expand All @@ -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.
Expand All @@ -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)
})
Expand Down Expand Up @@ -61,7 +52,7 @@ type basicConn struct {
net.PacketConn
}

var _ connection = &basicConn{}
var _ rawConn = &basicConn{}

func (c *basicConn) ReadPacket() (*receivedPacket, error) {
buffer := getPacketBuffer()
Expand Down
2 changes: 1 addition & 1 deletion sys_conn_no_oob.go
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion sys_conn_oob.go
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion sys_conn_windows.go
Expand Up @@ -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
}

Expand Down

0 comments on commit d7ad1b6

Please sign in to comment.