Commit Graph

2127 Commits

Author SHA1 Message Date
Gopher Robot
dfc720dfe0 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I471c86e74526efc14e23be5635951a56cf2643ec
Reviewed-on: https://go-review.googlesource.com/c/net/+/637575
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v0.33.0
2024-12-18 11:34:41 -08:00
Roland Shoemaker
8e66b04771 html: use strings.EqualFold instead of lowering ourselves
Instead of using strings.ToLower and == to check case insensitive
equality, just use strings.EqualFold, even when the strings are only
ASCII. This prevents us unnecessarily lowering extremely long strings,
which can be a somewhat expensive operation, even if we're only
attempting to compare equality with five characters.

Thanks to Guido Vranken for reporting this issue.

Fixes golang/go#70906
Fixes CVE-2024-45338

Change-Id: I323b919f912d60dab6a87cadfdcac3e6b54cd128
Reviewed-on: https://go-review.googlesource.com/c/net/+/637536
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
2024-12-18 11:24:30 -08:00
yincong
b935f7b5d7 html: avoid endless loop on error token
Fixes #70179

Change-Id: I2a0a1fc2e96f7d8eefd0abdf7ef8ba243a6e8645
GitHub-Last-Rev: a601ecd849
GitHub-Pull-Request: golang/net#226
Reviewed-on: https://go-review.googlesource.com/c/net/+/624895
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-18 08:05:47 -08:00
Tobias Klauser
9af49ef148 route: remove unused sizeof* consts
These were never used since they were added in CL 22446.

Cq-Include-Trybots: luci.golang.try:x_net-gotip-freebsd-amd64,x_net-gotip-darwin-arm64_13
Change-Id: I1d5952ec299ea22f2f0c62da552638ba0438a15b
Reviewed-on: https://go-review.googlesource.com/c/net/+/635135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2024-12-12 07:45:41 -08:00
Damien Neil
6705db9a4d quic: clean up crypto streams when dropping packet protection keys
When dropping packet protection keys for a number space:

Check to see if there is unused CRYPTO data received from the peer
in the space. If so, close the connection with an error. This can
only happen if the peer has sent us data with a gap in it. We
can never read the data that fills that gap (because we're dropping
the key it would be encrypted with), and this situation cannot
happen without the peer sending invalid TLS handshake data.

Drop any buffered CRYPTO data being sent to the peer.
Under normal operations, we may have data that was sent to the peer
but which we haven't received an ACK for yet. The peer has
received the data (or we wouldn't be dropping the number space)
and we will never see the ACK (because we're dropping the key it
would be encrypted with).

Fixes golang/go#70704

Change-Id: I53380169cb59a2a6f87e69b38522ba81ad38c2b0
Reviewed-on: https://go-review.googlesource.com/c/net/+/634617
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2024-12-10 23:31:58 +00:00
Damien Neil
4ef7588d2b quic: handle ACK frame in packet which drops number space
Avoid incorrectly closing a connection with a protocol violation
error when we receive a single packet containing a CRYPTO frame
that causes us to drop a packet number space (forgetting what
packet numbers we've sent in that space) followed by an ACK frame.

Fixes golang/go#70703

Change-Id: I37554cb6a3086736cb9d772f8a3441b544d414dc
Reviewed-on: https://go-review.googlesource.com/c/net/+/634616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-12-10 16:56:59 +00:00
Michael Knyszek
552d8ac903 Revert "route: change from syscall to x/sys/unix"
This reverts CL 632816.

Reason for revert: This CL causes x/net to depend on x/sys. We have a
policy that prevents us from vendoring x/sys into std, but x/net
needs to be vendored.

Change-Id: I0fe3bc9861d559d888db6fa7febd48a201f060b8
Reviewed-on: https://go-review.googlesource.com/c/net/+/634196
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-06 18:01:32 +00:00
Michael Knyszek
13a7c0108b Revert "route: remove unused sizeof* consts on freebsd"
This reverts CL 633155.

Reason for revert: This is part of a short chain of CLs that causes
x/net to depend on x/sys. We have a policy that prevents us from
vendoring x/sys into std, but x/net needs to be vendored.

Change-Id: Ib773f21dee59fe6f4afb7ba1d7ae01d8859110c6
Reviewed-on: https://go-review.googlesource.com/c/net/+/634255
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-06 18:00:53 +00:00
Gopher Robot
285e1cf665 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I5db578f0e340dbf37012f580b307155806d55993
Reviewed-on: https://go-review.googlesource.com/c/net/+/633584
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
v0.32.0
2024-12-04 21:36:24 +00:00
Tobias Klauser
d0a1049b7e route: remove unused sizeof* consts on freebsd
The sizeofSockaddr* consts were replaced by the respective x/sys/unix
consts by CL 632816.

The sizeofIfDataFreeBSD* consts were never used since they were added.

Cq-Include-Trybots: luci.golang.try:x_net-gotip-freebsd-amd64
Change-Id: Ieb0e01353199e08659d45cdc3293e817b679fed5
Reviewed-on: https://go-review.googlesource.com/c/net/+/633155
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-12-03 19:04:27 +00:00
Damien Neil
6e414109c2 http2: fix benchmarks using common frame read/write functions
CL 586249 unified frame read/write functions used by client
and server tests, but inadvertently broke some benchmarks.
Fix those benchmarks.

This mostly restores the previous behavior of the affected
benchmarks (for example, testing only to see that a DATA frame
contains an END_STREAM marker, ignoring the number of bytes
in the frame).

Fixes golang/go#70647

Change-Id: I2b0099c3513ac8754d11c4e37b7d63277a0fb0b1
Reviewed-on: https://go-review.googlesource.com/c/net/+/633055
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Antonio Ojea <aojea@google.com>
2024-12-03 16:13:40 +00:00
Ian Lance Taylor
4be12533d8 route: change from syscall to x/sys/unix
This lets us drop some of the defs files and cgo usage.

Change-Id: I5a00e77610da36c752d28ea07e40b8a9c7c59ae4
Reviewed-on: https://go-review.googlesource.com/c/net/+/632816
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-02 22:15:25 +00:00
Damien Neil
bc37675919 http2: limit number of PINGs bundled with RST_STREAMs
gRPC has an unfortunate behavior of stictly rate limiting
the number of PING frames that it will receive. The default is
two PING frames every two hours when no requests are in flight;
two PING frames every five minutes when a request is in flight;
and the limit resets every time the gRPC endpoint sends a
HEADERS or DATA frame.

When sending a RST_STREAM frame, the Transport can bundle a PING
frame with it to confirm the server is responding. When canceling
several requests in succession, this can result in hitting the
gRPC ping limit.

Work around this gRPC behavior by sending at most one bundled
PING per HEADERS or DATA  frame received. We already limit
ourselves to one PING in flight at a time; now, when we receive
a PING response, disable sending additional bundled PINGs
until we read a HEADERS/DATA frame.

This does not affect keep-alive pings.

Fixes golang/go#70575.

Change-Id: I7c4003039bd2dc52106b2806ca31eeeee37b7e09
Reviewed-on: https://go-review.googlesource.com/c/net/+/632995
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-02 21:34:57 +00:00
James Tucker
e9cd716925 route: fix parse of zero-length sockaddrs in RIBs
Zero-length sockaddrs were observed in RIBs within golang/go#70528.
These records are to be skipped, and an invariant for later slice
manipulation is to be enforced by a defensive check in parseAddr.

Fixes golang/go#70528

Change-Id: I4b8b5bd2339bbadc1d1be1ce14deeb6dd3b8e536
GitHub-Last-Rev: 066ba8a559
GitHub-Pull-Request: golang/net#228
Reviewed-on: https://go-review.googlesource.com/c/net/+/631475
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-11-25 23:21:39 +00:00
WeidiDeng
9a51899103 http2: add SETTINGS_ENABLE_CONNECT_PROTOCOL support
For golang/go#49918

Change-Id: Ibcd8fb189200c0976cf1bd03a796abae4afa4cfd
GitHub-Last-Rev: cba5ecd7b7
GitHub-Pull-Request: golang/net#221
Reviewed-on: https://go-review.googlesource.com/c/net/+/610977
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-11-22 01:14:11 +00:00
Gopher Robot
334afa0d53 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: Ic3d15c610f766d40730157ea878be90dd9e9c084
Reviewed-on: https://go-review.googlesource.com/c/net/+/626378
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v0.31.0
2024-11-08 16:07:27 +00:00
jfgiorgi
d7f220d3b8 quic: add LocalAddr and RemoteAddr to quic.Conn
These are missing for quic.Conn.

Fixes golang/go#70138

Change-Id: Ia443ffe0e73e143be5c29233a1ceb7cb16951acd
GitHub-Last-Rev: a326378fdd
GitHub-Pull-Request: golang/net#225
Reviewed-on: https://go-review.googlesource.com/c/net/+/623157
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-06 23:00:02 +00:00
Damien Neil
858db1a8c8 http2: surface errors occurring very early in a client conn's lifetime
When we create a new connection for a request, the request should
fail if the connection attempt fails.

There is a race condition which can cause this to not happen:

- net/http sends a request to a http2.Transport
- the http2.Transport returns ErrNoCachedConn
- net/http creates a new tls.Conn and passes it to the http2.Transport
- the http2.Transport adds the conn to its connection pool
- the connection immediately encounters an error
- the http2.Transport removes the conn from its connection pool
- net/http resends the request to the http2.Transport
- the http2.Transport returns ErrNoCachedConn, and the process repeates

If the request is sent to the http2.Transport before the connection
encounters an error, then the request fails. But otherwise, we get
stuck in an infinite loop of the http2.Transport asking for a new
connection, receiving one, and throwing it away.

To fix this, leave a dead connection in the pool for a short while
if it has never had a request sent to it. If a dead connection is
used for a new request, return an error and remove the connection
from the pool.

Change-Id: I64eb15a8f1512a6bda52db423072b945fab6f4b5
Reviewed-on: https://go-review.googlesource.com/c/net/+/625398
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-11-06 19:35:40 +00:00
Damien Neil
0aa844c2c8 http2: support unencrypted HTTP/2 handoff from net/http
Allow net/http to pass unencrypted net.Conns to Server/Transport.
We don't have an existing way to pass a conn other than a *tls.Conn
into this package, so (ab)use TLSNextProto to pass unencrypted
connections:

The http2 package adds an "unencrypted_http2" entry to the
TLSNextProto maps. The net/http package calls this function
with a *tls.Conn wrapping a net.Conn with an UnencryptedNetConn
method returning the underlying, unencrypted net.Conn.

For golang/go#67816

Change-Id: I31f9c1ba31a17c82c8ed651382bd94193acf09b9
Reviewed-on: https://go-review.googlesource.com/c/net/+/625175
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2024-11-05 19:37:20 +00:00
Damien Neil
f35fec92ec http2: detect hung client connections by confirming stream resets
Consider the case of an unresponsive client connection, where
the server has stopped responding. We send an infinite sequence of
requests to the connection in sequence, each with a timeout.
Each request counts against the concurrency limit for the
connection while active, but when a request times out we send
a RST_STREAM and free up the concurrency slot it was using.

We continue to try to send requests to the connection forever (or
until the kernel closes the underlying TCP connection, or until
ReadIdleTimeout/WriteByteTimeout results in us closing the connection).

Defend against this scenario by counting a canceled request
against the connection concurrency limit until we confirm the
server is responding. Specifically:

Track the number of in-flight request cancellations in cc.pendingResets.
This total counts against the connection concurrency limit.

When sending a RST_STREAM for a canceled request, increment
cc.pendingResets. Send a PING frame to the server, unless a PING
is already in flight.

When receiving a PING response, set cc.pendingResets to 0.

A hung connection will be used for at most
SETTINGS_MAX_CONCURRENT_STREAMS requests.

When StrictMaxConcurrentStreams is false, we will create a
new connection after reaching the concurrency limit for a hung one.

When StrictMaxConcurrentStreams is true, we will continue to
wait for the existing connection until some timeout closes it
or it becomes responsive again.

For golang/go#59690

Change-Id: I0151f9a594af14b32bcb6005a239fa19eb103704
Reviewed-on: https://go-review.googlesource.com/c/net/+/617655
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-11-01 22:10:14 +00:00
Ian Lance Taylor
e883daec58 README: don't recommend go get
These days people will just import the packages and the go tool will
do the right thing. We don't need to explain it.

Add a pointer to the git repo, though.

For golang/go#62645

Change-Id: Ia5a16d8d66395e3feee2029ea1c3140b4d3939e7
Reviewed-on: https://go-review.googlesource.com/c/net/+/624175
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-11-01 18:28:29 +00:00
Carlana Johnson
511cc3a406 html: add Node.{Ancestors,ChildNodes,Descendants}()
Adds iterators for the parents, immediate children, and all children of a Node respectively.

Fixes golang/go#62113

Change-Id: Iab015872cc3a20fe5e7cae3bc90b89cba68cc3f8
GitHub-Last-Rev: d99de580ab
GitHub-Pull-Request: golang/net#215
Reviewed-on: https://go-review.googlesource.com/c/net/+/594195
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-10-29 04:13:16 +00:00
Damien Neil
4783315416 http2: limit 1xx based on size, do not limit when delivered
Replace Transport's limit of 5 1xx responses with a limit based
on the maximum header size: The total size of all 1xx response
headers must not exceed the limit we use on the size of the
final response headers.

(This differs slightly from the corresponding HTTP/1 change,
which imposes a limit on all 1xx response headers *plus* the
final response headers. The difference isn't substantial,
and this implementation fits better with the HTTP/2 framer.)

When the user is reading 1xx responses using a Got1xxResponse
client trace hook, disable the limit: Each 1xx response is
individually limited by the header size limit, but there
is no limit on the total number of responses. The user is
responsible for imposing a limit if they want one.

For golang/go#65035

Change-Id: I9c19dbf068e0f580789d952f63113b3d21ad86fc
Reviewed-on: https://go-review.googlesource.com/c/net/+/615295
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2024-10-21 20:13:47 +00:00
cuishuang
5716b9813d internal/socket: execute gofmt
Change-Id: Ifc793d535c31da3ba183ee44e1808e0072d7f099
Reviewed-on: https://go-review.googlesource.com/c/net/+/619595
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-10-11 22:36:55 +00:00
Damien Neil
42b1186360 http2: support ResponseController.EnableFullDuplex
The ResponseController.EnableFullDuplex method indicates that an HTTP
handler intends to interleave reads from a request body with writes
to the response body.

Add an EnableFullDuplex method to the ResponseWriter so we don't
return a not-supported error. The HTTP/2 server always supports
full duplex, so this is a no-op.

For golang/go#57786

Change-Id: I6529e6ce01d59b8b48fb67ba7c244255df57c174
Reviewed-on: https://go-review.googlesource.com/c/net/+/472717
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Дарья Бочкар <dasha7vanya@gmail.com>
2024-10-10 22:34:18 +00:00
Gopher Robot
6cc5ac4e9a go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I57613519f6e5795e60d258865e81f6954d672606
Reviewed-on: https://go-review.googlesource.com/c/net/+/617959
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v0.30.0
2024-10-04 16:20:59 +00:00
Mathias Fredriksson
f88258d67e websocket: update nhooyr.io/websocket to github.com/coder/websocket
Maintenance of nhooyr.io/websocket has moved to github.com/coder/websocket.

Read more about the transition at https://coder.com/blog/websocket

Updates golang/go#18152

Change-Id: Ia2b11c9a57ad7ded775b50a5bbb7ea91562d39b5
GitHub-Last-Rev: 59cea5e101
GitHub-Pull-Request: golang/net#222
Reviewed-on: https://go-review.googlesource.com/c/net/+/614075
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2024-09-25 22:53:10 +00:00
Damien Neil
7191757bc6 http2: add support for net/http HTTP2 config field
For golang/go#67813

Change-Id: I6b7f857d6ed250ba8b09649730980a91b3e8d7e9
Reviewed-on: https://go-review.googlesource.com/c/net/+/607255
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-09-25 18:02:06 +00:00
Damien Neil
4790dc7047 http2: add support for server-originated pings
Add configurable support for health-checking idle connections
accepted by the HTTP/2 server, following the same configuration
as the Transport.

Fixes golang/go#67812

Change-Id: Ia4014e691546b2c29db8dad3af5f39966d0ceb93
Reviewed-on: https://go-review.googlesource.com/c/net/+/601497
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-25 18:00:35 +00:00
Damien Neil
541dbe58b6 http2: add Server.WriteByteTimeout
Transports support a WriteByteTimeout option which sets the maximum
amount of time we can go without being able to write any bytes to
a connection. Add an equivalent option to Server for consistency.

Fixes golang/go#61777

Change-Id: Iaa8a69dfc403906eb224829320f901e5a6a5c429
Reviewed-on: https://go-review.googlesource.com/c/net/+/601496
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2024-09-23 22:06:05 +00:00
Carlos Hernandez
3c333c0c52 route: fix address parsing of messages on Darwin
sizeofSockaddrInet is 16, but first byte of sockaddr specifies actual
size of sockaddr.

Although, 16 works for most cases, it fails for Netmasks addresses. On
Darwin only the significant bits of the netmask are in the msg.

Take this route message as an example

```
// rt_msg_hdr
88 00 05 01 00 00 00 00
41 08 00 00 07 00 00 00
92 7b 00 00 01 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00

// metrics
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

// SOCKADDRS - DST  (100.113.0.0)
10 02 00 00 64 71 00 00
00 00 00 00 00 00 00 00

// GW  utun4319
14 12 21 00 01 08 00 00
75 74 75 6e 34 33 31 39
00 00 00 00

// NETMASK 255.255.0.0
06 02 00 00 ff ff

// NULL
00 00
```

i.e. ipv4
```
06 02 00 00 ff ff
```

The above byte sequence is for a sockaddr that is 6 bytes long
representing an ipv4 for address that is 255.255.0.0.

i.e. ipv6 netmask
```
0e 1e 00 00 00 00 00 00 ff ff ff ff ff ff 00 00
```

The above is `/48` netmask that should also be parsed using `b[0]` of the
sockaddr that contains the length.

Confirmed by using `route monitor`.

sources:
https://github.com/apple/darwin-xnu/blob/main/bsd/net/route.h
https://github.com/apple/darwin-xnu/blob/main/bsd/sys/socket.h#L603

Fixes golang/go#44740

Change-Id: I8153130d02d0a5e547fbf60a85762d3889e1d08c
GitHub-Last-Rev: f7b9253061
GitHub-Pull-Request: golang/net#220
Reviewed-on: https://go-review.googlesource.com/c/net/+/609577
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-09-06 18:26:58 +00:00
Gopher Robot
35b4abaed9 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I4be730755989f3d982deaac30cf72c1f3546d4b7
Reviewed-on: https://go-review.googlesource.com/c/net/+/611198
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
v0.29.0
2024-09-05 16:43:33 +00:00
Dmitri Shuralyov
9bf379fa3e websocket: fix printf(var) mistake detected by latest printf checker
For golang/go#69267.

Change-Id: Ica6d123312495966ad6d222d67944fd602216853
Reviewed-on: https://go-review.googlesource.com/c/net/+/610799
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-04 22:19:48 +00:00
Gopher Robot
4542a42604 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I6a2e43cca79f719c018887e1d75b578fc27be8f1
Reviewed-on: https://go-review.googlesource.com/c/net/+/603399
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
v0.28.0
2024-08-06 17:39:36 +00:00
ghosind
765c7e89b3 xsrftoken: create no padding base64 string by RawURLEncoding
The XSRF token generation function creates the padded base64 string by
base64.URLEncoding, then removes the padding. It is equivalent to the
base64.RawURLEncoding but with more costs.

Change-Id: I9cf5ad94e9cf3dca9bbfc1b6818ab07d41acf417
GitHub-Last-Rev: a8263b543c
GitHub-Pull-Request: golang/net#217
Reviewed-on: https://go-review.googlesource.com/c/net/+/599895
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Damien Neil <dneil@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-07-22 18:18:19 +00:00
Russ Cox
032e4e4358 LICENSE: update per Google Legal
Very minor tweaks:
 - Remove (c) pseudosymbol.
 - Remove "All Rights Reserved."
 - Change "Google Inc." (no longer exists) to "Google LLC".

[git-generate]
echo '
,s/\(c\) //
,s/ All rights reserved.//
,s/Google Inc./Google LLC/
w
q
' | sam -d LICENSE

Change-Id: Ibaa49e00dd08950a577e4343bfc574980d327995
Reviewed-on: https://go-review.googlesource.com/c/net/+/598579
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-07-16 16:05:10 +00:00
Gopher Robot
e2310ae9eb go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: Ibb0ab46488252d035430a654eed5dd4caab7509e
Reviewed-on: https://go-review.googlesource.com/c/net/+/596895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
v0.27.0
2024-07-05 13:12:46 +00:00
Richard Miller
77708f716e quic: skip tests which depend on unimplemented UDP functions on Plan 9
The ReadMsgUDP and WriteMsgUDP methods of UDPConn are not implemented
(yet?) on Plan 9. Skip tests which require them.

Fixes golang/go#68288

Change-Id: Ic6c81b19322d589c10b16da61e9b89284294be05
Reviewed-on: https://go-review.googlesource.com/c/net/+/596795
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2024-07-05 10:47:41 +00:00
Damien Neil
9617c6335b http2: avoid Transport hang with Connection: close and AllowHTTP
CL 111835 changed Transport stream ID numbering to start at
stream 3 when AllowHTTP is set. This was based on a
misunderstanding:

When a connection upgrades an HTTP/1.1 request to HTTP/2,
the initial HTTP/1.1 request occupies stream 1.
However, Transport does not perform HTTP protocol upgrades.
When using a Transport to send unencrypted HTTP/2 requests,
the entire connection uses HTTP/2, the first request is
sent as HTTP/2, and there is no reason not to use stream 1
for this request.

Starting from stream 3 is mostly harmless,
but ClientConn.idleStateLocked assumes that client streams
start from 1. This causes it to misidentify new single-use
connections as having already sent a request (when AllowHTTP
is set), and therefore not suitable for use.

Revert to always starting stream IDs at 1.

Fixes golang/go#67671

Change-Id: I97c89de4ae49623d916f9dbd200f8252d2fd4247
Reviewed-on: https://go-review.googlesource.com/c/net/+/591275
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-06-12 20:39:16 +00:00
Gopher Robot
66e838c6fb go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I472c3d990ea3c7c88a92bc0824034b112cec0eff
Reviewed-on: https://go-review.googlesource.com/c/net/+/590237
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v0.26.0
2024-06-04 17:07:48 +00:00
Damien Neil
6249541f2a http2: avoid race in server handler SetReadDeadine/SetWriteDeadline
Can't safely access responseWriter.rws from on the server's serve loop.

Change-Id: I477abe58cf9dd23813a0c5507aed2319696fdfaf
Reviewed-on: https://go-review.googlesource.com/c/net/+/589856
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-03 20:27:50 +00:00
Damien Neil
603e3e6390 quic: disable X25519Kyber768Draft00 in tests
Enabling this bloats the TLS handshake so flights no longer
fit in a single datagram. Disable it in tests. Add a test
using the crypto/tls defaults, to ensure we do handshake
properly with them.

Fixes golang/go#67783

Change-Id: I521188e7b5a313e9289e726935e5b26994090b4a
Reviewed-on: https://go-review.googlesource.com/c/net/+/589855
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-03 16:01:40 +00:00
Damien Neil
67e8d0c95d http2: report an error if goroutines outlive serverTester tests
Change-Id: Icd2152b4bddacf12120be16c32c8c2d52d235fbd
Reviewed-on: https://go-review.googlesource.com/c/net/+/589075
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-30 19:56:53 +00:00
Damien Neil
56082791fe http2: avoid corruption in priority write scheduler
When removing a stream containing children in the priority
tree, it was possible for some children to not be correctly
moved to the parent of the removed stream.

Fixes golang/go#66514

Change-Id: Ie8a8743a6213a6b1a2426e023111878afff78f9e
Reviewed-on: https://go-review.googlesource.com/c/net/+/589255
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-30 19:26:57 +00:00
Damien Neil
0d515a535e http2: factor out frame read/write test functions
Client and server tests both write frames to a test connection
and read frames back. Frame reads are usually paired with
test expectations.

Unify the API used for frame reads/writes in tests.

Introduce a testConnFramer type that implements a common set
of read/write methods, and embed it in both client and server
test types.

Change-Id: I6927c43459ba24f150a21c058a92797754f82bf1
Reviewed-on: https://go-review.googlesource.com/c/net/+/586249
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-28 22:41:32 +00:00
Damien Neil
9f5b79b000 http2: drop unused retry function
Change-Id: Ibe7e022a4863c8b0e502d7952b870046443acf7e
Reviewed-on: https://go-review.googlesource.com/c/net/+/586248
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2024-05-28 22:41:19 +00:00
Damien Neil
03c24c2d76 http2: use synthetic time in server tests
Change newServerTester to return a server using fake time
and a fake net.Conn.

Change-Id: I9d5db0cbe75696aed6d99ff1cd2369c2dea426c3
Reviewed-on: https://go-review.googlesource.com/c/net/+/586247
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-28 22:41:08 +00:00
Damien Neil
022530c415 http2: add a more full-featured test net.Conn
Add a net.Conn implementation that plays nicely with testsyncGroup,
implements read/write timeouts, and gives control over buffering
to let us write tests that cause writes to a Conn to block at
specific points in time.

Change-Id: I9d870b211ac9d938a8c4a221277981cdb821a6e4
Reviewed-on: https://go-review.googlesource.com/c/net/+/586246
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-21 22:48:04 +00:00
Damien Neil
410d19ee56 http2: avoid racy access to clientStream.requestedGzip
clientStream.requestedGzip is set from clientStream.writeRequest,
and examined by clientConn.readLoop. I'm not sure if there's
any possible way for an actual data race to happen here in
practice, since the read loop should only examine the field
after the request is sent by writeRequest, but it's enough
for the race detector to complain.

Set the field in ClientConn.roundTrip instead, before
the clientStream has become accessible to any other goroutines.

No test, but a following CL has race detector failures without
this change.

Change-Id: Id30f1b95bcfcc35c213440e0e47cce3feaaff06d
Reviewed-on: https://go-review.googlesource.com/c/net/+/586245
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-21 22:20:24 +00:00
Damien Neil
332fe235e6 http2: remove spec coverage test
When run with -coverspec, tests track which portions of the
specification they cover and the TestSpecCoverage test produces
an error if any sections lack test coverage.

This is a lovely idea, and perhaps we should resurrect it at
some point, but there is currently exactly one coverage
annotation, dating back to the first commit of this package.

Change-Id: I5d2d8a1032b783d113ed0982f7e97a3bd1c07a33
Reviewed-on: https://go-review.googlesource.com/c/net/+/586243
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-21 22:20:14 +00:00