remove unused getPerspective function from quicConn interface (#4329)

This commit is contained in:
Marten Seemann 2024-02-11 10:05:27 +07:00 committed by GitHub
parent 69fe37885f
commit 7b8ceaa264
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 10 additions and 113 deletions

View file

@ -4,7 +4,6 @@ import (
"math/bits"
"net"
"github.com/quic-go/quic-go/internal/protocol"
"github.com/quic-go/quic-go/internal/utils"
)
@ -13,7 +12,6 @@ import (
// with an exponential backoff.
type closedLocalConn struct {
counter uint32
perspective protocol.Perspective
logger utils.Logger
sendPacket func(net.Addr, packetInfo)
@ -22,10 +20,9 @@ type closedLocalConn struct {
var _ packetHandler = &closedLocalConn{}
// newClosedLocalConn creates a new closedLocalConn and runs it.
func newClosedLocalConn(sendPacket func(net.Addr, packetInfo), pers protocol.Perspective, logger utils.Logger) packetHandler {
func newClosedLocalConn(sendPacket func(net.Addr, packetInfo), logger utils.Logger) packetHandler {
return &closedLocalConn{
sendPacket: sendPacket,
perspective: pers,
logger: logger,
}
}
@ -43,22 +40,18 @@ func (c *closedLocalConn) handlePacket(p receivedPacket) {
func (c *closedLocalConn) destroy(error) {}
func (c *closedLocalConn) closeWithTransportError(TransportErrorCode) {}
func (c *closedLocalConn) getPerspective() protocol.Perspective { return c.perspective }
// A closedRemoteConn is a connection that was closed remotely.
// For such a connection, we might receive reordered packets that were sent before the CONNECTION_CLOSE.
// We can just ignore those packets.
type closedRemoteConn struct {
perspective protocol.Perspective
}
type closedRemoteConn struct{}
var _ packetHandler = &closedRemoteConn{}
func newClosedRemoteConn(pers protocol.Perspective) packetHandler {
return &closedRemoteConn{perspective: pers}
func newClosedRemoteConn() packetHandler {
return &closedRemoteConn{}
}
func (c *closedRemoteConn) handlePacket(receivedPacket) {}
func (c *closedRemoteConn) destroy(error) {}
func (c *closedRemoteConn) closeWithTransportError(TransportErrorCode) {}
func (c *closedRemoteConn) getPerspective() protocol.Perspective { return c.perspective }

View file

@ -3,7 +3,6 @@ package quic
import (
"net"
"github.com/quic-go/quic-go/internal/protocol"
"github.com/quic-go/quic-go/internal/utils"
. "github.com/onsi/ginkgo/v2"
@ -11,18 +10,9 @@ import (
)
var _ = Describe("Closed local connection", func() {
It("tells its perspective", func() {
conn := newClosedLocalConn(nil, protocol.PerspectiveClient, utils.DefaultLogger)
Expect(conn.getPerspective()).To(Equal(protocol.PerspectiveClient))
})
It("repeats the packet containing the CONNECTION_CLOSE frame", func() {
written := make(chan net.Addr, 1)
conn := newClosedLocalConn(
func(addr net.Addr, _ packetInfo) { written <- addr },
protocol.PerspectiveClient,
utils.DefaultLogger,
)
conn := newClosedLocalConn(func(addr net.Addr, _ packetInfo) { written <- addr }, utils.DefaultLogger)
addr := &net.UDPAddr{IP: net.IPv4(127, 1, 2, 3), Port: 1337}
for i := 1; i <= 20; i++ {
conn.handlePacket(receivedPacket{remoteAddr: addr})

View file

@ -2379,10 +2379,6 @@ func (s *connection) RemoteAddr() net.Addr {
return s.conn.RemoteAddr()
}
func (s *connection) getPerspective() protocol.Perspective {
return s.perspective
}
func (s *connection) GetVersion() protocol.Version {
return s.version
}

View file

@ -11,7 +11,6 @@ package quic
import (
reflect "reflect"
protocol "github.com/quic-go/quic-go/internal/protocol"
qerr "github.com/quic-go/quic-go/internal/qerr"
gomock "go.uber.org/mock/gomock"
)
@ -111,44 +110,6 @@ func (c *PacketHandlerdestroyCall) DoAndReturn(f func(error)) *PacketHandlerdest
return c
}
// getPerspective mocks base method.
func (m *MockPacketHandler) getPerspective() protocol.Perspective {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "getPerspective")
ret0, _ := ret[0].(protocol.Perspective)
return ret0
}
// getPerspective indicates an expected call of getPerspective.
func (mr *MockPacketHandlerMockRecorder) getPerspective() *PacketHandlergetPerspectiveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "getPerspective", reflect.TypeOf((*MockPacketHandler)(nil).getPerspective))
return &PacketHandlergetPerspectiveCall{Call: call}
}
// PacketHandlergetPerspectiveCall wrap *gomock.Call
type PacketHandlergetPerspectiveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *PacketHandlergetPerspectiveCall) Return(arg0 protocol.Perspective) *PacketHandlergetPerspectiveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *PacketHandlergetPerspectiveCall) Do(f func() protocol.Perspective) *PacketHandlergetPerspectiveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *PacketHandlergetPerspectiveCall) DoAndReturn(f func() protocol.Perspective) *PacketHandlergetPerspectiveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// handlePacket mocks base method.
func (m *MockPacketHandler) handlePacket(arg0 receivedPacket) {
m.ctrl.T.Helper()

View file

@ -13,7 +13,6 @@ import (
net "net"
reflect "reflect"
protocol "github.com/quic-go/quic-go/internal/protocol"
qerr "github.com/quic-go/quic-go/internal/qerr"
gomock "go.uber.org/mock/gomock"
)
@ -728,44 +727,6 @@ func (c *QUICConnearlyConnReadyCall) DoAndReturn(f func() <-chan struct{}) *QUIC
return c
}
// getPerspective mocks base method.
func (m *MockQUICConn) getPerspective() protocol.Perspective {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "getPerspective")
ret0, _ := ret[0].(protocol.Perspective)
return ret0
}
// getPerspective indicates an expected call of getPerspective.
func (mr *MockQUICConnMockRecorder) getPerspective() *QUICConngetPerspectiveCall {
mr.mock.ctrl.T.Helper()
call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "getPerspective", reflect.TypeOf((*MockQUICConn)(nil).getPerspective))
return &QUICConngetPerspectiveCall{Call: call}
}
// QUICConngetPerspectiveCall wrap *gomock.Call
type QUICConngetPerspectiveCall struct {
*gomock.Call
}
// Return rewrite *gomock.Call.Return
func (c *QUICConngetPerspectiveCall) Return(arg0 protocol.Perspective) *QUICConngetPerspectiveCall {
c.Call = c.Call.Return(arg0)
return c
}
// Do rewrite *gomock.Call.Do
func (c *QUICConngetPerspectiveCall) Do(f func() protocol.Perspective) *QUICConngetPerspectiveCall {
c.Call = c.Call.Do(f)
return c
}
// DoAndReturn rewrite *gomock.Call.DoAndReturn
func (c *QUICConngetPerspectiveCall) DoAndReturn(f func() protocol.Perspective) *QUICConngetPerspectiveCall {
c.Call = c.Call.DoAndReturn(f)
return c
}
// handlePacket mocks base method.
func (m *MockQUICConn) handlePacket(arg0 receivedPacket) {
m.ctrl.T.Helper()

View file

@ -171,11 +171,10 @@ func (h *packetHandlerMap) ReplaceWithClosed(ids []protocol.ConnectionID, pers p
func(addr net.Addr, info packetInfo) {
h.enqueueClosePacket(closePacket{payload: connClosePacket, addr: addr, info: info})
},
pers,
h.logger,
)
} else {
handler = newClosedRemoteConn(pers)
handler = newClosedRemoteConn()
}
h.mutex.Lock()

View file

@ -26,7 +26,6 @@ type packetHandler interface {
handlePacket(receivedPacket)
destroy(error)
closeWithTransportError(qerr.TransportErrorCode)
getPerspective() protocol.Perspective
}
type packetHandlerManager interface {
@ -41,7 +40,6 @@ type quicConn interface {
EarlyConnection
earlyConnReady() <-chan struct{}
handlePacket(receivedPacket)
getPerspective() protocol.Perspective
run() error
destroy(error)
closeWithTransportError(TransportErrorCode)

View file

@ -1364,7 +1364,6 @@ var _ = Describe("Server", func() {
Consistently(done).ShouldNot(BeClosed())
// make the go routine return
conn.EXPECT().getPerspective().MaxTimes(2) // initOnce for every conn ID
Expect(serv.Close()).To(Succeed())
Eventually(done).Should(BeClosed())
})