9 Commits

Author SHA1 Message Date
Olivier Mengué
70576f07de http/httpproxy: godoc fixes
Doc improvements:
- use godoc link to net/http
- link use go.dev instead of golang.org
- fix typo in ProxyFunc doc

Change-Id: I7be0ebc78b3c34bc50fac6edc2c20a713478a315
Reviewed-on: https://go-review.googlesource.com/c/net/+/757980
Auto-Submit: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-24 07:44:58 -07:00
Damien Neil
cde1dda944 proxy, http/httpproxy: do not mismatch IPv6 zone ids against hosts
When matching against a host "example.com",
don't match an IPv6 address like "[1000::1%25.example.com]:80".

Thanks to Juho Forsén of Mattermost for reporting this issue.

Fixes CVE-2025-22870
For #71984

Change-Id: I0c4fdf18765decc27e6ddf220ebe3a9bf4a6454d
Reviewed-on: https://go-review.googlesource.com/c/net/+/654697
Auto-Submit: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Roland Shoemaker <roland@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2025-03-04 11:00:06 -08:00
胡玮文
8c07e20f92 httpproxy: allow any scheme
currently only http/https/socks5 scheme are allowed. However, any scheme
could be possible if user provides their own implementation.
Specifically, the widely used "socks5h://localhost" is parsed as
Scheme="http" Host="socks5h:", which does not make sense because host
name cannot contain ":".

This patch allows any scheme to appear in the proxy config. And only
fallback to http scheme if parsed scheme or host is empty.

url.Parse() result of fallback cases:

localhost      => Scheme="localhost"
localhost:1234 => Scheme="localhost" Opaque="1234"
example.com    => Path="example.com"

Updates golang/go#24135

Change-Id: Ia2c041e37e2ac61be16220fd41d6cb6fabeeca3d
Reviewed-on: https://go-review.googlesource.com/c/net/+/525257
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
2024-03-08 01:59:37 +00:00
Sean Liao
1e95f45603 http/httpproxy: remove comment on https proxy precedance
For golang/go#40909
For golang/go#54890

Change-Id: I1de1803f8fd00f54290404a8760d9f704ff766c3
Reviewed-on: https://go-review.googlesource.com/c/net/+/428795
Auto-Submit: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-09-07 13:56:53 +00:00
Shiming Zhang
de3da57026 net/http/httpproxy: support non-ASCII characters in NO_PROXY
Change-Id: I4b3a97a2046fcc2619535a508c9d71ffa4ca75df
GitHub-Last-Rev: 5e2316523c
GitHub-Pull-Request: golang/net#105
Reviewed-on: https://go-review.googlesource.com/c/net/+/326269
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-25 17:00:49 +00:00
Alexander Yastrebov
c6ed85c7a1 http/httpproxy: document all loopbacks are special cased not just localhost
Fixes golang/go#33695

Change-Id: I2f7598da7c6fda161ba357a75bba72de2fee8226
GitHub-Last-Rev: 443dbb13b1
GitHub-Pull-Request: golang/net#116
Reviewed-on: https://go-review.googlesource.com/c/net/+/356510
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
2021-10-19 23:23:29 +00:00
Michael Fraenkel
7b1cca2348 http/httpproxy: match http scheme when selecting http_proxy
Protocol specific proxies must match based on scheme.

If the https proxy is no configured, and the proxy for a https URL is
requested, no proxy should be returned.

Updates golang/go#40909

Change-Id: I62dfcf95d819c634e8f2862e891877a4eb55fca7
Reviewed-on: https://go-review.googlesource.com/c/net/+/249440
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2020-10-16 16:51:38 +00:00
Michael Fraenkel
c21de06aaf http/httpproxy: support CIDR notation and ports with NO_PROXY
NO_PROXY includes support for CIDR, and notations can also
match exactly on port information if provided.
When specifying a port with IPv6, the address must be enclosed with
square brackets, [IPv6 address]:port.

Updates golang/go#16704 (fixes after vendor into std)

Change-Id: Ideb61a9ec60a6b1908f5a2c885cd6d9dd10c37cf
Reviewed-on: https://go-review.googlesource.com/115255
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-09 17:18:25 +00:00
Roger Peppe
c7086645de http/httpproxy: new package
This factors out the HTTP proxy functionality from net/http,
with a view to vendoring it into net/http later.

See discussion in https://go-review.googlesource.com/c/go/+/68091

Change-Id: I8df8a92a13bca03504edd24b71a9a184f290b87d
Reviewed-on: https://go-review.googlesource.com/76910
Reviewed-by: roger peppe <rogpeppe@gmail.com>
2017-11-23 08:18:56 +00:00