TUN-5408: Update quic package to v0.24.0
This commit is contained in:
parent
157f5d1412
commit
e71b88fcaa
2
go.mod
2
go.mod
|
@ -28,7 +28,7 @@ require (
|
||||||
github.com/json-iterator/go v1.1.10
|
github.com/json-iterator/go v1.1.10
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/kylelemons/godebug v1.1.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/mattn/go-colorable v0.1.8
|
||||||
github.com/miekg/dns v1.1.31
|
github.com/miekg/dns v1.1.31
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
|
|
2
go.sum
2
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.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 h1:5vFnKtZ6nHDFsc/F3uuiF4T3y/AXaQdxjUqiVw26GZE=
|
||||||
github.com/lucas-clemente/quic-go v0.23.0/go.mod h1:paZuzjXCE5mj6sikVLMvqXk8lJV2AsqtJ6bDhjEfxx0=
|
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.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 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
||||||
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
|
|
|
@ -21,7 +21,6 @@ linters:
|
||||||
- depguard
|
- depguard
|
||||||
- exhaustive
|
- exhaustive
|
||||||
- exportloopref
|
- exportloopref
|
||||||
- goconst
|
|
||||||
- goimports
|
- goimports
|
||||||
- gofmt # redundant, since gofmt *should* be a no-op after gofumpt
|
- gofmt # redundant, since gofmt *should* be a no-op after gofumpt
|
||||||
- gofumpt
|
- gofumpt
|
||||||
|
@ -41,9 +40,6 @@ linters:
|
||||||
|
|
||||||
issues:
|
issues:
|
||||||
exclude-rules:
|
exclude-rules:
|
||||||
- path: qlog/
|
|
||||||
linters:
|
|
||||||
- goconst
|
|
||||||
- path: internal/qtls
|
- path: internal/qtls
|
||||||
linters:
|
linters:
|
||||||
- depguard
|
- depguard
|
||||||
|
|
|
@ -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
|
## 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.
|
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.
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
|
//go:build !darwin && !linux && !freebsd && !windows
|
||||||
// +build !darwin,!linux,!freebsd,!windows
|
// +build !darwin,!linux,!freebsd,!windows
|
||||||
|
|
||||||
package quic
|
package quic
|
||||||
|
|
||||||
import "net"
|
import "net"
|
||||||
|
|
||||||
|
const disablePathMTUDiscovery = false
|
||||||
|
|
||||||
func newConn(c net.PacketConn) (connection, error) {
|
func newConn(c net.PacketConn) (connection, error) {
|
||||||
return &basicConn{PacketConn: c}, nil
|
return &basicConn{PacketConn: c}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
|
//go:build darwin
|
||||||
// +build darwin
|
// +build darwin
|
||||||
|
|
||||||
package quic
|
package quic
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
const msgTypeIPTOS = unix.IP_RECVTOS
|
const (
|
||||||
|
msgTypeIPTOS = unix.IP_RECVTOS
|
||||||
|
disablePathMTUDiscovery = false
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ipv4RECVPKTINFO = unix.IP_RECVPKTINFO
|
ipv4RECVPKTINFO = unix.IP_RECVPKTINFO
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
|
//go:build freebsd
|
||||||
// +build freebsd
|
// +build freebsd
|
||||||
|
|
||||||
package quic
|
package quic
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
const msgTypeIPTOS = unix.IP_RECVTOS
|
const (
|
||||||
|
msgTypeIPTOS = unix.IP_RECVTOS
|
||||||
|
disablePathMTUDiscovery = false
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ipv4RECVPKTINFO = 0x7
|
ipv4RECVPKTINFO = 0x7
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
|
//go:build linux
|
||||||
// +build linux
|
// +build linux
|
||||||
|
|
||||||
package quic
|
package quic
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
const msgTypeIPTOS = unix.IP_TOS
|
const (
|
||||||
|
msgTypeIPTOS = unix.IP_TOS
|
||||||
|
disablePathMTUDiscovery = false
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ipv4RECVPKTINFO = unix.IP_PKTINFO
|
ipv4RECVPKTINFO = unix.IP_PKTINFO
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build darwin || linux || freebsd
|
||||||
// +build darwin linux freebsd
|
// +build darwin linux freebsd
|
||||||
|
|
||||||
package quic
|
package quic
|
||||||
|
@ -7,10 +8,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"runtime"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"golang.org/x/net/ipv4"
|
"golang.org/x/net/ipv4"
|
||||||
"golang.org/x/net/ipv6"
|
"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_spec_dst; /* Local address */
|
||||||
// struct in_addr ipi_addr; /* Header Destination address */
|
// struct in_addr ipi_addr; /* Header Destination address */
|
||||||
// };
|
// };
|
||||||
msgLen := 12
|
cm := ipv4.ControlMessage{
|
||||||
if runtime.GOOS == "freebsd" {
|
Src: ip4,
|
||||||
msgLen = 4
|
IfIndex: int(info.ifIndex),
|
||||||
}
|
}
|
||||||
cmsglen := cmsgLen(msgLen)
|
return cm.Marshal()
|
||||||
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
|
|
||||||
} else if len(info.addr) == 16 {
|
} else if len(info.addr) == 16 {
|
||||||
// struct in6_pktinfo {
|
// struct in6_pktinfo {
|
||||||
// struct in6_addr ipi6_addr; /* src/dst IPv6 address */
|
// struct in6_addr ipi6_addr; /* src/dst IPv6 address */
|
||||||
// unsigned int ipi6_ifindex; /* send/recv interface index */
|
// unsigned int ipi6_ifindex; /* send/recv interface index */
|
||||||
// };
|
// };
|
||||||
const msgLen = 20
|
cm := ipv6.ControlMessage{
|
||||||
cmsglen := cmsgLen(msgLen)
|
Src: info.addr,
|
||||||
oob := make([]byte, cmsglen)
|
IfIndex: int(info.ifIndex),
|
||||||
cmsg := (*syscall.Cmsghdr)(unsafe.Pointer(&oob[0]))
|
}
|
||||||
cmsg.Level = syscall.IPPROTO_IPV6
|
return cm.Marshal()
|
||||||
cmsg.Type = msgTypeIPv6PKTINFO
|
|
||||||
cmsg.SetLen(cmsglen)
|
|
||||||
off := cmsgLen(0)
|
|
||||||
off += copy(oob[off:], info.addr)
|
|
||||||
binary.LittleEndian.PutUint32(oob[off:], info.ifIndex)
|
|
||||||
return oob
|
|
||||||
}
|
}
|
||||||
return nil
|
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)
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build windows
|
||||||
// +build windows
|
// +build windows
|
||||||
|
|
||||||
package quic
|
package quic
|
||||||
|
@ -11,7 +12,10 @@ import (
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
const IP_DONTFRAGMENT = 14
|
const (
|
||||||
|
disablePathMTUDiscovery = true
|
||||||
|
IP_DONTFRAGMENT = 14
|
||||||
|
)
|
||||||
|
|
||||||
func newConn(c OOBCapablePacketConn) (connection, error) {
|
func newConn(c OOBCapablePacketConn) (connection, error) {
|
||||||
rawConn, err := c.SyscallConn()
|
rawConn, err := c.SyscallConn()
|
||||||
|
|
|
@ -283,6 +283,7 @@ type Config struct {
|
||||||
KeepAlive bool
|
KeepAlive bool
|
||||||
// DisablePathMTUDiscovery disables Path MTU Discovery (RFC 8899).
|
// DisablePathMTUDiscovery disables Path MTU Discovery (RFC 8899).
|
||||||
// Packets will then be at most 1252 (IPv4) / 1232 (IPv6) bytes in size.
|
// 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
|
DisablePathMTUDiscovery bool
|
||||||
// DisableVersionNegotiationPackets disables the sending of Version Negotiation packets.
|
// DisableVersionNegotiationPackets disables the sending of Version Negotiation packets.
|
||||||
// This can be useful if version information is exchanged out-of-band.
|
// This can be useful if version information is exchanged out-of-band.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// +build go1.16
|
//go:build go1.16 && !go1.17
|
||||||
// +build !go1.17
|
// +build go1.16,!go1.17
|
||||||
|
|
||||||
package qtls
|
package qtls
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build go1.17
|
||||||
// +build go1.17
|
// +build go1.17
|
||||||
|
|
||||||
package qtls
|
package qtls
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build go1.18
|
||||||
// +build go1.18
|
// +build go1.18
|
||||||
|
|
||||||
package qtls
|
package qtls
|
||||||
|
|
|
@ -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))
|
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:])
|
m := copy(p[bytesRead:], s.currentFrame[s.readPosInFrame:])
|
||||||
s.readPosInFrame += m
|
s.readPosInFrame += m
|
||||||
bytesRead += m
|
bytesRead += m
|
||||||
|
|
||||||
s.mutex.Lock()
|
|
||||||
// when a RESET_STREAM was received, the was already informed about the final byteOffset for this stream
|
// when a RESET_STREAM was received, the was already informed about the final byteOffset for this stream
|
||||||
if !s.resetRemotely {
|
if !s.resetRemotely {
|
||||||
s.flowController.AddBytesRead(protocol.ByteCount(m))
|
s.flowController.AddBytesRead(protocol.ByteCount(m))
|
||||||
|
|
|
@ -130,6 +130,10 @@ func (e *errCloseForRecreating) Error() string {
|
||||||
var sessionTracingID uint64 // to be accessed atomically
|
var sessionTracingID uint64 // to be accessed atomically
|
||||||
func nextSessionTracingID() uint64 { return atomic.AddUint64(&sessionTracingID, 1) }
|
func nextSessionTracingID() uint64 { return atomic.AddUint64(&sessionTracingID, 1) }
|
||||||
|
|
||||||
|
func pathMTUDiscoveryEnabled(config *Config) bool {
|
||||||
|
return !disablePathMTUDiscovery && !config.DisablePathMTUDiscovery
|
||||||
|
}
|
||||||
|
|
||||||
// A Session is a QUIC session
|
// A Session is a QUIC session
|
||||||
type session struct {
|
type session struct {
|
||||||
// Destination connection ID used during the handshake.
|
// Destination connection ID used during the handshake.
|
||||||
|
@ -590,7 +594,9 @@ runLoop:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if !processedUndecryptablePacket {
|
}
|
||||||
|
// If we processed any undecryptable packets, jump to the resetting of the timers directly.
|
||||||
|
if !processedUndecryptablePacket {
|
||||||
select {
|
select {
|
||||||
case closeErr = <-s.closeChan:
|
case closeErr = <-s.closeChan:
|
||||||
break runLoop
|
break runLoop
|
||||||
|
@ -743,7 +749,7 @@ func (s *session) maybeResetTimer() {
|
||||||
deadline = s.idleTimeoutStartTime().Add(s.idleTimeout)
|
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() {
|
if probeTime := s.mtuDiscoverer.NextProbeTime(); !probeTime.IsZero() {
|
||||||
deadline = utils.MinTime(deadline, probeTime)
|
deadline = utils.MinTime(deadline, probeTime)
|
||||||
}
|
}
|
||||||
|
@ -807,7 +813,7 @@ func (s *session) handleHandshakeConfirmed() {
|
||||||
s.sentPacketHandler.SetHandshakeConfirmed()
|
s.sentPacketHandler.SetHandshakeConfirmed()
|
||||||
s.cryptoStreamHandler.SetHandshakeConfirmed()
|
s.cryptoStreamHandler.SetHandshakeConfirmed()
|
||||||
|
|
||||||
if !s.config.DisablePathMTUDiscovery {
|
if pathMTUDiscoveryEnabled(s.config) {
|
||||||
maxPacketSize := s.peerParams.MaxUDPPayloadSize
|
maxPacketSize := s.peerParams.MaxUDPPayloadSize
|
||||||
if maxPacketSize == 0 {
|
if maxPacketSize == 0 {
|
||||||
maxPacketSize = protocol.MaxByteCount
|
maxPacketSize = protocol.MaxByteCount
|
||||||
|
@ -1768,7 +1774,7 @@ func (s *session) sendPacket() (bool, error) {
|
||||||
s.sendQueue.Send(packet.buffer)
|
s.sendQueue.Send(packet.buffer)
|
||||||
return true, nil
|
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())
|
packet, err := s.packer.PackMTUProbePacket(s.mtuDiscoverer.GetPing())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//go:build tools
|
||||||
// +build tools
|
// +build tools
|
||||||
|
|
||||||
package quic
|
package quic
|
||||||
|
|
|
@ -194,7 +194,7 @@ github.com/json-iterator/go
|
||||||
## explicit
|
## explicit
|
||||||
# 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.23.0
|
# github.com/lucas-clemente/quic-go v0.24.0
|
||||||
## 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
|
||||||
|
|
Loading…
Reference in New Issue