Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: upstream quic-go 0 42 0 #27

Merged
merged 150 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
348042e
simplify sending of INVALID_TOKEN errors (#4090)
marten-seemann Sep 25, 2023
ae2ef95
don't spawn a new Go routine to send a CONNECTION_REFUSED packet (#4091)
marten-seemann Sep 25, 2023
49e588a
don't spawn a new Go routine to send a Retry packet (#4092)
marten-seemann Sep 25, 2023
f49944b
README: add qlog to list of supported RFCs, add an example (#4102)
marten-seemann Oct 13, 2023
262cf0a
fix IPv4 ECN control message length on FreeBSD (#4110)
marten-seemann Oct 17, 2023
b344940
catch EPERM sendmsg errors for the very first packet on Linux (#4111)
marten-seemann Oct 17, 2023
a263164
use new gomock feature to generate type-safe methods in mocks (#4057)
marten-seemann Oct 21, 2023
36f7fe7
http3: discard body from responses to HEAD requests (#4115)
Glonee Oct 23, 2023
5314d90
fix logging of connection IDs in tracer test (#4118)
marten-seemann Oct 23, 2023
4c357c8
ci: create separate artifact archives per workflow run (#4121)
marten-seemann Oct 23, 2023
7884f87
ci: use bash on all platforms (#4122)
marten-seemann Oct 23, 2023
1c631cf
rename Connection.{Send,Receive}Message to {Send,Receive}Datagram (#4…
marten-seemann Oct 25, 2023
6239eff
fix IPv4 ECN control message length on Linux (#4127)
marten-seemann Oct 25, 2023
30f9c01
use typed atomics in integration tests (#4120)
marten-seemann Oct 25, 2023
1bcec70
ci: run linter on all supported Go versions (#4126)
marten-seemann Oct 25, 2023
746290b
never allow 0-RTT when using Dial, even if the session ticket allows …
marten-seemann Oct 25, 2023
e2622bf
reject ClientHellos that offer TLS versions older than 1.3 (for Go 1.…
marten-seemann Oct 25, 2023
d309060
handshake: clone the tls.Config returned by GetConfigForClient (#4133)
marten-seemann Oct 27, 2023
ef800d6
handshake: set MinVersion on the Config returned by GetConfigForClien…
marten-seemann Oct 27, 2023
dda63b9
don't close established connections on Listener.Close, when using a T…
marten-seemann Oct 27, 2023
5311f81
README: link to webtransport-go repo (#4117)
marten-seemann Oct 27, 2023
6eb0cac
fix race condition in multiplex integration test (#4136)
marten-seemann Oct 28, 2023
a360354
document what happens to established connections on Listener.Close (#…
marten-seemann Oct 28, 2023
f23da7d
congestion: don't use floating point math when calculating pacing tim…
marten-seemann Oct 31, 2023
d4ab27d
don't set the TLS version in the transport (#4135)
marten-seemann Nov 1, 2023
9414ea4
ackhandler: immediately acknowledge ECN-CE marked packets (#4147)
marten-seemann Nov 3, 2023
740119b
README: fix typo (#4166)
anderspitman Nov 14, 2023
427f533
fix flaky server test (#4167)
marten-seemann Nov 14, 2023
96ab48e
fix serialization of connection ID in filenames of qlog files (#4170)
marten-seemann Nov 17, 2023
3bf2e19
logging: pass the packet number to ConnectionTracer.DroppedPacket (#4…
marten-seemann Nov 17, 2023
771d136
interop: update Go version to 1.21.4 (#4179)
marten-seemann Nov 23, 2023
2d7ea37
wire: reject NEW_CONNECTION_ID frames with zero-length conneciton IDs…
marten-seemann Nov 23, 2023
7b9d21f
send large max_datagram_frame size, introduce a DatagramTooLargeError…
chungthuang Dec 2, 2023
87ef8ec
fuzzing: add transport parameter validation logic (#4175)
marten-seemann Dec 3, 2023
45922f7
reduce calls to time.Now() calls in connection (#4191)
birneee Dec 6, 2023
9b40c50
http3: use the AdditionalSettings for requests (#4156)
marten-seemann Dec 6, 2023
38eafe4
README: add gost project (#4154)
char8x Dec 7, 2023
d234d62
qtls: only attempt 0-RTT resumption for 0-RTT enabled session tickets…
marten-seemann Dec 9, 2023
f162b94
examples: close listener, connection and stream in echo client and se…
rfyiamcool Dec 9, 2023
659da8c
fuzzing: update Go version used on OSS-Fuzz to 1.21 (#4192)
marten-seemann Dec 9, 2023
a7a66f6
integrationtests: remove leftover code for Go 1.19 (#4193)
marten-seemann Dec 10, 2023
574dc84
limit the number of queued PATH_RESPONSE frames to 256 (#4199)
marten-seemann Dec 13, 2023
ff6d575
don't retransmit PATH_CHALLENGE and PATH_RESPONSE frames (#4200)
marten-seemann Dec 13, 2023
0489409
ci: update golangci-lint to v1.55.2 (#4204)
marten-seemann Dec 13, 2023
6ffb905
fuzzing: add frame validation logic (#4206)
marten-seemann Dec 14, 2023
06c6a84
http3: add remote address to request context (#4208)
oncilla Dec 16, 2023
e0bf13b
http3: reset stream when a handler panics (#4181)
WeidiDeng Dec 16, 2023
5d6bf7e
http3: don't use error string as a format string in debug log message…
nanokatze Dec 19, 2023
d3c5f38
http3: improve debug message when determining the listener port fails…
nanokatze Dec 19, 2023
2243fde
http3: return the context cancellation error from RoundTrip (#4203)
marten-seemann Dec 21, 2023
31a677c
qlog: add support for alpn_information event (#4216)
birneee Dec 26, 2023
d795250
drop support for Go 1.20, build on Go 1.22rc1 on CI (#4195)
marten-seemann Dec 28, 2023
18c591c
utils: use time.Duration.Abs (#4217)
marten-seemann Dec 28, 2023
22411e1
utils: switch to standard library min and max functions (#4218)
marten-seemann Dec 28, 2023
a937959
http3: fix channel size in ListenAndServe (#4219)
narqo Dec 29, 2023
d6e3f32
qtls: remove unneeded type alias for the tls.QUICEncryptionLevel (#4220)
marten-seemann Dec 29, 2023
7f080dd
discard DATAGRAM frames that don't fit into packets without an ACK (#…
marten-seemann Jan 1, 2024
1fce81f
queue up to 32 DATAGRAM frames to send (#4222)
marten-seemann Jan 1, 2024
22b7f77
use a ring buffer for the datagram queue (#4223)
marten-seemann Jan 1, 2024
1083d1f
handshake: remove unneeded mutex in cryptoSetup (#4227)
marten-seemann Jan 2, 2024
59ed517
README: add RoadRunner to list of projects (#4226)
marten-seemann Jan 3, 2024
8cad3d2
wire: use netip.AddrPort to encode the IPs in the Preferred Address (…
marten-seemann Jan 3, 2024
54d6f7d
ackhandler: refactor ACK queueing logic (#4225)
marten-seemann Jan 4, 2024
f1b3bdb
fix race condition when dropping Initial packet with short connection…
marten-seemann Jan 5, 2024
3ff5029
http3: add ConnContext to the server (#4230)
rthellend Jan 5, 2024
0a922b4
example: add config flag for TLS key and cert for the server (#4237)
marten-seemann Jan 5, 2024
1e87489
wire: improve logging of connection ID retirements (#4241)
marten-seemann Jan 11, 2024
2cd9ed3
qlog: add a default tracer that writes to QLOGDIR (#4233)
birneee Jan 12, 2024
1332752
example: remove -v flag and custom logger configuration (#4242)
marten-seemann Jan 13, 2024
3449ace
example: remove -qlog flag in favor of QLOGDIR (#4243)
marten-seemann Jan 14, 2024
d3c2020
http3: add a basic README (#4246)
marten-seemann Jan 17, 2024
b3eb375
remove shutdown method on the Connection (#4249)
marten-seemann Jan 19, 2024
cb1775a
send out the CONNECTION_REFUSED error when refusing a connection (#4250)
marten-seemann Jan 19, 2024
594440b
don't remove closed connections from the server's accept queue (#4245)
marten-seemann Jan 19, 2024
4407c60
handshake: unexport Set{Read,Write}Key methods on the cryptoSetup (#4…
marten-seemann Jan 20, 2024
bda5b7e
handshake: fix documentation for updatableAEAD.SetWriteKey (#4256)
putyWang Jan 23, 2024
892851e
add Transport config options to limit the number of handshakes (#4248)
marten-seemann Jan 23, 2024
a2cf43d
remove the RequireAddressValidation callback from the Config (#4253)
marten-seemann Jan 23, 2024
a968e25
fix incorrect statement about connection ID lengths in the Transport …
marten-seemann Jan 24, 2024
2a7a11f
remove unneeded nil check for new connections in the server (#4260)
marten-seemann Jan 24, 2024
baeec0f
ci: update to Go 1.22rc2 (#4267)
marten-seemann Jan 25, 2024
d3974e1
fix flaky handshake limiting test (#4270)
marten-seemann Jan 25, 2024
808f849
http3: only use :protocol pseudo-header for Extended CONNECT (#4261)
taoso Jan 26, 2024
c82c37a
fix flaky accept queue test (#4280)
marten-seemann Jan 29, 2024
9b83ac2
fix flaky handshake limiting test (#4281)
marten-seemann Jan 29, 2024
940feef
only log the discarding of Handshake keys once (#4274)
marten-seemann Jan 29, 2024
03ba124
testutils: add a perspective function parameter to ComposeInitialPack…
marten-seemann Jan 29, 2024
34c4d89
fix flaky outgoing streams map test (#4283)
marten-seemann Jan 29, 2024
be4838b
wire: remove FrameParser interface, expose FrameParser struct (#4284)
marten-seemann Jan 29, 2024
d330d2e
remove unused RTTStats from the received packet handler (#4287)
marten-seemann Jan 30, 2024
da25787
testutils: make the package public (#4290)
marten-seemann Jan 31, 2024
e65e99f
ci: remove unused depguard check for qtls (#4291)
marten-seemann Jan 31, 2024
86441f1
ci: make Codecov ignore testutils and testdata (#4292)
marten-seemann Jan 31, 2024
72c79db
testutils: expose aliases for all frame types (#4293)
marten-seemann Jan 31, 2024
69ba7ac
ackhandler: don't delay ACKs for Initial and Handshake packets (#4288)
marten-seemann Feb 1, 2024
fbaa941
protocol: rename VersionNumber to Version (#4295)
marten-seemann Feb 1, 2024
0582e93
wire: optimize generation of Version Negotiation packets (#4278)
marten-seemann Feb 1, 2024
2fbe713
protocol: don't capitalize Perspective.String (#4296)
marten-seemann Feb 1, 2024
f3c4be6
qlog: remove unneeded mutex from the ConnectionTracer (#4299)
marten-seemann Feb 1, 2024
0344401
qlog: rename qlog.go to connection_tracer.go (#4301)
marten-seemann Feb 2, 2024
225d2a3
qlog: disentangle the ConnectionTracer from the qlog writer (#4300)
marten-seemann Feb 2, 2024
b675e34
logging: add a Debug function to the Tracer (#4297)
marten-seemann Feb 3, 2024
07ec324
logging: add a Close function to the Tracer (#4298)
marten-seemann Feb 3, 2024
198de32
don't enqueue stream for sending on reordered MAX_STREAM_DATA frames …
marten-seemann Feb 3, 2024
dc49f56
fix flaky 0-RTT packet loss recovery test (#4306)
marten-seemann Feb 3, 2024
c22a3c8
handshake: validate HKDF-Expand-Label against crypto/tls implementati…
marten-seemann Feb 5, 2024
ab17a5d
qlog: rename generation to key_phase on key_updated and key_discarded…
marten-seemann Feb 8, 2024
43baf2d
README: add frp to list of projects (#4316)
bt90 Feb 8, 2024
013949c
ci: update to Go 1.22.0 (#4312)
marten-seemann Feb 8, 2024
8e93770
avoid lock contention when accepting new connections (#4313)
marten-seemann Feb 9, 2024
229ff4f
ci: update Codecov action to v4 (#4321)
marten-seemann Feb 9, 2024
f54a32e
don't preallocate the slice for STREAM frames when composing a packet…
marten-seemann Feb 9, 2024
02e4506
handshake: add benchmarks for the Initial AEAD (#4320)
marten-seemann Feb 9, 2024
4790797
only check for stateless resets if packet doesn't belong to a connect…
marten-seemann Feb 9, 2024
284996e
qtls: protect the tls.ClientSessionCache implementation with a mutex …
marten-seemann Feb 9, 2024
0a7823c
ci: update golangci-lint to v1.56.1 and golangci-lint action to v4 (#…
marten-seemann Feb 11, 2024
07a17ff
remove unused GetVersion function from quicConn interface (#4327)
marten-seemann Feb 11, 2024
69fe378
reenable previously disabled server unit test (#4328)
marten-seemann Feb 11, 2024
7b8ceaa
remove unused getPerspective function from quicConn interface (#4329)
marten-seemann Feb 11, 2024
c786a46
remove unused perspective arg from packetHandlerMap.ReplaceWithClosed…
marten-seemann Feb 11, 2024
0405634
http3: don't automatically set RoundTripper.QuicConfig.EnableDatagram…
marten-seemann Mar 3, 2024
9813766
http3: send SETTINGS_ENABLE_CONNECT_PROTOCOL (for Extended CONNECT) (…
marten-seemann Mar 3, 2024
c5f7096
http3: reject duplicate control streams opened by the server (#4342)
marten-seemann Mar 3, 2024
d41c0b6
http3: reject duplicate control streams opened by the client (#4344)
marten-seemann Mar 3, 2024
ba1fbbe
ci: enable Dependabot for GitHub Actions (#4343)
marten-seemann Mar 3, 2024
d6269b7
fix deadlock when concurrently closing server and transport (#4332)
sukunrt Mar 3, 2024
60b4a9c
ci: bump actions/upload-artifact from 3 to 4 (#4346)
dependabot[bot] Mar 3, 2024
b21bd58
ci: bump docker/build-push-action from 4 to 5 (#4347)
dependabot[bot] Mar 3, 2024
5a70d18
ci: bump docker/login-action from 2 to 3 (#4348)
dependabot[bot] Mar 3, 2024
dbbb6ca
ci: bump docker/setup-qemu-action from 2 to 3 (#4345)
dependabot[bot] Mar 3, 2024
067e7db
ci: bump docker/setup-buildx-action from 2 to 3 (#4349)
dependabot[bot] Mar 3, 2024
f856163
handshake: embed the mask as an array into the aesHeaderProtector (#4…
marten-seemann Mar 3, 2024
71f5ae5
handshake: optimize AEAD handling for long header sealers and openers…
marten-seemann Mar 3, 2024
a70419b
unmap IPv4-mapped IPv6 addresses (#4309)
thijsvandien Mar 5, 2024
ac12689
improve API documentation for OpenStreamSync (#4352)
wlynxg Mar 7, 2024
2abbd41
qlog: introduce a basic tracer for non-connection events
marten-seemann Feb 2, 2024
3a7a53f
qlog: log packet drops outside of a QUIC connection
marten-seemann Feb 2, 2024
aff90a6
qlog: log sent Version Negotiation packets
marten-seemann Feb 2, 2024
55c05ac
qlog: log sent packets outside of a QUIC connection
marten-seemann Feb 2, 2024
30e01b9
use the transport tracer in integration tests
marten-seemann Feb 3, 2024
5fd5d77
Merge pull request #4305 from quic-go/qlog-tracer
marten-seemann Mar 9, 2024
06b4214
remove unused ReceiveStream.CloseRemote method (#4357)
marten-seemann Mar 9, 2024
f147639
update gomock to v0.4.0 (#4361)
marten-seemann Mar 11, 2024
ca787d6
add an AddrVerified field to the ClientHelloInfo (#4360)
marten-seemann Mar 11, 2024
497d3f5
http3: add a RoundTripOpt to check the server's SETTINGS frame (#4355)
marten-seemann Mar 12, 2024
9971fed
use Transport.VerifySourceAddress to control the Retry Mechanism (#4362)
marten-seemann Mar 15, 2024
4a99b81
close connection when an abnormally large number of frames are queued…
marten-seemann Mar 18, 2024
4973374
sync: quic-go 0.42.0
gaukas Apr 24, 2024
b66e1ed
sync: 0.42.0 merge commit
gaukas Apr 24, 2024
05c1294
fix: build error after sync
gaukas Apr 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clusterfuzzlite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM gcr.io/oss-fuzz-base/base-builder-go:v1
ARG TARGETPLATFORM
RUN echo "TARGETPLATFORM: ${TARGETPLATFORM}"

ENV GOVERSION=1.20.7
ENV GOVERSION=1.22.0

RUN platform=$(echo ${TARGETPLATFORM} | tr '/' '-') && \
filename="go${GOVERSION}.${platform}.tar.gz" && \
Expand Down
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
11 changes: 0 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@ run:
skip-files:
- internal/handshake/cipher_suite.go
linters-settings:
depguard:
type: blacklist
packages:
- github.com/marten-seemann/qtls
- github.com/quic-go/qtls-go1-19
- github.com/quic-go/qtls-go1-20
packages-with-error-message:
- github.com/marten-seemann/qtls: "importing qtls only allowed in internal/qtls"
- github.com/quic-go/qtls-go1-19: "importing qtls only allowed in internal/qtls"
- github.com/quic-go/qtls-go1-20: "importing qtls only allowed in internal/qtls"
misspell:
ignore-words:
- ect
Expand All @@ -20,7 +10,6 @@ linters:
disable-all: true
enable:
- asciicheck
- depguard
- exhaustive
- exportloopref
- goimports
Expand Down
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type client struct {

initialPacketNumber protocol.PacketNumber
hasNegotiatedVersion bool
version protocol.VersionNumber
version protocol.Version

handshakeChan chan struct{}

Expand Down Expand Up @@ -237,7 +237,7 @@ func (c *client) dial(ctx context.Context) error {

select {
case <-ctx.Done():
c.conn.shutdown()
c.conn.destroy(nil)
return context.Cause(ctx)
case err := <-errorChan:
return err
Expand Down
26 changes: 13 additions & 13 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var _ = Describe("Client", func() {
tracer *logging.ConnectionTracer,
tracingID uint64,
logger utils.Logger,
v protocol.VersionNumber,
v protocol.Version,
) quicConn
)

Expand All @@ -61,7 +61,7 @@ var _ = Describe("Client", func() {
Tracer: func(ctx context.Context, perspective logging.Perspective, id ConnectionID) *logging.ConnectionTracer {
return tr
},
Versions: []protocol.VersionNumber{protocol.Version1},
Versions: []protocol.Version{protocol.Version1},
}
Eventually(areConnsRunning).Should(BeFalse())
packetConn = NewMockSendConn(mockCtrl)
Expand All @@ -88,7 +88,7 @@ var _ = Describe("Client", func() {

AfterEach(func() {
if s, ok := cl.conn.(*connection); ok {
s.shutdown()
s.destroy(nil)
}
Eventually(areConnsRunning).Should(BeFalse())
})
Expand Down Expand Up @@ -126,11 +126,11 @@ var _ = Describe("Client", func() {
_ *logging.ConnectionTracer,
_ uint64,
_ utils.Logger,
_ protocol.VersionNumber,
_ protocol.Version,
) quicConn {
Expect(enable0RTT).To(BeFalse())
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().run().Do(func() { close(run) })
conn.EXPECT().run().Do(func() error { close(run); return nil })
c := make(chan struct{})
close(c)
conn.EXPECT().HandshakeComplete().Return(c)
Expand Down Expand Up @@ -163,11 +163,11 @@ var _ = Describe("Client", func() {
_ *logging.ConnectionTracer,
_ uint64,
_ utils.Logger,
_ protocol.VersionNumber,
_ protocol.Version,
) quicConn {
Expect(enable0RTT).To(BeTrue())
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().run().Do(func() { close(done) })
conn.EXPECT().run().Do(func() error { close(done); return nil })
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
conn.EXPECT().earlyConnReady().Return(readyChan)
return conn
Expand Down Expand Up @@ -200,7 +200,7 @@ var _ = Describe("Client", func() {
_ *logging.ConnectionTracer,
_ uint64,
_ utils.Logger,
_ protocol.VersionNumber,
_ protocol.Version,
) quicConn {
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().run().Return(testErr)
Expand Down Expand Up @@ -266,9 +266,9 @@ var _ = Describe("Client", func() {
})

It("creates new connections with the right parameters", func() {
config := &Config{Versions: []protocol.VersionNumber{protocol.Version1}}
config := &Config{Versions: []protocol.Version{protocol.Version1}}
c := make(chan struct{})
var version protocol.VersionNumber
var version protocol.Version
var conf *Config
done := make(chan struct{})
newClientConnection = func(
Expand All @@ -285,7 +285,7 @@ var _ = Describe("Client", func() {
_ *logging.ConnectionTracer,
_ uint64,
_ utils.Logger,
versionP protocol.VersionNumber,
versionP protocol.Version,
) quicConn {
version = versionP
conf = configP
Expand Down Expand Up @@ -328,7 +328,7 @@ var _ = Describe("Client", func() {
_ *logging.ConnectionTracer,
_ uint64,
_ utils.Logger,
versionP protocol.VersionNumber,
versionP protocol.Version,
) quicConn {
conn := NewMockQUICConn(mockCtrl)
conn.EXPECT().HandshakeComplete().Return(make(chan struct{}))
Expand All @@ -352,7 +352,7 @@ var _ = Describe("Client", func() {
return conn
}

config := &Config{Tracer: config.Tracer, Versions: []protocol.VersionNumber{protocol.Version1}}
config := &Config{Tracer: config.Tracer, Versions: []protocol.Version{protocol.Version1}}
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
_, err := DialAddr(context.Background(), "localhost:7890", tlsConf, config)
Expect(err).ToNot(HaveOccurred())
Expand Down
33 changes: 13 additions & 20 deletions closed_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,26 @@ import (
"math/bits"
"net"

"github.com/refraction-networking/uquic/internal/protocol"
"github.com/refraction-networking/uquic/internal/utils"
)

// A closedLocalConn is a connection that we closed locally.
// When receiving packets for such a connection, we need to retransmit the packet containing the CONNECTION_CLOSE frame,
// with an exponential backoff.
type closedLocalConn struct {
counter uint32
perspective protocol.Perspective
logger utils.Logger
counter uint32
logger utils.Logger

sendPacket func(net.Addr, packetInfo)
}

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,
sendPacket: sendPacket,
logger: logger,
}
}

Expand All @@ -41,24 +38,20 @@ func (c *closedLocalConn) handlePacket(p receivedPacket) {
c.sendPacket(p.remoteAddr, p.info)
}

func (c *closedLocalConn) shutdown() {}
func (c *closedLocalConn) destroy(error) {}
func (c *closedLocalConn) getPerspective() protocol.Perspective { return c.perspective }
func (c *closedLocalConn) destroy(error) {}
func (c *closedLocalConn) closeWithTransportError(TransportErrorCode) {}

// 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 (s *closedRemoteConn) handlePacket(receivedPacket) {}
func (s *closedRemoteConn) shutdown() {}
func (s *closedRemoteConn) destroy(error) {}
func (s *closedRemoteConn) getPerspective() protocol.Perspective { return s.perspective }
func (c *closedRemoteConn) handlePacket(receivedPacket) {}
func (c *closedRemoteConn) destroy(error) {}
func (c *closedRemoteConn) closeWithTransportError(TransportErrorCode) {}
14 changes: 1 addition & 13 deletions closed_conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,16 @@ package quic
import (
"net"

"github.com/refraction-networking/uquic/internal/protocol"
"github.com/refraction-networking/uquic/internal/utils"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

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))
// stop the connection
conn.shutdown()
})

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})
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ coverage:
- interop/
- internal/handshake/cipher_suite.go
- internal/utils/linkedlist/linkedlist.go
- internal/testdata
- testutils/
- fuzzing/
- metrics/
status:
Expand Down
12 changes: 0 additions & 12 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package quic

import (
"fmt"
"net"
"time"

"github.com/refraction-networking/uquic/internal/protocol"
Expand Down Expand Up @@ -49,16 +48,6 @@ func validateConfig(config *Config) error {
return nil
}

// populateServerConfig populates fields in the quic.Config with their default values, if none are set
// it may be called with nil
func populateServerConfig(config *Config) *Config {
config = populateConfig(config)
if config.RequireAddressValidation == nil {
config.RequireAddressValidation = func(net.Addr) bool { return false }
}
return config
}

// populateConfig populates fields in the quic.Config with their default values, if none are set
// it may be called with nil
func populateConfig(config *Config) *Config {
Expand Down Expand Up @@ -111,7 +100,6 @@ func populateConfig(config *Config) *Config {
Versions: versions,
HandshakeIdleTimeout: handshakeIdleTimeout,
MaxIdleTimeout: idleTimeout,
RequireAddressValidation: config.RequireAddressValidation,
KeepAlivePeriod: config.KeepAlivePeriod,
InitialStreamReceiveWindow: initialStreamReceiveWindow,
MaxStreamReceiveWindow: maxStreamReceiveWindow,
Expand Down
31 changes: 4 additions & 27 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"net"
"reflect"
"time"

Expand All @@ -23,7 +22,7 @@ var _ = Describe("Config", func() {
})

It("validates a config with normal values", func() {
conf := populateServerConfig(&Config{
conf := populateConfig(&Config{
MaxIncomingStreams: 5,
MaxStreamReceiveWindow: 10,
})
Expand Down Expand Up @@ -69,7 +68,7 @@ var _ = Describe("Config", func() {
case "GetConfigForClient", "RequireAddressValidation", "GetLogWriter", "AllowConnectionWindowIncrease", "Tracer":
// Can't compare functions.
case "Versions":
f.Set(reflect.ValueOf([]VersionNumber{1, 2, 3}))
f.Set(reflect.ValueOf([]Version{1, 2, 3}))
case "ConnectionIDLength":
f.Set(reflect.ValueOf(8))
case "ConnectionIDGenerator":
Expand Down Expand Up @@ -118,19 +117,16 @@ var _ = Describe("Config", func() {

Context("cloning", func() {
It("clones function fields", func() {
var calledAddrValidation, calledAllowConnectionWindowIncrease, calledTracer bool
var calledAllowConnectionWindowIncrease, calledTracer bool
c1 := &Config{
GetConfigForClient: func(info *ClientHelloInfo) (*Config, error) { return nil, errors.New("nope") },
AllowConnectionWindowIncrease: func(Connection, uint64) bool { calledAllowConnectionWindowIncrease = true; return true },
RequireAddressValidation: func(net.Addr) bool { calledAddrValidation = true; return true },
Tracer: func(context.Context, logging.Perspective, ConnectionID) *logging.ConnectionTracer {
calledTracer = true
return nil
},
}
c2 := c1.Clone()
c2.RequireAddressValidation(&net.UDPAddr{})
Expect(calledAddrValidation).To(BeTrue())
c2.AllowConnectionWindowIncrease(nil, 1234)
Expect(calledAllowConnectionWindowIncrease).To(BeTrue())
_, err := c2.GetConfigForClient(&ClientHelloInfo{})
Expand All @@ -145,29 +141,15 @@ var _ = Describe("Config", func() {
})

It("returns a copy", func() {
c1 := &Config{
MaxIncomingStreams: 100,
RequireAddressValidation: func(net.Addr) bool { return true },
}
c1 := &Config{MaxIncomingStreams: 100}
c2 := c1.Clone()
c2.MaxIncomingStreams = 200
c2.RequireAddressValidation = func(net.Addr) bool { return false }

Expect(c1.MaxIncomingStreams).To(BeEquivalentTo(100))
Expect(c1.RequireAddressValidation(&net.UDPAddr{})).To(BeTrue())
})
})

Context("populating", func() {
It("populates function fields", func() {
var calledAddrValidation bool
c1 := &Config{}
c1.RequireAddressValidation = func(net.Addr) bool { calledAddrValidation = true; return true }
c2 := populateConfig(c1)
c2.RequireAddressValidation(&net.UDPAddr{})
Expect(calledAddrValidation).To(BeTrue())
})

It("copies non-function fields", func() {
c := configWithNonZeroNonFunctionFields()
Expect(populateConfig(c)).To(Equal(c))
Expand All @@ -186,10 +168,5 @@ var _ = Describe("Config", func() {
Expect(c.DisablePathMTUDiscovery).To(BeFalse())
Expect(c.GetConfigForClient).To(BeNil())
})

It("populates empty fields with default values, for the server", func() {
c := populateServerConfig(&Config{})
Expect(c.RequireAddressValidation).ToNot(BeNil())
})
})
})
Loading
Loading