mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-03-04 02:14:40 +01:00
Update deps
This commit is contained in:
parent
4ed02b02df
commit
3f551f4b66
56 changed files with 1094 additions and 479 deletions
12
go.mod
12
go.mod
|
@ -9,7 +9,7 @@ require (
|
|||
github.com/dchest/safefile v0.0.0-20151022103144-855e8d98f185
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1
|
||||
github.com/hectane/go-acl v0.0.0-20230122075934-ca0b05cb1adb
|
||||
github.com/jedisct1/dlog v0.0.0-20230811132706-443b333ff1b3
|
||||
github.com/jedisct1/dlog v0.0.0-20241011102921-a236bd13c4c1
|
||||
github.com/jedisct1/go-clocksmith v0.0.0-20230211133011-392c1afea73e
|
||||
github.com/jedisct1/go-dnsstamps v0.0.0-20240423203910-07a0735c7774
|
||||
github.com/jedisct1/go-hpke-compact v0.0.0-20230811132953-4ee502b61f80
|
||||
|
@ -20,10 +20,10 @@ require (
|
|||
github.com/miekg/dns v1.1.62
|
||||
github.com/opencoff/go-sieve v0.2.1
|
||||
github.com/powerman/check v1.7.0
|
||||
github.com/quic-go/quic-go v0.47.0
|
||||
golang.org/x/crypto v0.27.0
|
||||
golang.org/x/net v0.29.0
|
||||
golang.org/x/sys v0.25.0
|
||||
github.com/quic-go/quic-go v0.48.1
|
||||
golang.org/x/crypto v0.28.0
|
||||
golang.org/x/net v0.30.0
|
||||
golang.org/x/sys v0.26.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
)
|
||||
|
||||
|
@ -44,7 +44,7 @@ require (
|
|||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
|
||||
golang.org/x/mod v0.18.0 // indirect
|
||||
golang.org/x/sync v0.8.0 // indirect
|
||||
golang.org/x/text v0.18.0 // indirect
|
||||
golang.org/x/text v0.19.0 // indirect
|
||||
golang.org/x/tools v0.22.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
|
||||
google.golang.org/grpc v1.53.0 // indirect
|
||||
|
|
24
go.sum
24
go.sum
|
@ -37,8 +37,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||
github.com/hectane/go-acl v0.0.0-20230122075934-ca0b05cb1adb h1:PGufWXXDq9yaev6xX1YQauaO1MV90e6Mpoq1I7Lz/VM=
|
||||
github.com/hectane/go-acl v0.0.0-20230122075934-ca0b05cb1adb/go.mod h1:QiyDdbZLaJ/mZP4Zwc9g2QsfaEA4o7XvvgZegSci5/E=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/jedisct1/dlog v0.0.0-20230811132706-443b333ff1b3 h1:3wOfILZqpvhb7bNBGAVlXVyfoeXnmhitZ2qPVOx75Y0=
|
||||
github.com/jedisct1/dlog v0.0.0-20230811132706-443b333ff1b3/go.mod h1:m25Jh2eJ0FXLWjMXFZItQ24W0HAIjosAe4Z0a+SZitU=
|
||||
github.com/jedisct1/dlog v0.0.0-20241011102921-a236bd13c4c1 h1:QY+FfbHOmNRIfxzqarkdneapLTSIjrRALPYRA0EODzE=
|
||||
github.com/jedisct1/dlog v0.0.0-20241011102921-a236bd13c4c1/go.mod h1:OO1HpQNlMCMaPdHPuI00fhChZQZ8npbVTTjMvJUxUqQ=
|
||||
github.com/jedisct1/go-clocksmith v0.0.0-20230211133011-392c1afea73e h1:tzG4EjKgHIqKVkLIAC4pXTIapuM2BR05uXokEEysAXA=
|
||||
github.com/jedisct1/go-clocksmith v0.0.0-20230211133011-392c1afea73e/go.mod h1:SAINchklztk2jcLWJ4bpNF4KnwDUSUTX+cJbspWC2Rw=
|
||||
github.com/jedisct1/go-dnsstamps v0.0.0-20240423203910-07a0735c7774 h1:DobL5d8UxrYzlD0PbU/EVBAGHuDiFyH46gr6povMw50=
|
||||
|
@ -73,8 +73,8 @@ github.com/powerman/deepequal v0.1.0 h1:sVwtyTsBuYIvdbLR1O2wzRY63YgPqdGZmk/o80l+
|
|||
github.com/powerman/deepequal v0.1.0/go.mod h1:3k7aG/slufBhUANdN67o/UPg8i5YaiJ6FmibWX0cn04=
|
||||
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
|
||||
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
|
||||
github.com/quic-go/quic-go v0.47.0 h1:yXs3v7r2bm1wmPTYNLKAAJTHMYkPEsfYJmTazXrCZ7Y=
|
||||
github.com/quic-go/quic-go v0.47.0/go.mod h1:3bCapYsJvXGZcipOHuu7plYtaV6tnF+z7wIFsU0WK9E=
|
||||
github.com/quic-go/quic-go v0.48.1 h1:y/8xmfWI9qmGTc+lBr4jKRUWLGSlSigv847ULJ4hYXA=
|
||||
github.com/quic-go/quic-go v0.48.1/go.mod h1:yBgs3rWBOADpga7F+jJsb6Ybg1LSYiQvwWlLX+/6HMs=
|
||||
github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs=
|
||||
github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
|
||||
github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg=
|
||||
|
@ -86,26 +86,26 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8
|
|||
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
|
||||
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
|
||||
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
|
||||
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
|
||||
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
|
||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
|
||||
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
|
||||
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
|
||||
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190529164535-6a60838ec259/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
|
||||
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
|
||||
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
|
|
2
vendor/github.com/jedisct1/dlog/LICENSE
generated
vendored
2
vendor/github.com/jedisct1/dlog/LICENSE
generated
vendored
|
@ -1,6 +1,6 @@
|
|||
BSD 2-Clause License
|
||||
|
||||
Copyright (c) 2018-2023, Frank Denis
|
||||
Copyright (c) 2018-2024, Frank Denis
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
1
vendor/github.com/quic-go/quic-go/.golangci.yml
generated
vendored
1
vendor/github.com/quic-go/quic-go/.golangci.yml
generated
vendored
|
@ -43,3 +43,4 @@ issues:
|
|||
- path: _test\.go
|
||||
linters:
|
||||
- exhaustive
|
||||
- prealloc
|
||||
|
|
13
vendor/github.com/quic-go/quic-go/http3/capsule.go
generated
vendored
13
vendor/github.com/quic-go/quic-go/http3/capsule.go
generated
vendored
|
@ -6,16 +6,19 @@ import (
|
|||
"github.com/quic-go/quic-go/quicvarint"
|
||||
)
|
||||
|
||||
// CapsuleType is the type of the capsule.
|
||||
// CapsuleType is the type of the capsule
|
||||
type CapsuleType uint64
|
||||
|
||||
// CapsuleProtocolHeader is the header value used to advertise support for the capsule protocol
|
||||
const CapsuleProtocolHeader = "Capsule-Protocol"
|
||||
|
||||
type exactReader struct {
|
||||
R *io.LimitedReader
|
||||
R io.LimitedReader
|
||||
}
|
||||
|
||||
func (r *exactReader) Read(b []byte) (int, error) {
|
||||
n, err := r.R.Read(b)
|
||||
if r.R.N > 0 {
|
||||
if err == io.EOF && r.R.N > 0 {
|
||||
return n, io.ErrUnexpectedEOF
|
||||
}
|
||||
return n, err
|
||||
|
@ -35,7 +38,7 @@ func (r *countingByteReader) ReadByte() (byte, error) {
|
|||
}
|
||||
|
||||
// ParseCapsule parses the header of a Capsule.
|
||||
// It returns an io.LimitedReader that can be used to read the Capsule value.
|
||||
// It returns an io.Reader that can be used to read the Capsule value.
|
||||
// The Capsule value must be read entirely (i.e. until the io.EOF) before using r again.
|
||||
func ParseCapsule(r quicvarint.Reader) (CapsuleType, io.Reader, error) {
|
||||
cbr := countingByteReader{ByteReader: r}
|
||||
|
@ -55,7 +58,7 @@ func ParseCapsule(r quicvarint.Reader) (CapsuleType, io.Reader, error) {
|
|||
}
|
||||
return 0, nil, err
|
||||
}
|
||||
return CapsuleType(ct), &exactReader{R: io.LimitReader(r, int64(l)).(*io.LimitedReader)}, nil
|
||||
return CapsuleType(ct), &exactReader{R: io.LimitedReader{R: r, N: int64(l)}}, nil
|
||||
}
|
||||
|
||||
// WriteCapsule writes a capsule
|
||||
|
|
156
vendor/github.com/quic-go/quic-go/http3/client.go
generated
vendored
156
vendor/github.com/quic-go/quic-go/http3/client.go
generated
vendored
|
@ -9,7 +9,6 @@ import (
|
|||
"net/http"
|
||||
"net/http/httptrace"
|
||||
"net/textproto"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/quic-go/quic-go"
|
||||
|
@ -38,102 +37,122 @@ var defaultQuicConfig = &quic.Config{
|
|||
KeepAlivePeriod: 10 * time.Second,
|
||||
}
|
||||
|
||||
// SingleDestinationRoundTripper is an HTTP/3 client doing requests to a single remote server.
|
||||
type SingleDestinationRoundTripper struct {
|
||||
Connection quic.Connection
|
||||
// ClientConn is an HTTP/3 client doing requests to a single remote server.
|
||||
type ClientConn struct {
|
||||
connection
|
||||
|
||||
// Enable support for HTTP/3 datagrams (RFC 9297).
|
||||
// If a QUICConfig is set, datagram support also needs to be enabled on the QUIC layer by setting EnableDatagrams.
|
||||
EnableDatagrams bool
|
||||
// If a QUICConfig is set, datagram support also needs to be enabled on the QUIC layer by setting enableDatagrams.
|
||||
enableDatagrams bool
|
||||
|
||||
// Additional HTTP/3 settings.
|
||||
// It is invalid to specify any settings defined by RFC 9114 (HTTP/3) and RFC 9297 (HTTP Datagrams).
|
||||
AdditionalSettings map[uint64]uint64
|
||||
StreamHijacker func(FrameType, quic.ConnectionTracingID, quic.Stream, error) (hijacked bool, err error)
|
||||
UniStreamHijacker func(StreamType, quic.ConnectionTracingID, quic.ReceiveStream, error) (hijacked bool)
|
||||
additionalSettings map[uint64]uint64
|
||||
|
||||
// MaxResponseHeaderBytes specifies a limit on how many response bytes are
|
||||
// maxResponseHeaderBytes specifies a limit on how many response bytes are
|
||||
// allowed in the server's response header.
|
||||
// Zero means to use a default limit.
|
||||
MaxResponseHeaderBytes int64
|
||||
maxResponseHeaderBytes uint64
|
||||
|
||||
// DisableCompression, if true, prevents the Transport from requesting compression with an
|
||||
// disableCompression, if true, prevents the Transport from requesting compression with an
|
||||
// "Accept-Encoding: gzip" request header when the Request contains no existing Accept-Encoding value.
|
||||
// If the Transport requests gzip on its own and gets a gzipped response, it's transparently
|
||||
// decoded in the Response.Body.
|
||||
// However, if the user explicitly requested gzip it is not automatically uncompressed.
|
||||
DisableCompression bool
|
||||
disableCompression bool
|
||||
|
||||
Logger *slog.Logger
|
||||
logger *slog.Logger
|
||||
|
||||
initOnce sync.Once
|
||||
hconn *connection
|
||||
requestWriter *requestWriter
|
||||
decoder *qpack.Decoder
|
||||
}
|
||||
|
||||
var _ http.RoundTripper = &SingleDestinationRoundTripper{}
|
||||
var _ http.RoundTripper = &ClientConn{}
|
||||
|
||||
func (c *SingleDestinationRoundTripper) Start() Connection {
|
||||
c.initOnce.Do(func() { c.init() })
|
||||
return c.hconn
|
||||
}
|
||||
// Deprecated: SingleDestinationRoundTripper was renamed to ClientConn.
|
||||
// It can be obtained by calling NewClientConn on a Transport.
|
||||
type SingleDestinationRoundTripper = ClientConn
|
||||
|
||||
func (c *SingleDestinationRoundTripper) init() {
|
||||
func newClientConn(
|
||||
conn quic.Connection,
|
||||
enableDatagrams bool,
|
||||
additionalSettings map[uint64]uint64,
|
||||
streamHijacker func(FrameType, quic.ConnectionTracingID, quic.Stream, error) (hijacked bool, err error),
|
||||
uniStreamHijacker func(StreamType, quic.ConnectionTracingID, quic.ReceiveStream, error) (hijacked bool),
|
||||
maxResponseHeaderBytes int64,
|
||||
disableCompression bool,
|
||||
logger *slog.Logger,
|
||||
) *ClientConn {
|
||||
c := &ClientConn{
|
||||
enableDatagrams: enableDatagrams,
|
||||
additionalSettings: additionalSettings,
|
||||
disableCompression: disableCompression,
|
||||
logger: logger,
|
||||
}
|
||||
if maxResponseHeaderBytes <= 0 {
|
||||
c.maxResponseHeaderBytes = defaultMaxResponseHeaderBytes
|
||||
} else {
|
||||
c.maxResponseHeaderBytes = uint64(maxResponseHeaderBytes)
|
||||
}
|
||||
c.decoder = qpack.NewDecoder(func(hf qpack.HeaderField) {})
|
||||
c.requestWriter = newRequestWriter()
|
||||
c.hconn = newConnection(
|
||||
c.Connection.Context(),
|
||||
c.Connection,
|
||||
c.EnableDatagrams,
|
||||
c.connection = *newConnection(
|
||||
conn.Context(),
|
||||
conn,
|
||||
c.enableDatagrams,
|
||||
protocol.PerspectiveClient,
|
||||
c.Logger,
|
||||
c.logger,
|
||||
0,
|
||||
)
|
||||
// send the SETTINGs frame, using 0-RTT data, if possible
|
||||
go func() {
|
||||
if err := c.setupConn(c.hconn); err != nil {
|
||||
if c.Logger != nil {
|
||||
c.Logger.Debug("Setting up connection failed", "error", err)
|
||||
if err := c.setupConn(); err != nil {
|
||||
if c.logger != nil {
|
||||
c.logger.Debug("Setting up connection failed", "error", err)
|
||||
}
|
||||
c.hconn.CloseWithError(quic.ApplicationErrorCode(ErrCodeInternalError), "")
|
||||
c.connection.CloseWithError(quic.ApplicationErrorCode(ErrCodeInternalError), "")
|
||||
}
|
||||
}()
|
||||
if c.StreamHijacker != nil {
|
||||
go c.handleBidirectionalStreams()
|
||||
if streamHijacker != nil {
|
||||
go c.handleBidirectionalStreams(streamHijacker)
|
||||
}
|
||||
go c.hconn.HandleUnidirectionalStreams(c.UniStreamHijacker)
|
||||
go c.connection.handleUnidirectionalStreams(uniStreamHijacker)
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *SingleDestinationRoundTripper) setupConn(conn *connection) error {
|
||||
// OpenRequestStream opens a new request stream on the HTTP/3 connection.
|
||||
func (c *ClientConn) OpenRequestStream(ctx context.Context) (RequestStream, error) {
|
||||
return c.connection.openRequestStream(ctx, c.requestWriter, nil, c.disableCompression, c.maxResponseHeaderBytes)
|
||||
}
|
||||
|
||||
func (c *ClientConn) setupConn() error {
|
||||
// open the control stream
|
||||
str, err := conn.OpenUniStream()
|
||||
str, err := c.connection.OpenUniStream()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b := make([]byte, 0, 64)
|
||||
b = quicvarint.Append(b, streamTypeControlStream)
|
||||
// send the SETTINGS frame
|
||||
b = (&settingsFrame{Datagram: c.EnableDatagrams, Other: c.AdditionalSettings}).Append(b)
|
||||
b = (&settingsFrame{Datagram: c.enableDatagrams, Other: c.additionalSettings}).Append(b)
|
||||
_, err = str.Write(b)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *SingleDestinationRoundTripper) handleBidirectionalStreams() {
|
||||
func (c *ClientConn) handleBidirectionalStreams(streamHijacker func(FrameType, quic.ConnectionTracingID, quic.Stream, error) (hijacked bool, err error)) {
|
||||
for {
|
||||
str, err := c.hconn.AcceptStream(context.Background())
|
||||
str, err := c.connection.AcceptStream(context.Background())
|
||||
if err != nil {
|
||||
if c.Logger != nil {
|
||||
c.Logger.Debug("accepting bidirectional stream failed", "error", err)
|
||||
if c.logger != nil {
|
||||
c.logger.Debug("accepting bidirectional stream failed", "error", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
fp := &frameParser{
|
||||
r: str,
|
||||
conn: c.hconn,
|
||||
conn: &c.connection,
|
||||
unknownFrameHandler: func(ft FrameType, e error) (processed bool, err error) {
|
||||
id := c.hconn.Context().Value(quic.ConnectionTracingKey).(quic.ConnectionTracingID)
|
||||
return c.StreamHijacker(ft, id, str, e)
|
||||
id := c.connection.Context().Value(quic.ConnectionTracingKey).(quic.ConnectionTracingID)
|
||||
return streamHijacker(ft, id, str, e)
|
||||
},
|
||||
}
|
||||
go func() {
|
||||
|
@ -141,26 +160,17 @@ func (c *SingleDestinationRoundTripper) handleBidirectionalStreams() {
|
|||
return
|
||||
}
|
||||
if err != nil {
|
||||
if c.Logger != nil {
|
||||
c.Logger.Debug("error handling stream", "error", err)
|
||||
if c.logger != nil {
|
||||
c.logger.Debug("error handling stream", "error", err)
|
||||
}
|
||||
}
|
||||
c.hconn.CloseWithError(quic.ApplicationErrorCode(ErrCodeFrameUnexpected), "received HTTP/3 frame on bidirectional stream")
|
||||
c.connection.CloseWithError(quic.ApplicationErrorCode(ErrCodeFrameUnexpected), "received HTTP/3 frame on bidirectional stream")
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func (c *SingleDestinationRoundTripper) maxHeaderBytes() uint64 {
|
||||
if c.MaxResponseHeaderBytes <= 0 {
|
||||
return defaultMaxResponseHeaderBytes
|
||||
}
|
||||
return uint64(c.MaxResponseHeaderBytes)
|
||||
}
|
||||
|
||||
// RoundTrip executes a request and returns a response
|
||||
func (c *SingleDestinationRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
c.initOnce.Do(func() { c.init() })
|
||||
|
||||
func (c *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
rsp, err := c.roundTrip(req)
|
||||
if err != nil && req.Context().Err() != nil {
|
||||
// if the context was canceled, return the context cancellation error
|
||||
|
@ -169,7 +179,7 @@ func (c *SingleDestinationRoundTripper) RoundTrip(req *http.Request) (*http.Resp
|
|||
return rsp, err
|
||||
}
|
||||
|
||||
func (c *SingleDestinationRoundTripper) roundTrip(req *http.Request) (*http.Response, error) {
|
||||
func (c *ClientConn) roundTrip(req *http.Request) (*http.Response, error) {
|
||||
// Immediately send out this request, if this is a 0-RTT request.
|
||||
switch req.Method {
|
||||
case MethodGet0RTT:
|
||||
|
@ -200,17 +210,23 @@ func (c *SingleDestinationRoundTripper) roundTrip(req *http.Request) (*http.Resp
|
|||
connCtx := c.Connection.Context()
|
||||
// wait for the server's SETTINGS frame to arrive
|
||||
select {
|
||||
case <-c.hconn.ReceivedSettings():
|
||||
case <-c.connection.ReceivedSettings():
|
||||
case <-connCtx.Done():
|
||||
return nil, context.Cause(connCtx)
|
||||
}
|
||||
if !c.hconn.Settings().EnableExtendedConnect {
|
||||
if !c.connection.Settings().EnableExtendedConnect {
|
||||
return nil, errors.New("http3: server didn't enable Extended CONNECT")
|
||||
}
|
||||
}
|
||||
|
||||
reqDone := make(chan struct{})
|
||||
str, err := c.hconn.openRequestStream(req.Context(), c.requestWriter, reqDone, c.DisableCompression, c.maxHeaderBytes())
|
||||
str, err := c.connection.openRequestStream(
|
||||
req.Context(),
|
||||
c.requestWriter,
|
||||
reqDone,
|
||||
c.disableCompression,
|
||||
c.maxResponseHeaderBytes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -238,12 +254,6 @@ func (c *SingleDestinationRoundTripper) roundTrip(req *http.Request) (*http.Resp
|
|||
return rsp, maybeReplaceError(err)
|
||||
}
|
||||
|
||||
func (c *SingleDestinationRoundTripper) OpenRequestStream(ctx context.Context) (RequestStream, error) {
|
||||
c.initOnce.Do(func() { c.init() })
|
||||
|
||||
return c.hconn.openRequestStream(ctx, c.requestWriter, nil, c.DisableCompression, c.maxHeaderBytes())
|
||||
}
|
||||
|
||||
// cancelingReader reads from the io.Reader.
|
||||
// It cancels writing on the stream if any error other than io.EOF occurs.
|
||||
type cancelingReader struct {
|
||||
|
@ -259,7 +269,7 @@ func (r *cancelingReader) Read(b []byte) (int, error) {
|
|||
return n, err
|
||||
}
|
||||
|
||||
func (c *SingleDestinationRoundTripper) sendRequestBody(str Stream, body io.ReadCloser, contentLength int64) error {
|
||||
func (c *ClientConn) sendRequestBody(str Stream, body io.ReadCloser, contentLength int64) error {
|
||||
defer body.Close()
|
||||
buf := make([]byte, bodyCopyBufferSize)
|
||||
sr := &cancelingReader{str: str, r: body}
|
||||
|
@ -283,7 +293,7 @@ func (c *SingleDestinationRoundTripper) sendRequestBody(str Stream, body io.Read
|
|||
return err
|
||||
}
|
||||
|
||||
func (c *SingleDestinationRoundTripper) doRequest(req *http.Request, str *requestStream) (*http.Response, error) {
|
||||
func (c *ClientConn) doRequest(req *http.Request, str *requestStream) (*http.Response, error) {
|
||||
if err := str.SendRequestHeader(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -299,8 +309,8 @@ func (c *SingleDestinationRoundTripper) doRequest(req *http.Request, str *reques
|
|||
contentLength = req.ContentLength
|
||||
}
|
||||
if err := c.sendRequestBody(str, req.Body, contentLength); err != nil {
|
||||
if c.Logger != nil {
|
||||
c.Logger.Debug("error writing request", "error", err)
|
||||
if c.logger != nil {
|
||||
c.logger.Debug("error writing request", "error", err)
|
||||
}
|
||||
}
|
||||
str.Close()
|
||||
|
@ -337,7 +347,7 @@ func (c *SingleDestinationRoundTripper) doRequest(req *http.Request, str *reques
|
|||
}
|
||||
break
|
||||
}
|
||||
connState := c.hconn.ConnectionState().TLS
|
||||
connState := c.connection.ConnectionState().TLS
|
||||
res.TLS = &connState
|
||||
res.Request = req
|
||||
return res, nil
|
||||
|
|
4
vendor/github.com/quic-go/quic-go/http3/conn.go
generated
vendored
4
vendor/github.com/quic-go/quic-go/http3/conn.go
generated
vendored
|
@ -170,7 +170,7 @@ func (c *connection) CloseWithError(code quic.ApplicationErrorCode, msg string)
|
|||
return c.Connection.CloseWithError(code, msg)
|
||||
}
|
||||
|
||||
func (c *connection) HandleUnidirectionalStreams(hijack func(StreamType, quic.ConnectionTracingID, quic.ReceiveStream, error) (hijacked bool)) {
|
||||
func (c *connection) handleUnidirectionalStreams(hijack func(StreamType, quic.ConnectionTracingID, quic.ReceiveStream, error) (hijacked bool)) {
|
||||
var (
|
||||
rcvdControlStr atomic.Bool
|
||||
rcvdQPACKEncoderStr atomic.Bool
|
||||
|
@ -316,10 +316,12 @@ func (c *connection) receiveDatagrams() error {
|
|||
}
|
||||
|
||||
// ReceivedSettings returns a channel that is closed once the peer's SETTINGS frame was received.
|
||||
// Settings can be optained from the Settings method after the channel was closed.
|
||||
func (c *connection) ReceivedSettings() <-chan struct{} { return c.receivedSettings }
|
||||
|
||||
// Settings returns the settings received on this connection.
|
||||
// It is only valid to call this function after the channel returned by ReceivedSettings was closed.
|
||||
func (c *connection) Settings() *Settings { return c.settings }
|
||||
|
||||
// Context returns the context of the underlying QUIC connection.
|
||||
func (c *connection) Context() context.Context { return c.ctx }
|
||||
|
|
27
vendor/github.com/quic-go/quic-go/http3/frames.go
generated
vendored
27
vendor/github.com/quic-go/quic-go/http3/frames.go
generated
vendored
|
@ -66,7 +66,8 @@ func (p *frameParser) ParseNext() (frame, error) {
|
|||
return parseSettingsFrame(p.r, l)
|
||||
case 0x3: // CANCEL_PUSH
|
||||
case 0x5: // PUSH_PROMISE
|
||||
case 0x7: // GOAWAY
|
||||
case 0x7:
|
||||
return parseGoAwayFrame(qr, l)
|
||||
case 0xd: // MAX_PUSH_ID
|
||||
case 0x2, 0x6, 0x8, 0x9:
|
||||
p.conn.CloseWithError(quic.ApplicationErrorCode(ErrCodeFrameUnexpected), "")
|
||||
|
@ -194,3 +195,27 @@ func (f *settingsFrame) Append(b []byte) []byte {
|
|||
}
|
||||
return b
|
||||
}
|
||||
|
||||
type goAwayFrame struct {
|
||||
StreamID quic.StreamID
|
||||
}
|
||||
|
||||
func parseGoAwayFrame(r io.ByteReader, l uint64) (*goAwayFrame, error) {
|
||||
frame := &goAwayFrame{}
|
||||
cbr := countingByteReader{ByteReader: r}
|
||||
id, err := quicvarint.Read(&cbr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cbr.Read != int(l) {
|
||||
return nil, errors.New("GOAWAY frame: inconsistent length")
|
||||
}
|
||||
frame.StreamID = quic.StreamID(id)
|
||||
return frame, nil
|
||||
}
|
||||
|
||||
func (f *goAwayFrame) Append(b []byte) []byte {
|
||||
b = quicvarint.Append(b, 0x7)
|
||||
b = quicvarint.Append(b, uint64(quicvarint.Len(uint64(f.StreamID))))
|
||||
return quicvarint.Append(b, uint64(f.StreamID))
|
||||
}
|
||||
|
|
162
vendor/github.com/quic-go/quic-go/http3/server.go
generated
vendored
162
vendor/github.com/quic-go/quic-go/http3/server.go
generated
vendored
|
@ -13,6 +13,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/quic-go/quic-go"
|
||||
|
@ -45,6 +46,8 @@ const (
|
|||
streamTypeQPACKDecoderStream = 3
|
||||
)
|
||||
|
||||
const goawayTimeout = 5 * time.Second
|
||||
|
||||
// A QUICEarlyListener listens for incoming QUIC connections.
|
||||
type QUICEarlyListener interface {
|
||||
Accept(context.Context) (quic.EarlyConnection, error)
|
||||
|
@ -213,7 +216,13 @@ type Server struct {
|
|||
mutex sync.RWMutex
|
||||
listeners map[*QUICEarlyListener]listenerInfo
|
||||
|
||||
closed bool
|
||||
closed bool
|
||||
closeCtx context.Context // canceled when the server is closed
|
||||
closeCancel context.CancelFunc // cancels the closeCtx
|
||||
graceCtx context.Context // canceled when the server is closed or gracefully closed
|
||||
graceCancel context.CancelFunc // cancels the graceCtx
|
||||
connCount atomic.Int64
|
||||
connHandlingDone chan struct{}
|
||||
|
||||
altSvcHeader string
|
||||
}
|
||||
|
@ -265,8 +274,31 @@ func (s *Server) Serve(conn net.PacketConn) error {
|
|||
return s.serveListener(ln)
|
||||
}
|
||||
|
||||
// init initializes the contexts used for shutting down the server.
|
||||
// It must be called with the mutex held.
|
||||
func (s *Server) init() {
|
||||
if s.closeCtx == nil {
|
||||
s.closeCtx, s.closeCancel = context.WithCancel(context.Background())
|
||||
s.graceCtx, s.graceCancel = context.WithCancel(s.closeCtx)
|
||||
}
|
||||
s.connHandlingDone = make(chan struct{}, 1)
|
||||
}
|
||||
|
||||
func (s *Server) decreaseConnCount() {
|
||||
if s.connCount.Add(-1) == 0 && s.graceCtx.Err() != nil {
|
||||
close(s.connHandlingDone)
|
||||
}
|
||||
}
|
||||
|
||||
// ServeQUICConn serves a single QUIC connection.
|
||||
func (s *Server) ServeQUICConn(conn quic.Connection) error {
|
||||
s.mutex.Lock()
|
||||
s.init()
|
||||
s.mutex.Unlock()
|
||||
|
||||
s.connCount.Add(1)
|
||||
defer s.decreaseConnCount()
|
||||
|
||||
return s.handleConn(conn)
|
||||
}
|
||||
|
||||
|
@ -289,14 +321,17 @@ func (s *Server) ServeListener(ln QUICEarlyListener) error {
|
|||
|
||||
func (s *Server) serveListener(ln QUICEarlyListener) error {
|
||||
for {
|
||||
conn, err := ln.Accept(context.Background())
|
||||
if err == quic.ErrServerClosed {
|
||||
conn, err := ln.Accept(s.graceCtx)
|
||||
// server closed
|
||||
if errors.Is(err, quic.ErrServerClosed) || s.graceCtx.Err() != nil {
|
||||
return http.ErrServerClosed
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.connCount.Add(1)
|
||||
go func() {
|
||||
defer s.decreaseConnCount()
|
||||
if err := s.handleConn(conn); err != nil {
|
||||
if s.Logger != nil {
|
||||
s.Logger.Debug("handling connection failed", "error", err)
|
||||
|
@ -430,6 +465,7 @@ func (s *Server) addListener(l *QUICEarlyListener) error {
|
|||
if s.listeners == nil {
|
||||
s.listeners = make(map[*QUICEarlyListener]listenerInfo)
|
||||
}
|
||||
s.init()
|
||||
|
||||
laddr := (*l).Addr()
|
||||
if port, err := extractPort(laddr.String()); err == nil {
|
||||
|
@ -453,9 +489,12 @@ func (s *Server) removeListener(l *QUICEarlyListener) {
|
|||
s.generateAltSvcHeader()
|
||||
}
|
||||
|
||||
// handleConn handles the HTTP/3 exchange on a QUIC connection.
|
||||
// It blocks until all HTTP handlers for all streams have returned.
|
||||
func (s *Server) handleConn(conn quic.Connection) error {
|
||||
// send a SETTINGS frame
|
||||
str, err := conn.OpenUniStream()
|
||||
// open the control stream and send a SETTINGS frame, it's also used to send a GOAWAY frame later
|
||||
// when the server is gracefully closed
|
||||
ctrlStr, err := conn.OpenUniStream()
|
||||
if err != nil {
|
||||
return fmt.Errorf("opening the control stream failed: %w", err)
|
||||
}
|
||||
|
@ -466,7 +505,7 @@ func (s *Server) handleConn(conn quic.Connection) error {
|
|||
ExtendedConnect: true,
|
||||
Other: s.AdditionalSettings,
|
||||
}).Append(b)
|
||||
str.Write(b)
|
||||
ctrlStr.Write(b)
|
||||
|
||||
ctx := conn.Context()
|
||||
ctx = context.WithValue(ctx, ServerContextKey, s)
|
||||
|
@ -487,21 +526,60 @@ func (s *Server) handleConn(conn quic.Connection) error {
|
|||
s.Logger,
|
||||
s.IdleTimeout,
|
||||
)
|
||||
go hconn.HandleUnidirectionalStreams(s.UniStreamHijacker)
|
||||
go hconn.handleUnidirectionalStreams(s.UniStreamHijacker)
|
||||
|
||||
var nextStreamID quic.StreamID
|
||||
var wg sync.WaitGroup
|
||||
var handleErr error
|
||||
// Process all requests immediately.
|
||||
// It's the client's responsibility to decide which requests are eligible for 0-RTT.
|
||||
for {
|
||||
str, datagrams, err := hconn.acceptStream(context.Background())
|
||||
str, datagrams, err := hconn.acceptStream(s.graceCtx)
|
||||
if err != nil {
|
||||
var appErr *quic.ApplicationError
|
||||
if errors.As(err, &appErr) && appErr.ErrorCode == quic.ApplicationErrorCode(ErrCodeNoError) {
|
||||
return nil
|
||||
// server (not gracefully) closed, close the connection immediately
|
||||
if s.closeCtx.Err() != nil {
|
||||
conn.CloseWithError(quic.ApplicationErrorCode(ErrCodeNoError), "")
|
||||
handleErr = http.ErrServerClosed
|
||||
break
|
||||
}
|
||||
return fmt.Errorf("accepting stream failed: %w", err)
|
||||
|
||||
// gracefully closed, send GOAWAY frame and wait for requests to complete or grace period to end
|
||||
// new requests will be rejected and shouldn't be sent
|
||||
if s.graceCtx.Err() != nil {
|
||||
b = (&goAwayFrame{StreamID: nextStreamID}).Append(b[:0])
|
||||
// set a deadline to send the GOAWAY frame
|
||||
ctrlStr.SetWriteDeadline(time.Now().Add(goawayTimeout))
|
||||
ctrlStr.Write(b)
|
||||
|
||||
select {
|
||||
case <-hconn.Context().Done():
|
||||
// we expect the client to eventually close the connection after receiving the GOAWAY
|
||||
case <-s.closeCtx.Done():
|
||||
// close the connection after graceful period
|
||||
conn.CloseWithError(quic.ApplicationErrorCode(ErrCodeNoError), "")
|
||||
}
|
||||
handleErr = http.ErrServerClosed
|
||||
break
|
||||
}
|
||||
|
||||
var appErr *quic.ApplicationError
|
||||
if !errors.As(err, &appErr) || appErr.ErrorCode != quic.ApplicationErrorCode(ErrCodeNoError) {
|
||||
handleErr = fmt.Errorf("accepting stream failed: %w", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
go s.handleRequest(hconn, str, datagrams, hconn.decoder)
|
||||
|
||||
nextStreamID = str.StreamID() + 4
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
// handleRequest will return once the request has been handled,
|
||||
// or the underlying connection is closed
|
||||
defer wg.Done()
|
||||
s.handleRequest(hconn, str, datagrams, hconn.decoder)
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
return handleErr
|
||||
}
|
||||
|
||||
func (s *Server) maxHeaderBytes() uint64 {
|
||||
|
@ -606,7 +684,7 @@ func (s *Server) handleRequest(conn *connection, str quic.Stream, datagrams *dat
|
|||
if logger == nil {
|
||||
logger = slog.Default()
|
||||
}
|
||||
logger.Error("http: panic serving", "arg", p, "trace", buf)
|
||||
logger.Error("http: panic serving", "arg", p, "trace", string(buf))
|
||||
}
|
||||
}()
|
||||
handler.ServeHTTP(r, req)
|
||||
|
@ -643,11 +721,17 @@ func (s *Server) handleRequest(conn *connection, str quic.Stream, datagrams *dat
|
|||
|
||||
// Close the server immediately, aborting requests and sending CONNECTION_CLOSE frames to connected clients.
|
||||
// Close in combination with ListenAndServe() (instead of Serve()) may race if it is called before a UDP socket is established.
|
||||
// It is the caller's responsibility to close any connection passed to ServeQUICConn.
|
||||
func (s *Server) Close() error {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
||||
s.closed = true
|
||||
// server is never used
|
||||
if s.closeCtx == nil {
|
||||
return nil
|
||||
}
|
||||
s.closeCancel()
|
||||
|
||||
var err error
|
||||
for ln := range s.listeners {
|
||||
|
@ -655,14 +739,44 @@ func (s *Server) Close() error {
|
|||
err = cerr
|
||||
}
|
||||
}
|
||||
if s.connCount.Load() == 0 {
|
||||
return err
|
||||
}
|
||||
// wait for all connections to be closed
|
||||
<-s.connHandlingDone
|
||||
return err
|
||||
}
|
||||
|
||||
// CloseGracefully shuts down the server gracefully. The server sends a GOAWAY frame first, then waits for either timeout to trigger, or for all running requests to complete.
|
||||
// CloseGracefully in combination with ListenAndServe() (instead of Serve()) may race if it is called before a UDP socket is established.
|
||||
func (s *Server) CloseGracefully(timeout time.Duration) error {
|
||||
// TODO: implement
|
||||
return nil
|
||||
// Shutdown shuts down the server gracefully.
|
||||
// The server sends a GOAWAY frame first, then or for all running requests to complete.
|
||||
// Shutdown in combination with ListenAndServe() (instead of Serve()) may race if it is called before a UDP socket is established.
|
||||
func (s *Server) Shutdown(ctx context.Context) error {
|
||||
s.mutex.Lock()
|
||||
s.closed = true
|
||||
// server is never used
|
||||
if s.closeCtx == nil {
|
||||
s.mutex.Unlock()
|
||||
return nil
|
||||
}
|
||||
s.graceCancel()
|
||||
s.mutex.Unlock()
|
||||
|
||||
if s.connCount.Load() == 0 {
|
||||
return s.Close()
|
||||
}
|
||||
select {
|
||||
case <-s.connHandlingDone: // all connections were closed
|
||||
// When receiving a GOAWAY frame, HTTP/3 clients are expected to close the connection
|
||||
// once all requests were successfully handled...
|
||||
return s.Close()
|
||||
case <-ctx.Done():
|
||||
// ... however, clients handling long-lived requests (and misbehaving clients),
|
||||
// might not do so before the context is cancelled.
|
||||
// In this case, we close the server, which closes all existing connections
|
||||
// (expect those passed to ServeQUICConn).
|
||||
_ = s.Close()
|
||||
return ctx.Err()
|
||||
}
|
||||
}
|
||||
|
||||
// ErrNoAltSvcPort is the error returned by SetQUICHeaders when no port was found
|
||||
|
@ -690,11 +804,6 @@ func (s *Server) SetQUICHeaders(hdr http.Header) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Deprecated: use SetQUICHeaders instead.
|
||||
func (s *Server) SetQuicHeaders(hdr http.Header) error {
|
||||
return s.SetQUICHeaders(hdr)
|
||||
}
|
||||
|
||||
// ListenAndServeQUIC listens on the UDP network address addr and calls the
|
||||
// handler for HTTP/3 requests on incoming connections. http.DefaultServeMux is
|
||||
// used when handler is nil.
|
||||
|
@ -706,11 +815,6 @@ func ListenAndServeQUIC(addr, certFile, keyFile string, handler http.Handler) er
|
|||
return server.ListenAndServeTLS(certFile, keyFile)
|
||||
}
|
||||
|
||||
// Deprecated: use ListenAndServeTLS instead.
|
||||
func ListenAndServe(addr, certFile, keyFile string, handler http.Handler) error {
|
||||
return ListenAndServeTLS(addr, certFile, keyFile, handler)
|
||||
}
|
||||
|
||||
// ListenAndServeTLS listens on the given network address for both TLS/TCP and QUIC
|
||||
// connections in parallel. It returns if one of the two returns an error.
|
||||
// http.DefaultServeMux is used when handler is nil.
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
@ -30,7 +31,7 @@ type Settings struct {
|
|||
|
||||
// RoundTripOpt are options for the Transport.RoundTripOpt method.
|
||||
type RoundTripOpt struct {
|
||||
// OnlyCachedConn controls whether the RoundTripper may create a new QUIC connection.
|
||||
// OnlyCachedConn controls whether the Transport may create a new QUIC connection.
|
||||
// If set true and no cached connection is available, RoundTripOpt will return ErrNoCachedConn.
|
||||
OnlyCachedConn bool
|
||||
}
|
||||
|
@ -59,10 +60,8 @@ func (r *roundTripperWithCount) Close() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// RoundTripper implements the http.RoundTripper interface
|
||||
type RoundTripper struct {
|
||||
mutex sync.Mutex
|
||||
|
||||
// Transport implements the http.RoundTripper interface
|
||||
type Transport struct {
|
||||
// TLSClientConfig specifies the TLS configuration to use with
|
||||
// tls.Client. If nil, the default configuration is used.
|
||||
TLSClientConfig *tls.Config
|
||||
|
@ -97,6 +96,13 @@ type RoundTripper struct {
|
|||
// However, if the user explicitly requested gzip it is not automatically uncompressed.
|
||||
DisableCompression bool
|
||||
|
||||
StreamHijacker func(FrameType, quic.ConnectionTracingID, quic.Stream, error) (hijacked bool, err error)
|
||||
UniStreamHijacker func(StreamType, quic.ConnectionTracingID, quic.ReceiveStream, error) (hijacked bool)
|
||||
|
||||
Logger *slog.Logger
|
||||
|
||||
mutex sync.Mutex
|
||||
|
||||
initOnce sync.Once
|
||||
initErr error
|
||||
|
||||
|
@ -107,18 +113,56 @@ type RoundTripper struct {
|
|||
}
|
||||
|
||||
var (
|
||||
_ http.RoundTripper = &RoundTripper{}
|
||||
_ io.Closer = &RoundTripper{}
|
||||
_ http.RoundTripper = &Transport{}
|
||||
_ io.Closer = &Transport{}
|
||||
)
|
||||
|
||||
// ErrNoCachedConn is returned when RoundTripper.OnlyCachedConn is set
|
||||
// Deprecated: RoundTripper was renamed to Transport.
|
||||
type RoundTripper = Transport
|
||||
|
||||
// ErrNoCachedConn is returned when Transport.OnlyCachedConn is set
|
||||
var ErrNoCachedConn = errors.New("http3: no cached connection was available")
|
||||
|
||||
func (t *Transport) init() error {
|
||||
if t.newClient == nil {
|
||||
t.newClient = func(conn quic.EarlyConnection) singleRoundTripper {
|
||||
return newClientConn(
|
||||
conn,
|
||||
t.EnableDatagrams,
|
||||
t.AdditionalSettings,
|
||||
t.StreamHijacker,
|
||||
t.UniStreamHijacker,
|
||||
t.MaxResponseHeaderBytes,
|
||||
t.DisableCompression,
|
||||
t.Logger,
|
||||
)
|
||||
}
|
||||
}
|
||||
if t.QUICConfig == nil {
|
||||
t.QUICConfig = defaultQuicConfig.Clone()
|
||||
t.QUICConfig.EnableDatagrams = t.EnableDatagrams
|
||||
}
|
||||
if t.EnableDatagrams && !t.QUICConfig.EnableDatagrams {
|
||||
return errors.New("HTTP Datagrams enabled, but QUIC Datagrams disabled")
|
||||
}
|
||||
if len(t.QUICConfig.Versions) == 0 {
|
||||
t.QUICConfig = t.QUICConfig.Clone()
|
||||
t.QUICConfig.Versions = []quic.Version{protocol.SupportedVersions[0]}
|
||||
}
|
||||
if len(t.QUICConfig.Versions) != 1 {
|
||||
return errors.New("can only use a single QUIC version for dialing a HTTP/3 connection")
|
||||
}
|
||||
if t.QUICConfig.MaxIncomingStreams == 0 {
|
||||
t.QUICConfig.MaxIncomingStreams = -1 // don't allow any bidirectional streams
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RoundTripOpt is like RoundTrip, but takes options.
|
||||
func (r *RoundTripper) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error) {
|
||||
r.initOnce.Do(func() { r.initErr = r.init() })
|
||||
if r.initErr != nil {
|
||||
return nil, r.initErr
|
||||
func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error) {
|
||||
t.initOnce.Do(func() { t.initErr = t.init() })
|
||||
if t.initErr != nil {
|
||||
return nil, t.initErr
|
||||
}
|
||||
|
||||
if req.URL == nil {
|
||||
|
@ -154,7 +198,7 @@ func (r *RoundTripper) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.
|
|||
}
|
||||
|
||||
hostname := authorityAddr(hostnameFromURL(req.URL))
|
||||
cl, isReused, err := r.getClient(req.Context(), hostname, opt.OnlyCachedConn)
|
||||
cl, isReused, err := t.getClient(req.Context(), hostname, opt.OnlyCachedConn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -166,7 +210,7 @@ func (r *RoundTripper) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.
|
|||
}
|
||||
|
||||
if cl.dialErr != nil {
|
||||
r.removeClient(hostname)
|
||||
t.removeClient(hostname)
|
||||
return nil, cl.dialErr
|
||||
}
|
||||
defer cl.useCount.Add(-1)
|
||||
|
@ -176,12 +220,12 @@ func (r *RoundTripper) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.
|
|||
// so we remove the client from the cache so that subsequent trips reconnect
|
||||
// context cancelation is excluded as is does not signify a connection error
|
||||
if !errors.Is(err, context.Canceled) {
|
||||
r.removeClient(hostname)
|
||||
t.removeClient(hostname)
|
||||
}
|
||||
|
||||
if isReused {
|
||||
if nerr, ok := err.(net.Error); ok && nerr.Timeout() {
|
||||
return r.RoundTripOpt(req, opt)
|
||||
return t.RoundTripOpt(req, opt)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,51 +233,19 @@ func (r *RoundTripper) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.
|
|||
}
|
||||
|
||||
// RoundTrip does a round trip.
|
||||
func (r *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
return r.RoundTripOpt(req, RoundTripOpt{})
|
||||
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
return t.RoundTripOpt(req, RoundTripOpt{})
|
||||
}
|
||||
|
||||
func (r *RoundTripper) init() error {
|
||||
if r.newClient == nil {
|
||||
r.newClient = func(conn quic.EarlyConnection) singleRoundTripper {
|
||||
return &SingleDestinationRoundTripper{
|
||||
Connection: conn,
|
||||
EnableDatagrams: r.EnableDatagrams,
|
||||
DisableCompression: r.DisableCompression,
|
||||
AdditionalSettings: r.AdditionalSettings,
|
||||
MaxResponseHeaderBytes: r.MaxResponseHeaderBytes,
|
||||
}
|
||||
}
|
||||
}
|
||||
if r.QUICConfig == nil {
|
||||
r.QUICConfig = defaultQuicConfig.Clone()
|
||||
r.QUICConfig.EnableDatagrams = r.EnableDatagrams
|
||||
}
|
||||
if r.EnableDatagrams && !r.QUICConfig.EnableDatagrams {
|
||||
return errors.New("HTTP Datagrams enabled, but QUIC Datagrams disabled")
|
||||
}
|
||||
if len(r.QUICConfig.Versions) == 0 {
|
||||
r.QUICConfig = r.QUICConfig.Clone()
|
||||
r.QUICConfig.Versions = []quic.Version{protocol.SupportedVersions[0]}
|
||||
}
|
||||
if len(r.QUICConfig.Versions) != 1 {
|
||||
return errors.New("can only use a single QUIC version for dialing a HTTP/3 connection")
|
||||
}
|
||||
if r.QUICConfig.MaxIncomingStreams == 0 {
|
||||
r.QUICConfig.MaxIncomingStreams = -1 // don't allow any bidirectional streams
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (t *Transport) getClient(ctx context.Context, hostname string, onlyCached bool) (rtc *roundTripperWithCount, isReused bool, err error) {
|
||||
t.mutex.Lock()
|
||||
defer t.mutex.Unlock()
|
||||
|
||||
func (r *RoundTripper) getClient(ctx context.Context, hostname string, onlyCached bool) (rtc *roundTripperWithCount, isReused bool, err error) {
|
||||
r.mutex.Lock()
|
||||
defer r.mutex.Unlock()
|
||||
|
||||
if r.clients == nil {
|
||||
r.clients = make(map[string]*roundTripperWithCount)
|
||||
if t.clients == nil {
|
||||
t.clients = make(map[string]*roundTripperWithCount)
|
||||
}
|
||||
|
||||
cl, ok := r.clients[hostname]
|
||||
cl, ok := t.clients[hostname]
|
||||
if !ok {
|
||||
if onlyCached {
|
||||
return nil, false, ErrNoCachedConn
|
||||
|
@ -246,7 +258,7 @@ func (r *RoundTripper) getClient(ctx context.Context, hostname string, onlyCache
|
|||
go func() {
|
||||
defer close(cl.dialing)
|
||||
defer cancel()
|
||||
conn, rt, err := r.dial(ctx, hostname)
|
||||
conn, rt, err := t.dial(ctx, hostname)
|
||||
if err != nil {
|
||||
cl.dialErr = err
|
||||
return
|
||||
|
@ -254,12 +266,12 @@ func (r *RoundTripper) getClient(ctx context.Context, hostname string, onlyCache
|
|||
cl.conn = conn
|
||||
cl.rt = rt
|
||||
}()
|
||||
r.clients[hostname] = cl
|
||||
t.clients[hostname] = cl
|
||||
}
|
||||
select {
|
||||
case <-cl.dialing:
|
||||
if cl.dialErr != nil {
|
||||
delete(r.clients, hostname)
|
||||
delete(t.clients, hostname)
|
||||
return nil, false, cl.dialErr
|
||||
}
|
||||
select {
|
||||
|
@ -273,12 +285,12 @@ func (r *RoundTripper) getClient(ctx context.Context, hostname string, onlyCache
|
|||
return cl, isReused, nil
|
||||
}
|
||||
|
||||
func (r *RoundTripper) dial(ctx context.Context, hostname string) (quic.EarlyConnection, singleRoundTripper, error) {
|
||||
func (t *Transport) dial(ctx context.Context, hostname string) (quic.EarlyConnection, singleRoundTripper, error) {
|
||||
var tlsConf *tls.Config
|
||||
if r.TLSClientConfig == nil {
|
||||
if t.TLSClientConfig == nil {
|
||||
tlsConf = &tls.Config{}
|
||||
} else {
|
||||
tlsConf = r.TLSClientConfig.Clone()
|
||||
tlsConf = t.TLSClientConfig.Clone()
|
||||
}
|
||||
if tlsConf.ServerName == "" {
|
||||
sni, _, err := net.SplitHostPort(hostname)
|
||||
|
@ -289,61 +301,79 @@ func (r *RoundTripper) dial(ctx context.Context, hostname string) (quic.EarlyCon
|
|||
tlsConf.ServerName = sni
|
||||
}
|
||||
// Replace existing ALPNs by H3
|
||||
tlsConf.NextProtos = []string{versionToALPN(r.QUICConfig.Versions[0])}
|
||||
tlsConf.NextProtos = []string{versionToALPN(t.QUICConfig.Versions[0])}
|
||||
|
||||
dial := r.Dial
|
||||
dial := t.Dial
|
||||
if dial == nil {
|
||||
if r.transport == nil {
|
||||
if t.transport == nil {
|
||||
udpConn, err := net.ListenUDP("udp", nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
r.transport = &quic.Transport{Conn: udpConn}
|
||||
t.transport = &quic.Transport{Conn: udpConn}
|
||||
}
|
||||
dial = func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error) {
|
||||
udpAddr, err := net.ResolveUDPAddr("udp", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return r.transport.DialEarly(ctx, udpAddr, tlsCfg, cfg)
|
||||
return t.transport.DialEarly(ctx, udpAddr, tlsCfg, cfg)
|
||||
}
|
||||
}
|
||||
|
||||
conn, err := dial(ctx, hostname, tlsConf, r.QUICConfig)
|
||||
conn, err := dial(ctx, hostname, tlsConf, t.QUICConfig)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return conn, r.newClient(conn), nil
|
||||
return conn, t.newClient(conn), nil
|
||||
}
|
||||
|
||||
func (r *RoundTripper) removeClient(hostname string) {
|
||||
r.mutex.Lock()
|
||||
defer r.mutex.Unlock()
|
||||
if r.clients == nil {
|
||||
func (t *Transport) removeClient(hostname string) {
|
||||
t.mutex.Lock()
|
||||
defer t.mutex.Unlock()
|
||||
if t.clients == nil {
|
||||
return
|
||||
}
|
||||
delete(r.clients, hostname)
|
||||
delete(t.clients, hostname)
|
||||
}
|
||||
|
||||
// Close closes the QUIC connections that this RoundTripper has used.
|
||||
// It also closes the underlying UDPConn if it is not nil.
|
||||
func (r *RoundTripper) Close() error {
|
||||
r.mutex.Lock()
|
||||
defer r.mutex.Unlock()
|
||||
for _, cl := range r.clients {
|
||||
// NewClientConn creates a new HTTP/3 client connection on top of a QUIC connection.
|
||||
// Most users should use RoundTrip instead of creating a connection directly.
|
||||
// Specifically, it is not needed to perform GET, POST, HEAD and CONNECT requests.
|
||||
//
|
||||
// Obtaining a ClientConn is only needed for more advanced use cases, such as
|
||||
// using Extended CONNECT for WebTransport or the various MASQUE protocols.
|
||||
func (t *Transport) NewClientConn(conn quic.Connection) *ClientConn {
|
||||
return newClientConn(
|
||||
conn,
|
||||
t.EnableDatagrams,
|
||||
t.AdditionalSettings,
|
||||
t.StreamHijacker,
|
||||
t.UniStreamHijacker,
|
||||
t.MaxResponseHeaderBytes,
|
||||
t.DisableCompression,
|
||||
t.Logger,
|
||||
)
|
||||
}
|
||||
|
||||
// Close closes the QUIC connections that this Transport has used.
|
||||
func (t *Transport) Close() error {
|
||||
t.mutex.Lock()
|
||||
defer t.mutex.Unlock()
|
||||
for _, cl := range t.clients {
|
||||
if err := cl.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
r.clients = nil
|
||||
if r.transport != nil {
|
||||
if err := r.transport.Close(); err != nil {
|
||||
t.clients = nil
|
||||
if t.transport != nil {
|
||||
if err := t.transport.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := r.transport.Conn.Close(); err != nil {
|
||||
if err := t.transport.Conn.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
r.transport = nil
|
||||
t.transport = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -376,13 +406,17 @@ func isNotToken(r rune) bool {
|
|||
return !httpguts.IsTokenRune(r)
|
||||
}
|
||||
|
||||
func (r *RoundTripper) CloseIdleConnections() {
|
||||
r.mutex.Lock()
|
||||
defer r.mutex.Unlock()
|
||||
for hostname, cl := range r.clients {
|
||||
// CloseIdleConnections closes any QUIC connections in the transport's pool that are currently idle.
|
||||
// An idle connection is one that was previously used for requests but is now sitting unused.
|
||||
// This method does not interrupt any connections currently in use.
|
||||
// It also does not affect connections obtained via NewClientConn.
|
||||
func (t *Transport) CloseIdleConnections() {
|
||||
t.mutex.Lock()
|
||||
defer t.mutex.Unlock()
|
||||
for hostname, cl := range t.clients {
|
||||
if cl.useCount.Load() == 0 {
|
||||
cl.Close()
|
||||
delete(r.clients, hostname)
|
||||
delete(t.clients, hostname)
|
||||
}
|
||||
}
|
||||
}
|
23
vendor/github.com/quic-go/quic-go/internal/handshake/interface.go
generated
vendored
23
vendor/github.com/quic-go/quic-go/internal/handshake/interface.go
generated
vendored
|
@ -83,6 +83,29 @@ const (
|
|||
EventHandshakeComplete
|
||||
)
|
||||
|
||||
func (k EventKind) String() string {
|
||||
switch k {
|
||||
case EventNoEvent:
|
||||
return "EventNoEvent"
|
||||
case EventWriteInitialData:
|
||||
return "EventWriteInitialData"
|
||||
case EventWriteHandshakeData:
|
||||
return "EventWriteHandshakeData"
|
||||
case EventReceivedReadKeys:
|
||||
return "EventReceivedReadKeys"
|
||||
case EventDiscard0RTTKeys:
|
||||
return "EventDiscard0RTTKeys"
|
||||
case EventReceivedTransportParameters:
|
||||
return "EventReceivedTransportParameters"
|
||||
case EventRestoredTransportParameters:
|
||||
return "EventRestoredTransportParameters"
|
||||
case EventHandshakeComplete:
|
||||
return "EventHandshakeComplete"
|
||||
default:
|
||||
return "Unknown EventKind"
|
||||
}
|
||||
}
|
||||
|
||||
// Event is a handshake event.
|
||||
type Event struct {
|
||||
Kind EventKind
|
||||
|
|
21
vendor/github.com/quic-go/quic-go/internal/utils/rtt_stats.go
generated
vendored
21
vendor/github.com/quic-go/quic-go/internal/utils/rtt_stats.go
generated
vendored
|
@ -27,11 +27,6 @@ type RTTStats struct {
|
|||
maxAckDelay time.Duration
|
||||
}
|
||||
|
||||
// NewRTTStats makes a properly initialized RTTStats object
|
||||
func NewRTTStats() *RTTStats {
|
||||
return &RTTStats{}
|
||||
}
|
||||
|
||||
// MinRTT Returns the minRTT for the entire connection.
|
||||
// May return Zero if no valid updates have occurred.
|
||||
func (r *RTTStats) MinRTT() time.Duration { return r.minRTT }
|
||||
|
@ -113,19 +108,3 @@ func (r *RTTStats) SetInitialRTT(t time.Duration) {
|
|||
r.smoothedRTT = t
|
||||
r.latestRTT = t
|
||||
}
|
||||
|
||||
// OnConnectionMigration is called when connection migrates and rtt measurement needs to be reset.
|
||||
func (r *RTTStats) OnConnectionMigration() {
|
||||
r.latestRTT = 0
|
||||
r.minRTT = 0
|
||||
r.smoothedRTT = 0
|
||||
r.meanDeviation = 0
|
||||
}
|
||||
|
||||
// ExpireSmoothedMetrics causes the smoothed_rtt to be increased to the latest_rtt if the latest_rtt
|
||||
// is larger. The mean deviation is increased to the most recent deviation if
|
||||
// it's larger.
|
||||
func (r *RTTStats) ExpireSmoothedMetrics() {
|
||||
r.meanDeviation = max(r.meanDeviation, (r.smoothedRTT - r.latestRTT).Abs())
|
||||
r.smoothedRTT = max(r.smoothedRTT, r.latestRTT)
|
||||
}
|
||||
|
|
3
vendor/github.com/quic-go/quic-go/receive_stream.go
generated
vendored
3
vendor/github.com/quic-go/quic-go/receive_stream.go
generated
vendored
|
@ -253,6 +253,9 @@ func (s *receiveStream) cancelReadImpl(errorCode qerr.StreamErrorCode) (queuedNe
|
|||
if s.cancelledLocally { // duplicate call to CancelRead
|
||||
return false
|
||||
}
|
||||
if s.closeForShutdownErr != nil {
|
||||
return false
|
||||
}
|
||||
s.cancelledLocally = true
|
||||
if s.errorRead || s.cancelledRemotely {
|
||||
return false
|
||||
|
|
4
vendor/github.com/quic-go/quic-go/send_stream.go
generated
vendored
4
vendor/github.com/quic-go/quic-go/send_stream.go
generated
vendored
|
@ -423,6 +423,10 @@ func (s *sendStream) CancelWrite(errorCode StreamErrorCode) {
|
|||
|
||||
func (s *sendStream) cancelWriteImpl(errorCode qerr.StreamErrorCode, remote bool) {
|
||||
s.mutex.Lock()
|
||||
if s.closeForShutdownErr != nil {
|
||||
s.mutex.Unlock()
|
||||
return
|
||||
}
|
||||
if !remote {
|
||||
s.cancellationFlagged = true
|
||||
if s.cancelWriteErr != nil {
|
||||
|
|
122
vendor/golang.org/x/net/http2/config.go
generated
vendored
Normal file
122
vendor/golang.org/x/net/http2/config.go
generated
vendored
Normal file
|
@ -0,0 +1,122 @@
|
|||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package http2
|
||||
|
||||
import (
|
||||
"math"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
// http2Config is a package-internal version of net/http.HTTP2Config.
|
||||
//
|
||||
// http.HTTP2Config was added in Go 1.24.
|
||||
// When running with a version of net/http that includes HTTP2Config,
|
||||
// we merge the configuration with the fields in Transport or Server
|
||||
// to produce an http2Config.
|
||||
//
|
||||
// Zero valued fields in http2Config are interpreted as in the
|
||||
// net/http.HTTPConfig documentation.
|
||||
//
|
||||
// Precedence order for reconciling configurations is:
|
||||
//
|
||||
// - Use the net/http.{Server,Transport}.HTTP2Config value, when non-zero.
|
||||
// - Otherwise use the http2.{Server.Transport} value.
|
||||
// - If the resulting value is zero or out of range, use a default.
|
||||
type http2Config struct {
|
||||
MaxConcurrentStreams uint32
|
||||
MaxDecoderHeaderTableSize uint32
|
||||
MaxEncoderHeaderTableSize uint32
|
||||
MaxReadFrameSize uint32
|
||||
MaxUploadBufferPerConnection int32
|
||||
MaxUploadBufferPerStream int32
|
||||
SendPingTimeout time.Duration
|
||||
PingTimeout time.Duration
|
||||
WriteByteTimeout time.Duration
|
||||
PermitProhibitedCipherSuites bool
|
||||
CountError func(errType string)
|
||||
}
|
||||
|
||||
// configFromServer merges configuration settings from
|
||||
// net/http.Server.HTTP2Config and http2.Server.
|
||||
func configFromServer(h1 *http.Server, h2 *Server) http2Config {
|
||||
conf := http2Config{
|
||||
MaxConcurrentStreams: h2.MaxConcurrentStreams,
|
||||
MaxEncoderHeaderTableSize: h2.MaxEncoderHeaderTableSize,
|
||||
MaxDecoderHeaderTableSize: h2.MaxDecoderHeaderTableSize,
|
||||
MaxReadFrameSize: h2.MaxReadFrameSize,
|
||||
MaxUploadBufferPerConnection: h2.MaxUploadBufferPerConnection,
|
||||
MaxUploadBufferPerStream: h2.MaxUploadBufferPerStream,
|
||||
SendPingTimeout: h2.ReadIdleTimeout,
|
||||
PingTimeout: h2.PingTimeout,
|
||||
WriteByteTimeout: h2.WriteByteTimeout,
|
||||
PermitProhibitedCipherSuites: h2.PermitProhibitedCipherSuites,
|
||||
CountError: h2.CountError,
|
||||
}
|
||||
fillNetHTTPServerConfig(&conf, h1)
|
||||
setConfigDefaults(&conf, true)
|
||||
return conf
|
||||
}
|
||||
|
||||
// configFromServer merges configuration settings from h2 and h2.t1.HTTP2
|
||||
// (the net/http Transport).
|
||||
func configFromTransport(h2 *Transport) http2Config {
|
||||
conf := http2Config{
|
||||
MaxEncoderHeaderTableSize: h2.MaxEncoderHeaderTableSize,
|
||||
MaxDecoderHeaderTableSize: h2.MaxDecoderHeaderTableSize,
|
||||
MaxReadFrameSize: h2.MaxReadFrameSize,
|
||||
SendPingTimeout: h2.ReadIdleTimeout,
|
||||
PingTimeout: h2.PingTimeout,
|
||||
WriteByteTimeout: h2.WriteByteTimeout,
|
||||
}
|
||||
|
||||
// Unlike most config fields, where out-of-range values revert to the default,
|
||||
// Transport.MaxReadFrameSize clips.
|
||||
if conf.MaxReadFrameSize < minMaxFrameSize {
|
||||
conf.MaxReadFrameSize = minMaxFrameSize
|
||||
} else if conf.MaxReadFrameSize > maxFrameSize {
|
||||
conf.MaxReadFrameSize = maxFrameSize
|
||||
}
|
||||
|
||||
if h2.t1 != nil {
|
||||
fillNetHTTPTransportConfig(&conf, h2.t1)
|
||||
}
|
||||
setConfigDefaults(&conf, false)
|
||||
return conf
|
||||
}
|
||||
|
||||
func setDefault[T ~int | ~int32 | ~uint32 | ~int64](v *T, minval, maxval, defval T) {
|
||||
if *v < minval || *v > maxval {
|
||||
*v = defval
|
||||
}
|
||||
}
|
||||
|
||||
func setConfigDefaults(conf *http2Config, server bool) {
|
||||
setDefault(&conf.MaxConcurrentStreams, 1, math.MaxUint32, defaultMaxStreams)
|
||||
setDefault(&conf.MaxEncoderHeaderTableSize, 1, math.MaxUint32, initialHeaderTableSize)
|
||||
setDefault(&conf.MaxDecoderHeaderTableSize, 1, math.MaxUint32, initialHeaderTableSize)
|
||||
if server {
|
||||
setDefault(&conf.MaxUploadBufferPerConnection, initialWindowSize, math.MaxInt32, 1<<20)
|
||||
} else {
|
||||
setDefault(&conf.MaxUploadBufferPerConnection, initialWindowSize, math.MaxInt32, transportDefaultConnFlow)
|
||||
}
|
||||
if server {
|
||||
setDefault(&conf.MaxUploadBufferPerStream, 1, math.MaxInt32, 1<<20)
|
||||
} else {
|
||||
setDefault(&conf.MaxUploadBufferPerStream, 1, math.MaxInt32, transportDefaultStreamFlow)
|
||||
}
|
||||
setDefault(&conf.MaxReadFrameSize, minMaxFrameSize, maxFrameSize, defaultMaxReadFrameSize)
|
||||
setDefault(&conf.PingTimeout, 1, math.MaxInt64, 15*time.Second)
|
||||
}
|
||||
|
||||
// adjustHTTP1MaxHeaderSize converts a limit in bytes on the size of an HTTP/1 header
|
||||
// to an HTTP/2 MAX_HEADER_LIST_SIZE value.
|
||||
func adjustHTTP1MaxHeaderSize(n int64) int64 {
|
||||
// http2's count is in a slightly different unit and includes 32 bytes per pair.
|
||||
// So, take the net/http.Server value and pad it up a bit, assuming 10 headers.
|
||||
const perFieldOverhead = 32 // per http2 spec
|
||||
const typicalHeaders = 10 // conservative
|
||||
return n + typicalHeaders*perFieldOverhead
|
||||
}
|
61
vendor/golang.org/x/net/http2/config_go124.go
generated
vendored
Normal file
61
vendor/golang.org/x/net/http2/config_go124.go
generated
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build go1.24
|
||||
|
||||
package http2
|
||||
|
||||
import "net/http"
|
||||
|
||||
// fillNetHTTPServerConfig sets fields in conf from srv.HTTP2.
|
||||
func fillNetHTTPServerConfig(conf *http2Config, srv *http.Server) {
|
||||
fillNetHTTPConfig(conf, srv.HTTP2)
|
||||
}
|
||||
|
||||
// fillNetHTTPServerConfig sets fields in conf from tr.HTTP2.
|
||||
func fillNetHTTPTransportConfig(conf *http2Config, tr *http.Transport) {
|
||||
fillNetHTTPConfig(conf, tr.HTTP2)
|
||||
}
|
||||
|
||||
func fillNetHTTPConfig(conf *http2Config, h2 *http.HTTP2Config) {
|
||||
if h2 == nil {
|
||||
return
|
||||
}
|
||||
if h2.MaxConcurrentStreams != 0 {
|
||||
conf.MaxConcurrentStreams = uint32(h2.MaxConcurrentStreams)
|
||||
}
|
||||
if h2.MaxEncoderHeaderTableSize != 0 {
|
||||
conf.MaxEncoderHeaderTableSize = uint32(h2.MaxEncoderHeaderTableSize)
|
||||
}
|
||||
if h2.MaxDecoderHeaderTableSize != 0 {
|
||||
conf.MaxDecoderHeaderTableSize = uint32(h2.MaxDecoderHeaderTableSize)
|
||||
}
|
||||
if h2.MaxConcurrentStreams != 0 {
|
||||
conf.MaxConcurrentStreams = uint32(h2.MaxConcurrentStreams)
|
||||
}
|
||||
if h2.MaxReadFrameSize != 0 {
|
||||
conf.MaxReadFrameSize = uint32(h2.MaxReadFrameSize)
|
||||
}
|
||||
if h2.MaxReceiveBufferPerConnection != 0 {
|
||||
conf.MaxUploadBufferPerConnection = int32(h2.MaxReceiveBufferPerConnection)
|
||||
}
|
||||
if h2.MaxReceiveBufferPerStream != 0 {
|
||||
conf.MaxUploadBufferPerStream = int32(h2.MaxReceiveBufferPerStream)
|
||||
}
|
||||
if h2.SendPingTimeout != 0 {
|
||||
conf.SendPingTimeout = h2.SendPingTimeout
|
||||
}
|
||||
if h2.PingTimeout != 0 {
|
||||
conf.PingTimeout = h2.PingTimeout
|
||||
}
|
||||
if h2.WriteByteTimeout != 0 {
|
||||
conf.WriteByteTimeout = h2.WriteByteTimeout
|
||||
}
|
||||
if h2.PermitProhibitedCipherSuites {
|
||||
conf.PermitProhibitedCipherSuites = true
|
||||
}
|
||||
if h2.CountError != nil {
|
||||
conf.CountError = h2.CountError
|
||||
}
|
||||
}
|
16
vendor/golang.org/x/net/http2/config_pre_go124.go
generated
vendored
Normal file
16
vendor/golang.org/x/net/http2/config_pre_go124.go
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !go1.24
|
||||
|
||||
package http2
|
||||
|
||||
import "net/http"
|
||||
|
||||
// Pre-Go 1.24 fallback.
|
||||
// The Server.HTTP2 and Transport.HTTP2 config fields were added in Go 1.24.
|
||||
|
||||
func fillNetHTTPServerConfig(conf *http2Config, srv *http.Server) {}
|
||||
|
||||
func fillNetHTTPTransportConfig(conf *http2Config, tr *http.Transport) {}
|
53
vendor/golang.org/x/net/http2/http2.go
generated
vendored
53
vendor/golang.org/x/net/http2/http2.go
generated
vendored
|
@ -19,8 +19,9 @@ import (
|
|||
"bufio"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"sort"
|
||||
|
@ -237,13 +238,19 @@ func (cw closeWaiter) Wait() {
|
|||
// Its buffered writer is lazily allocated as needed, to minimize
|
||||
// idle memory usage with many connections.
|
||||
type bufferedWriter struct {
|
||||
_ incomparable
|
||||
w io.Writer // immutable
|
||||
bw *bufio.Writer // non-nil when data is buffered
|
||||
_ incomparable
|
||||
group synctestGroupInterface // immutable
|
||||
conn net.Conn // immutable
|
||||
bw *bufio.Writer // non-nil when data is buffered
|
||||
byteTimeout time.Duration // immutable, WriteByteTimeout
|
||||
}
|
||||
|
||||
func newBufferedWriter(w io.Writer) *bufferedWriter {
|
||||
return &bufferedWriter{w: w}
|
||||
func newBufferedWriter(group synctestGroupInterface, conn net.Conn, timeout time.Duration) *bufferedWriter {
|
||||
return &bufferedWriter{
|
||||
group: group,
|
||||
conn: conn,
|
||||
byteTimeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// bufWriterPoolBufferSize is the size of bufio.Writer's
|
||||
|
@ -270,7 +277,7 @@ func (w *bufferedWriter) Available() int {
|
|||
func (w *bufferedWriter) Write(p []byte) (n int, err error) {
|
||||
if w.bw == nil {
|
||||
bw := bufWriterPool.Get().(*bufio.Writer)
|
||||
bw.Reset(w.w)
|
||||
bw.Reset((*bufferedWriterTimeoutWriter)(w))
|
||||
w.bw = bw
|
||||
}
|
||||
return w.bw.Write(p)
|
||||
|
@ -288,6 +295,38 @@ func (w *bufferedWriter) Flush() error {
|
|||
return err
|
||||
}
|
||||
|
||||
type bufferedWriterTimeoutWriter bufferedWriter
|
||||
|
||||
func (w *bufferedWriterTimeoutWriter) Write(p []byte) (n int, err error) {
|
||||
return writeWithByteTimeout(w.group, w.conn, w.byteTimeout, p)
|
||||
}
|
||||
|
||||
// writeWithByteTimeout writes to conn.
|
||||
// If more than timeout passes without any bytes being written to the connection,
|
||||
// the write fails.
|
||||
func writeWithByteTimeout(group synctestGroupInterface, conn net.Conn, timeout time.Duration, p []byte) (n int, err error) {
|
||||
if timeout <= 0 {
|
||||
return conn.Write(p)
|
||||
}
|
||||
for {
|
||||
var now time.Time
|
||||
if group == nil {
|
||||
now = time.Now()
|
||||
} else {
|
||||
now = group.Now()
|
||||
}
|
||||
conn.SetWriteDeadline(now.Add(timeout))
|
||||
nn, err := conn.Write(p[n:])
|
||||
n += nn
|
||||
if n == len(p) || nn == 0 || !errors.Is(err, os.ErrDeadlineExceeded) {
|
||||
// Either we finished the write, made no progress, or hit the deadline.
|
||||
// Whichever it is, we're done now.
|
||||
conn.SetWriteDeadline(time.Time{})
|
||||
return n, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mustUint31(v int32) uint32 {
|
||||
if v < 0 || v > 2147483647 {
|
||||
panic("out of range")
|
||||
|
|
181
vendor/golang.org/x/net/http2/server.go
generated
vendored
181
vendor/golang.org/x/net/http2/server.go
generated
vendored
|
@ -29,6 +29,7 @@ import (
|
|||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -52,10 +53,14 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
prefaceTimeout = 10 * time.Second
|
||||
firstSettingsTimeout = 2 * time.Second // should be in-flight with preface anyway
|
||||
handlerChunkWriteSize = 4 << 10
|
||||
defaultMaxStreams = 250 // TODO: make this 100 as the GFE seems to?
|
||||
prefaceTimeout = 10 * time.Second
|
||||
firstSettingsTimeout = 2 * time.Second // should be in-flight with preface anyway
|
||||
handlerChunkWriteSize = 4 << 10
|
||||
defaultMaxStreams = 250 // TODO: make this 100 as the GFE seems to?
|
||||
|
||||
// maxQueuedControlFrames is the maximum number of control frames like
|
||||
// SETTINGS, PING and RST_STREAM that will be queued for writing before
|
||||
// the connection is closed to prevent memory exhaustion attacks.
|
||||
maxQueuedControlFrames = 10000
|
||||
)
|
||||
|
||||
|
@ -127,6 +132,22 @@ type Server struct {
|
|||
// If zero or negative, there is no timeout.
|
||||
IdleTimeout time.Duration
|
||||
|
||||
// ReadIdleTimeout is the timeout after which a health check using a ping
|
||||
// frame will be carried out if no frame is received on the connection.
|
||||
// If zero, no health check is performed.
|
||||
ReadIdleTimeout time.Duration
|
||||
|
||||
// PingTimeout is the timeout after which the connection will be closed
|
||||
// if a response to a ping is not received.
|
||||
// If zero, a default of 15 seconds is used.
|
||||
PingTimeout time.Duration
|
||||
|
||||
// WriteByteTimeout is the timeout after which a connection will be
|
||||
// closed if no data can be written to it. The timeout begins when data is
|
||||
// available to write, and is extended whenever any bytes are written.
|
||||
// If zero or negative, there is no timeout.
|
||||
WriteByteTimeout time.Duration
|
||||
|
||||
// MaxUploadBufferPerConnection is the size of the initial flow
|
||||
// control window for each connections. The HTTP/2 spec does not
|
||||
// allow this to be smaller than 65535 or larger than 2^32-1.
|
||||
|
@ -189,57 +210,6 @@ func (s *Server) afterFunc(d time.Duration, f func()) timer {
|
|||
return timeTimer{time.AfterFunc(d, f)}
|
||||
}
|
||||
|
||||
func (s *Server) initialConnRecvWindowSize() int32 {
|
||||
if s.MaxUploadBufferPerConnection >= initialWindowSize {
|
||||
return s.MaxUploadBufferPerConnection
|
||||
}
|
||||
return 1 << 20
|
||||
}
|
||||
|
||||
func (s *Server) initialStreamRecvWindowSize() int32 {
|
||||
if s.MaxUploadBufferPerStream > 0 {
|
||||
return s.MaxUploadBufferPerStream
|
||||
}
|
||||
return 1 << 20
|
||||
}
|
||||
|
||||
func (s *Server) maxReadFrameSize() uint32 {
|
||||
if v := s.MaxReadFrameSize; v >= minMaxFrameSize && v <= maxFrameSize {
|
||||
return v
|
||||
}
|
||||
return defaultMaxReadFrameSize
|
||||
}
|
||||
|
||||
func (s *Server) maxConcurrentStreams() uint32 {
|
||||
if v := s.MaxConcurrentStreams; v > 0 {
|
||||
return v
|
||||
}
|
||||
return defaultMaxStreams
|
||||
}
|
||||
|
||||
func (s *Server) maxDecoderHeaderTableSize() uint32 {
|
||||
if v := s.MaxDecoderHeaderTableSize; v > 0 {
|
||||
return v
|
||||
}
|
||||
return initialHeaderTableSize
|
||||
}
|
||||
|
||||
func (s *Server) maxEncoderHeaderTableSize() uint32 {
|
||||
if v := s.MaxEncoderHeaderTableSize; v > 0 {
|
||||
return v
|
||||
}
|
||||
return initialHeaderTableSize
|
||||
}
|
||||
|
||||
// maxQueuedControlFrames is the maximum number of control frames like
|
||||
// SETTINGS, PING and RST_STREAM that will be queued for writing before
|
||||
// the connection is closed to prevent memory exhaustion attacks.
|
||||
func (s *Server) maxQueuedControlFrames() int {
|
||||
// TODO: if anybody asks, add a Server field, and remember to define the
|
||||
// behavior of negative values.
|
||||
return maxQueuedControlFrames
|
||||
}
|
||||
|
||||
type serverInternalState struct {
|
||||
mu sync.Mutex
|
||||
activeConns map[*serverConn]struct{}
|
||||
|
@ -440,13 +410,15 @@ func (s *Server) serveConn(c net.Conn, opts *ServeConnOpts, newf func(*serverCon
|
|||
baseCtx, cancel := serverConnBaseContext(c, opts)
|
||||
defer cancel()
|
||||
|
||||
http1srv := opts.baseConfig()
|
||||
conf := configFromServer(http1srv, s)
|
||||
sc := &serverConn{
|
||||
srv: s,
|
||||
hs: opts.baseConfig(),
|
||||
hs: http1srv,
|
||||
conn: c,
|
||||
baseCtx: baseCtx,
|
||||
remoteAddrStr: c.RemoteAddr().String(),
|
||||
bw: newBufferedWriter(c),
|
||||
bw: newBufferedWriter(s.group, c, conf.WriteByteTimeout),
|
||||
handler: opts.handler(),
|
||||
streams: make(map[uint32]*stream),
|
||||
readFrameCh: make(chan readFrameResult),
|
||||
|
@ -456,9 +428,12 @@ func (s *Server) serveConn(c net.Conn, opts *ServeConnOpts, newf func(*serverCon
|
|||
bodyReadCh: make(chan bodyReadMsg), // buffering doesn't matter either way
|
||||
doneServing: make(chan struct{}),
|
||||
clientMaxStreams: math.MaxUint32, // Section 6.5.2: "Initially, there is no limit to this value"
|
||||
advMaxStreams: s.maxConcurrentStreams(),
|
||||
advMaxStreams: conf.MaxConcurrentStreams,
|
||||
initialStreamSendWindowSize: initialWindowSize,
|
||||
initialStreamRecvWindowSize: conf.MaxUploadBufferPerStream,
|
||||
maxFrameSize: initialMaxFrameSize,
|
||||
pingTimeout: conf.PingTimeout,
|
||||
countErrorFunc: conf.CountError,
|
||||
serveG: newGoroutineLock(),
|
||||
pushEnabled: true,
|
||||
sawClientPreface: opts.SawClientPreface,
|
||||
|
@ -491,15 +466,15 @@ func (s *Server) serveConn(c net.Conn, opts *ServeConnOpts, newf func(*serverCon
|
|||
sc.flow.add(initialWindowSize)
|
||||
sc.inflow.init(initialWindowSize)
|
||||
sc.hpackEncoder = hpack.NewEncoder(&sc.headerWriteBuf)
|
||||
sc.hpackEncoder.SetMaxDynamicTableSizeLimit(s.maxEncoderHeaderTableSize())
|
||||
sc.hpackEncoder.SetMaxDynamicTableSizeLimit(conf.MaxEncoderHeaderTableSize)
|
||||
|
||||
fr := NewFramer(sc.bw, c)
|
||||
if s.CountError != nil {
|
||||
fr.countError = s.CountError
|
||||
if conf.CountError != nil {
|
||||
fr.countError = conf.CountError
|
||||
}
|
||||
fr.ReadMetaHeaders = hpack.NewDecoder(s.maxDecoderHeaderTableSize(), nil)
|
||||
fr.ReadMetaHeaders = hpack.NewDecoder(conf.MaxDecoderHeaderTableSize, nil)
|
||||
fr.MaxHeaderListSize = sc.maxHeaderListSize()
|
||||
fr.SetMaxReadFrameSize(s.maxReadFrameSize())
|
||||
fr.SetMaxReadFrameSize(conf.MaxReadFrameSize)
|
||||
sc.framer = fr
|
||||
|
||||
if tc, ok := c.(connectionStater); ok {
|
||||
|
@ -532,7 +507,7 @@ func (s *Server) serveConn(c net.Conn, opts *ServeConnOpts, newf func(*serverCon
|
|||
// So for now, do nothing here again.
|
||||
}
|
||||
|
||||
if !s.PermitProhibitedCipherSuites && isBadCipher(sc.tlsState.CipherSuite) {
|
||||
if !conf.PermitProhibitedCipherSuites && isBadCipher(sc.tlsState.CipherSuite) {
|
||||
// "Endpoints MAY choose to generate a connection error
|
||||
// (Section 5.4.1) of type INADEQUATE_SECURITY if one of
|
||||
// the prohibited cipher suites are negotiated."
|
||||
|
@ -569,7 +544,7 @@ func (s *Server) serveConn(c net.Conn, opts *ServeConnOpts, newf func(*serverCon
|
|||
opts.UpgradeRequest = nil
|
||||
}
|
||||
|
||||
sc.serve()
|
||||
sc.serve(conf)
|
||||
}
|
||||
|
||||
func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx context.Context, cancel func()) {
|
||||
|
@ -609,6 +584,7 @@ type serverConn struct {
|
|||
tlsState *tls.ConnectionState // shared by all handlers, like net/http
|
||||
remoteAddrStr string
|
||||
writeSched WriteScheduler
|
||||
countErrorFunc func(errType string)
|
||||
|
||||
// Everything following is owned by the serve loop; use serveG.check():
|
||||
serveG goroutineLock // used to verify funcs are on serve()
|
||||
|
@ -628,6 +604,7 @@ type serverConn struct {
|
|||
streams map[uint32]*stream
|
||||
unstartedHandlers []unstartedHandler
|
||||
initialStreamSendWindowSize int32
|
||||
initialStreamRecvWindowSize int32
|
||||
maxFrameSize int32
|
||||
peerMaxHeaderListSize uint32 // zero means unknown (default)
|
||||
canonHeader map[string]string // http2-lower-case -> Go-Canonical-Case
|
||||
|
@ -638,9 +615,14 @@ type serverConn struct {
|
|||
inGoAway bool // we've started to or sent GOAWAY
|
||||
inFrameScheduleLoop bool // whether we're in the scheduleFrameWrite loop
|
||||
needToSendGoAway bool // we need to schedule a GOAWAY frame write
|
||||
pingSent bool
|
||||
sentPingData [8]byte
|
||||
goAwayCode ErrCode
|
||||
shutdownTimer timer // nil until used
|
||||
idleTimer timer // nil if unused
|
||||
readIdleTimeout time.Duration
|
||||
pingTimeout time.Duration
|
||||
readIdleTimer timer // nil if unused
|
||||
|
||||
// Owned by the writeFrameAsync goroutine:
|
||||
headerWriteBuf bytes.Buffer
|
||||
|
@ -655,11 +637,7 @@ func (sc *serverConn) maxHeaderListSize() uint32 {
|
|||
if n <= 0 {
|
||||
n = http.DefaultMaxHeaderBytes
|
||||
}
|
||||
// http2's count is in a slightly different unit and includes 32 bytes per pair.
|
||||
// So, take the net/http.Server value and pad it up a bit, assuming 10 headers.
|
||||
const perFieldOverhead = 32 // per http2 spec
|
||||
const typicalHeaders = 10 // conservative
|
||||
return uint32(n + typicalHeaders*perFieldOverhead)
|
||||
return uint32(adjustHTTP1MaxHeaderSize(int64(n)))
|
||||
}
|
||||
|
||||
func (sc *serverConn) curOpenStreams() uint32 {
|
||||
|
@ -923,7 +901,7 @@ func (sc *serverConn) notePanic() {
|
|||
}
|
||||
}
|
||||
|
||||
func (sc *serverConn) serve() {
|
||||
func (sc *serverConn) serve(conf http2Config) {
|
||||
sc.serveG.check()
|
||||
defer sc.notePanic()
|
||||
defer sc.conn.Close()
|
||||
|
@ -937,18 +915,18 @@ func (sc *serverConn) serve() {
|
|||
|
||||
sc.writeFrame(FrameWriteRequest{
|
||||
write: writeSettings{
|
||||
{SettingMaxFrameSize, sc.srv.maxReadFrameSize()},
|
||||
{SettingMaxFrameSize, conf.MaxReadFrameSize},
|
||||
{SettingMaxConcurrentStreams, sc.advMaxStreams},
|
||||
{SettingMaxHeaderListSize, sc.maxHeaderListSize()},
|
||||
{SettingHeaderTableSize, sc.srv.maxDecoderHeaderTableSize()},
|
||||
{SettingInitialWindowSize, uint32(sc.srv.initialStreamRecvWindowSize())},
|
||||
{SettingHeaderTableSize, conf.MaxDecoderHeaderTableSize},
|
||||
{SettingInitialWindowSize, uint32(sc.initialStreamRecvWindowSize)},
|
||||
},
|
||||
})
|
||||
sc.unackedSettings++
|
||||
|
||||
// Each connection starts with initialWindowSize inflow tokens.
|
||||
// If a higher value is configured, we add more tokens.
|
||||
if diff := sc.srv.initialConnRecvWindowSize() - initialWindowSize; diff > 0 {
|
||||
if diff := conf.MaxUploadBufferPerConnection - initialWindowSize; diff > 0 {
|
||||
sc.sendWindowUpdate(nil, int(diff))
|
||||
}
|
||||
|
||||
|
@ -968,11 +946,18 @@ func (sc *serverConn) serve() {
|
|||
defer sc.idleTimer.Stop()
|
||||
}
|
||||
|
||||
if conf.SendPingTimeout > 0 {
|
||||
sc.readIdleTimeout = conf.SendPingTimeout
|
||||
sc.readIdleTimer = sc.srv.afterFunc(conf.SendPingTimeout, sc.onReadIdleTimer)
|
||||
defer sc.readIdleTimer.Stop()
|
||||
}
|
||||
|
||||
go sc.readFrames() // closed by defer sc.conn.Close above
|
||||
|
||||
settingsTimer := sc.srv.afterFunc(firstSettingsTimeout, sc.onSettingsTimer)
|
||||
defer settingsTimer.Stop()
|
||||
|
||||
lastFrameTime := sc.srv.now()
|
||||
loopNum := 0
|
||||
for {
|
||||
loopNum++
|
||||
|
@ -986,6 +971,7 @@ func (sc *serverConn) serve() {
|
|||
case res := <-sc.wroteFrameCh:
|
||||
sc.wroteFrame(res)
|
||||
case res := <-sc.readFrameCh:
|
||||
lastFrameTime = sc.srv.now()
|
||||
// Process any written frames before reading new frames from the client since a
|
||||
// written frame could have triggered a new stream to be started.
|
||||
if sc.writingFrameAsync {
|
||||
|
@ -1017,6 +1003,8 @@ func (sc *serverConn) serve() {
|
|||
case idleTimerMsg:
|
||||
sc.vlogf("connection is idle")
|
||||
sc.goAway(ErrCodeNo)
|
||||
case readIdleTimerMsg:
|
||||
sc.handlePingTimer(lastFrameTime)
|
||||
case shutdownTimerMsg:
|
||||
sc.vlogf("GOAWAY close timer fired; closing conn from %v", sc.conn.RemoteAddr())
|
||||
return
|
||||
|
@ -1039,7 +1027,7 @@ func (sc *serverConn) serve() {
|
|||
// If the peer is causing us to generate a lot of control frames,
|
||||
// but not reading them from us, assume they are trying to make us
|
||||
// run out of memory.
|
||||
if sc.queuedControlFrames > sc.srv.maxQueuedControlFrames() {
|
||||
if sc.queuedControlFrames > maxQueuedControlFrames {
|
||||
sc.vlogf("http2: too many control frames in send queue, closing connection")
|
||||
return
|
||||
}
|
||||
|
@ -1055,12 +1043,39 @@ func (sc *serverConn) serve() {
|
|||
}
|
||||
}
|
||||
|
||||
func (sc *serverConn) handlePingTimer(lastFrameReadTime time.Time) {
|
||||
if sc.pingSent {
|
||||
sc.vlogf("timeout waiting for PING response")
|
||||
sc.conn.Close()
|
||||
return
|
||||
}
|
||||
|
||||
pingAt := lastFrameReadTime.Add(sc.readIdleTimeout)
|
||||
now := sc.srv.now()
|
||||
if pingAt.After(now) {
|
||||
// We received frames since arming the ping timer.
|
||||
// Reset it for the next possible timeout.
|
||||
sc.readIdleTimer.Reset(pingAt.Sub(now))
|
||||
return
|
||||
}
|
||||
|
||||
sc.pingSent = true
|
||||
// Ignore crypto/rand.Read errors: It generally can't fail, and worse case if it does
|
||||
// is we send a PING frame containing 0s.
|
||||
_, _ = rand.Read(sc.sentPingData[:])
|
||||
sc.writeFrame(FrameWriteRequest{
|
||||
write: &writePing{data: sc.sentPingData},
|
||||
})
|
||||
sc.readIdleTimer.Reset(sc.pingTimeout)
|
||||
}
|
||||
|
||||
type serverMessage int
|
||||
|
||||
// Message values sent to serveMsgCh.
|
||||
var (
|
||||
settingsTimerMsg = new(serverMessage)
|
||||
idleTimerMsg = new(serverMessage)
|
||||
readIdleTimerMsg = new(serverMessage)
|
||||
shutdownTimerMsg = new(serverMessage)
|
||||
gracefulShutdownMsg = new(serverMessage)
|
||||
handlerDoneMsg = new(serverMessage)
|
||||
|
@ -1068,6 +1083,7 @@ var (
|
|||
|
||||
func (sc *serverConn) onSettingsTimer() { sc.sendServeMsg(settingsTimerMsg) }
|
||||
func (sc *serverConn) onIdleTimer() { sc.sendServeMsg(idleTimerMsg) }
|
||||
func (sc *serverConn) onReadIdleTimer() { sc.sendServeMsg(readIdleTimerMsg) }
|
||||
func (sc *serverConn) onShutdownTimer() { sc.sendServeMsg(shutdownTimerMsg) }
|
||||
|
||||
func (sc *serverConn) sendServeMsg(msg interface{}) {
|
||||
|
@ -1320,6 +1336,10 @@ func (sc *serverConn) wroteFrame(res frameWriteResult) {
|
|||
sc.writingFrame = false
|
||||
sc.writingFrameAsync = false
|
||||
|
||||
if res.err != nil {
|
||||
sc.conn.Close()
|
||||
}
|
||||
|
||||
wr := res.wr
|
||||
|
||||
if writeEndsStream(wr.write) {
|
||||
|
@ -1594,6 +1614,11 @@ func (sc *serverConn) processFrame(f Frame) error {
|
|||
func (sc *serverConn) processPing(f *PingFrame) error {
|
||||
sc.serveG.check()
|
||||
if f.IsAck() {
|
||||
if sc.pingSent && sc.sentPingData == f.Data {
|
||||
// This is a response to a PING we sent.
|
||||
sc.pingSent = false
|
||||
sc.readIdleTimer.Reset(sc.readIdleTimeout)
|
||||
}
|
||||
// 6.7 PING: " An endpoint MUST NOT respond to PING frames
|
||||
// containing this flag."
|
||||
return nil
|
||||
|
@ -2160,7 +2185,7 @@ func (sc *serverConn) newStream(id, pusherID uint32, state streamState) *stream
|
|||
st.cw.Init()
|
||||
st.flow.conn = &sc.flow // link to conn-level counter
|
||||
st.flow.add(sc.initialStreamSendWindowSize)
|
||||
st.inflow.init(sc.srv.initialStreamRecvWindowSize())
|
||||
st.inflow.init(sc.initialStreamRecvWindowSize)
|
||||
if sc.hs.WriteTimeout > 0 {
|
||||
st.writeDeadline = sc.srv.afterFunc(sc.hs.WriteTimeout, st.onWriteTimeout)
|
||||
}
|
||||
|
@ -3301,7 +3326,7 @@ func (sc *serverConn) countError(name string, err error) error {
|
|||
if sc == nil || sc.srv == nil {
|
||||
return err
|
||||
}
|
||||
f := sc.srv.CountError
|
||||
f := sc.countErrorFunc
|
||||
if f == nil {
|
||||
return err
|
||||
}
|
||||
|
|
141
vendor/golang.org/x/net/http2/transport.go
generated
vendored
141
vendor/golang.org/x/net/http2/transport.go
generated
vendored
|
@ -25,7 +25,6 @@ import (
|
|||
"net/http"
|
||||
"net/http/httptrace"
|
||||
"net/textproto"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -227,40 +226,26 @@ func (t *Transport) contextWithTimeout(ctx context.Context, d time.Duration) (co
|
|||
}
|
||||
|
||||
func (t *Transport) maxHeaderListSize() uint32 {
|
||||
if t.MaxHeaderListSize == 0 {
|
||||
n := int64(t.MaxHeaderListSize)
|
||||
if t.t1 != nil && t.t1.MaxResponseHeaderBytes != 0 {
|
||||
n = t.t1.MaxResponseHeaderBytes
|
||||
if n > 0 {
|
||||
n = adjustHTTP1MaxHeaderSize(n)
|
||||
}
|
||||
}
|
||||
if n <= 0 {
|
||||
return 10 << 20
|
||||
}
|
||||
if t.MaxHeaderListSize == 0xffffffff {
|
||||
if n >= 0xffffffff {
|
||||
return 0
|
||||
}
|
||||
return t.MaxHeaderListSize
|
||||
}
|
||||
|
||||
func (t *Transport) maxFrameReadSize() uint32 {
|
||||
if t.MaxReadFrameSize == 0 {
|
||||
return 0 // use the default provided by the peer
|
||||
}
|
||||
if t.MaxReadFrameSize < minMaxFrameSize {
|
||||
return minMaxFrameSize
|
||||
}
|
||||
if t.MaxReadFrameSize > maxFrameSize {
|
||||
return maxFrameSize
|
||||
}
|
||||
return t.MaxReadFrameSize
|
||||
return uint32(n)
|
||||
}
|
||||
|
||||
func (t *Transport) disableCompression() bool {
|
||||
return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression)
|
||||
}
|
||||
|
||||
func (t *Transport) pingTimeout() time.Duration {
|
||||
if t.PingTimeout == 0 {
|
||||
return 15 * time.Second
|
||||
}
|
||||
return t.PingTimeout
|
||||
|
||||
}
|
||||
|
||||
// ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2.
|
||||
// It returns an error if t1 has already been HTTP/2-enabled.
|
||||
//
|
||||
|
@ -370,11 +355,14 @@ type ClientConn struct {
|
|||
lastActive time.Time
|
||||
lastIdle time.Time // time last idle
|
||||
// Settings from peer: (also guarded by wmu)
|
||||
maxFrameSize uint32
|
||||
maxConcurrentStreams uint32
|
||||
peerMaxHeaderListSize uint64
|
||||
peerMaxHeaderTableSize uint32
|
||||
initialWindowSize uint32
|
||||
maxFrameSize uint32
|
||||
maxConcurrentStreams uint32
|
||||
peerMaxHeaderListSize uint64
|
||||
peerMaxHeaderTableSize uint32
|
||||
initialWindowSize uint32
|
||||
initialStreamRecvWindowSize int32
|
||||
readIdleTimeout time.Duration
|
||||
pingTimeout time.Duration
|
||||
|
||||
// reqHeaderMu is a 1-element semaphore channel controlling access to sending new requests.
|
||||
// Write to reqHeaderMu to lock it, read from it to unlock.
|
||||
|
@ -499,6 +487,7 @@ func (cs *clientStream) closeReqBodyLocked() {
|
|||
}
|
||||
|
||||
type stickyErrWriter struct {
|
||||
group synctestGroupInterface
|
||||
conn net.Conn
|
||||
timeout time.Duration
|
||||
err *error
|
||||
|
@ -508,22 +497,9 @@ func (sew stickyErrWriter) Write(p []byte) (n int, err error) {
|
|||
if *sew.err != nil {
|
||||
return 0, *sew.err
|
||||
}
|
||||
for {
|
||||
if sew.timeout != 0 {
|
||||
sew.conn.SetWriteDeadline(time.Now().Add(sew.timeout))
|
||||
}
|
||||
nn, err := sew.conn.Write(p[n:])
|
||||
n += nn
|
||||
if n < len(p) && nn > 0 && errors.Is(err, os.ErrDeadlineExceeded) {
|
||||
// Keep extending the deadline so long as we're making progress.
|
||||
continue
|
||||
}
|
||||
if sew.timeout != 0 {
|
||||
sew.conn.SetWriteDeadline(time.Time{})
|
||||
}
|
||||
*sew.err = err
|
||||
return n, err
|
||||
}
|
||||
n, err = writeWithByteTimeout(sew.group, sew.conn, sew.timeout, p)
|
||||
*sew.err = err
|
||||
return n, err
|
||||
}
|
||||
|
||||
// noCachedConnError is the concrete type of ErrNoCachedConn, which
|
||||
|
@ -758,44 +734,36 @@ func (t *Transport) expectContinueTimeout() time.Duration {
|
|||
return t.t1.ExpectContinueTimeout
|
||||
}
|
||||
|
||||
func (t *Transport) maxDecoderHeaderTableSize() uint32 {
|
||||
if v := t.MaxDecoderHeaderTableSize; v > 0 {
|
||||
return v
|
||||
}
|
||||
return initialHeaderTableSize
|
||||
}
|
||||
|
||||
func (t *Transport) maxEncoderHeaderTableSize() uint32 {
|
||||
if v := t.MaxEncoderHeaderTableSize; v > 0 {
|
||||
return v
|
||||
}
|
||||
return initialHeaderTableSize
|
||||
}
|
||||
|
||||
func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) {
|
||||
return t.newClientConn(c, t.disableKeepAlives())
|
||||
}
|
||||
|
||||
func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, error) {
|
||||
conf := configFromTransport(t)
|
||||
cc := &ClientConn{
|
||||
t: t,
|
||||
tconn: c,
|
||||
readerDone: make(chan struct{}),
|
||||
nextStreamID: 1,
|
||||
maxFrameSize: 16 << 10, // spec default
|
||||
initialWindowSize: 65535, // spec default
|
||||
maxConcurrentStreams: initialMaxConcurrentStreams, // "infinite", per spec. Use a smaller value until we have received server settings.
|
||||
peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead.
|
||||
streams: make(map[uint32]*clientStream),
|
||||
singleUse: singleUse,
|
||||
wantSettingsAck: true,
|
||||
pings: make(map[[8]byte]chan struct{}),
|
||||
reqHeaderMu: make(chan struct{}, 1),
|
||||
t: t,
|
||||
tconn: c,
|
||||
readerDone: make(chan struct{}),
|
||||
nextStreamID: 1,
|
||||
maxFrameSize: 16 << 10, // spec default
|
||||
initialWindowSize: 65535, // spec default
|
||||
initialStreamRecvWindowSize: conf.MaxUploadBufferPerStream,
|
||||
maxConcurrentStreams: initialMaxConcurrentStreams, // "infinite", per spec. Use a smaller value until we have received server settings.
|
||||
peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead.
|
||||
streams: make(map[uint32]*clientStream),
|
||||
singleUse: singleUse,
|
||||
wantSettingsAck: true,
|
||||
readIdleTimeout: conf.SendPingTimeout,
|
||||
pingTimeout: conf.PingTimeout,
|
||||
pings: make(map[[8]byte]chan struct{}),
|
||||
reqHeaderMu: make(chan struct{}, 1),
|
||||
}
|
||||
var group synctestGroupInterface
|
||||
if t.transportTestHooks != nil {
|
||||
t.markNewGoroutine()
|
||||
t.transportTestHooks.newclientconn(cc)
|
||||
c = cc.tconn
|
||||
group = t.group
|
||||
}
|
||||
if VerboseLogs {
|
||||
t.vlogf("http2: Transport creating client conn %p to %v", cc, c.RemoteAddr())
|
||||
|
@ -807,24 +775,23 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
|
|||
// TODO: adjust this writer size to account for frame size +
|
||||
// MTU + crypto/tls record padding.
|
||||
cc.bw = bufio.NewWriter(stickyErrWriter{
|
||||
group: group,
|
||||
conn: c,
|
||||
timeout: t.WriteByteTimeout,
|
||||
timeout: conf.WriteByteTimeout,
|
||||
err: &cc.werr,
|
||||
})
|
||||
cc.br = bufio.NewReader(c)
|
||||
cc.fr = NewFramer(cc.bw, cc.br)
|
||||
if t.maxFrameReadSize() != 0 {
|
||||
cc.fr.SetMaxReadFrameSize(t.maxFrameReadSize())
|
||||
}
|
||||
cc.fr.SetMaxReadFrameSize(conf.MaxReadFrameSize)
|
||||
if t.CountError != nil {
|
||||
cc.fr.countError = t.CountError
|
||||
}
|
||||
maxHeaderTableSize := t.maxDecoderHeaderTableSize()
|
||||
maxHeaderTableSize := conf.MaxDecoderHeaderTableSize
|
||||
cc.fr.ReadMetaHeaders = hpack.NewDecoder(maxHeaderTableSize, nil)
|
||||
cc.fr.MaxHeaderListSize = t.maxHeaderListSize()
|
||||
|
||||
cc.henc = hpack.NewEncoder(&cc.hbuf)
|
||||
cc.henc.SetMaxDynamicTableSizeLimit(t.maxEncoderHeaderTableSize())
|
||||
cc.henc.SetMaxDynamicTableSizeLimit(conf.MaxEncoderHeaderTableSize)
|
||||
cc.peerMaxHeaderTableSize = initialHeaderTableSize
|
||||
|
||||
if cs, ok := c.(connectionStater); ok {
|
||||
|
@ -834,11 +801,9 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
|
|||
|
||||
initialSettings := []Setting{
|
||||
{ID: SettingEnablePush, Val: 0},
|
||||
{ID: SettingInitialWindowSize, Val: transportDefaultStreamFlow},
|
||||
}
|
||||
if max := t.maxFrameReadSize(); max != 0 {
|
||||
initialSettings = append(initialSettings, Setting{ID: SettingMaxFrameSize, Val: max})
|
||||
{ID: SettingInitialWindowSize, Val: uint32(cc.initialStreamRecvWindowSize)},
|
||||
}
|
||||
initialSettings = append(initialSettings, Setting{ID: SettingMaxFrameSize, Val: conf.MaxReadFrameSize})
|
||||
if max := t.maxHeaderListSize(); max != 0 {
|
||||
initialSettings = append(initialSettings, Setting{ID: SettingMaxHeaderListSize, Val: max})
|
||||
}
|
||||
|
@ -848,8 +813,8 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
|
|||
|
||||
cc.bw.Write(clientPreface)
|
||||
cc.fr.WriteSettings(initialSettings...)
|
||||
cc.fr.WriteWindowUpdate(0, transportDefaultConnFlow)
|
||||
cc.inflow.init(transportDefaultConnFlow + initialWindowSize)
|
||||
cc.fr.WriteWindowUpdate(0, uint32(conf.MaxUploadBufferPerConnection))
|
||||
cc.inflow.init(conf.MaxUploadBufferPerConnection + initialWindowSize)
|
||||
cc.bw.Flush()
|
||||
if cc.werr != nil {
|
||||
cc.Close()
|
||||
|
@ -867,7 +832,7 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
|
|||
}
|
||||
|
||||
func (cc *ClientConn) healthCheck() {
|
||||
pingTimeout := cc.t.pingTimeout()
|
||||
pingTimeout := cc.pingTimeout
|
||||
// We don't need to periodically ping in the health check, because the readLoop of ClientConn will
|
||||
// trigger the healthCheck again if there is no frame received.
|
||||
ctx, cancel := cc.t.contextWithTimeout(context.Background(), pingTimeout)
|
||||
|
@ -2199,7 +2164,7 @@ type resAndError struct {
|
|||
func (cc *ClientConn) addStreamLocked(cs *clientStream) {
|
||||
cs.flow.add(int32(cc.initialWindowSize))
|
||||
cs.flow.setConnFlow(&cc.flow)
|
||||
cs.inflow.init(transportDefaultStreamFlow)
|
||||
cs.inflow.init(cc.initialStreamRecvWindowSize)
|
||||
cs.ID = cc.nextStreamID
|
||||
cc.nextStreamID += 2
|
||||
cc.streams[cs.ID] = cs
|
||||
|
@ -2345,7 +2310,7 @@ func (cc *ClientConn) countReadFrameError(err error) {
|
|||
func (rl *clientConnReadLoop) run() error {
|
||||
cc := rl.cc
|
||||
gotSettings := false
|
||||
readIdleTimeout := cc.t.ReadIdleTimeout
|
||||
readIdleTimeout := cc.readIdleTimeout
|
||||
var t timer
|
||||
if readIdleTimeout != 0 {
|
||||
t = cc.t.afterFunc(readIdleTimeout, cc.healthCheck)
|
||||
|
|
10
vendor/golang.org/x/net/http2/write.go
generated
vendored
10
vendor/golang.org/x/net/http2/write.go
generated
vendored
|
@ -131,6 +131,16 @@ func (se StreamError) writeFrame(ctx writeContext) error {
|
|||
|
||||
func (se StreamError) staysWithinBuffer(max int) bool { return frameHeaderLen+4 <= max }
|
||||
|
||||
type writePing struct {
|
||||
data [8]byte
|
||||
}
|
||||
|
||||
func (w writePing) writeFrame(ctx writeContext) error {
|
||||
return ctx.Framer().WritePing(false, w.data)
|
||||
}
|
||||
|
||||
func (w writePing) staysWithinBuffer(max int) bool { return frameHeaderLen+len(w.data) <= max }
|
||||
|
||||
type writePingAck struct{ pf *PingFrame }
|
||||
|
||||
func (w writePingAck) writeFrame(ctx writeContext) error {
|
||||
|
|
2
vendor/golang.org/x/sys/unix/README.md
generated
vendored
2
vendor/golang.org/x/sys/unix/README.md
generated
vendored
|
@ -156,7 +156,7 @@ from the generated architecture-specific files listed below, and merge these
|
|||
into a common file for each OS.
|
||||
|
||||
The merge is performed in the following steps:
|
||||
1. Construct the set of common code that is idential in all architecture-specific files.
|
||||
1. Construct the set of common code that is identical in all architecture-specific files.
|
||||
2. Write this common code to the merged file.
|
||||
3. Remove the common code from all architecture-specific files.
|
||||
|
||||
|
|
4
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
4
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
|
@ -656,7 +656,7 @@ errors=$(
|
|||
signals=$(
|
||||
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
||||
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
|
||||
grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' |
|
||||
grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' |
|
||||
sort
|
||||
)
|
||||
|
||||
|
@ -666,7 +666,7 @@ echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
|
|||
sort >_error.grep
|
||||
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
||||
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
||||
grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' |
|
||||
grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' |
|
||||
sort >_signal.grep
|
||||
|
||||
echo '// mkerrors.sh' "$@"
|
||||
|
|
2
vendor/golang.org/x/sys/unix/syscall_aix.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_aix.go
generated
vendored
|
@ -360,7 +360,7 @@ func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int,
|
|||
var status _C_int
|
||||
var r Pid_t
|
||||
err = ERESTART
|
||||
// AIX wait4 may return with ERESTART errno, while the processus is still
|
||||
// AIX wait4 may return with ERESTART errno, while the process is still
|
||||
// active.
|
||||
for err == ERESTART {
|
||||
r, err = wait4(Pid_t(pid), &status, options, rusage)
|
||||
|
|
63
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
63
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
|
@ -1295,6 +1295,48 @@ func GetsockoptTCPInfo(fd, level, opt int) (*TCPInfo, error) {
|
|||
return &value, err
|
||||
}
|
||||
|
||||
// GetsockoptTCPCCVegasInfo returns algorithm specific congestion control information for a socket using the "vegas"
|
||||
// algorithm.
|
||||
//
|
||||
// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
|
||||
//
|
||||
// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
|
||||
func GetsockoptTCPCCVegasInfo(fd, level, opt int) (*TCPVegasInfo, error) {
|
||||
var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
|
||||
vallen := _Socklen(SizeofTCPCCInfo)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||
out := (*TCPVegasInfo)(unsafe.Pointer(&value[0]))
|
||||
return out, err
|
||||
}
|
||||
|
||||
// GetsockoptTCPCCDCTCPInfo returns algorithm specific congestion control information for a socket using the "dctp"
|
||||
// algorithm.
|
||||
//
|
||||
// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
|
||||
//
|
||||
// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
|
||||
func GetsockoptTCPCCDCTCPInfo(fd, level, opt int) (*TCPDCTCPInfo, error) {
|
||||
var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
|
||||
vallen := _Socklen(SizeofTCPCCInfo)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||
out := (*TCPDCTCPInfo)(unsafe.Pointer(&value[0]))
|
||||
return out, err
|
||||
}
|
||||
|
||||
// GetsockoptTCPCCBBRInfo returns algorithm specific congestion control information for a socket using the "bbr"
|
||||
// algorithm.
|
||||
//
|
||||
// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
|
||||
//
|
||||
// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
|
||||
func GetsockoptTCPCCBBRInfo(fd, level, opt int) (*TCPBBRInfo, error) {
|
||||
var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
|
||||
vallen := _Socklen(SizeofTCPCCInfo)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||
out := (*TCPBBRInfo)(unsafe.Pointer(&value[0]))
|
||||
return out, err
|
||||
}
|
||||
|
||||
// GetsockoptString returns the string value of the socket option opt for the
|
||||
// socket associated with fd at the given socket level.
|
||||
func GetsockoptString(fd, level, opt int) (string, error) {
|
||||
|
@ -1959,7 +2001,26 @@ func Getpgrp() (pid int) {
|
|||
//sysnb Getpid() (pid int)
|
||||
//sysnb Getppid() (ppid int)
|
||||
//sys Getpriority(which int, who int) (prio int, err error)
|
||||
//sys Getrandom(buf []byte, flags int) (n int, err error)
|
||||
|
||||
func Getrandom(buf []byte, flags int) (n int, err error) {
|
||||
vdsoRet, supported := vgetrandom(buf, uint32(flags))
|
||||
if supported {
|
||||
if vdsoRet < 0 {
|
||||
return 0, errnoErr(syscall.Errno(-vdsoRet))
|
||||
}
|
||||
return vdsoRet, nil
|
||||
}
|
||||
var p *byte
|
||||
if len(buf) > 0 {
|
||||
p = &buf[0]
|
||||
}
|
||||
r, _, e := Syscall(SYS_GETRANDOM, uintptr(unsafe.Pointer(p)), uintptr(len(buf)), uintptr(flags))
|
||||
if e != 0 {
|
||||
return 0, errnoErr(e)
|
||||
}
|
||||
return int(r), nil
|
||||
}
|
||||
|
||||
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||
//sysnb Getsid(pid int) (sid int, err error)
|
||||
//sysnb Gettid() (tid int)
|
||||
|
|
2
vendor/golang.org/x/sys/unix/syscall_linux_arm64.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_arm64.go
generated
vendored
|
@ -182,3 +182,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error
|
|||
}
|
||||
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
|
||||
}
|
||||
|
||||
const SYS_FSTATAT = SYS_NEWFSTATAT
|
||||
|
|
2
vendor/golang.org/x/sys/unix/syscall_linux_loong64.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_loong64.go
generated
vendored
|
@ -214,3 +214,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error
|
|||
}
|
||||
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
|
||||
}
|
||||
|
||||
const SYS_FSTATAT = SYS_NEWFSTATAT
|
||||
|
|
2
vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go
generated
vendored
|
@ -187,3 +187,5 @@ func RISCVHWProbe(pairs []RISCVHWProbePairs, set *CPUSet, flags uint) (err error
|
|||
}
|
||||
return riscvHWProbe(pairs, setSize, set, flags)
|
||||
}
|
||||
|
||||
const SYS_FSTATAT = SYS_NEWFSTATAT
|
||||
|
|
13
vendor/golang.org/x/sys/unix/vgetrandom_linux.go
generated
vendored
Normal file
13
vendor/golang.org/x/sys/unix/vgetrandom_linux.go
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build linux && go1.24
|
||||
|
||||
package unix
|
||||
|
||||
import _ "unsafe"
|
||||
|
||||
//go:linkname vgetrandom runtime.vgetrandom
|
||||
//go:noescape
|
||||
func vgetrandom(p []byte, flags uint32) (ret int, supported bool)
|
11
vendor/golang.org/x/sys/unix/vgetrandom_unsupported.go
generated
vendored
Normal file
11
vendor/golang.org/x/sys/unix/vgetrandom_unsupported.go
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !linux || !go1.24
|
||||
|
||||
package unix
|
||||
|
||||
func vgetrandom(p []byte, flags uint32) (ret int, supported bool) {
|
||||
return -1, false
|
||||
}
|
13
vendor/golang.org/x/sys/unix/zerrors_linux.go
generated
vendored
13
vendor/golang.org/x/sys/unix/zerrors_linux.go
generated
vendored
|
@ -495,6 +495,7 @@ const (
|
|||
BPF_F_TEST_REG_INVARIANTS = 0x80
|
||||
BPF_F_TEST_RND_HI32 = 0x4
|
||||
BPF_F_TEST_RUN_ON_CPU = 0x1
|
||||
BPF_F_TEST_SKB_CHECKSUM_COMPLETE = 0x4
|
||||
BPF_F_TEST_STATE_FREQ = 0x8
|
||||
BPF_F_TEST_XDP_LIVE_FRAMES = 0x2
|
||||
BPF_F_XDP_DEV_BOUND_ONLY = 0x40
|
||||
|
@ -1922,6 +1923,7 @@ const (
|
|||
MNT_EXPIRE = 0x4
|
||||
MNT_FORCE = 0x1
|
||||
MNT_ID_REQ_SIZE_VER0 = 0x18
|
||||
MNT_ID_REQ_SIZE_VER1 = 0x20
|
||||
MODULE_INIT_COMPRESSED_FILE = 0x4
|
||||
MODULE_INIT_IGNORE_MODVERSIONS = 0x1
|
||||
MODULE_INIT_IGNORE_VERMAGIC = 0x2
|
||||
|
@ -2187,7 +2189,7 @@ const (
|
|||
NFT_REG_SIZE = 0x10
|
||||
NFT_REJECT_ICMPX_MAX = 0x3
|
||||
NFT_RT_MAX = 0x4
|
||||
NFT_SECMARK_CTX_MAXLEN = 0x100
|
||||
NFT_SECMARK_CTX_MAXLEN = 0x1000
|
||||
NFT_SET_MAXNAMELEN = 0x100
|
||||
NFT_SOCKET_MAX = 0x3
|
||||
NFT_TABLE_F_MASK = 0x7
|
||||
|
@ -2356,9 +2358,11 @@ const (
|
|||
PERF_MEM_LVLNUM_IO = 0xa
|
||||
PERF_MEM_LVLNUM_L1 = 0x1
|
||||
PERF_MEM_LVLNUM_L2 = 0x2
|
||||
PERF_MEM_LVLNUM_L2_MHB = 0x5
|
||||
PERF_MEM_LVLNUM_L3 = 0x3
|
||||
PERF_MEM_LVLNUM_L4 = 0x4
|
||||
PERF_MEM_LVLNUM_LFB = 0xc
|
||||
PERF_MEM_LVLNUM_MSC = 0x6
|
||||
PERF_MEM_LVLNUM_NA = 0xf
|
||||
PERF_MEM_LVLNUM_PMEM = 0xe
|
||||
PERF_MEM_LVLNUM_RAM = 0xd
|
||||
|
@ -2431,6 +2435,7 @@ const (
|
|||
PRIO_PGRP = 0x1
|
||||
PRIO_PROCESS = 0x0
|
||||
PRIO_USER = 0x2
|
||||
PROCFS_IOCTL_MAGIC = 'f'
|
||||
PROC_SUPER_MAGIC = 0x9fa0
|
||||
PROT_EXEC = 0x4
|
||||
PROT_GROWSDOWN = 0x1000000
|
||||
|
@ -2933,11 +2938,12 @@ const (
|
|||
RUSAGE_SELF = 0x0
|
||||
RUSAGE_THREAD = 0x1
|
||||
RWF_APPEND = 0x10
|
||||
RWF_ATOMIC = 0x40
|
||||
RWF_DSYNC = 0x2
|
||||
RWF_HIPRI = 0x1
|
||||
RWF_NOAPPEND = 0x20
|
||||
RWF_NOWAIT = 0x8
|
||||
RWF_SUPPORTED = 0x3f
|
||||
RWF_SUPPORTED = 0x7f
|
||||
RWF_SYNC = 0x4
|
||||
RWF_WRITE_LIFE_NOT_SET = 0x0
|
||||
SCHED_BATCH = 0x3
|
||||
|
@ -3210,6 +3216,7 @@ const (
|
|||
STATX_ATTR_MOUNT_ROOT = 0x2000
|
||||
STATX_ATTR_NODUMP = 0x40
|
||||
STATX_ATTR_VERITY = 0x100000
|
||||
STATX_ATTR_WRITE_ATOMIC = 0x400000
|
||||
STATX_BASIC_STATS = 0x7ff
|
||||
STATX_BLOCKS = 0x400
|
||||
STATX_BTIME = 0x800
|
||||
|
@ -3226,6 +3233,7 @@ const (
|
|||
STATX_SUBVOL = 0x8000
|
||||
STATX_TYPE = 0x1
|
||||
STATX_UID = 0x8
|
||||
STATX_WRITE_ATOMIC = 0x10000
|
||||
STATX__RESERVED = 0x80000000
|
||||
SYNC_FILE_RANGE_WAIT_AFTER = 0x4
|
||||
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
|
||||
|
@ -3624,6 +3632,7 @@ const (
|
|||
XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
|
||||
XDP_UMEM_PGOFF_FILL_RING = 0x100000000
|
||||
XDP_UMEM_REG = 0x4
|
||||
XDP_UMEM_TX_METADATA_LEN = 0x4
|
||||
XDP_UMEM_TX_SW_CSUM = 0x2
|
||||
XDP_UMEM_UNALIGNED_CHUNK_FLAG = 0x1
|
||||
XDP_USE_NEED_WAKEUP = 0x8
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_386.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_386.go
generated
vendored
|
@ -153,9 +153,14 @@ const (
|
|||
NFDBITS = 0x20
|
||||
NLDLY = 0x100
|
||||
NOFLSH = 0x80
|
||||
NS_GET_MNTNS_ID = 0x8008b705
|
||||
NS_GET_NSTYPE = 0xb703
|
||||
NS_GET_OWNER_UID = 0xb704
|
||||
NS_GET_PARENT = 0xb702
|
||||
NS_GET_PID_FROM_PIDNS = 0x8004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x8004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x8004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x8004b709
|
||||
NS_GET_USERNS = 0xb701
|
||||
OLCUC = 0x2
|
||||
ONLCR = 0x4
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
generated
vendored
|
@ -153,9 +153,14 @@ const (
|
|||
NFDBITS = 0x40
|
||||
NLDLY = 0x100
|
||||
NOFLSH = 0x80
|
||||
NS_GET_MNTNS_ID = 0x8008b705
|
||||
NS_GET_NSTYPE = 0xb703
|
||||
NS_GET_OWNER_UID = 0xb704
|
||||
NS_GET_PARENT = 0xb702
|
||||
NS_GET_PID_FROM_PIDNS = 0x8004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x8004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x8004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x8004b709
|
||||
NS_GET_USERNS = 0xb701
|
||||
OLCUC = 0x2
|
||||
ONLCR = 0x4
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
generated
vendored
|
@ -150,9 +150,14 @@ const (
|
|||
NFDBITS = 0x20
|
||||
NLDLY = 0x100
|
||||
NOFLSH = 0x80
|
||||
NS_GET_MNTNS_ID = 0x8008b705
|
||||
NS_GET_NSTYPE = 0xb703
|
||||
NS_GET_OWNER_UID = 0xb704
|
||||
NS_GET_PARENT = 0xb702
|
||||
NS_GET_PID_FROM_PIDNS = 0x8004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x8004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x8004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x8004b709
|
||||
NS_GET_USERNS = 0xb701
|
||||
OLCUC = 0x2
|
||||
ONLCR = 0x4
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
generated
vendored
|
@ -154,9 +154,14 @@ const (
|
|||
NFDBITS = 0x40
|
||||
NLDLY = 0x100
|
||||
NOFLSH = 0x80
|
||||
NS_GET_MNTNS_ID = 0x8008b705
|
||||
NS_GET_NSTYPE = 0xb703
|
||||
NS_GET_OWNER_UID = 0xb704
|
||||
NS_GET_PARENT = 0xb702
|
||||
NS_GET_PID_FROM_PIDNS = 0x8004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x8004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x8004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x8004b709
|
||||
NS_GET_USERNS = 0xb701
|
||||
OLCUC = 0x2
|
||||
ONLCR = 0x4
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go
generated
vendored
|
@ -154,9 +154,14 @@ const (
|
|||
NFDBITS = 0x40
|
||||
NLDLY = 0x100
|
||||
NOFLSH = 0x80
|
||||
NS_GET_MNTNS_ID = 0x8008b705
|
||||
NS_GET_NSTYPE = 0xb703
|
||||
NS_GET_OWNER_UID = 0xb704
|
||||
NS_GET_PARENT = 0xb702
|
||||
NS_GET_PID_FROM_PIDNS = 0x8004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x8004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x8004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x8004b709
|
||||
NS_GET_USERNS = 0xb701
|
||||
OLCUC = 0x2
|
||||
ONLCR = 0x4
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
generated
vendored
|
@ -150,9 +150,14 @@ const (
|
|||
NFDBITS = 0x20
|
||||
NLDLY = 0x100
|
||||
NOFLSH = 0x80
|
||||
NS_GET_MNTNS_ID = 0x4008b705
|
||||
NS_GET_NSTYPE = 0x2000b703
|
||||
NS_GET_OWNER_UID = 0x2000b704
|
||||
NS_GET_PARENT = 0x2000b702
|
||||
NS_GET_PID_FROM_PIDNS = 0x4004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x4004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x4004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x4004b709
|
||||
NS_GET_USERNS = 0x2000b701
|
||||
OLCUC = 0x2
|
||||
ONLCR = 0x4
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
generated
vendored
|
@ -150,9 +150,14 @@ const (
|
|||
NFDBITS = 0x40
|
||||
NLDLY = 0x100
|
||||
NOFLSH = 0x80
|
||||
NS_GET_MNTNS_ID = 0x4008b705
|
||||
NS_GET_NSTYPE = 0x2000b703
|
||||
NS_GET_OWNER_UID = 0x2000b704
|
||||
NS_GET_PARENT = 0x2000b702
|
||||
NS_GET_PID_FROM_PIDNS = 0x4004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x4004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x4004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x4004b709
|
||||
NS_GET_USERNS = 0x2000b701
|
||||
OLCUC = 0x2
|
||||
ONLCR = 0x4
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
generated
vendored
|
@ -150,9 +150,14 @@ const (
|
|||
NFDBITS = 0x40
|
||||
NLDLY = 0x100
|
||||
NOFLSH = 0x80
|
||||
NS_GET_MNTNS_ID = 0x4008b705
|
||||
NS_GET_NSTYPE = 0x2000b703
|
||||
NS_GET_OWNER_UID = 0x2000b704
|
||||
NS_GET_PARENT = 0x2000b702
|
||||
NS_GET_PID_FROM_PIDNS = 0x4004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x4004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x4004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x4004b709
|
||||
NS_GET_USERNS = 0x2000b701
|
||||
OLCUC = 0x2
|
||||
ONLCR = 0x4
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
generated
vendored
|
@ -150,9 +150,14 @@ const (
|
|||
NFDBITS = 0x20
|
||||
NLDLY = 0x100
|
||||
NOFLSH = 0x80
|
||||
NS_GET_MNTNS_ID = 0x4008b705
|
||||
NS_GET_NSTYPE = 0x2000b703
|
||||
NS_GET_OWNER_UID = 0x2000b704
|
||||
NS_GET_PARENT = 0x2000b702
|
||||
NS_GET_PID_FROM_PIDNS = 0x4004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x4004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x4004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x4004b709
|
||||
NS_GET_USERNS = 0x2000b701
|
||||
OLCUC = 0x2
|
||||
ONLCR = 0x4
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go
generated
vendored
|
@ -152,9 +152,14 @@ const (
|
|||
NL3 = 0x300
|
||||
NLDLY = 0x300
|
||||
NOFLSH = 0x80000000
|
||||
NS_GET_MNTNS_ID = 0x4008b705
|
||||
NS_GET_NSTYPE = 0x2000b703
|
||||
NS_GET_OWNER_UID = 0x2000b704
|
||||
NS_GET_PARENT = 0x2000b702
|
||||
NS_GET_PID_FROM_PIDNS = 0x4004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x4004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x4004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x4004b709
|
||||
NS_GET_USERNS = 0x2000b701
|
||||
OLCUC = 0x4
|
||||
ONLCR = 0x2
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
generated
vendored
|
@ -152,9 +152,14 @@ const (
|
|||
NL3 = 0x300
|
||||
NLDLY = 0x300
|
||||
NOFLSH = 0x80000000
|
||||
NS_GET_MNTNS_ID = 0x4008b705
|
||||
NS_GET_NSTYPE = 0x2000b703
|
||||
NS_GET_OWNER_UID = 0x2000b704
|
||||
NS_GET_PARENT = 0x2000b702
|
||||
NS_GET_PID_FROM_PIDNS = 0x4004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x4004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x4004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x4004b709
|
||||
NS_GET_USERNS = 0x2000b701
|
||||
OLCUC = 0x4
|
||||
ONLCR = 0x2
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
generated
vendored
|
@ -152,9 +152,14 @@ const (
|
|||
NL3 = 0x300
|
||||
NLDLY = 0x300
|
||||
NOFLSH = 0x80000000
|
||||
NS_GET_MNTNS_ID = 0x4008b705
|
||||
NS_GET_NSTYPE = 0x2000b703
|
||||
NS_GET_OWNER_UID = 0x2000b704
|
||||
NS_GET_PARENT = 0x2000b702
|
||||
NS_GET_PID_FROM_PIDNS = 0x4004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x4004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x4004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x4004b709
|
||||
NS_GET_USERNS = 0x2000b701
|
||||
OLCUC = 0x4
|
||||
ONLCR = 0x2
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
generated
vendored
|
@ -150,9 +150,14 @@ const (
|
|||
NFDBITS = 0x40
|
||||
NLDLY = 0x100
|
||||
NOFLSH = 0x80
|
||||
NS_GET_MNTNS_ID = 0x8008b705
|
||||
NS_GET_NSTYPE = 0xb703
|
||||
NS_GET_OWNER_UID = 0xb704
|
||||
NS_GET_PARENT = 0xb702
|
||||
NS_GET_PID_FROM_PIDNS = 0x8004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x8004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x8004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x8004b709
|
||||
NS_GET_USERNS = 0xb701
|
||||
OLCUC = 0x2
|
||||
ONLCR = 0x4
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
generated
vendored
|
@ -150,9 +150,14 @@ const (
|
|||
NFDBITS = 0x40
|
||||
NLDLY = 0x100
|
||||
NOFLSH = 0x80
|
||||
NS_GET_MNTNS_ID = 0x8008b705
|
||||
NS_GET_NSTYPE = 0xb703
|
||||
NS_GET_OWNER_UID = 0xb704
|
||||
NS_GET_PARENT = 0xb702
|
||||
NS_GET_PID_FROM_PIDNS = 0x8004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x8004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x8004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x8004b709
|
||||
NS_GET_USERNS = 0xb701
|
||||
OLCUC = 0x2
|
||||
ONLCR = 0x4
|
||||
|
|
5
vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
generated
vendored
5
vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
generated
vendored
|
@ -155,9 +155,14 @@ const (
|
|||
NFDBITS = 0x40
|
||||
NLDLY = 0x100
|
||||
NOFLSH = 0x80
|
||||
NS_GET_MNTNS_ID = 0x4008b705
|
||||
NS_GET_NSTYPE = 0x2000b703
|
||||
NS_GET_OWNER_UID = 0x2000b704
|
||||
NS_GET_PARENT = 0x2000b702
|
||||
NS_GET_PID_FROM_PIDNS = 0x4004b706
|
||||
NS_GET_PID_IN_PIDNS = 0x4004b708
|
||||
NS_GET_TGID_FROM_PIDNS = 0x4004b707
|
||||
NS_GET_TGID_IN_PIDNS = 0x4004b709
|
||||
NS_GET_USERNS = 0x2000b701
|
||||
OLCUC = 0x2
|
||||
ONLCR = 0x4
|
||||
|
|
17
vendor/golang.org/x/sys/unix/zsyscall_linux.go
generated
vendored
17
vendor/golang.org/x/sys/unix/zsyscall_linux.go
generated
vendored
|
@ -971,23 +971,6 @@ func Getpriority(which int, who int) (prio int, err error) {
|
|||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Getrandom(buf []byte, flags int) (n int, err error) {
|
||||
var _p0 unsafe.Pointer
|
||||
if len(buf) > 0 {
|
||||
_p0 = unsafe.Pointer(&buf[0])
|
||||
} else {
|
||||
_p0 = unsafe.Pointer(&_zero)
|
||||
}
|
||||
r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags))
|
||||
n = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Getrusage(who int, rusage *Rusage) (err error) {
|
||||
_, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
|
||||
if e1 != 0 {
|
||||
|
|
1
vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go
generated
vendored
1
vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go
generated
vendored
|
@ -341,6 +341,7 @@ const (
|
|||
SYS_STATX = 332
|
||||
SYS_IO_PGETEVENTS = 333
|
||||
SYS_RSEQ = 334
|
||||
SYS_URETPROBE = 335
|
||||
SYS_PIDFD_SEND_SIGNAL = 424
|
||||
SYS_IO_URING_SETUP = 425
|
||||
SYS_IO_URING_ENTER = 426
|
||||
|
|
2
vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go
generated
vendored
2
vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go
generated
vendored
|
@ -85,7 +85,7 @@ const (
|
|||
SYS_SPLICE = 76
|
||||
SYS_TEE = 77
|
||||
SYS_READLINKAT = 78
|
||||
SYS_FSTATAT = 79
|
||||
SYS_NEWFSTATAT = 79
|
||||
SYS_FSTAT = 80
|
||||
SYS_SYNC = 81
|
||||
SYS_FSYNC = 82
|
||||
|
|
2
vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go
generated
vendored
2
vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go
generated
vendored
|
@ -84,6 +84,8 @@ const (
|
|||
SYS_SPLICE = 76
|
||||
SYS_TEE = 77
|
||||
SYS_READLINKAT = 78
|
||||
SYS_NEWFSTATAT = 79
|
||||
SYS_FSTAT = 80
|
||||
SYS_SYNC = 81
|
||||
SYS_FSYNC = 82
|
||||
SYS_FDATASYNC = 83
|
||||
|
|
2
vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go
generated
vendored
2
vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go
generated
vendored
|
@ -84,7 +84,7 @@ const (
|
|||
SYS_SPLICE = 76
|
||||
SYS_TEE = 77
|
||||
SYS_READLINKAT = 78
|
||||
SYS_FSTATAT = 79
|
||||
SYS_NEWFSTATAT = 79
|
||||
SYS_FSTAT = 80
|
||||
SYS_SYNC = 81
|
||||
SYS_FSYNC = 82
|
||||
|
|
88
vendor/golang.org/x/sys/unix/ztypes_linux.go
generated
vendored
88
vendor/golang.org/x/sys/unix/ztypes_linux.go
generated
vendored
|
@ -87,31 +87,35 @@ type StatxTimestamp struct {
|
|||
}
|
||||
|
||||
type Statx_t struct {
|
||||
Mask uint32
|
||||
Blksize uint32
|
||||
Attributes uint64
|
||||
Nlink uint32
|
||||
Uid uint32
|
||||
Gid uint32
|
||||
Mode uint16
|
||||
_ [1]uint16
|
||||
Ino uint64
|
||||
Size uint64
|
||||
Blocks uint64
|
||||
Attributes_mask uint64
|
||||
Atime StatxTimestamp
|
||||
Btime StatxTimestamp
|
||||
Ctime StatxTimestamp
|
||||
Mtime StatxTimestamp
|
||||
Rdev_major uint32
|
||||
Rdev_minor uint32
|
||||
Dev_major uint32
|
||||
Dev_minor uint32
|
||||
Mnt_id uint64
|
||||
Dio_mem_align uint32
|
||||
Dio_offset_align uint32
|
||||
Subvol uint64
|
||||
_ [11]uint64
|
||||
Mask uint32
|
||||
Blksize uint32
|
||||
Attributes uint64
|
||||
Nlink uint32
|
||||
Uid uint32
|
||||
Gid uint32
|
||||
Mode uint16
|
||||
_ [1]uint16
|
||||
Ino uint64
|
||||
Size uint64
|
||||
Blocks uint64
|
||||
Attributes_mask uint64
|
||||
Atime StatxTimestamp
|
||||
Btime StatxTimestamp
|
||||
Ctime StatxTimestamp
|
||||
Mtime StatxTimestamp
|
||||
Rdev_major uint32
|
||||
Rdev_minor uint32
|
||||
Dev_major uint32
|
||||
Dev_minor uint32
|
||||
Mnt_id uint64
|
||||
Dio_mem_align uint32
|
||||
Dio_offset_align uint32
|
||||
Subvol uint64
|
||||
Atomic_write_unit_min uint32
|
||||
Atomic_write_unit_max uint32
|
||||
Atomic_write_segments_max uint32
|
||||
_ [1]uint32
|
||||
_ [9]uint64
|
||||
}
|
||||
|
||||
type Fsid struct {
|
||||
|
@ -516,6 +520,29 @@ type TCPInfo struct {
|
|||
Total_rto_time uint32
|
||||
}
|
||||
|
||||
type TCPVegasInfo struct {
|
||||
Enabled uint32
|
||||
Rttcnt uint32
|
||||
Rtt uint32
|
||||
Minrtt uint32
|
||||
}
|
||||
|
||||
type TCPDCTCPInfo struct {
|
||||
Enabled uint16
|
||||
Ce_state uint16
|
||||
Alpha uint32
|
||||
Ab_ecn uint32
|
||||
Ab_tot uint32
|
||||
}
|
||||
|
||||
type TCPBBRInfo struct {
|
||||
Bw_lo uint32
|
||||
Bw_hi uint32
|
||||
Min_rtt uint32
|
||||
Pacing_gain uint32
|
||||
Cwnd_gain uint32
|
||||
}
|
||||
|
||||
type CanFilter struct {
|
||||
Id uint32
|
||||
Mask uint32
|
||||
|
@ -557,6 +584,7 @@ const (
|
|||
SizeofICMPv6Filter = 0x20
|
||||
SizeofUcred = 0xc
|
||||
SizeofTCPInfo = 0xf8
|
||||
SizeofTCPCCInfo = 0x14
|
||||
SizeofCanFilter = 0x8
|
||||
SizeofTCPRepairOpt = 0x8
|
||||
)
|
||||
|
@ -3766,7 +3794,7 @@ const (
|
|||
ETHTOOL_MSG_PSE_GET = 0x24
|
||||
ETHTOOL_MSG_PSE_SET = 0x25
|
||||
ETHTOOL_MSG_RSS_GET = 0x26
|
||||
ETHTOOL_MSG_USER_MAX = 0x2b
|
||||
ETHTOOL_MSG_USER_MAX = 0x2c
|
||||
ETHTOOL_MSG_KERNEL_NONE = 0x0
|
||||
ETHTOOL_MSG_STRSET_GET_REPLY = 0x1
|
||||
ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2
|
||||
|
@ -3806,7 +3834,7 @@ const (
|
|||
ETHTOOL_MSG_MODULE_NTF = 0x24
|
||||
ETHTOOL_MSG_PSE_GET_REPLY = 0x25
|
||||
ETHTOOL_MSG_RSS_GET_REPLY = 0x26
|
||||
ETHTOOL_MSG_KERNEL_MAX = 0x2b
|
||||
ETHTOOL_MSG_KERNEL_MAX = 0x2c
|
||||
ETHTOOL_FLAG_COMPACT_BITSETS = 0x1
|
||||
ETHTOOL_FLAG_OMIT_REPLY = 0x2
|
||||
ETHTOOL_FLAG_STATS = 0x4
|
||||
|
@ -3951,7 +3979,7 @@ const (
|
|||
ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 0x17
|
||||
ETHTOOL_A_COALESCE_USE_CQE_MODE_TX = 0x18
|
||||
ETHTOOL_A_COALESCE_USE_CQE_MODE_RX = 0x19
|
||||
ETHTOOL_A_COALESCE_MAX = 0x1c
|
||||
ETHTOOL_A_COALESCE_MAX = 0x1e
|
||||
ETHTOOL_A_PAUSE_UNSPEC = 0x0
|
||||
ETHTOOL_A_PAUSE_HEADER = 0x1
|
||||
ETHTOOL_A_PAUSE_AUTONEG = 0x2
|
||||
|
@ -4609,7 +4637,7 @@ const (
|
|||
NL80211_ATTR_MAC_HINT = 0xc8
|
||||
NL80211_ATTR_MAC_MASK = 0xd7
|
||||
NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca
|
||||
NL80211_ATTR_MAX = 0x14a
|
||||
NL80211_ATTR_MAX = 0x14c
|
||||
NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4
|
||||
NL80211_ATTR_MAX_CSA_COUNTERS = 0xce
|
||||
NL80211_ATTR_MAX_MATCH_SETS = 0x85
|
||||
|
@ -5213,7 +5241,7 @@ const (
|
|||
NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf
|
||||
NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe
|
||||
NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf
|
||||
NL80211_FREQUENCY_ATTR_MAX = 0x20
|
||||
NL80211_FREQUENCY_ATTR_MAX = 0x21
|
||||
NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6
|
||||
NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11
|
||||
NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc
|
||||
|
|
2
vendor/golang.org/x/sys/windows/dll_windows.go
generated
vendored
2
vendor/golang.org/x/sys/windows/dll_windows.go
generated
vendored
|
@ -65,7 +65,7 @@ func LoadDLL(name string) (dll *DLL, err error) {
|
|||
return d, nil
|
||||
}
|
||||
|
||||
// MustLoadDLL is like LoadDLL but panics if load operation failes.
|
||||
// MustLoadDLL is like LoadDLL but panics if load operation fails.
|
||||
func MustLoadDLL(name string) *DLL {
|
||||
d, e := LoadDLL(name)
|
||||
if e != nil {
|
||||
|
|
2
vendor/golang.org/x/sys/windows/svc/mgr/config.go
generated
vendored
2
vendor/golang.org/x/sys/windows/svc/mgr/config.go
generated
vendored
|
@ -63,7 +63,7 @@ func toStringSlice(ps *uint16) []string {
|
|||
return r
|
||||
}
|
||||
|
||||
// Config retrieves service s configuration paramteres.
|
||||
// Config retrieves service s configuration parameters.
|
||||
func (s *Service) Config() (Config, error) {
|
||||
var p *windows.QUERY_SERVICE_CONFIG
|
||||
n := uint32(1024)
|
||||
|
|
4
vendor/golang.org/x/sys/windows/svc/mgr/recovery.go
generated
vendored
4
vendor/golang.org/x/sys/windows/svc/mgr/recovery.go
generated
vendored
|
@ -137,7 +137,7 @@ func (s *Service) RecoveryCommand() (string, error) {
|
|||
// SetRecoveryActionsOnNonCrashFailures sets the failure actions flag. If the
|
||||
// flag is set to false, recovery actions will only be performed if the service
|
||||
// terminates without reporting a status of SERVICE_STOPPED. If the flag is set
|
||||
// to true, recovery actions are also perfomed if the service stops with a
|
||||
// to true, recovery actions are also performed if the service stops with a
|
||||
// nonzero exit code.
|
||||
func (s *Service) SetRecoveryActionsOnNonCrashFailures(flag bool) error {
|
||||
var setting windows.SERVICE_FAILURE_ACTIONS_FLAG
|
||||
|
@ -151,7 +151,7 @@ func (s *Service) SetRecoveryActionsOnNonCrashFailures(flag bool) error {
|
|||
// actions flag. If the flag is set to false, recovery actions will only be
|
||||
// performed if the service terminates without reporting a status of
|
||||
// SERVICE_STOPPED. If the flag is set to true, recovery actions are also
|
||||
// perfomed if the service stops with a nonzero exit code.
|
||||
// performed if the service stops with a nonzero exit code.
|
||||
func (s *Service) RecoveryActionsOnNonCrashFailures() (bool, error) {
|
||||
b, err := s.queryServiceConfig2(windows.SERVICE_CONFIG_FAILURE_ACTIONS_FLAG)
|
||||
if err != nil {
|
||||
|
|
14
vendor/modules.txt
vendored
14
vendor/modules.txt
vendored
|
@ -41,8 +41,8 @@ github.com/hashicorp/golang-lru/simplelru
|
|||
## explicit; go 1.12
|
||||
github.com/hectane/go-acl
|
||||
github.com/hectane/go-acl/api
|
||||
# github.com/jedisct1/dlog v0.0.0-20230811132706-443b333ff1b3
|
||||
## explicit; go 1.20
|
||||
# github.com/jedisct1/dlog v0.0.0-20241011102921-a236bd13c4c1
|
||||
## explicit; go 1.23
|
||||
github.com/jedisct1/dlog
|
||||
# github.com/jedisct1/go-clocksmith v0.0.0-20230211133011-392c1afea73e
|
||||
## explicit
|
||||
|
@ -104,7 +104,7 @@ github.com/powerman/deepequal
|
|||
# github.com/quic-go/qpack v0.5.1
|
||||
## explicit; go 1.22
|
||||
github.com/quic-go/qpack
|
||||
# github.com/quic-go/quic-go v0.47.0
|
||||
# github.com/quic-go/quic-go v0.48.1
|
||||
## explicit; go 1.22
|
||||
github.com/quic-go/quic-go
|
||||
github.com/quic-go/quic-go/http3
|
||||
|
@ -129,7 +129,7 @@ github.com/smartystreets/goconvey/convey/reporting
|
|||
## explicit; go 1.20
|
||||
go.uber.org/mock/mockgen
|
||||
go.uber.org/mock/mockgen/model
|
||||
# golang.org/x/crypto v0.27.0
|
||||
# golang.org/x/crypto v0.28.0
|
||||
## explicit; go 1.20
|
||||
golang.org/x/crypto/blake2b
|
||||
golang.org/x/crypto/chacha20
|
||||
|
@ -152,7 +152,7 @@ golang.org/x/mod/internal/lazyregexp
|
|||
golang.org/x/mod/modfile
|
||||
golang.org/x/mod/module
|
||||
golang.org/x/mod/semver
|
||||
# golang.org/x/net v0.29.0
|
||||
# golang.org/x/net v0.30.0
|
||||
## explicit; go 1.18
|
||||
golang.org/x/net/bpf
|
||||
golang.org/x/net/http/httpguts
|
||||
|
@ -168,7 +168,7 @@ golang.org/x/net/proxy
|
|||
# golang.org/x/sync v0.8.0
|
||||
## explicit; go 1.18
|
||||
golang.org/x/sync/errgroup
|
||||
# golang.org/x/sys v0.25.0
|
||||
# golang.org/x/sys v0.26.0
|
||||
## explicit; go 1.18
|
||||
golang.org/x/sys/cpu
|
||||
golang.org/x/sys/unix
|
||||
|
@ -177,7 +177,7 @@ golang.org/x/sys/windows/registry
|
|||
golang.org/x/sys/windows/svc
|
||||
golang.org/x/sys/windows/svc/eventlog
|
||||
golang.org/x/sys/windows/svc/mgr
|
||||
# golang.org/x/text v0.18.0
|
||||
# golang.org/x/text v0.19.0
|
||||
## explicit; go 1.18
|
||||
golang.org/x/text/secure/bidirule
|
||||
golang.org/x/text/transform
|
||||
|
|
Loading…
Add table
Reference in a new issue