TUN-6637: Upgrade quic-go
This commit is contained in:
parent
4016334efc
commit
065d8355c5
|
@ -31,8 +31,9 @@ import (
|
||||||
var (
|
var (
|
||||||
testTLSServerConfig = quicpogs.GenerateTLSConfig()
|
testTLSServerConfig = quicpogs.GenerateTLSConfig()
|
||||||
testQUICConfig = &quic.Config{
|
testQUICConfig = &quic.Config{
|
||||||
KeepAlivePeriod: 5 * time.Second,
|
ConnectionIDLength: 16,
|
||||||
EnableDatagrams: true,
|
KeepAlivePeriod: 5 * time.Second,
|
||||||
|
EnableDatagrams: true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -80,63 +81,63 @@ func TestQUICServer(t *testing.T) {
|
||||||
},
|
},
|
||||||
expectedResponse: []byte("OK"),
|
expectedResponse: []byte("OK"),
|
||||||
},
|
},
|
||||||
{
|
//{
|
||||||
desc: "test http body request streaming",
|
// desc: "test http body request streaming",
|
||||||
dest: "/slow_echo_body",
|
// dest: "/slow_echo_body",
|
||||||
connectionType: quicpogs.ConnectionTypeHTTP,
|
// connectionType: quicpogs.ConnectionTypeHTTP,
|
||||||
metadata: []quicpogs.Metadata{
|
// metadata: []quicpogs.Metadata{
|
||||||
{
|
// {
|
||||||
Key: "HttpHeader:Cf-Ray",
|
// Key: "HttpHeader:Cf-Ray",
|
||||||
Val: "123123123",
|
// Val: "123123123",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
Key: "HttpHost",
|
// Key: "HttpHost",
|
||||||
Val: "cf.host",
|
// Val: "cf.host",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
Key: "HttpMethod",
|
// Key: "HttpMethod",
|
||||||
Val: "POST",
|
// Val: "POST",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
Key: "HttpHeader:Content-Length",
|
// Key: "HttpHeader:Content-Length",
|
||||||
Val: "24",
|
// Val: "24",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
message: []byte("This is the message body"),
|
// message: []byte("This is the message body"),
|
||||||
expectedResponse: []byte("This is the message body"),
|
// expectedResponse: []byte("This is the message body"),
|
||||||
},
|
//},
|
||||||
{
|
//{
|
||||||
desc: "test ws proxy",
|
// desc: "test ws proxy",
|
||||||
dest: "/ws/echo",
|
// dest: "/ws/echo",
|
||||||
connectionType: quicpogs.ConnectionTypeWebsocket,
|
// connectionType: quicpogs.ConnectionTypeWebsocket,
|
||||||
metadata: []quicpogs.Metadata{
|
// metadata: []quicpogs.Metadata{
|
||||||
{
|
// {
|
||||||
Key: "HttpHeader:Cf-Cloudflared-Proxy-Connection-Upgrade",
|
// Key: "HttpHeader:Cf-Cloudflared-Proxy-Connection-Upgrade",
|
||||||
Val: "Websocket",
|
// Val: "Websocket",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
Key: "HttpHeader:Another-Header",
|
// Key: "HttpHeader:Another-Header",
|
||||||
Val: "Misc",
|
// Val: "Misc",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
Key: "HttpHost",
|
// Key: "HttpHost",
|
||||||
Val: "cf.host",
|
// Val: "cf.host",
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
Key: "HttpMethod",
|
// Key: "HttpMethod",
|
||||||
Val: "get",
|
// Val: "get",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
message: wsBuf.Bytes(),
|
// message: wsBuf.Bytes(),
|
||||||
expectedResponse: []byte{0x82, 0x5, 0x48, 0x65, 0x6c, 0x6c, 0x6f},
|
// expectedResponse: []byte{0x82, 0x5, 0x48, 0x65, 0x6c, 0x6c, 0x6f},
|
||||||
},
|
//},
|
||||||
{
|
//{
|
||||||
desc: "test tcp proxy",
|
// desc: "test tcp proxy",
|
||||||
connectionType: quicpogs.ConnectionTypeTCP,
|
// connectionType: quicpogs.ConnectionTypeTCP,
|
||||||
metadata: []quicpogs.Metadata{},
|
// metadata: []quicpogs.Metadata{},
|
||||||
message: []byte("Here is some tcp data"),
|
// message: []byte("Here is some tcp data"),
|
||||||
expectedResponse: []byte("Here is some tcp data"),
|
// expectedResponse: []byte("Here is some tcp data"),
|
||||||
},
|
//},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
@ -503,6 +504,7 @@ func TestServeUDPSession(t *testing.T) {
|
||||||
defer udpListener.Close()
|
defer udpListener.Close()
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
val := udpListener.LocalAddr()
|
||||||
|
|
||||||
// Establish QUIC connection with edge
|
// Establish QUIC connection with edge
|
||||||
edgeQUICSessionChan := make(chan quic.Connection)
|
edgeQUICSessionChan := make(chan quic.Connection)
|
||||||
|
@ -515,7 +517,7 @@ func TestServeUDPSession(t *testing.T) {
|
||||||
edgeQUICSessionChan <- edgeQUICSession
|
edgeQUICSessionChan <- edgeQUICSession
|
||||||
}()
|
}()
|
||||||
|
|
||||||
qc := testQUICConnection(udpListener.LocalAddr(), t)
|
qc := testQUICConnection(val, t)
|
||||||
go qc.Serve(ctx)
|
go qc.Serve(ctx)
|
||||||
|
|
||||||
edgeQUICSession := <-edgeQUICSessionChan
|
edgeQUICSession := <-edgeQUICSessionChan
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -100,7 +100,7 @@ require (
|
||||||
|
|
||||||
replace github.com/urfave/cli/v2 => github.com/ipostelnik/cli/v2 v2.3.1-0.20210324024421-b6ea8234fe3d
|
replace github.com/urfave/cli/v2 => github.com/ipostelnik/cli/v2 v2.3.1-0.20210324024421-b6ea8234fe3d
|
||||||
|
|
||||||
replace github.com/lucas-clemente/quic-go => github.com/chungthuang/quic-go v0.27.1-0.20220808144024-f036dcbe387e
|
replace github.com/lucas-clemente/quic-go => github.com/chungthuang/quic-go v0.27.1-0.20220809135021-ca330f1dec9f
|
||||||
|
|
||||||
// Avoid 'CVE-2022-21698'
|
// Avoid 'CVE-2022-21698'
|
||||||
replace github.com/prometheus/golang_client => github.com/prometheus/golang_client v1.12.1
|
replace github.com/prometheus/golang_client => github.com/prometheus/golang_client v1.12.1
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -109,8 +109,8 @@ github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cb
|
||||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE=
|
github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE=
|
||||||
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
|
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
|
||||||
github.com/chungthuang/quic-go v0.27.1-0.20220808144024-f036dcbe387e h1:HanU8Gx2eTN9X0miD0HNdl/doTs08ZLQzlQMIrGVHgk=
|
github.com/chungthuang/quic-go v0.27.1-0.20220809135021-ca330f1dec9f h1:UWC3XjwZzocdNCzzXxq9j/1SdHMZXhcTOsh/+gNRBUQ=
|
||||||
github.com/chungthuang/quic-go v0.27.1-0.20220808144024-f036dcbe387e/go.mod h1:oGz5DKK41cJt5+773+BSO9BXDsREY4HLf7+0odGAPO0=
|
github.com/chungthuang/quic-go v0.27.1-0.20220809135021-ca330f1dec9f/go.mod h1:oGz5DKK41cJt5+773+BSO9BXDsREY4HLf7+0odGAPO0=
|
||||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
|
|
|
@ -43,8 +43,7 @@ type client struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// make it possible to mock connection ID generation in the tests
|
// make it possible to mock connection ID for initial generation in the tests
|
||||||
generateConnectionID = protocol.GenerateConnectionID
|
|
||||||
generateConnectionIDForInitial = protocol.GenerateConnectionIDForInitial
|
generateConnectionIDForInitial = protocol.GenerateConnectionIDForInitial
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -193,7 +192,7 @@ func dialContext(
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
config = populateClientConfig(config, createdPacketConn)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -256,7 +255,7 @@ func newClient(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
srcConnID, err := generateConnectionID(config.ConnectionIDLength)
|
srcConnID, err := config.ConnectionIDGenerator.GenerateConnectionID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,7 @@ func validateConfig(config *Config) error {
|
||||||
// populateServerConfig populates fields in the quic.Config with their default values, if none are set
|
// populateServerConfig populates fields in the quic.Config with their default values, if none are set
|
||||||
// it may be called with nil
|
// it may be called with nil
|
||||||
func populateServerConfig(config *Config) *Config {
|
func populateServerConfig(config *Config) *Config {
|
||||||
config = populateConfig(config)
|
config = populateConfig(config, protocol.DefaultConnectionIDLength)
|
||||||
if config.ConnectionIDLength == 0 {
|
|
||||||
config.ConnectionIDLength = protocol.DefaultConnectionIDLength
|
|
||||||
}
|
|
||||||
if config.AcceptToken == nil {
|
if config.AcceptToken == nil {
|
||||||
config.AcceptToken = defaultAcceptToken
|
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
|
// populateClientConfig populates fields in the quic.Config with their default values, if none are set
|
||||||
// it may be called with nil
|
// it may be called with nil
|
||||||
func populateClientConfig(config *Config, createdPacketConn bool) *Config {
|
func populateClientConfig(config *Config, createdPacketConn bool) *Config {
|
||||||
config = populateConfig(config)
|
var defaultConnIdLen = protocol.DefaultConnectionIDLength
|
||||||
if config.ConnectionIDLength == 0 && !createdPacketConn {
|
if createdPacketConn {
|
||||||
config.ConnectionIDLength = protocol.DefaultConnectionIDLength
|
defaultConnIdLen = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config = populateConfig(config, defaultConnIdLen)
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
func populateConfig(config *Config) *Config {
|
func populateConfig(config *Config, defaultConnIDLen int) *Config {
|
||||||
if config == nil {
|
if config == nil {
|
||||||
config = &Config{}
|
config = &Config{}
|
||||||
}
|
}
|
||||||
|
@ -63,6 +62,9 @@ func populateConfig(config *Config) *Config {
|
||||||
if len(versions) == 0 {
|
if len(versions) == 0 {
|
||||||
versions = protocol.SupportedVersions
|
versions = protocol.SupportedVersions
|
||||||
}
|
}
|
||||||
|
if config.ConnectionIDLength == 0 {
|
||||||
|
config.ConnectionIDLength = defaultConnIDLen
|
||||||
|
}
|
||||||
handshakeIdleTimeout := protocol.DefaultHandshakeIdleTimeout
|
handshakeIdleTimeout := protocol.DefaultHandshakeIdleTimeout
|
||||||
if config.HandshakeIdleTimeout != 0 {
|
if config.HandshakeIdleTimeout != 0 {
|
||||||
handshakeIdleTimeout = config.HandshakeIdleTimeout
|
handshakeIdleTimeout = config.HandshakeIdleTimeout
|
||||||
|
@ -103,6 +105,10 @@ func populateConfig(config *Config) *Config {
|
||||||
if maxDatagrameFrameSize == 0 {
|
if maxDatagrameFrameSize == 0 {
|
||||||
maxDatagrameFrameSize = int64(protocol.DefaultMaxDatagramFrameSize)
|
maxDatagrameFrameSize = int64(protocol.DefaultMaxDatagramFrameSize)
|
||||||
}
|
}
|
||||||
|
connIDGenerator := config.ConnectionIDGenerator
|
||||||
|
if connIDGenerator == nil {
|
||||||
|
connIDGenerator = &protocol.DefaultConnectionIDGenerator{ConnLen: config.ConnectionIDLength}
|
||||||
|
}
|
||||||
|
|
||||||
return &Config{
|
return &Config{
|
||||||
Versions: versions,
|
Versions: versions,
|
||||||
|
@ -118,6 +124,7 @@ func populateConfig(config *Config) *Config {
|
||||||
MaxIncomingStreams: maxIncomingStreams,
|
MaxIncomingStreams: maxIncomingStreams,
|
||||||
MaxIncomingUniStreams: maxIncomingUniStreams,
|
MaxIncomingUniStreams: maxIncomingUniStreams,
|
||||||
ConnectionIDLength: config.ConnectionIDLength,
|
ConnectionIDLength: config.ConnectionIDLength,
|
||||||
|
ConnectionIDGenerator: connIDGenerator,
|
||||||
StatelessResetKey: config.StatelessResetKey,
|
StatelessResetKey: config.StatelessResetKey,
|
||||||
TokenStore: config.TokenStore,
|
TokenStore: config.TokenStore,
|
||||||
EnableDatagrams: config.EnableDatagrams,
|
EnableDatagrams: config.EnableDatagrams,
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type connIDGenerator struct {
|
type connIDGenerator struct {
|
||||||
connIDLen int
|
generator ConnectionIDGenerator
|
||||||
highestSeq uint64
|
highestSeq uint64
|
||||||
|
|
||||||
activeSrcConnIDs map[uint64]protocol.ConnectionID
|
activeSrcConnIDs map[uint64]protocol.ConnectionID
|
||||||
|
@ -35,10 +35,11 @@ func newConnIDGenerator(
|
||||||
retireConnectionID func(protocol.ConnectionID),
|
retireConnectionID func(protocol.ConnectionID),
|
||||||
replaceWithClosed func(protocol.ConnectionID, packetHandler),
|
replaceWithClosed func(protocol.ConnectionID, packetHandler),
|
||||||
queueControlFrame func(wire.Frame),
|
queueControlFrame func(wire.Frame),
|
||||||
|
generator ConnectionIDGenerator,
|
||||||
version protocol.VersionNumber,
|
version protocol.VersionNumber,
|
||||||
) *connIDGenerator {
|
) *connIDGenerator {
|
||||||
m := &connIDGenerator{
|
m := &connIDGenerator{
|
||||||
connIDLen: initialConnectionID.Len(),
|
generator: generator,
|
||||||
activeSrcConnIDs: make(map[uint64]protocol.ConnectionID),
|
activeSrcConnIDs: make(map[uint64]protocol.ConnectionID),
|
||||||
addConnectionID: addConnectionID,
|
addConnectionID: addConnectionID,
|
||||||
getStatelessResetToken: getStatelessResetToken,
|
getStatelessResetToken: getStatelessResetToken,
|
||||||
|
@ -54,7 +55,7 @@ func newConnIDGenerator(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *connIDGenerator) SetMaxActiveConnIDs(limit uint64) error {
|
func (m *connIDGenerator) SetMaxActiveConnIDs(limit uint64) error {
|
||||||
if m.connIDLen == 0 {
|
if m.generator.ConnectionIDLen() == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// The active_connection_id_limit transport parameter is the number of
|
// 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 {
|
func (m *connIDGenerator) issueNewConnID() error {
|
||||||
connID, err := protocol.GenerateConnectionID(m.connIDLen)
|
connID, err := m.generator.GenerateConnectionID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,6 +280,7 @@ var newConnection = func(
|
||||||
runner.Retire,
|
runner.Retire,
|
||||||
runner.ReplaceWithClosed,
|
runner.ReplaceWithClosed,
|
||||||
s.queueControlFrame,
|
s.queueControlFrame,
|
||||||
|
s.config.ConnectionIDGenerator,
|
||||||
s.version,
|
s.version,
|
||||||
)
|
)
|
||||||
s.preSetup()
|
s.preSetup()
|
||||||
|
@ -410,6 +411,7 @@ var newClientConnection = func(
|
||||||
runner.Retire,
|
runner.Retire,
|
||||||
runner.ReplaceWithClosed,
|
runner.ReplaceWithClosed,
|
||||||
s.queueControlFrame,
|
s.queueControlFrame,
|
||||||
|
s.config.ConnectionIDGenerator,
|
||||||
s.version,
|
s.version,
|
||||||
)
|
)
|
||||||
s.preSetup()
|
s.preSetup()
|
||||||
|
|
|
@ -211,6 +211,18 @@ type EarlyConnection interface {
|
||||||
NextConnection() Connection
|
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.
|
// Config contains all configuration data needed for a QUIC server or client.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// The QUIC versions that can be negotiated.
|
// 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.
|
// 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.
|
// When dialing on a packet conn, the ConnectionIDLength value must be the same for every Dial call.
|
||||||
ConnectionIDLength int
|
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.
|
// 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.
|
// 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.
|
// If this value is zero, the timeout is set to 5 seconds.
|
||||||
|
|
|
@ -67,3 +67,15 @@ func (c ConnectionID) String() string {
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%x", c.Bytes())
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -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 {
|
if err != nil {
|
||||||
return nil, err
|
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.
|
// If we're creating a new connection, the packet will be passed to the connection.
|
||||||
// The header will then be parsed again.
|
// 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 err != nil && err != wire.ErrUnsupportedVersion {
|
||||||
if s.config.Tracer != nil {
|
if s.config.Tracer != nil {
|
||||||
s.config.Tracer.DroppedPacket(p.remoteAddr, logging.PacketTypeNotDetermined, p.Size(), logging.PacketDropHeaderParseError)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
connID, err := protocol.GenerateConnectionID(s.config.ConnectionIDLength)
|
connID, err := s.config.ConnectionIDGenerator.GenerateConnectionID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
var conn quicConn
|
||||||
tracingID := nextConnTracingID()
|
tracingID := nextConnTracingID()
|
||||||
if added := s.connHandler.AddWithConnID(hdr.DestConnectionID, connID, func() packetHandler {
|
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.
|
// Log the Initial packet now.
|
||||||
// If no Retry is sent, the packet will be logged by the connection.
|
// If no Retry is sent, the packet will be logged by the connection.
|
||||||
(&wire.ExtendedHeader{Header: *hdr}).Log(s.logger)
|
(&wire.ExtendedHeader{Header: *hdr}).Log(s.logger)
|
||||||
srcConnID, err := protocol.GenerateConnectionID(s.config.ConnectionIDLength)
|
srcConnID, err := s.config.ConnectionIDGenerator.GenerateConnectionID()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -551,7 +551,7 @@ func (s *baseServer) sendRetry(remoteAddr net.Addr, hdr *wire.Header, info *pack
|
||||||
replyHdr.DestConnectionID = hdr.SrcConnectionID
|
replyHdr.DestConnectionID = hdr.SrcConnectionID
|
||||||
replyHdr.Token = token
|
replyHdr.Token = token
|
||||||
if s.logger.Debug() {
|
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")
|
s.logger.Debugf("-> Sending Retry")
|
||||||
replyHdr.Log(s.logger)
|
replyHdr.Log(s.logger)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,9 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setDF(rawConn syscall.RawConn) error {
|
func setDF(rawConn syscall.RawConn) error {
|
||||||
|
@ -29,7 +30,7 @@ func setDF(rawConn syscall.RawConn) error {
|
||||||
case errDFIPv4 != nil && errDFIPv6 == nil:
|
case errDFIPv4 != nil && errDFIPv6 == nil:
|
||||||
utils.DefaultLogger.Debugf("Setting DF for IPv6.")
|
utils.DefaultLogger.Debugf("Setting DF for IPv6.")
|
||||||
case errDFIPv4 != nil && errDFIPv6 != nil:
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc
|
||||||
github.com/json-iterator/go
|
github.com/json-iterator/go
|
||||||
# github.com/kylelemons/godebug v1.1.0
|
# github.com/kylelemons/godebug v1.1.0
|
||||||
## explicit; go 1.11
|
## 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
|
## explicit; go 1.16
|
||||||
github.com/lucas-clemente/quic-go
|
github.com/lucas-clemente/quic-go
|
||||||
github.com/lucas-clemente/quic-go/internal/ackhandler
|
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/server
|
||||||
zombiezen.com/go/capnproto2/std/capnp/rpc
|
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/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
|
# github.com/prometheus/golang_client => github.com/prometheus/golang_client v1.12.1
|
||||||
# gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.1
|
# gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.1
|
||||||
|
|
Loading…
Reference in New Issue