Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
update quic-go to v0.21.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 11, 2021
1 parent 6f581f3 commit 144c18c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 39 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/libp2p/go-libp2p-core v0.8.0
github.com/libp2p/go-libp2p-tls v0.1.3
github.com/libp2p/go-netroute v0.1.3
github.com/lucas-clemente/quic-go v0.20.1
github.com/lucas-clemente/quic-go v0.21.0-rc.1
github.com/minio/sha256-simd v0.1.1
github.com/multiformats/go-multiaddr v0.3.1
github.com/multiformats/go-multiaddr-fmt v0.1.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ github.com/libp2p/go-sockaddr v0.0.2 h1:tCuXfpA9rq7llM/v834RKc/Xvovy/AqM9kHvTV/j
github.com/libp2p/go-sockaddr v0.0.2/go.mod h1:syPvOmNs24S3dFVGJA1/mrqdeijPxLV2Le3BRLKd68k=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
github.com/lucas-clemente/quic-go v0.20.1 h1:hb5m76V8QS/8Nw/suHvXqo3BMHAozvIkcnzpJdpanSk=
github.com/lucas-clemente/quic-go v0.20.1/go.mod h1:fZq/HUDIM+mW6X6wtzORjC0E/WDBMKe5Hf9bgjISwLk=
github.com/lucas-clemente/quic-go v0.21.0-rc.1 h1:RtmBqOc4AUWsjyDIMBp7Lk+f6wcEOS/HXaVMQWZk3eY=
github.com/lucas-clemente/quic-go v0.21.0-rc.1/go.mod h1:T+SpiNEBFsIo/TO6N8XDIhpnx3LMlNL/b9vyQtuvj1M=
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
Expand Down
12 changes: 6 additions & 6 deletions stream.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package libp2pquic

import (
"errors"

"github.com/libp2p/go-libp2p-core/mux"

quic "github.com/lucas-clemente/quic-go"
"github.com/lucas-clemente/quic-go"
)

const (
reset quic.ErrorCode = 0
reset quic.StreamErrorCode = 0
)

type stream struct {
Expand All @@ -16,19 +18,17 @@ type stream struct {

func (s *stream) Read(b []byte) (n int, err error) {
n, err = s.Stream.Read(b)
if serr, ok := err.(quic.StreamError); ok && serr.Canceled() {
if errors.Is(err, &quic.StreamError{}) {
err = mux.ErrReset
}

return n, err
}

func (s *stream) Write(b []byte) (n int, err error) {
n, err = s.Stream.Write(b)
if serr, ok := err.(quic.StreamError); ok && serr.Canceled() {
if errors.Is(err, &quic.StreamError{}) {
err = mux.ErrReset
}

return n, err
}

Expand Down
66 changes: 37 additions & 29 deletions tracer_metrics.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package libp2pquic

import (
"context"
"errors"
"fmt"
"net"
"sync"
"time"

"github.com/lucas-clemente/quic-go/logging"
"github.com/prometheus/client_golang/prometheus"

"github.com/lucas-clemente/quic-go"
"github.com/lucas-clemente/quic-go/logging"
)

var (
Expand Down Expand Up @@ -164,7 +169,9 @@ func init() {

type metricsTracer struct{}

func (m *metricsTracer) TracerForConnection(p logging.Perspective, connID logging.ConnectionID) logging.ConnectionTracer {
var _ logging.Tracer = &metricsTracer{}

func (m *metricsTracer) TracerForConnection(_ context.Context, p logging.Perspective, connID logging.ConnectionID) logging.ConnectionTracer {
return &metricsConnTracer{perspective: p, connID: connID}
}

Expand Down Expand Up @@ -217,37 +224,38 @@ func (m *metricsConnTracer) StartedConnection(net.Addr, net.Addr, logging.Connec
collector.AddConn(m.connID.String(), m)
}

func (m *metricsConnTracer) ClosedConnection(r logging.CloseReason) {
if _, _, ok := r.ApplicationError(); ok {
func (m *metricsConnTracer) NegotiatedVersion(chosen quic.VersionNumber, clientVersions []quic.VersionNumber, serverVersions []quic.VersionNumber) {
}

func (m *metricsConnTracer) ClosedConnection(e error) {
var (
transportErr *quic.TransportError
remote bool
desc string
)

switch {
case errors.Is(e, &quic.ApplicationError{}):
return
}
var desc string
side := "local"
if _, ok := r.StatelessReset(); ok {
side = "remote"
case errors.As(e, &transportErr):
remote = transportErr.Remote
desc = transportErr.ErrorCode.String()
case errors.Is(e, &quic.StatelessResetError{}):
remote = true
desc = "stateless_reset"
}
if _, ok := r.VersionNegotiation(); ok {
case errors.Is(e, &quic.VersionNegotiationError{}):
desc = "version_negotiation"
case errors.Is(e, &quic.IdleTimeoutError{}):
desc = "idle_timeout"
case errors.Is(e, &quic.HandshakeTimeoutError{}):
desc = "handshake_timeout"
default:
desc = fmt.Sprintf("unknown error: %v", e)
}
if timeout, ok := r.Timeout(); ok {
switch timeout {
case logging.TimeoutReasonHandshake:
desc = "handshake_timeout"
case logging.TimeoutReasonIdle:
desc = "idle_timeout"
default:
desc = "unknown timeout"
}
}
if code, remote, ok := r.TransportError(); ok {
if code == 0xc { // ignore APPLICATION_ERROR
return
}
if remote {
side = "remote"
}
desc = code.String()

side := "local"
if remote {
side = "remote"
}
connErrors.WithLabelValues(side, desc).Inc()
}
Expand Down
2 changes: 1 addition & 1 deletion transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var quicConfig = &quic.Config{
return true
},
KeepAlive: true,
Versions: []quic.VersionNumber{quic.VersionDraft29, quic.VersionDraft32},
Versions: []quic.VersionNumber{quic.VersionDraft29},
}

const statelessResetKeyInfo = "libp2p quic stateless reset key"
Expand Down

0 comments on commit 144c18c

Please sign in to comment.