From e71b88fcaa39d3ee0b83851de125dc7d83559cf0 Mon Sep 17 00:00:00 2001 From: cthuang Date: Wed, 10 Nov 2021 18:45:26 +0000 Subject: [PATCH] TUN-5408: Update quic package to v0.24.0 --- go.mod | 2 +- go.sum | 2 + .../lucas-clemente/quic-go/.golangci.yml | 4 -- .../lucas-clemente/quic-go/README.md | 13 +++++ .../lucas-clemente/quic-go/conn_generic.go | 3 ++ .../quic-go/conn_helper_darwin.go | 6 ++- .../quic-go/conn_helper_freebsd.go | 6 ++- .../quic-go/conn_helper_linux.go | 6 ++- .../lucas-clemente/quic-go/conn_oob.go | 50 ++++--------------- .../lucas-clemente/quic-go/conn_windows.go | 6 ++- .../lucas-clemente/quic-go/interface.go | 1 + .../quic-go/internal/qtls/go116.go | 4 +- .../quic-go/internal/qtls/go117.go | 1 + .../quic-go/internal/qtls/go118.go | 1 + .../lucas-clemente/quic-go/receive_stream.go | 3 -- .../lucas-clemente/quic-go/session.go | 14 ++++-- .../lucas-clemente/quic-go/tools.go | 1 + vendor/modules.txt | 2 +- 18 files changed, 66 insertions(+), 59 deletions(-) diff --git a/go.mod b/go.mod index 4c88a044..83201f55 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/json-iterator/go v1.1.10 github.com/kr/text v0.2.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/lucas-clemente/quic-go v0.23.0 + github.com/lucas-clemente/quic-go v0.24.0 github.com/mattn/go-colorable v0.1.8 github.com/miekg/dns v1.1.31 github.com/mitchellh/go-homedir v1.1.0 diff --git a/go.sum b/go.sum index e213baa5..7bc5313c 100644 --- a/go.sum +++ b/go.sum @@ -422,6 +422,8 @@ github.com/liquidweb/liquidweb-go v1.6.0/go.mod h1:UDcVnAMDkZxpw4Y7NOHkqoeiGacVL github.com/lucas-clemente/quic-go v0.13.1/go.mod h1:Vn3/Fb0/77b02SGhQk36KzOUmXgVpFfizUfW5WMaqyU= github.com/lucas-clemente/quic-go v0.23.0 h1:5vFnKtZ6nHDFsc/F3uuiF4T3y/AXaQdxjUqiVw26GZE= github.com/lucas-clemente/quic-go v0.23.0/go.mod h1:paZuzjXCE5mj6sikVLMvqXk8lJV2AsqtJ6bDhjEfxx0= +github.com/lucas-clemente/quic-go v0.24.0 h1:ToR7SIIEdrgOhgVTHvPgdVRJfgVy+N0wQAagH7L4d5g= +github.com/lucas-clemente/quic-go v0.24.0/go.mod h1:paZuzjXCE5mj6sikVLMvqXk8lJV2AsqtJ6bDhjEfxx0= github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s= github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= diff --git a/vendor/github.com/lucas-clemente/quic-go/.golangci.yml b/vendor/github.com/lucas-clemente/quic-go/.golangci.yml index 381ba3bf..05ddb79a 100644 --- a/vendor/github.com/lucas-clemente/quic-go/.golangci.yml +++ b/vendor/github.com/lucas-clemente/quic-go/.golangci.yml @@ -21,7 +21,6 @@ linters: - depguard - exhaustive - exportloopref - - goconst - goimports - gofmt # redundant, since gofmt *should* be a no-op after gofumpt - gofumpt @@ -41,9 +40,6 @@ linters: issues: exclude-rules: - - path: qlog/ - linters: - - goconst - path: internal/qtls linters: - depguard diff --git a/vendor/github.com/lucas-clemente/quic-go/README.md b/vendor/github.com/lucas-clemente/quic-go/README.md index fb8297af..f047525e 100644 --- a/vendor/github.com/lucas-clemente/quic-go/README.md +++ b/vendor/github.com/lucas-clemente/quic-go/README.md @@ -44,6 +44,19 @@ http.Client{ } ``` +## Projects using quic-go + +| Project | Description | Stars | +|------------------------------------------------------|--------------------------------------------------------------------------------------------------------|-------| +| [algernon](https://github.com/xyproto/algernon) | Small self-contained pure-Go web server with Lua, Markdown, HTTP/2, QUIC, Redis and PostgreSQL support | ![GitHub Repo stars](https://img.shields.io/github/stars/xyproto/algernon?style=flat-square) | +| [caddy](https://github.com/caddyserver/caddy/) | Fast, multi-platform web server with automatic HTTPS | ![GitHub Repo stars](https://img.shields.io/github/stars/caddyserver/caddy?style=flat-square) | +| [go-ipfs](https://github.com/ipfs/go-ipfs) | IPFS implementation in go | ![GitHub Repo stars](https://img.shields.io/github/stars/ipfs/go-ipfs?style=flat-square) | +| [nextdns](https://github.com/nextdns/nextdns) | NextDNS CLI client (DoH Proxy) | ![GitHub Repo stars](https://img.shields.io/github/stars/nextdns/nextdns?style=flat-square) | +| [syncthing](https://github.com/syncthing/syncthing/) | Open Source Continuous File Synchronization | ![GitHub Repo stars](https://img.shields.io/github/stars/syncthing/syncthing?style=flat-square) | +| [traefik](https://github.com/traefik/traefik) | The Cloud Native Application Proxy | ![GitHub Repo stars](https://img.shields.io/github/stars/traefik/traefik?style=flat-square) | +| [v2ray-core](https://github.com/v2fly/v2ray-core) | A platform for building proxies to bypass network restrictions | ![GitHub Repo stars](https://img.shields.io/github/stars/v2fly/v2ray-core?style=flat-square) | + + ## Contributing We are always happy to welcome new contributors! We have a number of self-contained issues that are suitable for first-time contributors, they are tagged with [help wanted](https://github.com/lucas-clemente/quic-go/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22). If you have any questions, please feel free to reach out by opening an issue or leaving a comment. diff --git a/vendor/github.com/lucas-clemente/quic-go/conn_generic.go b/vendor/github.com/lucas-clemente/quic-go/conn_generic.go index 451a70ae..526778c1 100644 --- a/vendor/github.com/lucas-clemente/quic-go/conn_generic.go +++ b/vendor/github.com/lucas-clemente/quic-go/conn_generic.go @@ -1,9 +1,12 @@ +//go:build !darwin && !linux && !freebsd && !windows // +build !darwin,!linux,!freebsd,!windows package quic import "net" +const disablePathMTUDiscovery = false + func newConn(c net.PacketConn) (connection, error) { return &basicConn{PacketConn: c}, nil } diff --git a/vendor/github.com/lucas-clemente/quic-go/conn_helper_darwin.go b/vendor/github.com/lucas-clemente/quic-go/conn_helper_darwin.go index 591e09fd..fdab73b6 100644 --- a/vendor/github.com/lucas-clemente/quic-go/conn_helper_darwin.go +++ b/vendor/github.com/lucas-clemente/quic-go/conn_helper_darwin.go @@ -1,10 +1,14 @@ +//go:build darwin // +build darwin package quic import "golang.org/x/sys/unix" -const msgTypeIPTOS = unix.IP_RECVTOS +const ( + msgTypeIPTOS = unix.IP_RECVTOS + disablePathMTUDiscovery = false +) const ( ipv4RECVPKTINFO = unix.IP_RECVPKTINFO diff --git a/vendor/github.com/lucas-clemente/quic-go/conn_helper_freebsd.go b/vendor/github.com/lucas-clemente/quic-go/conn_helper_freebsd.go index 96f28b53..e22f9861 100644 --- a/vendor/github.com/lucas-clemente/quic-go/conn_helper_freebsd.go +++ b/vendor/github.com/lucas-clemente/quic-go/conn_helper_freebsd.go @@ -1,10 +1,14 @@ +//go:build freebsd // +build freebsd package quic import "golang.org/x/sys/unix" -const msgTypeIPTOS = unix.IP_RECVTOS +const ( + msgTypeIPTOS = unix.IP_RECVTOS + disablePathMTUDiscovery = false +) const ( ipv4RECVPKTINFO = 0x7 diff --git a/vendor/github.com/lucas-clemente/quic-go/conn_helper_linux.go b/vendor/github.com/lucas-clemente/quic-go/conn_helper_linux.go index 9ef92f13..4aa04dc9 100644 --- a/vendor/github.com/lucas-clemente/quic-go/conn_helper_linux.go +++ b/vendor/github.com/lucas-clemente/quic-go/conn_helper_linux.go @@ -1,10 +1,14 @@ +//go:build linux // +build linux package quic import "golang.org/x/sys/unix" -const msgTypeIPTOS = unix.IP_TOS +const ( + msgTypeIPTOS = unix.IP_TOS + disablePathMTUDiscovery = false +) const ( ipv4RECVPKTINFO = unix.IP_PKTINFO diff --git a/vendor/github.com/lucas-clemente/quic-go/conn_oob.go b/vendor/github.com/lucas-clemente/quic-go/conn_oob.go index 8f888a62..b4678137 100644 --- a/vendor/github.com/lucas-clemente/quic-go/conn_oob.go +++ b/vendor/github.com/lucas-clemente/quic-go/conn_oob.go @@ -1,3 +1,4 @@ +//go:build darwin || linux || freebsd // +build darwin linux freebsd package quic @@ -7,10 +8,8 @@ import ( "errors" "fmt" "net" - "runtime" "syscall" "time" - "unsafe" "golang.org/x/net/ipv4" "golang.org/x/net/ipv6" @@ -238,50 +237,21 @@ func (info *packetInfo) OOB() []byte { // struct in_addr ipi_spec_dst; /* Local address */ // struct in_addr ipi_addr; /* Header Destination address */ // }; - msgLen := 12 - if runtime.GOOS == "freebsd" { - msgLen = 4 + cm := ipv4.ControlMessage{ + Src: ip4, + IfIndex: int(info.ifIndex), } - cmsglen := cmsgLen(msgLen) - oob := make([]byte, cmsglen) - cmsg := (*syscall.Cmsghdr)(unsafe.Pointer(&oob[0])) - cmsg.Level = syscall.IPPROTO_TCP - cmsg.Type = msgTypeIPv4PKTINFO - cmsg.SetLen(cmsglen) - off := cmsgLen(0) - if runtime.GOOS != "freebsd" { - // FreeBSD does not support in_pktinfo, just an in_addr is sent - binary.LittleEndian.PutUint32(oob[off:], info.ifIndex) - off += 4 - } - copy(oob[off:], ip4) - return oob + return cm.Marshal() } else if len(info.addr) == 16 { // struct in6_pktinfo { // struct in6_addr ipi6_addr; /* src/dst IPv6 address */ // unsigned int ipi6_ifindex; /* send/recv interface index */ // }; - const msgLen = 20 - cmsglen := cmsgLen(msgLen) - oob := make([]byte, cmsglen) - cmsg := (*syscall.Cmsghdr)(unsafe.Pointer(&oob[0])) - cmsg.Level = syscall.IPPROTO_IPV6 - cmsg.Type = msgTypeIPv6PKTINFO - cmsg.SetLen(cmsglen) - off := cmsgLen(0) - off += copy(oob[off:], info.addr) - binary.LittleEndian.PutUint32(oob[off:], info.ifIndex) - return oob + cm := ipv6.ControlMessage{ + Src: info.addr, + IfIndex: int(info.ifIndex), + } + return cm.Marshal() } return nil } - -func cmsgLen(datalen int) int { - return cmsgAlign(syscall.SizeofCmsghdr) + datalen -} - -func cmsgAlign(salen int) int { - const sizeOfPtr = 0x8 - salign := sizeOfPtr - return (salen + salign - 1) & ^(salign - 1) -} diff --git a/vendor/github.com/lucas-clemente/quic-go/conn_windows.go b/vendor/github.com/lucas-clemente/quic-go/conn_windows.go index 2540d851..a6e591b6 100644 --- a/vendor/github.com/lucas-clemente/quic-go/conn_windows.go +++ b/vendor/github.com/lucas-clemente/quic-go/conn_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package quic @@ -11,7 +12,10 @@ import ( "golang.org/x/sys/windows" ) -const IP_DONTFRAGMENT = 14 +const ( + disablePathMTUDiscovery = true + IP_DONTFRAGMENT = 14 +) func newConn(c OOBCapablePacketConn) (connection, error) { rawConn, err := c.SyscallConn() diff --git a/vendor/github.com/lucas-clemente/quic-go/interface.go b/vendor/github.com/lucas-clemente/quic-go/interface.go index eb1faae5..36d8b9b3 100644 --- a/vendor/github.com/lucas-clemente/quic-go/interface.go +++ b/vendor/github.com/lucas-clemente/quic-go/interface.go @@ -283,6 +283,7 @@ type Config struct { KeepAlive bool // DisablePathMTUDiscovery disables Path MTU Discovery (RFC 8899). // Packets will then be at most 1252 (IPv4) / 1232 (IPv6) bytes in size. + // Note that Path MTU discovery is always disabled on Windows, see https://github.com/lucas-clemente/quic-go/issues/3273. DisablePathMTUDiscovery bool // DisableVersionNegotiationPackets disables the sending of Version Negotiation packets. // This can be useful if version information is exchanged out-of-band. diff --git a/vendor/github.com/lucas-clemente/quic-go/internal/qtls/go116.go b/vendor/github.com/lucas-clemente/quic-go/internal/qtls/go116.go index 35826df4..e3024624 100644 --- a/vendor/github.com/lucas-clemente/quic-go/internal/qtls/go116.go +++ b/vendor/github.com/lucas-clemente/quic-go/internal/qtls/go116.go @@ -1,5 +1,5 @@ -// +build go1.16 -// +build !go1.17 +//go:build go1.16 && !go1.17 +// +build go1.16,!go1.17 package qtls diff --git a/vendor/github.com/lucas-clemente/quic-go/internal/qtls/go117.go b/vendor/github.com/lucas-clemente/quic-go/internal/qtls/go117.go index 8e076101..64ff3b62 100644 --- a/vendor/github.com/lucas-clemente/quic-go/internal/qtls/go117.go +++ b/vendor/github.com/lucas-clemente/quic-go/internal/qtls/go117.go @@ -1,3 +1,4 @@ +//go:build go1.17 // +build go1.17 package qtls diff --git a/vendor/github.com/lucas-clemente/quic-go/internal/qtls/go118.go b/vendor/github.com/lucas-clemente/quic-go/internal/qtls/go118.go index fa2df5fd..b443f089 100644 --- a/vendor/github.com/lucas-clemente/quic-go/internal/qtls/go118.go +++ b/vendor/github.com/lucas-clemente/quic-go/internal/qtls/go118.go @@ -1,3 +1,4 @@ +//go:build go1.18 // +build go1.18 package qtls diff --git a/vendor/github.com/lucas-clemente/quic-go/receive_stream.go b/vendor/github.com/lucas-clemente/quic-go/receive_stream.go index cca3f709..f9a1e066 100644 --- a/vendor/github.com/lucas-clemente/quic-go/receive_stream.go +++ b/vendor/github.com/lucas-clemente/quic-go/receive_stream.go @@ -166,13 +166,10 @@ func (s *receiveStream) readImpl(p []byte) (bool /*stream completed */, int, err return false, bytesRead, fmt.Errorf("BUG: readPosInFrame (%d) > frame.DataLen (%d) in stream.Read", s.readPosInFrame, len(s.currentFrame)) } - s.mutex.Unlock() - m := copy(p[bytesRead:], s.currentFrame[s.readPosInFrame:]) s.readPosInFrame += m bytesRead += m - s.mutex.Lock() // when a RESET_STREAM was received, the was already informed about the final byteOffset for this stream if !s.resetRemotely { s.flowController.AddBytesRead(protocol.ByteCount(m)) diff --git a/vendor/github.com/lucas-clemente/quic-go/session.go b/vendor/github.com/lucas-clemente/quic-go/session.go index 24bde4c3..713f15fc 100644 --- a/vendor/github.com/lucas-clemente/quic-go/session.go +++ b/vendor/github.com/lucas-clemente/quic-go/session.go @@ -130,6 +130,10 @@ func (e *errCloseForRecreating) Error() string { var sessionTracingID uint64 // to be accessed atomically func nextSessionTracingID() uint64 { return atomic.AddUint64(&sessionTracingID, 1) } +func pathMTUDiscoveryEnabled(config *Config) bool { + return !disablePathMTUDiscovery && !config.DisablePathMTUDiscovery +} + // A Session is a QUIC session type session struct { // Destination connection ID used during the handshake. @@ -590,7 +594,9 @@ runLoop: default: } } - } else if !processedUndecryptablePacket { + } + // If we processed any undecryptable packets, jump to the resetting of the timers directly. + if !processedUndecryptablePacket { select { case closeErr = <-s.closeChan: break runLoop @@ -743,7 +749,7 @@ func (s *session) maybeResetTimer() { deadline = s.idleTimeoutStartTime().Add(s.idleTimeout) } } - if s.handshakeConfirmed && !s.config.DisablePathMTUDiscovery { + if s.handshakeConfirmed && pathMTUDiscoveryEnabled(s.config) { if probeTime := s.mtuDiscoverer.NextProbeTime(); !probeTime.IsZero() { deadline = utils.MinTime(deadline, probeTime) } @@ -807,7 +813,7 @@ func (s *session) handleHandshakeConfirmed() { s.sentPacketHandler.SetHandshakeConfirmed() s.cryptoStreamHandler.SetHandshakeConfirmed() - if !s.config.DisablePathMTUDiscovery { + if pathMTUDiscoveryEnabled(s.config) { maxPacketSize := s.peerParams.MaxUDPPayloadSize if maxPacketSize == 0 { maxPacketSize = protocol.MaxByteCount @@ -1768,7 +1774,7 @@ func (s *session) sendPacket() (bool, error) { s.sendQueue.Send(packet.buffer) return true, nil } - if !s.config.DisablePathMTUDiscovery && s.mtuDiscoverer.ShouldSendProbe(now) { + if pathMTUDiscoveryEnabled(s.config) && s.mtuDiscoverer.ShouldSendProbe(now) { packet, err := s.packer.PackMTUProbePacket(s.mtuDiscoverer.GetPing()) if err != nil { return false, err diff --git a/vendor/github.com/lucas-clemente/quic-go/tools.go b/vendor/github.com/lucas-clemente/quic-go/tools.go index 12807f90..ee68fafb 100644 --- a/vendor/github.com/lucas-clemente/quic-go/tools.go +++ b/vendor/github.com/lucas-clemente/quic-go/tools.go @@ -1,3 +1,4 @@ +//go:build tools // +build tools package quic diff --git a/vendor/modules.txt b/vendor/modules.txt index 5b1a9180..ce8019a2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -194,7 +194,7 @@ github.com/json-iterator/go ## explicit # github.com/kylelemons/godebug v1.1.0 ## explicit; go 1.11 -# github.com/lucas-clemente/quic-go v0.23.0 +# github.com/lucas-clemente/quic-go v0.24.0 ## explicit; go 1.16 github.com/lucas-clemente/quic-go github.com/lucas-clemente/quic-go/internal/ackhandler