mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
remove unused getPerspective function from quicConn interface (#4329)
This commit is contained in:
parent
69fe37885f
commit
7b8ceaa264
8 changed files with 10 additions and 113 deletions
|
@ -4,7 +4,6 @@ import (
|
||||||
"math/bits"
|
"math/bits"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/quic-go/quic-go/internal/protocol"
|
|
||||||
"github.com/quic-go/quic-go/internal/utils"
|
"github.com/quic-go/quic-go/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -12,9 +11,8 @@ import (
|
||||||
// When receiving packets for such a connection, we need to retransmit the packet containing the CONNECTION_CLOSE frame,
|
// When receiving packets for such a connection, we need to retransmit the packet containing the CONNECTION_CLOSE frame,
|
||||||
// with an exponential backoff.
|
// with an exponential backoff.
|
||||||
type closedLocalConn struct {
|
type closedLocalConn struct {
|
||||||
counter uint32
|
counter uint32
|
||||||
perspective protocol.Perspective
|
logger utils.Logger
|
||||||
logger utils.Logger
|
|
||||||
|
|
||||||
sendPacket func(net.Addr, packetInfo)
|
sendPacket func(net.Addr, packetInfo)
|
||||||
}
|
}
|
||||||
|
@ -22,11 +20,10 @@ type closedLocalConn struct {
|
||||||
var _ packetHandler = &closedLocalConn{}
|
var _ packetHandler = &closedLocalConn{}
|
||||||
|
|
||||||
// newClosedLocalConn creates a new closedLocalConn and runs it.
|
// 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{
|
return &closedLocalConn{
|
||||||
sendPacket: sendPacket,
|
sendPacket: sendPacket,
|
||||||
perspective: pers,
|
logger: logger,
|
||||||
logger: logger,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,22 +40,18 @@ func (c *closedLocalConn) handlePacket(p receivedPacket) {
|
||||||
|
|
||||||
func (c *closedLocalConn) destroy(error) {}
|
func (c *closedLocalConn) destroy(error) {}
|
||||||
func (c *closedLocalConn) closeWithTransportError(TransportErrorCode) {}
|
func (c *closedLocalConn) closeWithTransportError(TransportErrorCode) {}
|
||||||
func (c *closedLocalConn) getPerspective() protocol.Perspective { return c.perspective }
|
|
||||||
|
|
||||||
// A closedRemoteConn is a connection that was closed remotely.
|
// 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.
|
// For such a connection, we might receive reordered packets that were sent before the CONNECTION_CLOSE.
|
||||||
// We can just ignore those packets.
|
// We can just ignore those packets.
|
||||||
type closedRemoteConn struct {
|
type closedRemoteConn struct{}
|
||||||
perspective protocol.Perspective
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ packetHandler = &closedRemoteConn{}
|
var _ packetHandler = &closedRemoteConn{}
|
||||||
|
|
||||||
func newClosedRemoteConn(pers protocol.Perspective) packetHandler {
|
func newClosedRemoteConn() packetHandler {
|
||||||
return &closedRemoteConn{perspective: pers}
|
return &closedRemoteConn{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *closedRemoteConn) handlePacket(receivedPacket) {}
|
func (c *closedRemoteConn) handlePacket(receivedPacket) {}
|
||||||
func (c *closedRemoteConn) destroy(error) {}
|
func (c *closedRemoteConn) destroy(error) {}
|
||||||
func (c *closedRemoteConn) closeWithTransportError(TransportErrorCode) {}
|
func (c *closedRemoteConn) closeWithTransportError(TransportErrorCode) {}
|
||||||
func (c *closedRemoteConn) getPerspective() protocol.Perspective { return c.perspective }
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package quic
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/quic-go/quic-go/internal/protocol"
|
|
||||||
"github.com/quic-go/quic-go/internal/utils"
|
"github.com/quic-go/quic-go/internal/utils"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
|
@ -11,18 +10,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Closed local connection", func() {
|
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() {
|
It("repeats the packet containing the CONNECTION_CLOSE frame", func() {
|
||||||
written := make(chan net.Addr, 1)
|
written := make(chan net.Addr, 1)
|
||||||
conn := newClosedLocalConn(
|
conn := newClosedLocalConn(func(addr net.Addr, _ packetInfo) { written <- addr }, utils.DefaultLogger)
|
||||||
func(addr net.Addr, _ packetInfo) { written <- addr },
|
|
||||||
protocol.PerspectiveClient,
|
|
||||||
utils.DefaultLogger,
|
|
||||||
)
|
|
||||||
addr := &net.UDPAddr{IP: net.IPv4(127, 1, 2, 3), Port: 1337}
|
addr := &net.UDPAddr{IP: net.IPv4(127, 1, 2, 3), Port: 1337}
|
||||||
for i := 1; i <= 20; i++ {
|
for i := 1; i <= 20; i++ {
|
||||||
conn.handlePacket(receivedPacket{remoteAddr: addr})
|
conn.handlePacket(receivedPacket{remoteAddr: addr})
|
||||||
|
|
|
@ -2379,10 +2379,6 @@ func (s *connection) RemoteAddr() net.Addr {
|
||||||
return s.conn.RemoteAddr()
|
return s.conn.RemoteAddr()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *connection) getPerspective() protocol.Perspective {
|
|
||||||
return s.perspective
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *connection) GetVersion() protocol.Version {
|
func (s *connection) GetVersion() protocol.Version {
|
||||||
return s.version
|
return s.version
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ package quic
|
||||||
import (
|
import (
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|
||||||
protocol "github.com/quic-go/quic-go/internal/protocol"
|
|
||||||
qerr "github.com/quic-go/quic-go/internal/qerr"
|
qerr "github.com/quic-go/quic-go/internal/qerr"
|
||||||
gomock "go.uber.org/mock/gomock"
|
gomock "go.uber.org/mock/gomock"
|
||||||
)
|
)
|
||||||
|
@ -111,44 +110,6 @@ func (c *PacketHandlerdestroyCall) DoAndReturn(f func(error)) *PacketHandlerdest
|
||||||
return c
|
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.
|
// handlePacket mocks base method.
|
||||||
func (m *MockPacketHandler) handlePacket(arg0 receivedPacket) {
|
func (m *MockPacketHandler) handlePacket(arg0 receivedPacket) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
net "net"
|
net "net"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|
||||||
protocol "github.com/quic-go/quic-go/internal/protocol"
|
|
||||||
qerr "github.com/quic-go/quic-go/internal/qerr"
|
qerr "github.com/quic-go/quic-go/internal/qerr"
|
||||||
gomock "go.uber.org/mock/gomock"
|
gomock "go.uber.org/mock/gomock"
|
||||||
)
|
)
|
||||||
|
@ -728,44 +727,6 @@ func (c *QUICConnearlyConnReadyCall) DoAndReturn(f func() <-chan struct{}) *QUIC
|
||||||
return c
|
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.
|
// handlePacket mocks base method.
|
||||||
func (m *MockQUICConn) handlePacket(arg0 receivedPacket) {
|
func (m *MockQUICConn) handlePacket(arg0 receivedPacket) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
|
|
@ -171,11 +171,10 @@ func (h *packetHandlerMap) ReplaceWithClosed(ids []protocol.ConnectionID, pers p
|
||||||
func(addr net.Addr, info packetInfo) {
|
func(addr net.Addr, info packetInfo) {
|
||||||
h.enqueueClosePacket(closePacket{payload: connClosePacket, addr: addr, info: info})
|
h.enqueueClosePacket(closePacket{payload: connClosePacket, addr: addr, info: info})
|
||||||
},
|
},
|
||||||
pers,
|
|
||||||
h.logger,
|
h.logger,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
handler = newClosedRemoteConn(pers)
|
handler = newClosedRemoteConn()
|
||||||
}
|
}
|
||||||
|
|
||||||
h.mutex.Lock()
|
h.mutex.Lock()
|
||||||
|
|
|
@ -26,7 +26,6 @@ type packetHandler interface {
|
||||||
handlePacket(receivedPacket)
|
handlePacket(receivedPacket)
|
||||||
destroy(error)
|
destroy(error)
|
||||||
closeWithTransportError(qerr.TransportErrorCode)
|
closeWithTransportError(qerr.TransportErrorCode)
|
||||||
getPerspective() protocol.Perspective
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type packetHandlerManager interface {
|
type packetHandlerManager interface {
|
||||||
|
@ -41,7 +40,6 @@ type quicConn interface {
|
||||||
EarlyConnection
|
EarlyConnection
|
||||||
earlyConnReady() <-chan struct{}
|
earlyConnReady() <-chan struct{}
|
||||||
handlePacket(receivedPacket)
|
handlePacket(receivedPacket)
|
||||||
getPerspective() protocol.Perspective
|
|
||||||
run() error
|
run() error
|
||||||
destroy(error)
|
destroy(error)
|
||||||
closeWithTransportError(TransportErrorCode)
|
closeWithTransportError(TransportErrorCode)
|
||||||
|
|
|
@ -1364,7 +1364,6 @@ var _ = Describe("Server", func() {
|
||||||
Consistently(done).ShouldNot(BeClosed())
|
Consistently(done).ShouldNot(BeClosed())
|
||||||
|
|
||||||
// make the go routine return
|
// make the go routine return
|
||||||
conn.EXPECT().getPerspective().MaxTimes(2) // initOnce for every conn ID
|
|
||||||
Expect(serv.Close()).To(Succeed())
|
Expect(serv.Close()).To(Succeed())
|
||||||
Eventually(done).Should(BeClosed())
|
Eventually(done).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue