mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 17:29:58 +00:00
TUN-6637: Upgrade quic-go
This commit is contained in:
7
vendor/github.com/lucas-clemente/quic-go/client.go
generated
vendored
7
vendor/github.com/lucas-clemente/quic-go/client.go
generated
vendored
@@ -43,8 +43,7 @@ type client struct {
|
||||
}
|
||||
|
||||
var (
|
||||
// make it possible to mock connection ID generation in the tests
|
||||
generateConnectionID = protocol.GenerateConnectionID
|
||||
// make it possible to mock connection ID for initial generation in the tests
|
||||
generateConnectionIDForInitial = protocol.GenerateConnectionIDForInitial
|
||||
)
|
||||
|
||||
@@ -193,7 +192,7 @@ func dialContext(
|
||||
return nil, err
|
||||
}
|
||||
config = populateClientConfig(config, createdPacketConn)
|
||||
packetHandlers, err := getMultiplexer().AddConn(pconn, config.ConnectionIDLength, config.StatelessResetKey, config.Tracer)
|
||||
packetHandlers, err := getMultiplexer().AddConn(pconn, config.ConnectionIDGenerator.ConnectionIDLen(), config.StatelessResetKey, config.Tracer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -256,7 +255,7 @@ func newClient(
|
||||
}
|
||||
}
|
||||
|
||||
srcConnID, err := generateConnectionID(config.ConnectionIDLength)
|
||||
srcConnID, err := config.ConnectionIDGenerator.GenerateConnectionID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
23
vendor/github.com/lucas-clemente/quic-go/config.go
generated
vendored
23
vendor/github.com/lucas-clemente/quic-go/config.go
generated
vendored
@@ -35,10 +35,7 @@ func validateConfig(config *Config) error {
|
||||
// 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.ConnectionIDLength == 0 {
|
||||
config.ConnectionIDLength = protocol.DefaultConnectionIDLength
|
||||
}
|
||||
config = populateConfig(config, protocol.DefaultConnectionIDLength)
|
||||
if config.AcceptToken == nil {
|
||||
config.AcceptToken = defaultAcceptToken
|
||||
}
|
||||
@@ -48,14 +45,16 @@ func populateServerConfig(config *Config) *Config {
|
||||
// populateClientConfig populates fields in the quic.Config with their default values, if none are set
|
||||
// it may be called with nil
|
||||
func populateClientConfig(config *Config, createdPacketConn bool) *Config {
|
||||
config = populateConfig(config)
|
||||
if config.ConnectionIDLength == 0 && !createdPacketConn {
|
||||
config.ConnectionIDLength = protocol.DefaultConnectionIDLength
|
||||
var defaultConnIdLen = protocol.DefaultConnectionIDLength
|
||||
if createdPacketConn {
|
||||
defaultConnIdLen = 0
|
||||
}
|
||||
|
||||
config = populateConfig(config, defaultConnIdLen)
|
||||
return config
|
||||
}
|
||||
|
||||
func populateConfig(config *Config) *Config {
|
||||
func populateConfig(config *Config, defaultConnIDLen int) *Config {
|
||||
if config == nil {
|
||||
config = &Config{}
|
||||
}
|
||||
@@ -63,6 +62,9 @@ func populateConfig(config *Config) *Config {
|
||||
if len(versions) == 0 {
|
||||
versions = protocol.SupportedVersions
|
||||
}
|
||||
if config.ConnectionIDLength == 0 {
|
||||
config.ConnectionIDLength = defaultConnIDLen
|
||||
}
|
||||
handshakeIdleTimeout := protocol.DefaultHandshakeIdleTimeout
|
||||
if config.HandshakeIdleTimeout != 0 {
|
||||
handshakeIdleTimeout = config.HandshakeIdleTimeout
|
||||
@@ -103,6 +105,10 @@ func populateConfig(config *Config) *Config {
|
||||
if maxDatagrameFrameSize == 0 {
|
||||
maxDatagrameFrameSize = int64(protocol.DefaultMaxDatagramFrameSize)
|
||||
}
|
||||
connIDGenerator := config.ConnectionIDGenerator
|
||||
if connIDGenerator == nil {
|
||||
connIDGenerator = &protocol.DefaultConnectionIDGenerator{ConnLen: config.ConnectionIDLength}
|
||||
}
|
||||
|
||||
return &Config{
|
||||
Versions: versions,
|
||||
@@ -118,6 +124,7 @@ func populateConfig(config *Config) *Config {
|
||||
MaxIncomingStreams: maxIncomingStreams,
|
||||
MaxIncomingUniStreams: maxIncomingUniStreams,
|
||||
ConnectionIDLength: config.ConnectionIDLength,
|
||||
ConnectionIDGenerator: connIDGenerator,
|
||||
StatelessResetKey: config.StatelessResetKey,
|
||||
TokenStore: config.TokenStore,
|
||||
EnableDatagrams: config.EnableDatagrams,
|
||||
|
9
vendor/github.com/lucas-clemente/quic-go/conn_id_generator.go
generated
vendored
9
vendor/github.com/lucas-clemente/quic-go/conn_id_generator.go
generated
vendored
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type connIDGenerator struct {
|
||||
connIDLen int
|
||||
generator ConnectionIDGenerator
|
||||
highestSeq uint64
|
||||
|
||||
activeSrcConnIDs map[uint64]protocol.ConnectionID
|
||||
@@ -35,10 +35,11 @@ func newConnIDGenerator(
|
||||
retireConnectionID func(protocol.ConnectionID),
|
||||
replaceWithClosed func(protocol.ConnectionID, packetHandler),
|
||||
queueControlFrame func(wire.Frame),
|
||||
generator ConnectionIDGenerator,
|
||||
version protocol.VersionNumber,
|
||||
) *connIDGenerator {
|
||||
m := &connIDGenerator{
|
||||
connIDLen: initialConnectionID.Len(),
|
||||
generator: generator,
|
||||
activeSrcConnIDs: make(map[uint64]protocol.ConnectionID),
|
||||
addConnectionID: addConnectionID,
|
||||
getStatelessResetToken: getStatelessResetToken,
|
||||
@@ -54,7 +55,7 @@ func newConnIDGenerator(
|
||||
}
|
||||
|
||||
func (m *connIDGenerator) SetMaxActiveConnIDs(limit uint64) error {
|
||||
if m.connIDLen == 0 {
|
||||
if m.generator.ConnectionIDLen() == 0 {
|
||||
return nil
|
||||
}
|
||||
// The active_connection_id_limit transport parameter is the number of
|
||||
@@ -99,7 +100,7 @@ func (m *connIDGenerator) Retire(seq uint64, sentWithDestConnID protocol.Connect
|
||||
}
|
||||
|
||||
func (m *connIDGenerator) issueNewConnID() error {
|
||||
connID, err := protocol.GenerateConnectionID(m.connIDLen)
|
||||
connID, err := m.generator.GenerateConnectionID()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
2
vendor/github.com/lucas-clemente/quic-go/connection.go
generated
vendored
2
vendor/github.com/lucas-clemente/quic-go/connection.go
generated
vendored
@@ -280,6 +280,7 @@ var newConnection = func(
|
||||
runner.Retire,
|
||||
runner.ReplaceWithClosed,
|
||||
s.queueControlFrame,
|
||||
s.config.ConnectionIDGenerator,
|
||||
s.version,
|
||||
)
|
||||
s.preSetup()
|
||||
@@ -410,6 +411,7 @@ var newClientConnection = func(
|
||||
runner.Retire,
|
||||
runner.ReplaceWithClosed,
|
||||
s.queueControlFrame,
|
||||
s.config.ConnectionIDGenerator,
|
||||
s.version,
|
||||
)
|
||||
s.preSetup()
|
||||
|
17
vendor/github.com/lucas-clemente/quic-go/interface.go
generated
vendored
17
vendor/github.com/lucas-clemente/quic-go/interface.go
generated
vendored
@@ -211,6 +211,18 @@ type EarlyConnection interface {
|
||||
NextConnection() Connection
|
||||
}
|
||||
|
||||
// A ConnectionIDGenerator is a interface that allows clients to implement their own format
|
||||
// for the Connection IDs that servers/clients use as SrcConnectionID in QUIC packets.
|
||||
type ConnectionIDGenerator interface {
|
||||
|
||||
// GenerateConnectionID generates a new ConnectionID.
|
||||
GenerateConnectionID() ([]byte, error)
|
||||
|
||||
// ConnectionIDLen tells what is the length of the ConnectionIDs generated by the implementation of
|
||||
// this interface.
|
||||
ConnectionIDLen() int
|
||||
}
|
||||
|
||||
// Config contains all configuration data needed for a QUIC server or client.
|
||||
type Config struct {
|
||||
// The QUIC versions that can be negotiated.
|
||||
@@ -223,6 +235,11 @@ type Config struct {
|
||||
// If used for a server, or dialing on a packet conn, a 4 byte connection ID will be used.
|
||||
// When dialing on a packet conn, the ConnectionIDLength value must be the same for every Dial call.
|
||||
ConnectionIDLength int
|
||||
// An optional ConnectionIDGenerator to be used for ConnectionIDs generated during the lifecycle of a QUIC connection.
|
||||
// The goal is to give some control on how connection IDs, which can be useful in some scenarios, in particular for servers.
|
||||
// By default, if not provided, random connection IDs with the length given by ConnectionIDLength is used.
|
||||
// Otherwise, if one is provided, then ConnectionIDLength is ignored.
|
||||
ConnectionIDGenerator ConnectionIDGenerator
|
||||
// HandshakeIdleTimeout is the idle timeout before completion of the handshake.
|
||||
// Specifically, if we don't receive any packet from the peer within this time, the connection attempt is aborted.
|
||||
// If this value is zero, the timeout is set to 5 seconds.
|
||||
|
12
vendor/github.com/lucas-clemente/quic-go/internal/protocol/connection_id.go
generated
vendored
12
vendor/github.com/lucas-clemente/quic-go/internal/protocol/connection_id.go
generated
vendored
@@ -67,3 +67,15 @@ func (c ConnectionID) String() string {
|
||||
}
|
||||
return fmt.Sprintf("%x", c.Bytes())
|
||||
}
|
||||
|
||||
type DefaultConnectionIDGenerator struct {
|
||||
ConnLen int
|
||||
}
|
||||
|
||||
func (d *DefaultConnectionIDGenerator) GenerateConnectionID() ([]byte, error) {
|
||||
return GenerateConnectionID(d.ConnLen)
|
||||
}
|
||||
|
||||
func (d *DefaultConnectionIDGenerator) ConnectionIDLen() int {
|
||||
return d.ConnLen
|
||||
}
|
||||
|
12
vendor/github.com/lucas-clemente/quic-go/server.go
generated
vendored
12
vendor/github.com/lucas-clemente/quic-go/server.go
generated
vendored
@@ -190,7 +190,7 @@ func listen(conn net.PacketConn, tlsConf *tls.Config, config *Config, acceptEarl
|
||||
}
|
||||
}
|
||||
|
||||
connHandler, err := getMultiplexer().AddConn(conn, config.ConnectionIDLength, config.StatelessResetKey, config.Tracer)
|
||||
connHandler, err := getMultiplexer().AddConn(conn, config.ConnectionIDGenerator.ConnectionIDLen(), config.StatelessResetKey, config.Tracer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -341,7 +341,7 @@ func (s *baseServer) handlePacketImpl(p *receivedPacket) bool /* is the buffer s
|
||||
}
|
||||
// If we're creating a new connection, the packet will be passed to the connection.
|
||||
// The header will then be parsed again.
|
||||
hdr, _, _, err := wire.ParsePacket(p.data, s.config.ConnectionIDLength)
|
||||
hdr, _, _, err := wire.ParsePacket(p.data, s.config.ConnectionIDGenerator.ConnectionIDLen())
|
||||
if err != nil && err != wire.ErrUnsupportedVersion {
|
||||
if s.config.Tracer != nil {
|
||||
s.config.Tracer.DroppedPacket(p.remoteAddr, logging.PacketTypeNotDetermined, p.Size(), logging.PacketDropHeaderParseError)
|
||||
@@ -450,11 +450,11 @@ func (s *baseServer) handleInitialImpl(p *receivedPacket, hdr *wire.Header) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
connID, err := protocol.GenerateConnectionID(s.config.ConnectionIDLength)
|
||||
connID, err := s.config.ConnectionIDGenerator.GenerateConnectionID()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.logger.Debugf("Changing connection ID to %s.", connID)
|
||||
s.logger.Debugf("Changing connection ID to %s.", protocol.ConnectionID(connID))
|
||||
var conn quicConn
|
||||
tracingID := nextConnTracingID()
|
||||
if added := s.connHandler.AddWithConnID(hdr.DestConnectionID, connID, func() packetHandler {
|
||||
@@ -535,7 +535,7 @@ func (s *baseServer) sendRetry(remoteAddr net.Addr, hdr *wire.Header, info *pack
|
||||
// Log the Initial packet now.
|
||||
// If no Retry is sent, the packet will be logged by the connection.
|
||||
(&wire.ExtendedHeader{Header: *hdr}).Log(s.logger)
|
||||
srcConnID, err := protocol.GenerateConnectionID(s.config.ConnectionIDLength)
|
||||
srcConnID, err := s.config.ConnectionIDGenerator.GenerateConnectionID()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -551,7 +551,7 @@ func (s *baseServer) sendRetry(remoteAddr net.Addr, hdr *wire.Header, info *pack
|
||||
replyHdr.DestConnectionID = hdr.SrcConnectionID
|
||||
replyHdr.Token = token
|
||||
if s.logger.Debug() {
|
||||
s.logger.Debugf("Changing connection ID to %s.", srcConnID)
|
||||
s.logger.Debugf("Changing connection ID to %s.", protocol.ConnectionID(srcConnID))
|
||||
s.logger.Debugf("-> Sending Retry")
|
||||
replyHdr.Log(s.logger)
|
||||
}
|
||||
|
5
vendor/github.com/lucas-clemente/quic-go/sys_conn_df_linux.go
generated
vendored
5
vendor/github.com/lucas-clemente/quic-go/sys_conn_df_linux.go
generated
vendored
@@ -7,8 +7,9 @@ import (
|
||||
"errors"
|
||||
"syscall"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||
)
|
||||
|
||||
func setDF(rawConn syscall.RawConn) error {
|
||||
@@ -29,7 +30,7 @@ func setDF(rawConn syscall.RawConn) error {
|
||||
case errDFIPv4 != nil && errDFIPv6 == nil:
|
||||
utils.DefaultLogger.Debugf("Setting DF for IPv6.")
|
||||
case errDFIPv4 != nil && errDFIPv6 != nil:
|
||||
return errors.New("setting DF failed for both IPv4 and IPv6")
|
||||
utils.DefaultLogger.Errorf("setting DF failed for both IPv4 and IPv6")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@@ -146,7 +146,7 @@ github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc
|
||||
github.com/json-iterator/go
|
||||
# github.com/kylelemons/godebug v1.1.0
|
||||
## explicit; go 1.11
|
||||
# github.com/lucas-clemente/quic-go v0.28.1 => github.com/chungthuang/quic-go v0.27.1-0.20220808144024-f036dcbe387e
|
||||
# github.com/lucas-clemente/quic-go v0.28.1 => github.com/chungthuang/quic-go v0.27.1-0.20220809135021-ca330f1dec9f
|
||||
## explicit; go 1.16
|
||||
github.com/lucas-clemente/quic-go
|
||||
github.com/lucas-clemente/quic-go/internal/ackhandler
|
||||
@@ -546,6 +546,6 @@ zombiezen.com/go/capnproto2/schemas
|
||||
zombiezen.com/go/capnproto2/server
|
||||
zombiezen.com/go/capnproto2/std/capnp/rpc
|
||||
# github.com/urfave/cli/v2 => github.com/ipostelnik/cli/v2 v2.3.1-0.20210324024421-b6ea8234fe3d
|
||||
# github.com/lucas-clemente/quic-go => github.com/chungthuang/quic-go v0.27.1-0.20220808144024-f036dcbe387e
|
||||
# github.com/lucas-clemente/quic-go => github.com/chungthuang/quic-go v0.27.1-0.20220809135021-ca330f1dec9f
|
||||
# github.com/prometheus/golang_client => github.com/prometheus/golang_client v1.12.1
|
||||
# gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.1
|
||||
|
Reference in New Issue
Block a user