Skip to content

Commit fb5f112

Browse files
committed
Update quic-go to v0.45.1
1 parent 500b9c0 commit fb5f112

File tree

11 files changed

+46
-78
lines changed

11 files changed

+46
-78
lines changed

congestion_meta1/bbr_sender.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,19 @@ import (
66
"fmt"
77
"math"
88
"math/rand"
9-
"net"
109
"time"
1110

1211
"github.com/sagernet/quic-go/congestion"
1312
)
1413

1514
const (
1615
// InitialMaxDatagramSize is the default maximum packet size used in QUIC for congestion window computations in bytes.
17-
InitialMaxDatagramSize = 1252
18-
InitialPacketSizeIPv4 = 1252
19-
InitialPacketSizeIPv6 = 1232
16+
InitialMaxDatagramSize = 1280
17+
InitialPacketSize = 1280
2018
InitialCongestionWindow = 32
2119
DefaultBBRMaxCongestionWindow = 10000
2220
)
2321

24-
func GetInitialPacketSize(addr net.Addr) congestion.ByteCount {
25-
maxSize := congestion.ByteCount(1200)
26-
// If this is not a UDP address, we don't know anything about the MTU.
27-
// Use the minimum size of an Initial packet as the max packet size.
28-
if udpAddr, ok := addr.(*net.UDPAddr); ok {
29-
if udpAddr.IP.To4() != nil {
30-
maxSize = InitialPacketSizeIPv4
31-
} else {
32-
maxSize = InitialPacketSizeIPv6
33-
}
34-
}
35-
return congestion.ByteCount(maxSize)
36-
}
37-
3822
var (
3923

4024
// Default initial rtt used before any samples are received.

congestion_meta1/cubic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
cubeCongestionWindowScale = 410
2222
cubeFactor congestion.ByteCount = 1 << cubeScale / cubeCongestionWindowScale / maxDatagramSize
2323
// TODO: when re-enabling cubic, make sure to use the actual packet size here
24-
maxDatagramSize = congestion.ByteCount(InitialPacketSizeIPv4)
24+
maxDatagramSize = congestion.ByteCount(congestion.InitialPacketSizeIPv4)
2525
)
2626

2727
const defaultNumConnections = 1

congestion_meta2/bbr_sender.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package congestion
55
import (
66
"fmt"
77
"math/rand"
8-
"net"
98
"time"
109

1110
"github.com/sagernet/quic-go/congestion"
@@ -929,17 +928,3 @@ func (b *bbrSender) shouldExitStartupDueToLoss(lastPacketSendState *sendTimeStat
929928
func bdpFromRttAndBandwidth(rtt time.Duration, bandwidth Bandwidth) congestion.ByteCount {
930929
return congestion.ByteCount(rtt) * congestion.ByteCount(bandwidth) / congestion.ByteCount(BytesPerSecond) / congestion.ByteCount(time.Second)
931930
}
932-
933-
func GetInitialPacketSize(addr net.Addr) congestion.ByteCount {
934-
// If this is not a UDP address, we don't know anything about the MTU.
935-
// Use the minimum size of an Initial packet as the max packet size.
936-
if udpAddr, ok := addr.(*net.UDPAddr); ok {
937-
if udpAddr.IP.To4() != nil {
938-
return congestion.InitialPacketSizeIPv4
939-
} else {
940-
return congestion.InitialPacketSizeIPv6
941-
}
942-
} else {
943-
return congestion.MinInitialPacketSize
944-
}
945-
}

go.mod

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ go 1.20
44

55
require (
66
github.com/gofrs/uuid/v5 v5.2.0
7-
github.com/sagernet/quic-go v0.43.1-beta.1
8-
github.com/sagernet/sing v0.4.0-beta.19
7+
github.com/sagernet/quic-go v0.45.1-beta.2
8+
github.com/sagernet/sing v0.4.1
99
golang.org/x/crypto v0.23.0
10-
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
10+
golang.org/x/exp v0.0.0-20190121172915-509febef88a4
1111
)
1212

1313
require (
@@ -17,8 +17,7 @@ require (
1717
github.com/quic-go/qpack v0.4.0 // indirect
1818
github.com/quic-go/qtls-go1-20 v0.4.1 // indirect
1919
golang.org/x/net v0.25.0 // indirect
20-
golang.org/x/sys v0.20.0 // indirect
21-
golang.org/x/text v0.15.0 // indirect
22-
golang.org/x/tools v0.21.0 // indirect
23-
google.golang.org/protobuf v1.31.0 // indirect
20+
golang.org/x/sys v0.21.0 // indirect
21+
golang.org/x/text v0.16.0 // indirect
22+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
2423
)

go.sum

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEe
66
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
77
github.com/gofrs/uuid/v5 v5.2.0 h1:qw1GMx6/y8vhVsx626ImfKMuS5CvJmhIKKtuyvfajMM=
88
github.com/gofrs/uuid/v5 v5.2.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
9-
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
109
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
11-
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
1210
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
1311
github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a h1:fEBsGL/sjAuJrgah5XqmmYsTLzJp/TO9Lhy39gkverk=
1412
github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik=
@@ -21,29 +19,31 @@ github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo=
2119
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
2220
github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs=
2321
github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
24-
github.com/sagernet/quic-go v0.43.1-beta.1 h1:alizUjpvWYcz08dBCQsULOd+1xu0o7UtlyYf6SLbRNg=
25-
github.com/sagernet/quic-go v0.43.1-beta.1/go.mod h1:BkrQYeop7Jx3hN3TW8/76CXcdhYiNPyYEBL/BVJ1ifc=
26-
github.com/sagernet/sing v0.4.0-beta.19 h1:Kzh2f6eaxt09S+bEL8F4Bgy03qkNf+4Tt8g7/5lxp/o=
27-
github.com/sagernet/sing v0.4.0-beta.19/go.mod h1:PFQKbElc2Pke7faBLv8oEba5ehtKO21Ho+TkYemTI3Y=
22+
github.com/sagernet/quic-go v0.45.1-beta.2 h1:zkEeCbhdFFkrxKcuIRBtXNKci/1t2J/39QSG/sPvlmc=
23+
github.com/sagernet/quic-go v0.45.1-beta.2/go.mod h1:+N3FqM9DAzOWfe64uxXuBejVJwX7DeW7BslzLO6N/xI=
24+
github.com/sagernet/sing v0.4.1 h1:zVlpE+7k7AFoC2pv6ReqLf0PIHjihL/jsBl5k05PQFk=
25+
github.com/sagernet/sing v0.4.1/go.mod h1:ieZHA/+Y9YZfXs2I3WtuwgyCZ6GPsIR7HdKb1SdEnls=
2826
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
2927
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
3028
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
3129
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
3230
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
33-
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
34-
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
35-
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
31+
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
32+
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
33+
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
34+
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
35+
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
3636
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
37-
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
38-
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
39-
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
40-
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
41-
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
42-
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
43-
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
44-
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
45-
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
46-
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
37+
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
38+
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
39+
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
40+
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
41+
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
42+
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
43+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
44+
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
45+
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
46+
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
4747
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
4848
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4949
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

hysteria/packet.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (c *udpPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr)
182182
default:
183183
}
184184
if buffer.Len() > 0xffff {
185-
return &quic.DatagramTooLargeError{PeerMaxDatagramFrameSize: 0xffff}
185+
return &quic.DatagramTooLargeError{MaxDatagramPayloadSize: 0xffff}
186186
}
187187
packetId := uint16(c.packetId.Add(1) % math.MaxUint16)
188188
message := allocMessage()
@@ -208,7 +208,7 @@ func (c *udpPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr)
208208
if !errors.As(err, &tooLargeErr) {
209209
return err
210210
}
211-
return c.writePackets(fragUDPMessage(message, int(tooLargeErr.PeerMaxDatagramFrameSize-3)))
211+
return c.writePackets(fragUDPMessage(message, int(tooLargeErr.MaxDatagramPayloadSize-3)))
212212
}
213213

214214
func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
@@ -218,7 +218,7 @@ func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
218218
default:
219219
}
220220
if len(p) > 0xffff {
221-
return 0, &quic.DatagramTooLargeError{PeerMaxDatagramFrameSize: 0xffff}
221+
return 0, &quic.DatagramTooLargeError{MaxDatagramPayloadSize: 0xffff}
222222
}
223223
packetId := uint16(c.packetId.Add(1) % math.MaxUint16)
224224
message := allocMessage()
@@ -246,7 +246,7 @@ func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
246246
if !errors.As(err, &tooLargeErr) {
247247
return
248248
}
249-
err = c.writePackets(fragUDPMessage(message, int(tooLargeErr.PeerMaxDatagramFrameSize-3)))
249+
err = c.writePackets(fragUDPMessage(message, int(tooLargeErr.MaxDatagramPayloadSize-3)))
250250
if err == nil {
251251
return len(p), nil
252252
}

hysteria2/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (c *Client) offerNew(ctx context.Context) (*clientQUICConnection, error) {
166166
}
167167
quicConn.SetCongestionControl(congestion_meta2.NewBbrSender(
168168
congestion_meta2.DefaultClock{TimeFunc: timeFunc},
169-
congestion_meta2.GetInitialPacketSize(quicConn.RemoteAddr()),
169+
congestion.ByteCount(quicConn.Config().InitialPacketSize),
170170
congestion.ByteCount(congestion_meta1.InitialCongestionWindow),
171171
))
172172
}

hysteria2/packet.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (c *udpPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr)
178178
default:
179179
}
180180
if buffer.Len() > 0xffff {
181-
return &quic.DatagramTooLargeError{PeerMaxDatagramFrameSize: 0xffff}
181+
return &quic.DatagramTooLargeError{MaxDatagramPayloadSize: 0xffff}
182182
}
183183
packetId := uint16(c.packetId.Add(1) % math.MaxUint16)
184184
message := allocMessage()
@@ -203,7 +203,7 @@ func (c *udpPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr)
203203
if !errors.As(err, &tooLargeErr) {
204204
return err
205205
}
206-
return c.writePackets(fragUDPMessage(message, int(tooLargeErr.PeerMaxDatagramFrameSize-3)))
206+
return c.writePackets(fragUDPMessage(message, int(tooLargeErr.MaxDatagramPayloadSize-3)))
207207
}
208208

209209
func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
@@ -213,7 +213,7 @@ func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
213213
default:
214214
}
215215
if len(p) > 0xffff {
216-
return 0, &quic.DatagramTooLargeError{PeerMaxDatagramFrameSize: 0xffff}
216+
return 0, &quic.DatagramTooLargeError{MaxDatagramPayloadSize: 0xffff}
217217
}
218218
packetId := uint16(c.packetId.Add(1) % math.MaxUint16)
219219
message := allocMessage()
@@ -239,7 +239,7 @@ func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
239239
if !errors.As(err, &tooLargeErr) {
240240
return
241241
}
242-
err = c.writePackets(fragUDPMessage(message, int(tooLargeErr.PeerMaxDatagramFrameSize-3)))
242+
err = c.writePackets(fragUDPMessage(message, int(tooLargeErr.MaxDatagramPayloadSize-3)))
243243
if err == nil {
244244
return len(p), nil
245245
}

hysteria2/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (s *serverSession[U]) ServeHTTP(w http.ResponseWriter, r *http.Request) {
214214
}
215215
s.quicConn.SetCongestionControl(congestion_meta2.NewBbrSender(
216216
congestion_meta2.DefaultClock{TimeFunc: timeFunc},
217-
congestion_meta2.GetInitialPacketSize(s.quicConn.RemoteAddr()),
217+
congestion.ByteCount(s.quicConn.Config().InitialPacketSize),
218218
congestion.ByteCount(congestion_meta1.InitialCongestionWindow),
219219
))
220220
}

tuic/congestion.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func setCongestion(ctx context.Context, connection quic.Connection, congestionNa
2121
connection.SetCongestionControl(
2222
congestion_meta1.NewCubicSender(
2323
congestion_meta1.DefaultClock{TimeFunc: timeFunc},
24-
congestion_meta1.GetInitialPacketSize(connection.RemoteAddr()),
24+
congestion.ByteCount(connection.Config().InitialPacketSize),
2525
false,
2626
nil,
2727
),
@@ -30,22 +30,22 @@ func setCongestion(ctx context.Context, connection quic.Connection, congestionNa
3030
connection.SetCongestionControl(
3131
congestion_meta1.NewCubicSender(
3232
congestion_meta1.DefaultClock{TimeFunc: timeFunc},
33-
congestion_meta1.GetInitialPacketSize(connection.RemoteAddr()),
33+
congestion.ByteCount(connection.Config().InitialPacketSize),
3434
true,
3535
nil,
3636
),
3737
)
3838
case "bbr_meta_v1":
3939
connection.SetCongestionControl(congestion_meta1.NewBBRSender(
4040
congestion_meta1.DefaultClock{TimeFunc: timeFunc},
41-
congestion_meta1.GetInitialPacketSize(connection.RemoteAddr()),
41+
congestion.ByteCount(connection.Config().InitialPacketSize),
4242
congestion_meta1.InitialCongestionWindow*congestion_meta1.InitialMaxDatagramSize,
4343
congestion_meta1.DefaultBBRMaxCongestionWindow*congestion_meta1.InitialMaxDatagramSize,
4444
))
4545
case "bbr":
4646
connection.SetCongestionControl(congestion_meta2.NewBbrSender(
4747
congestion_meta2.DefaultClock{TimeFunc: timeFunc},
48-
congestion_meta2.GetInitialPacketSize(connection.RemoteAddr()),
48+
congestion.ByteCount(connection.Config().InitialPacketSize),
4949
congestion.ByteCount(congestion_meta1.InitialCongestionWindow),
5050
))
5151
}

0 commit comments

Comments
 (0)