Skip to content

Commit fda1888

Browse files
build(deps): bump github.com/quic-go/quic-go from 0.40.1 to 0.42.0 (#289)
* build(deps): bump github.com/quic-go/quic-go from 0.40.1 to 0.42.0 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.40.1 to 0.42.0. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](quic-go/quic-go@v0.40.1...v0.42.0) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * update: remove dependency of quic-go We now vendor the quicvarint submodule from quic-go for a minimal dependency tree. This also updates the minimal Go version requirement to Go 1.21, given uTLS promised to support 2 most recent minor versions of Go. Signed-off-by: Gaukas Wang <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Gaukas Wang <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Gaukas Wang <[email protected]>
1 parent 3d4788c commit fda1888

File tree

7 files changed

+307
-15
lines changed

7 files changed

+307
-15
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
os: [ "ubuntu-latest", "windows-latest", "macos-latest" ]
18-
go: [ "1.20.x", "1.21.x" ]
18+
go: [ "1.21.x", "1.22.x" ]
1919
runs-on: ${{ matrix.os }}
2020
steps:
2121
- uses: actions/checkout@v3

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
---
55
uTLS is a fork of "crypto/tls", which provides ClientHello fingerprinting resistance, low-level access to handshake, fake session tickets and some other features. Handshake is still performed by "crypto/tls", this library merely changes ClientHello part of it and provides low-level access.
66

7-
Golang 1.20+ is required.
7+
**Minimal Go Version**: Go 1.21
88

99
If you have any questions, bug reports or contributions, you are welcome to publish those on GitHub. If you want to do so in private, ~~you can contact one of developers personally via [email protected]~~.
1010

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/refraction-networking/utls
22

3-
go 1.20
3+
go 1.21
44

55
retract (
66
v1.4.1 // #218
@@ -11,7 +11,6 @@ require (
1111
github.com/andybalholm/brotli v1.0.6
1212
github.com/cloudflare/circl v1.3.7
1313
github.com/klauspost/compress v1.17.4
14-
github.com/quic-go/quic-go v0.40.1
1514
golang.org/x/crypto v0.18.0
1615
golang.org/x/net v0.20.0
1716
golang.org/x/sys v0.16.0

go.sum

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,8 @@ github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sx
22
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
33
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
44
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
5-
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
6-
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
7-
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
8-
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
95
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
106
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
11-
github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q=
12-
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
13-
github.com/quic-go/quic-go v0.40.1 h1:X3AGzUNFs0jVuO3esAGnTfvdgvL4fq655WaOi1snv1Q=
14-
github.com/quic-go/quic-go v0.40.1/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpTx31vx60c=
157
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
168
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
179
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
@@ -20,5 +12,3 @@ golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
2012
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
2113
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
2214
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
23-
golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=
24-
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
// Copyright 2024 The quic-go Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file of
4+
// the quic-go repository.
5+
6+
package protocol
7+
8+
import (
9+
"fmt"
10+
"time"
11+
)
12+
13+
// The PacketType is the Long Header Type
14+
type PacketType uint8
15+
16+
const (
17+
// PacketTypeInitial is the packet type of an Initial packet
18+
PacketTypeInitial PacketType = 1 + iota
19+
// PacketTypeRetry is the packet type of a Retry packet
20+
PacketTypeRetry
21+
// PacketTypeHandshake is the packet type of a Handshake packet
22+
PacketTypeHandshake
23+
// PacketType0RTT is the packet type of a 0-RTT packet
24+
PacketType0RTT
25+
)
26+
27+
func (t PacketType) String() string {
28+
switch t {
29+
case PacketTypeInitial:
30+
return "Initial"
31+
case PacketTypeRetry:
32+
return "Retry"
33+
case PacketTypeHandshake:
34+
return "Handshake"
35+
case PacketType0RTT:
36+
return "0-RTT Protected"
37+
default:
38+
return fmt.Sprintf("unknown packet type: %d", t)
39+
}
40+
}
41+
42+
type ECN uint8
43+
44+
const (
45+
ECNUnsupported ECN = iota
46+
ECNNon // 00
47+
ECT1 // 01
48+
ECT0 // 10
49+
ECNCE // 11
50+
)
51+
52+
func ParseECNHeaderBits(bits byte) ECN {
53+
switch bits {
54+
case 0:
55+
return ECNNon
56+
case 0b00000010:
57+
return ECT0
58+
case 0b00000001:
59+
return ECT1
60+
case 0b00000011:
61+
return ECNCE
62+
default:
63+
panic("invalid ECN bits")
64+
}
65+
}
66+
67+
func (e ECN) ToHeaderBits() byte {
68+
//nolint:exhaustive // There are only 4 values.
69+
switch e {
70+
case ECNNon:
71+
return 0
72+
case ECT0:
73+
return 0b00000010
74+
case ECT1:
75+
return 0b00000001
76+
case ECNCE:
77+
return 0b00000011
78+
default:
79+
panic("ECN unsupported")
80+
}
81+
}
82+
83+
func (e ECN) String() string {
84+
switch e {
85+
case ECNUnsupported:
86+
return "ECN unsupported"
87+
case ECNNon:
88+
return "Not-ECT"
89+
case ECT1:
90+
return "ECT(1)"
91+
case ECT0:
92+
return "ECT(0)"
93+
case ECNCE:
94+
return "CE"
95+
default:
96+
return fmt.Sprintf("invalid ECN value: %d", e)
97+
}
98+
}
99+
100+
// A ByteCount in QUIC
101+
type ByteCount int64
102+
103+
// MaxByteCount is the maximum value of a ByteCount
104+
const MaxByteCount = ByteCount(1<<62 - 1)
105+
106+
// InvalidByteCount is an invalid byte count
107+
const InvalidByteCount ByteCount = -1
108+
109+
// A StatelessResetToken is a stateless reset token.
110+
type StatelessResetToken [16]byte
111+
112+
// MaxPacketBufferSize maximum packet size of any QUIC packet, based on
113+
// ethernet's max size, minus the IP and UDP headers. IPv6 has a 40 byte header,
114+
// UDP adds an additional 8 bytes. This is a total overhead of 48 bytes.
115+
// Ethernet's max packet size is 1500 bytes, 1500 - 48 = 1452.
116+
const MaxPacketBufferSize = 1452
117+
118+
// MaxLargePacketBufferSize is used when using GSO
119+
const MaxLargePacketBufferSize = 20 * 1024
120+
121+
// MinInitialPacketSize is the minimum size an Initial packet is required to have.
122+
const MinInitialPacketSize = 1200
123+
124+
// MinUnknownVersionPacketSize is the minimum size a packet with an unknown version
125+
// needs to have in order to trigger a Version Negotiation packet.
126+
const MinUnknownVersionPacketSize = MinInitialPacketSize
127+
128+
// MinStatelessResetSize is the minimum size of a stateless reset packet that we send
129+
const MinStatelessResetSize = 1 /* first byte */ + 20 /* max. conn ID length */ + 4 /* max. packet number length */ + 1 /* min. payload length */ + 16 /* token */
130+
131+
// MinConnectionIDLenInitial is the minimum length of the destination connection ID on an Initial packet.
132+
const MinConnectionIDLenInitial = 8
133+
134+
// DefaultAckDelayExponent is the default ack delay exponent
135+
const DefaultAckDelayExponent = 3
136+
137+
// DefaultActiveConnectionIDLimit is the default active connection ID limit
138+
const DefaultActiveConnectionIDLimit = 2
139+
140+
// MaxAckDelayExponent is the maximum ack delay exponent
141+
const MaxAckDelayExponent = 20
142+
143+
// DefaultMaxAckDelay is the default max_ack_delay
144+
const DefaultMaxAckDelay = 25 * time.Millisecond
145+
146+
// MaxMaxAckDelay is the maximum max_ack_delay
147+
const MaxMaxAckDelay = (1<<14 - 1) * time.Millisecond
148+
149+
// MaxConnIDLen is the maximum length of the connection ID
150+
const MaxConnIDLen = 20
151+
152+
// InvalidPacketLimitAES is the maximum number of packets that we can fail to decrypt when using
153+
// AEAD_AES_128_GCM or AEAD_AES_265_GCM.
154+
const InvalidPacketLimitAES = 1 << 52
155+
156+
// InvalidPacketLimitChaCha is the maximum number of packets that we can fail to decrypt when using AEAD_CHACHA20_POLY1305.
157+
const InvalidPacketLimitChaCha = 1 << 36

internal/quicvarint/varint.go

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
// Copyright 2024 The quic-go Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file of
4+
// the quic-go repository.
5+
6+
package quicvarint
7+
8+
import (
9+
"fmt"
10+
"io"
11+
12+
"github.com/refraction-networking/utls/internal/quicvarint/protocol"
13+
)
14+
15+
// taken from the QUIC draft
16+
const (
17+
// Min is the minimum value allowed for a QUIC varint.
18+
Min = 0
19+
20+
// Max is the maximum allowed value for a QUIC varint (2^62-1).
21+
Max = maxVarInt8
22+
23+
maxVarInt1 = 63
24+
maxVarInt2 = 16383
25+
maxVarInt4 = 1073741823
26+
maxVarInt8 = 4611686018427387903
27+
)
28+
29+
// Read reads a number in the QUIC varint format from r.
30+
func Read(r io.ByteReader) (uint64, error) {
31+
firstByte, err := r.ReadByte()
32+
if err != nil {
33+
return 0, err
34+
}
35+
// the first two bits of the first byte encode the length
36+
len := 1 << ((firstByte & 0xc0) >> 6)
37+
b1 := firstByte & (0xff - 0xc0)
38+
if len == 1 {
39+
return uint64(b1), nil
40+
}
41+
b2, err := r.ReadByte()
42+
if err != nil {
43+
return 0, err
44+
}
45+
if len == 2 {
46+
return uint64(b2) + uint64(b1)<<8, nil
47+
}
48+
b3, err := r.ReadByte()
49+
if err != nil {
50+
return 0, err
51+
}
52+
b4, err := r.ReadByte()
53+
if err != nil {
54+
return 0, err
55+
}
56+
if len == 4 {
57+
return uint64(b4) + uint64(b3)<<8 + uint64(b2)<<16 + uint64(b1)<<24, nil
58+
}
59+
b5, err := r.ReadByte()
60+
if err != nil {
61+
return 0, err
62+
}
63+
b6, err := r.ReadByte()
64+
if err != nil {
65+
return 0, err
66+
}
67+
b7, err := r.ReadByte()
68+
if err != nil {
69+
return 0, err
70+
}
71+
b8, err := r.ReadByte()
72+
if err != nil {
73+
return 0, err
74+
}
75+
return uint64(b8) + uint64(b7)<<8 + uint64(b6)<<16 + uint64(b5)<<24 + uint64(b4)<<32 + uint64(b3)<<40 + uint64(b2)<<48 + uint64(b1)<<56, nil
76+
}
77+
78+
// Append appends i in the QUIC varint format.
79+
func Append(b []byte, i uint64) []byte {
80+
if i <= maxVarInt1 {
81+
return append(b, uint8(i))
82+
}
83+
if i <= maxVarInt2 {
84+
return append(b, []byte{uint8(i>>8) | 0x40, uint8(i)}...)
85+
}
86+
if i <= maxVarInt4 {
87+
return append(b, []byte{uint8(i>>24) | 0x80, uint8(i >> 16), uint8(i >> 8), uint8(i)}...)
88+
}
89+
if i <= maxVarInt8 {
90+
return append(b, []byte{
91+
uint8(i>>56) | 0xc0, uint8(i >> 48), uint8(i >> 40), uint8(i >> 32),
92+
uint8(i >> 24), uint8(i >> 16), uint8(i >> 8), uint8(i),
93+
}...)
94+
}
95+
panic(fmt.Sprintf("%#x doesn't fit into 62 bits", i))
96+
}
97+
98+
// AppendWithLen append i in the QUIC varint format with the desired length.
99+
func AppendWithLen(b []byte, i uint64, length protocol.ByteCount) []byte {
100+
if length != 1 && length != 2 && length != 4 && length != 8 {
101+
panic("invalid varint length")
102+
}
103+
l := Len(i)
104+
if l == length {
105+
return Append(b, i)
106+
}
107+
if l > length {
108+
panic(fmt.Sprintf("cannot encode %d in %d bytes", i, length))
109+
}
110+
if length == 2 {
111+
b = append(b, 0b01000000)
112+
} else if length == 4 {
113+
b = append(b, 0b10000000)
114+
} else if length == 8 {
115+
b = append(b, 0b11000000)
116+
}
117+
for j := protocol.ByteCount(1); j < length-l; j++ {
118+
b = append(b, 0)
119+
}
120+
for j := protocol.ByteCount(0); j < l; j++ {
121+
b = append(b, uint8(i>>(8*(l-1-j))))
122+
}
123+
return b
124+
}
125+
126+
// Len determines the number of bytes that will be needed to write the number i.
127+
func Len(i uint64) protocol.ByteCount {
128+
if i <= maxVarInt1 {
129+
return 1
130+
}
131+
if i <= maxVarInt2 {
132+
return 2
133+
}
134+
if i <= maxVarInt4 {
135+
return 4
136+
}
137+
if i <= maxVarInt8 {
138+
return 8
139+
}
140+
// Don't use a fmt.Sprintf here to format the error message.
141+
// The function would then exceed the inlining budget.
142+
panic(struct {
143+
message string
144+
num uint64
145+
}{"value doesn't fit into 62 bits: ", i})
146+
}

u_quic_transport_parameters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"math"
77
"math/big"
88

9-
"github.com/quic-go/quic-go/quicvarint"
9+
"github.com/refraction-networking/utls/internal/quicvarint"
1010
)
1111

1212
const (

0 commit comments

Comments
 (0)