Skip to content

Commit

Permalink
quic: disable sending of Version Negotiation packets (#2015)
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored Feb 4, 2023
1 parent 079dbfa commit 5da8497
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions p2p/test/quic/quic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package quic_test
import (
"context"
"testing"
"time"

"github.com/libp2p/go-libp2p"
"github.com/libp2p/go-libp2p/core/network"
Expand Down Expand Up @@ -99,9 +100,13 @@ func TestDisableQUICDraft29(t *testing.T) {
)
require.NoError(t, err)
defer h2.Close()
require.ErrorContains(t,
h2.Connect(context.Background(), peer.AddrInfo{ID: h1.ID(), Addrs: []ma.Multiaddr{ma.StringCast("/ip4/127.0.0.1/udp/12346/quic")}}),
"no compatible QUIC version found",
// We disabled QUIC Version Negotiation, so we will _not_ receive a Version Negotiation packet.
// Instead, the connection will run into the context timeout.
ctx, cancel := context.WithTimeout(context.Background(), 300*time.Microsecond)
defer cancel()
require.ErrorIs(t,
h2.Connect(ctx, peer.AddrInfo{ID: h1.ID(), Addrs: []ma.Multiaddr{ma.StringCast("/ip4/127.0.0.1/udp/12346/quic")}}),
context.DeadlineExceeded,
)
// make sure that dialing QUIC v1 works
require.NoError(t, h2.Connect(context.Background(), peer.AddrInfo{ID: h1.ID(), Addrs: []ma.Multiaddr{addrs[0]}}))
Expand Down
2 changes: 2 additions & 0 deletions p2p/transport/quicreuse/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ var quicConfig = &quic.Config{
Versions: []quic.VersionNumber{quic.VersionDraft29, quic.Version1},
// We don't use datagrams (yet), but this is necessary for WebTransport
EnableDatagrams: true,
// The multiaddress encodes the QUIC version, thus there's no need to send Version Negotiation packets.
DisableVersionNegotiationPackets: true,
}

0 comments on commit 5da8497

Please sign in to comment.