aboutsummaryrefslogtreecommitdiff
path: root/src/net/dial_test.go
AgeCommit message (Collapse)Author
2026-01-23net: fix some ineffectual assignments reported by ineffassignLin Lin
Updates #35136 Change-Id: I5422a50dde51c0a57f135c83f4963053285a9bc2 GitHub-Last-Rev: 6db1a88da60fce3e4fd6697d5db75d55d53b2b49 GitHub-Pull-Request: golang/go#76704 Reviewed-on: https://go-review.googlesource.com/c/go/+/727080 Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-10-17all: remove unnecessary loop variable copies in testsTobias Klauser
Copying the loop variable is no longer necessary since Go 1.22. Change-Id: Iebb21dac44a20ec200567f1d786f105a4ee4999d Reviewed-on: https://go-review.googlesource.com/c/go/+/711640 Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-08-11net: context aware Dialer.Dial functionsMichael Fraenkel
Add context aware dial functions for TCP, UDP, IP and Unix networks. Fixes #49097 Updates #59897 Change-Id: I7523452e8e463a587a852e0555cec822d8dcb3dd Reviewed-on: https://go-review.googlesource.com/c/go/+/490975 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Sean Liao <sean@liao.dev>
2024-02-20net: add KeepAliveConfig and implement SetKeepAliveConfigAndy Pan
Fixes #62254 Fixes #48622 Change-Id: Ida598e7fa914c8737fdbc1c813bcd68adb5119c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/542275 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2023-09-18net: enable most tests on wasip1 and jsBryan C. Mills
To get them to pass, implement more fake syscalls. To make those syscalls easier to reason about, replace the use of sync.Cond with selectable channels. Fixes #59718. Fixes #50216. Change-Id: I135a6656f5c48f0e5c43dc4d4bcbdb48ee5535d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/526117 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Achille Roussel <achille.roussel@gmail.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-07-31net: ignore blackhole route in TestDialCancelMeng Zhuo
CL 496037 had ignored 3 types of null route, however blackhole route is not included i.e. on Linux we can add a blackhole route by `ip route add blackhole 198.18.0.254/32` Fixes #61590 Change-Id: I9ddb86c5be0e5e261afa96cbaf55d9fdf30b2795 Reviewed-on: https://go-review.googlesource.com/c/go/+/513595 Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: M Zhuo <mzh@golangcn.org>
2023-07-27net: make mustHaveExternalNetwork work as usual on GOOS=linuxDmitri Shuralyov
I considered deleting mustHaveExternalNetwork in favor of just using the real testenv.MustHaveExternalNetwork. That certainly makes these tests that call it easier to understand. But that negatively affects some ports that don't have a longtest builder as it'd make the tests not run automatically on any builder at all. So, make a minimal change that applies only to GOOS=linux for now. If we make more progress on establishing -longtest builders for all ports, this intermediate layer helper will cease to have any benefit and can be deleted in favor of the one in testenv package. Change-Id: Iaea207d98e780db429ab49e6e227650a8b35b786 Reviewed-on: https://go-review.googlesource.com/c/go/+/513416 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2023-05-20net: ignore more errors in TestDialCancelIan Lance Taylor
TestDialCancel assumes that packets sent to the private IP addresses 198.18.0.254 and 2001:2::254 will be routed to /dev/null. Not all systems are configured that way. We already ignore one error case in the test; ignore a couple more than have appeared on the builders. The test is still valid as long as some builders discard the packets as expected. Fixes #52579 Fixes #57364 Change-Id: Ibe9ed73b8b3b498623f1d18203dadf9207a0467e Reviewed-on: https://go-review.googlesource.com/c/go/+/496037 Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-19net: make Dial fail faster on Windows closed loopback devicesqmuntal
On Windows when connecting to an unavailable port, ConnectEx() will retry for 2s, even on loopback devices. This CL uses a call to WSAIoctl to make the ConnectEx() call fail faster on local connections. Fixes #23366 Change-Id: Iafeca8ea0053f01116b2504c45d88120f84d05e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/495875 Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-04-11net: add wasip1 supportJohan Brandhorst-Satzkorn
For #58141 Co-authored-by: Richard Musiol <neelance@gmail.com> Co-authored-by: Achille Roussel <achille.roussel@gmail.com> Co-authored-by: Julien Fabre <ju.pryz@gmail.com> Co-authored-by: Evan Phoenix <evan@phx.io> Change-Id: I09a7cf33e43cb0e17ab3793c22cbad90b9e83b62 Reviewed-on: https://go-review.googlesource.com/c/go/+/479626 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-04-11net: allow TestDialListenerAddr without an external networkBryan C. Mills
As of CL 482163, this test now works when only a loopback network is available. Updates #59497. Change-Id: I32be4b74bbc663eb109763ea19d79f22c63f50ae Reviewed-on: https://go-review.googlesource.com/c/go/+/483696 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Bypass: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2023-04-10net: avoid opening an external port in TestDialListenerAddrBryan C. Mills
The behavior in #18806 can be tested with a localhost-only port, provided that we're willing to assume what format the listener would report for an external dual-stack port. Fixes #59497. Change-Id: I171fb03eb46aee8e85480e04626a23f4f3b923e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/482163 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
2022-11-04net: add ControlContext to Dialercuiweixie
Fixes #55301 Change-Id: Ie8abcd383eee9af75038bde908ac638f43d33b7e Reviewed-on: https://go-review.googlesource.com/c/go/+/444955 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: xie cui <523516579@qq.com>
2022-10-02all: use time.Since instead of time.Now().Subhopehook
Change-Id: Ifaa73b64e5b6a1d37c753e2440b642478d7dfbce Reviewed-on: https://go-review.googlesource.com/c/go/+/436957 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: hopehook <hopehook@golangcn.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-06-13net: avoid darwin_arm64 bug in TestDialParallelSpuriousConnectionDamien Neil
On darwin_arm64, reading from a socket at the same time as the other end is closing it will occasionally hang for 60 seconds before returning ECONNRESET. (This is a macOS issue, not a Go issue.) Work around this condition by adding a brief sleep before the read. Fixes #37795. Change-Id: I63f92b91fb297cd66f89cdab707583afd50ab9c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/411155 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Damien Neil <dneil@google.com>
2022-06-08net: fix testHookDialTCP raceDamien Neil
CL 410754 introduces a race accessing the global testHookDialTCP hook. Avoiding this race is difficult, since Dial can return while goroutines it starts are still running. Add a version of this hook to sysDialer, so it can be set on a per-test basis. (Perhaps other uses of this hook should be moved to use the sysDialer-local hook, but this change fixes the immediate data race.) For #52173. Change-Id: I8fb9be13957e91f92919cae7be213c38ad2af75a Reviewed-on: https://go-review.googlesource.com/c/go/+/410957 Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-07net: use synthetic network in TestDialParallelDamien Neil
TestDialParallel is testing the Happy Eyeballs algorithm implementation, which dials IPv4 and IPv6 addresses in parallel with the preferred address family getting a head start. This test doesn't care about the actual network operations, just the handling of the parallel connections. Use testHookDialTCP to replace socket creation with a function that returns successfully, with an error, or after context cancellation as required. Limit tests of elapsed times to a check that the fallback deadline has been exceeded in cases where this is expected. This should fix persistent test flakiness. Fixes #52173. Change-Id: Ic93f270fccb63b24a91105a4d541479fc33a2de4 Reviewed-on: https://go-review.googlesource.com/c/go/+/410754 Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-25net: add even more timing slop for TestDialParallelDamien Neil
This test expects dials of a closed port to complete in about the same amount of time: an initial probe value +/- 20%. Reduce test flakes on Windows by increasing the slop to +/- 50% of the original value. Fixes #52173 Change-Id: I813492c36aca2b0264b3b5b8c96e8bf97193af76 Reviewed-on: https://go-review.googlesource.com/c/go/+/408354 Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-26net: skip TestDialCancel on darwin-arm64Heschi Kreinick
We're turning up Macs in a network environment that clashes with this test. I don't think it's critical to get it working, so skip it. For #49149. Change-Id: I925e3ecc5356c4cefd208bdcff3d98021215d0b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/402181 Reviewed-by: Alex Rakoczy <alex@golang.org> Run-TryBot: Heschi Kreinick <heschi@google.com> Auto-Submit: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-06net: synchronize instead of sleeping in TestDialParallelSpuriousConnectionBryan C. Mills
The arbitrary sleep in this test is empirically not always long enough on slower builders. However, we know the exact number of connections that should be dialed: we can wait on that number in the dial hook instead. Fixes #34495 Change-Id: I538244ceb75a80271a724304b993309482bd5b41 Reviewed-on: https://go-review.googlesource.com/c/go/+/375694 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-13net: pass a testing.TB to newLocal* helpersBryan C. Mills
Passing in an explicit testing.TB gives two benefits: 1. It allows the helper to fail the test itself, instead of returning an error to the caller. A non-nil error invariably fails the calling test, and none of these callers bother to add detail to the error when logging it anyway so returning the error just added noise to the test bodies. 2. It allows the helper to use t.Cleanup to perform any needed cleanup tasks, which will be used in CL 370695 to clean up temp directories used as namespaces for unix socket paths. For #34611 Change-Id: I805e701687c12de2caca955649369294229c10b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/370696 Trust: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-10net: ignore EADDRINUSE errors when dialing to IPv4 from IPv6 on FreeBSDBryan C. Mills
The failure mode in #34264 appears to match https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210726. That bug was supposed to have been fixed in FreeBSD 12, but we're still observing failures specifically for the 6-to-4 case on FreeBSD 12.2. It is not clear to me whether FreeBSD 13.0 is also affected. For #34264 Change-Id: Iba7c7fc57676ae628b13c0b8fe43ddf2251c3637 Reviewed-on: https://go-review.googlesource.com/c/go/+/369157 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Trust: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-28all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor)Russ Cox
When these packages are released as part of Go 1.18, Go 1.16 will no longer be supported, so we can remove the +build tags in these files. Ran go fix -fix=buildtag std cmd and then reverted the bootstrapDirs as defined in src/cmd/dist/buildtool.go, which need to continue to build with Go 1.4 for now. Also reverted src/vendor and src/cmd/vendor, which will need to be updated in their own repos first. Manual changes in runtime/pprof/mprof_test.go to adjust line numbers. For #41184. Change-Id: Ic0f93f7091295b6abc76ed5cd6e6746e1280861e Reviewed-on: https://go-review.googlesource.com/c/go/+/344955 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-06-24net: remove hard-coded timeout in dialClosedPort test helperBryan C. Mills
The helper function claims that dialing a closed port should be "nearly instantaneous", but that is empirically not the case on OpenBSD or Windows. The tests do not appear to be particularly sensitive to the exact upper bound otherwise, so let's just remove the arbitrary latency assumption. Fixes #46884 Change-Id: If00c9fdc3063da6aaf60d365d4a2ee2c94dc6df1 Reviewed-on: https://go-review.googlesource.com/c/go/+/330250 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-05-10net, runtime: drop macOS 10.12 skip conditions in testsTobias Klauser
Go 1.17 requires macOS 10.13 or later. Thus, drop the special cases for the darwin-amd64-10_12 builder added in CL 202618. Updates #22019 Updates #23011 Updates #32919 Change-Id: Idef11c213dfb25fd002b7cda6d425cf2e26a2e06 Reviewed-on: https://go-review.googlesource.com/c/go/+/318329 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-02-20all: go fmt std cmd (but revert vendor)Russ Cox
Make all our package sources use Go 1.17 gofmt format (adding //go:build lines). Part of //go:build change (#41184). See https://golang.org/design/draft-gobuild Change-Id: Ia0534360e4957e58cd9a18429c39d0e32a6addb4 Reviewed-on: https://go-review.googlesource.com/c/go/+/294430 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-06all: enable more tests on macOS/ARM64Cherry Zhang
Updates #38485. Change-Id: Iac96f5ffe88521fcb11eab306d0df6463bdce046 Reviewed-on: https://go-review.googlesource.com/c/go/+/256920 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-09-23all: add GOOS=iosCherry Zhang
Introduce GOOS=ios for iOS systems. GOOS=ios matches "darwin" build tag, like GOOS=android matches "linux" and GOOS=illumos matches "solaris". Only ios/arm64 is supported (ios/amd64 is not). GOOS=ios and GOOS=darwin remain essentially the same at this point. They will diverge at later time, to differentiate macOS and iOS. Uses of GOOS=="darwin" are changed to (GOOS=="darwin" || GOOS=="ios"), except if it clearly means macOS (e.g. GOOS=="darwin" && GOARCH=="amd64"), it remains GOOS=="darwin". Updates #38485. Change-Id: I4faacdc1008f42434599efb3c3ad90763a83b67c Reviewed-on: https://go-review.googlesource.com/c/go/+/254740 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2020-04-25os, net: define and use os.ErrDeadlineExceededIan Lance Taylor
If an I/O operation fails because a deadline was exceeded, return os.ErrDeadlineExceeded. We used to return poll.ErrTimeout, an internal error, and told users to check the Timeout method. However, there are other errors with a Timeout method that returns true, notably syscall.ETIMEDOUT which is returned for a keep-alive timeout. Checking errors.Is(err, os.ErrDeadlineExceeded) should permit code to reliably tell why it failed. This change does not affect the handling of net.Dialer.Deadline, nor does it change the handling of net.DialContext when the context deadline is exceeded. Those cases continue to return an error reported as "i/o timeout" for which Timeout is true, but that error is not os.ErrDeadlineExceeded. Fixes #31449 Change-Id: I0323f42e944324c6f2578f00c3ac90c24fe81177 Reviewed-on: https://go-review.googlesource.com/c/go/+/228645 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-04-08all: remove scattered remnants of darwin/armAustin Clements
This removes all conditions and conditional code (that I could find) that depended on darwin/arm. Fixes #35439 (since that only happened on darwin/arm) Fixes #37611. Change-Id: Ia4c32a5a4368ed75231075832b0b5bfb1ad11986 Reviewed-on: https://go-review.googlesource.com/c/go/+/227198 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-11net: use t.Deadline instead of an arbitrary read deadline in ↵Bryan C. Mills
TestDialParallelSpuriousConnection Also increase the default deadline to 5s, since it empirically doesn't need to be short and 1s seems to be too slow on some platforms. Fixes #37795 Change-Id: Ie6bf3916b107401235a1fa8cb0f22c4a98eb2dae Reviewed-on: https://go-review.googlesource.com/c/go/+/222959 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-01-06net: update renamed test name in commentBrad Fitzpatrick
TestSelfConnect from CL 5650071 was renamed TestTCPSelfConnect in CL 21447. Change-Id: I0de110dbe1da77bfba540a1b51c139f3bedae67f Reviewed-on: https://go-review.googlesource.com/c/go/+/213437 Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-11-16net: add more timing slop for TestDialParallel on WindowsIan Lance Taylor
Fixes #35616 Change-Id: I51b2490100cfe0e902da09eee8d027e0ec86ed53 Reviewed-on: https://go-review.googlesource.com/c/go/+/207466 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-11-15net: fix improper Context.Deadline usage in DialContextSergey Zagursky
The existing implementation is erroneously assume that having no deadline in context.Context means that time returned from Deadline method will have IsZero() == true. But technically speaking this is an invalid assumption. The context.Context interface specification doesn't specify what time should be returned from Deadline method when there is no deadline set. It only specifies that second result of Deadline should be false. Fixes #35594 Change-Id: Ife00aad77ab3585e469f15017550ac6c0431b140 Reviewed-on: https://go-review.googlesource.com/c/go/+/207297 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-11-07net: skip TestDialCancel if Dial fails with "connection refused"Ian Lance Taylor
Fixes #15191 Change-Id: I86214ede619400acd44f21138b5ddf6cef4649a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/205698 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-22net: ignore or skip known-flaky localhost Dial operations on macOS 10.12 builderBryan C. Mills
Fixes #22019 Fixes #32919 Change-Id: I60bf6c69b18c3e2d78b494e54adc958fe40134da Reviewed-on: https://go-review.googlesource.com/c/go/+/202618 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-09all: remove the nacl port (part 1)Brad Fitzpatrick
You were a useful port and you've served your purpose. Thanks for all the play. A subsequent CL will remove amd64p32 (including assembly files and toolchain bits) and remaining bits. The amd64p32 removal will be separated into its own CL in case we want to support the Linux x32 ABI in the future and want our old amd64p32 support as a starting point. Updates #30439 Change-Id: Ia3a0c7d49804adc87bf52a4dea7e3d3007f2b1cd Reviewed-on: https://go-review.googlesource.com/c/go/+/199499 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-03net: skip DNS tests on self-hosted AndroidElias Naur
They were already skipped on tethered Android builders because the tests are gated on GO_BUILDER_NAME being set and the Android exec wrapper does not propagate GO_BUILDER_NAME. Updates #31722 Change-Id: Ifd2c7daecc19a4e540d86d1f38083f43cc3e6b15 Reviewed-on: https://go-review.googlesource.com/c/go/+/175177 Run-TryBot: Elias Naur <mail@eliasnaur.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-16all: s/cancelation/cancellation/Josh Bleecher Snyder
Though there is variation in the spelling of canceled, cancellation is always spelled with a double l. Reference: https://www.grammarly.com/blog/canceled-vs-cancelled/ Change-Id: I240f1a297776c8e27e74f3eca566d2bc4c856f2f Reviewed-on: https://go-review.googlesource.com/c/go/+/170060 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-27Revert "net: add missing error check in test"Mikio Hara
This reverts commit ec521467e33eee0a62ed426ca0c66b865baedfc7. Reson for revert: The test cases using slowDst4 and slowDst6 are fragile. We need to find out a better approach to the trick on the IP routeability. Change-Id: I544453886e809d1c7b339673d8f1d5bdef357147 Reviewed-on: https://go-review.googlesource.com/c/163919 Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-27net: add missing error check in testLeon Klingele
Change-Id: Id2e57bc8e18e062f60c6ac8a58dc15e049352088 GitHub-Last-Rev: 6d33b809cf8a3b5412333b1c3cc237000be8101d GitHub-Pull-Request: golang/go#30016 Reviewed-on: https://go-review.googlesource.com/c/160440 Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Mikio Hara <mikioh.public.networking@gmail.com>
2018-12-03net: enable TCP keepalives by defaultCarlo Alberto Ferraris
This is just the first step in attempting to make all network connection have timeouts as a "safe default". TCP keepalives only protect against certain classes of network and host issues (e.g. server/OS crash), but do nothing against application-level issues (e.g. an application that accepts connections but then fails to serve requests). The actual keep-alive duration (15s) is chosen to cause broken connections to be closed after 2~3 minutes (depending on the OS, see #23549 for details). We don't make the actual default value part of the public API for a number of reasons: - because it's not very useful by itself: as discussed in #23549 the actual "timeout" after which the connection is torn down is duration*(KEEPCNT+1), and we use the OS-wide value for KEEPCNT because there's currently no way to set it from Go. - because it may change in the future: if users need to rely on a specific value they should explicitly set this value instead of relying on the default. Fixes #23459 Change-Id: I348c03be97588d5001e6de0f377e7a93b51957fd Reviewed-on: https://go-review.googlesource.com/c/107196 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-25net: make cgo resolver work more accurately with network parameterEugene Kalinin
Unlike the go resolver, the existing cgo resolver exchanges both DNS A and AAAA RR queries unconditionally and causes unreasonable connection setup latencies to applications using the cgo resolver. This change adds new argument (`network`) in all functions through the series of calls: from Resolver.internetAddrList to cgoLookupIPCNAME. Benefit: no redundant DNS calls if certain IP version is used IPv4/IPv6 (no `AAAA` DNS requests if used tcp4, udp4, ip4 network. And vice versa: no `A` DNS requests if used tcp6, udp6, ip6 network) Fixes #25947 Change-Id: I39edbd726d82d6133fdada4d06cd90d401e7e669 Reviewed-on: https://go-review.googlesource.com/c/120215 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-07net: simplify bool expressionludweeg
Simplify `!(x <= y)` to `x > y` and `!(x >= y)` to `x < y` where x,y are not defined as float. Change-Id: Id1e5b518395d97e75f96aa4ac5d6c0ee990c0e7d Reviewed-on: https://go-review.googlesource.com/c/140337 Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2018-06-04net: add js/wasm architectureRichard Musiol
This commit adds the js/wasm architecture to the net package. The net package is not supported by js/wasm, but a simple fake networking is available so tests of other packages that require basic TCP sockets can pass. The tests of the net package itself are mostly disabled. Updates #18892 Change-Id: Id287200c39f0a3e23d20ef17260ca15ccdcca032 Reviewed-on: https://go-review.googlesource.com/109995 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-30net: add ListenConfig, Dialer.Control to permit socket opts before listen/dialAudrius Butkevicius
Existing implementation does not provide a way to set options such as SO_REUSEPORT, that has to be set prior the socket being bound. New exposed API: pkg net, method (*ListenConfig) Listen(context.Context, string, string) (Listener, error) pkg net, method (*ListenConfig) ListenPacket(context.Context, string, string) (PacketConn, error) pkg net, type ListenConfig struct pkg net, type ListenConfig struct, Control func(string, string, syscall.RawConn) error pkg net, type Dialer struct, Control func(string, string, syscall.RawConn) error Fixes #9661 Change-Id: If4d275711f823df72d3ac5cc3858651a6a57cccb Reviewed-on: https://go-review.googlesource.com/72810 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-29net: move dial and listen functions under sysDialer, sysListenerAudrius Butkevicius
Updates #9661 Change-Id: I237e7502cb9faad6dece1e25b1a503739c54d826 Reviewed-on: https://go-review.googlesource.com/115175 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-17net: skip external net tests on iOSElias Naur
CL 113095 tried to deflake net tests on iOS by skipping the test that uses the most sockets. That didn't work well enough and will be reverted in CL 113555. The flakes appeared after the iOS exec harness started to forward environment variables, causing testenv.Builder to be non-empty on the iOS builder. This CL attempts to fix the flakes with the more conservative strategy of skipping tests that only run on builders. The skipped tests happen to be those requiring external network access; it's plausible that the iOS builder network isn't reliable enough to run the many parallel DNS lookups and dial outs, while keeping the number of open file descriptors below the 250 limit. Change-Id: I9cafdaf2845dd6f3844c4819dcaaaa5970f5da15 Reviewed-on: https://go-review.googlesource.com/113575 Run-TryBot: Elias Naur <elias.naur@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-01-03net: ignore TestDialerLocalAddr timeout failures on DarwinIan Lance Taylor
I don't know why these errors occur. Ignore them to avoid breaking the build. Updates #22019 Change-Id: Ia048e6d9b928e8e237b311ff3a364e7a23af4aa4 Reviewed-on: https://go-review.googlesource.com/86000 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-12-08net: increase timeout for TestDialerDualStackFDLeakIan Lance Taylor
This test has been getting occasional timeouts on the race builder. The point of the test is whether a file descriptor leaks, not whether the connection occurs in a certain amount of time. So use a very large timeout. The connection is normally fast and the timeout doesn't matter. Updates #13324 Change-Id: Ie1051c4a0be1fca4e63b1277101770be0cdae512 Reviewed-on: https://go-review.googlesource.com/82916 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>