Commit Graph

23 Commits

Author SHA1 Message Date
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
Tobias Klauser
49bf2d7d05 proxy: use strings.TrimSuffix
Change-Id: Icca4cdbdc1fb964eda8e0fed559f8d4e5dc45073
Reviewed-on: https://go-review.googlesource.com/c/net/+/586115
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-20 19:51:47 +00:00
Jacob Blain Christen
da137c7871 proxy: fix TestDial failures on wasm/js
Modified `TestDial` to emulate `internal/socks/dial_test.go` and leverage `nettest#NetLocalListener()` while also honoring the returned `net.Listener` address. It seems that the wasm/js runtime doesn't like dialing addresses with no host.

Fixes golang/go#32842

Change-Id: I1915f2ebac773f24a5b37ab7c09a52137abe758d
GitHub-Last-Rev: 8f2967fa7d
GitHub-Pull-Request: golang/net#45
Reviewed-on: https://go-review.googlesource.com/c/net/+/184178
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-28 18:53:45 +00:00
Brad Fitzpatrick
f4e77d36d6 proxy: add ProxyFromEnvironmentUsing
Updates golang/go#31813

Change-Id: Ic05fcdb5881c9e01967697542228224611b7a73f
Reviewed-on: https://go-review.googlesource.com/c/net/+/175100
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jacob Blain Christen <dweomer5@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-03 19:29:46 +00:00
Jacob Blain Christen
7f726cade0 proxy: add Dial (with context)
The existing API does not allow client code to take advantage of Dialer implementations that implement DialContext receivers. This a familiar API, see net.Dialer.

Fixes golang/go#27874
Fixes golang/go#19354
Fixes golang/go#17759
Fixes golang/go#13455

Change-Id: I0f247783d2037da28c9917db99adda51db1647bd
GitHub-Last-Rev: b0a372707f
GitHub-Pull-Request: golang/net#38
Reviewed-on: https://go-review.googlesource.com/c/net/+/168921
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-02 18:39:28 +00:00
Wèi Cōngruì
395948e2f5 proxy: support socks5h scheme in proxy URL
Environment variable 'ALL_PROXY=socks5h://example.com' is commonly
used to specify a SOCKS5 proxy server.
In curl, 'socks5' means the host name will be resolved locally,
and 'socks5h' means the host name will be resolved by the server.

Go SOCKS5 client always uses the server to resolve host names.
So this change just added socks5h as a supported URL scheme.

Fixes golang/go#13454

Change-Id: I06d2b07f66cd0923c114dba4df0f884b39e58bc0
Reviewed-on: https://go-review.googlesource.com/c/156517
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-01-08 15:50:00 +00:00
Mikio Hara
61147c48b2 internal/{socks,sockstest}: new packages
This change factors out the code related to SOCKS protocol version 5
from the golang/x/net/proxy package and provides new SOCKS-specific
API to fix the following:
- inflexbility of forward proxy connection setup; e.g., no support for
  context-based deadline or canceling, no support for dial deadline,
  no support for working with external authentication mechanisms,
- useless error values for troubleshooting.

The new package socks is supposed to be used by the net/http package
of standard library and proxy package of golang.org/x/net repository.

Fixes golang/go#11682.
Updates golang/go#17759.
Updates golang/go#19354.
Updates golang/go#19688.
Fixes golang/go#21333.

Change-Id: I24098ac8522dcbdceb03d534147c5101ec9e7350
Reviewed-on: https://go-review.googlesource.com/38278
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-06 21:48:16 +00:00
Joe Kyo
aabf50738b proxy: fix typos in comments
Change-Id: I7091af7efe71d46a0f55fd8341afcaa76073adaf
Reviewed-on: https://go-review.googlesource.com/71630
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-10-19 16:49:06 +00:00
Joe Kyo
0744d001aa proxy: add mention of RFC 1929 for SOCKS5
RFC 1929 describes the SOCKS5 username/password authentication method.
The proxy package implements this method, but doesn't mention RFC 1929.
This change adds mention of RFC 1929.

Change-Id: I30487fb41c1baa16b6ee8a99210168a597e5cb65
Reviewed-on: https://go-review.googlesource.com/60870
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Avelino <t@avelino.xxx>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-22 01:12:44 +00:00
Daniela Petruzalek
5d0d7096b5 net: replaces "hostname" with "host name" in the proxy package
Updates golang/go#17613

Change-Id: I0b272c19c263f20084a936b5122bb3cfebacc752
Reviewed-on: https://go-review.googlesource.com/49750
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-18 21:25:42 +00:00
Shi Han Ng
054b33e652 proxy: add support for ALL_PROXY and NO_PROXY
Fixes golang/go#13456

Change-Id: I0b938f824c47b29ac2026eff83e61c2f227a6cc1
Reviewed-on: https://go-review.googlesource.com/47530
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-06 00:57:53 +00:00
Michel Lespinasse
a689eb3bc4 proxy: split SOCKS5 Dial method in two
Split off a new SOCKS5 connect() method from Dial.

connect() takes an existing connection to a socks5 server, and
commands the server to extend that connection to a given target
address and port.

Change-Id: I5dbba58a67a0d884bda3d3ac194dc18bdebe74ab
Reviewed-on: https://go-review.googlesource.com/36643
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-02-09 17:24:21 +00:00
David Symonds
8aa6e209cb net: add import comments.
Change-Id: Ifab0fdaec1d810d268b7c19ad30f476802203b37
2014-12-09 14:17:11 +11:00
Robert Obryk
fbcd5c9bb3 go.net/proxy: don't pass invalid domain name length to SOCKS5 proxies
SOCKS5 uses a single-byte field for domain name length. This change
causes dials to domain names longer than 255 chars to fail instead
of sending an invalid request to the proxy.

LGTM=mikioh.mikioh
R=golang-codereviews, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/90790044
2014-04-27 00:24:21 +09:00
ChaiShushan
77895031fa go.net/proxy: fix typo in doc
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/12702044
2013-08-12 08:54:40 +10:00
Adam Langley
f013f1fe6d go.net/proxy: fix SOCSK5 user/pass auth.
The code was using the SOCKS version number (5) where it should have been using the username/password protocol version number (1).

With this change, username/password authentication actually works.

R=golang-dev
CC=golang-dev
https://golang.org/cl/10134044
2013-06-09 13:20:33 -04:00
Mikio Hara
5a456bdb1f go.net/proxy: make proxy tests able to run with host protocol stack
R=golang-dev, dave, agl
CC=golang-dev
https://golang.org/cl/7314047
2013-02-10 10:45:18 +09:00
Mikio Hara
6440e89078 go.net/proxy: make use of constants
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7299056
2013-02-06 19:33:08 +09:00
Mikio Hara
1509ba553c go.net/proxy: fix typo
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7301052
2013-02-06 19:32:30 +09:00
Mikio Hara
cd34c46d3f go.net/proxy: fix desired destination address in SOCKS5 CONNECT
Both types IPv6 IPv4-mapped address and IPv4-compatible
address are not allowed to be used in wire protocols.

Fixes golang/go#4709.

Thank you raptium for original CL 6922050.

R=golang-dev, agl
CC=golang-dev, raptium
https://golang.org/cl/7220047
2013-01-29 03:24:44 +09:00
Mikio Hara
3805a43191 go.net/proxy: fix IP address determination
net.IP represents either an IPv4 or IPv6 address. In case of
the address of IPv4 node, it uses IPv4-mapped IPv6 address
format by default.

R=agl, dave
CC=golang-dev
https://golang.org/cl/6782078
2012-11-17 14:35:42 +09:00
Adam Langley
67afa4a398 proxy: fix wrong function name in comment
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6459055
2012-08-13 21:29:05 -04:00
Adam Langley
c906410556 proxy: move from exp/proxy
This change copies exp/proxy to go.net without any code changes. A
followup CL will remove exp/proxy.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6449097
2012-08-07 12:02:26 -04:00