aboutsummaryrefslogtreecommitdiff
path: root/src/net/conf.go
AgeCommit message (Collapse)Author
2024-09-30net: improve GODEBUG=netdns=1 debug messagesMateusz Poliwczak
Fixes #69680 Change-Id: I73b0506c7a3245ba282cffabe47543f5fce86692 GitHub-Last-Rev: 4c6a1a4c706f39d2756c65b72b78896cd4881302 GitHub-Pull-Request: golang/go#69684 Reviewed-on: https://go-review.googlesource.com/c/go/+/616263 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-09-30net,os: use os.LookupEnv instead of syscall.GetenvMateusz Poliwczak
The os package already has a function for retrieving an environment variable with a ok boolean, we don't need to use syscall directly. Change-Id: Ife873e7245261ec765b628e31a0e7a7bc4dff934 GitHub-Last-Rev: bc5f30bf56c87a94e0f17dd67a15aa4b2d7e3fd4 GitHub-Pull-Request: golang/go#69700 Reviewed-on: https://go-review.googlesource.com/c/go/+/616342 Reviewed-by: Michael Knyszek <mknyszek@google.com> 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>
2024-05-18net: use stringslite package for string operationsaimuz
- Replace manual string suffix removal with stringslite.TrimSuffix in conf.go - Use stringslite.Cut for string splitting in ParseCIDR function in ip.go - Add stringslite import in ip.go This change simplifies string operations and improves code readability. Change-Id: I02c238d0bc91e95789d8060e6ef4c7d4f6e3f0d9 GitHub-Last-Rev: aef5dc5011217abc95b2a2d7c1d991ca84060d59 GitHub-Pull-Request: golang/go#67461 Reviewed-on: https://go-review.googlesource.com/c/go/+/586157 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Commit-Queue: Ian Lance Taylor <iant@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2024-05-06all: make use of stringslite.{HasPrefix, HasSuffix}Jes Cok
Just a code cleanup. Change-Id: Ie887ab2c71de11b4844c4e6fd4e5aca3265ac3aa Reviewed-on: https://go-review.googlesource.com/c/go/+/583216 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2024-04-04all: fix some commentscui fliter
Change-Id: I0ee85161846c13d938213ef04d3a34f690a93e48 Reviewed-on: https://go-review.googlesource.com/c/go/+/553435 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2024-02-26net: don't force cgo resolver for .local subdomain queriesMateusz Poliwczak
The cgo resolver sends DNS queries for .local subdomain lookups, just as we do in the go resolver. We don't need to fallback to the cgo resolver for this domains when nsswitch.conf uses only file and dns modules. This has a benefit that we select a consistent resolver, that is only based on the system configuration, regardless of the queried domain. Updates #63978 Change-Id: I9166103adb94d7ab52992925f413f361130e7c52 GitHub-Last-Rev: e2bc5874cb5c9165e3cc058e9effe36d0ce68cd6 GitHub-Pull-Request: golang/go#63986 Reviewed-on: https://go-review.googlesource.com/c/go/+/540555 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2023-11-20src: a/an grammar fixesVille Skyttä
Change-Id: I179b50ae8e73677d4d408b83424afbbfe6aa17a1 GitHub-Last-Rev: 2e2d9c1e45556155d02db4df381b99f2d1bc5c0e GitHub-Pull-Request: golang/go#63478 Reviewed-on: https://go-review.googlesource.com/c/go/+/534015 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-10-14all: fix function namescui fliter
Change-Id: Iba8878420c59d705066d1d9955e91a5c2eb4faf5 Reviewed-on: https://go-review.googlesource.com/c/go/+/507615 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
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-09-04net: respect hosts file when resolving names for WindowsNikita Vaniasin
Fixes #57757. Change-Id: I896dae8e5905ae98539ab83c9379fd1c9886d44a Reviewed-on: https://go-review.googlesource.com/c/go/+/467335 Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com> Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-08-26net: centralize resolver selection logicMateusz Poliwczak
This change removes the per GOOS hostLookupOrder wrappers. passes the correct hostname to hostLookupOrder (windows, plan9), so that the netdns+2 GODEBUG doesn't show empty hostnames. Uses the mustUseGoResolver instead of hostLookupOrder, hostLookupOrder should only be used for hostname resolution, not for lookups that do only DNS. Change-Id: I18bbff06957910ae25c2bc78dfa9a46da76529fd GitHub-Last-Rev: a27545dc25fffb3a51da9d943ffa9bd1a09182ee GitHub-Pull-Request: golang/go#61525 Reviewed-on: https://go-review.googlesource.com/c/go/+/512215 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-29net: enable pure Go resolver for wasip1Chris O'Hara
Top-level functions in the net package that only read files, for example LookupPort(...), or LookupIP(host) where host resides in /etc/hosts, now work on wasip1. If the application has the ability to create sockets (for example, when using a sockets extension to WASI preview 1), it's now possible to do name resolution by passing a custom Dial function to a Resolver instance. Change-Id: I923886f67e336820bc89f09ea1855387c8dac61a Reviewed-on: https://go-review.googlesource.com/c/go/+/500579 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Randy Reddig <ydnar@shaderlab.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-05-11net: don't treat unknown sources as dns when there is a dns sourceMateusz Poliwczak
Change-Id: I3a6c3a804604b1e74a1ea6b66ab2c932a0ac973a GitHub-Last-Rev: ea5403549a51a29a2799674d74425b480253d2f1 GitHub-Pull-Request: golang/go#60025 Reviewed-on: https://go-review.googlesource.com/c/go/+/493236 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-11net: return fallbackOrder immediately for some GOOSMateusz Poliwczak
We don't need to check resolv.conf, nsswitch.conf on these systems. Seems like this was the behaviour before CL 487196. Change-Id: I34ef3510891c572772a222fbbe47693aa6c7cf38 GitHub-Last-Rev: 3aace0e6615b79bbf379e05ca3a353e194dc7c0b GitHub-Pull-Request: golang/go#59946 Reviewed-on: https://go-review.googlesource.com/c/go/+/491995 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-05-11net: force cgo for myhostname and mdns nss modules for LookupAddr on unixMateusz Poliwczak
Currently there is a small bug in the LookupAddr for unix systems that causes the use of go resolver instead of the cgo one. Example for nss myhostname: func main() { fmt.Println(net.LookupAddr(os.Args[1])) } root@arch:~# cat /etc/nsswitch.conf | grep host hosts: myhostname dns root@arch:~# GODEBUG=netdns=+3 go run main.go 192.168.1.200 go package net: confVal.netCgo = false netGo = false go package net: dynamic selection of DNS resolver go package net: hostLookupOrder() = dns [] lookup 200.1.168.192.in-addr.arpa. on 8.8.8.8:53: no such host root@arch:~# GODEBUG=netdns=go+3 go run main.go 192.168.1.200 go package net: confVal.netCgo = false netGo = true go package net: GODEBUG setting forcing use of Go's resolver go package net: hostLookupOrder() = dns [] lookup 200.1.168.192.in-addr.arpa. on 8.8.8.8:53: no such host root@arch:~# GODEBUG=netdns=cgo+3 go run main.go 192.168.1.200 go package net: confVal.netCgo = true netGo = false go package net: using cgo DNS resolver go package net: hostLookupOrder() = cgo [arch] <nil> The problem come from that we are only checking for hostnames that the myhostname can resolve, but not for the addrs that it can also. man nss-myhostname: Please keep in mind that nss-myhostname (and nss-resolve) also resolve in the other direction — from locally attached IP addresses to hostnames. Change-Id: Ic18a9f99a2214b2938463e9a95f7f3ca5db1c01b GitHub-Last-Rev: ade40fd3e3057de418b9b6a79f79fb9a53fb6c09 GitHub-Pull-Request: golang/go#59921 Reviewed-on: https://go-review.googlesource.com/c/go/+/491235 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>
2023-05-02net: don't recheck goosPrefersCgo in hostLookupOrderIan Lance Taylor
We only did it for testing. Remove the single test that required it. Change-Id: Ib6c3a2debfd3f48e95af37f23fdfde847ff87a41 Reviewed-on: https://go-review.googlesource.com/c/go/+/490395 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-04-28net: re check conf.goos even if it equals runtime.GOOSIan Lance Taylor
This field is only for testing purposes, where we can't assume that the conf value was initialized as expected for that GOOS. This fixes the net tests on android. Change-Id: I8432587f219a05adbb4d234a813467f876a764b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/489975 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-04-27net: rewrite and simplify resolver configurationIan Lance Taylor
The resulting code behaves mostly the same. There are some minor differences in error cases when the cgo resolver is not available: instead of just falling back we keep trying to work out the right nsswitch.conf order. Change-Id: I17fadc940528fa2397043ac8f8ed7da3bd7a95c0 Reviewed-on: https://go-review.googlesource.com/c/go/+/487196 Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
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>
2022-11-15net: use a consistent dnsConfig in hostLookupOrderMateusz Poliwczak
Use the same dnsConfig throughout a DNS lookup operation. Before this CL it was possible to decide to re-read a modified resolv.conf file during the DNS lookup, which could lead to inconsistencies between the lookup order and the name server list. Change-Id: I0689749272b8263268d00b9a9cb4458cd68b23eb GitHub-Last-Rev: 64810a22bc8a7dd5e804b5f5253d11b73942dfe3 GitHub-Pull-Request: golang/go#56690 Reviewed-on: https://go-review.googlesource.com/c/go/+/449337 Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-11-14internal/godebug: define more efficient APIRuss Cox
We have been expanding our use of GODEBUG for compatibility, and the current implementation forces a tradeoff between freshness and efficiency. It parses the environment variable in full each time it is called, which is expensive. But if clients cache the result, they won't respond to run-time GODEBUG changes, as happened with x509sha1 (#56436). This CL changes the GODEBUG API to provide efficient, up-to-date results. Instead of a single Get function, New returns a *godebug.Setting that itself has a Get method. Clients can save the result of New, which is no more expensive than errors.New, in a global variable, and then call that variable's Get method to get the value. Get costs only two atomic loads in the case where the variable hasn't changed since the last call. Unfortunately, these changes do require importing sync from godebug, which will mean that sync itself will never be able to use a GODEBUG setting. That doesn't seem like such a hardship. If it was really necessary, the runtime could pass a setting to package sync itself at startup, with the caveat that that setting, like the ones used by runtime itself, would not respond to run-time GODEBUG changes. Change-Id: I99a3acfa24fb2a692610af26a5d14bbc62c966ac Reviewed-on: https://go-review.googlesource.com/c/go/+/449504 Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-11net: handle correctly the _gateway and _outbound hostnames for nss myhostnameMateusz Poliwczak
Fixes #56387 Change-Id: If412134344600caefec425699398522399986d4d GitHub-Last-Rev: f33540ef8f90e9a8c09f3947aba8c01155516d39 GitHub-Pull-Request: golang/go#56388 Reviewed-on: https://go-review.googlesource.com/c/go/+/445075 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-11-10net: auto-reload the /etc/nsswitch.conf on unix systemsMateusz Poliwczak
This change is made to align with the current (recently changed) glibc behaviour, it will allow the hostLookupOrder method to change its decisions on runtime (based on /etc/nsswitch.conf changes). Fixes #56515 Change-Id: I241d67f053b6d2111eebcd67744adee02829166e GitHub-Last-Rev: 82842c127474d5d225d2e9b68568387ee6b0ba04 GitHub-Pull-Request: golang/go#56588 Reviewed-on: https://go-review.googlesource.com/c/go/+/448075 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-30net: permit use of Resolver.PreferGo, netgo on Windows and Plan 9Brad Fitzpatrick
This reverts commit CL 401754 (440c9312c8) which reverted CL 400654, thus reapplying CL 400654, re-adding the func init() { netGo = true } to cgo_stub.go CL 400654 had originally removed (mistakenly during development?) that had broken the darwin nocgo builder. Fixes #33097 Change-Id: I90f59746d2ceb6b5d2bd832c9fc90068f8ff7417 Reviewed-on: https://go-review.googlesource.com/c/go/+/409234 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com>
2022-04-22Revert "net: permit use of Resolver.PreferGo, netgo on Windows and Plan 9"Bryan Mills
This reverts CL 400654. Reason for revert: broke net.TestGoLookupIP on the darwin-amd64-nocgo builder. Updates #33097. Change-Id: Idaf94eda88c9d4401e667a4d31c00ce376d91909 Reviewed-on: https://go-review.googlesource.com/c/go/+/401754 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-22net: permit use of Resolver.PreferGo, netgo on Windows and Plan 9Brad Fitzpatrick
Fixes #33097 Change-Id: I2e55c7c113683814521f2068e0922b63c62ea5d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/400654 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-11all: gofmt main repoRuss Cox
[This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-29all: use new "unix" build tag where appropriateIan Lance Taylor
For #20322 For #51572 Change-Id: Id0b4799d097d01128e98ba4cc0092298357bca45 Reviewed-on: https://go-review.googlesource.com/c/go/+/389935 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-11-02net/netip: add new IP address packageBrad Fitzpatrick
Co-authored-by: Alex Willmer <alex@moreati.org.uk> (GitHub @moreati) Co-authored-by: Alexander Yastrebov <yastrebov.alex@gmail.com> Co-authored-by: David Anderson <dave@natulte.net> (Tailscale CLA) Co-authored-by: David Crawshaw <crawshaw@tailscale.com> (Tailscale CLA) Co-authored-by: Dmytro Shynkevych <dmytro@tailscale.com> (Tailscale CLA) Co-authored-by: Elias Naur <mail@eliasnaur.com> Co-authored-by: Joe Tsai <joetsai@digital-static.net> (Tailscale CLA) Co-authored-by: Jonathan Yu <jawnsy@cpan.org> (GitHub @jawnsy) Co-authored-by: Josh Bleecher Snyder <josharian@gmail.com> (Tailscale CLA) Co-authored-by: Maisem Ali <maisem@tailscale.com> (Tailscale CLA) Co-authored-by: Manuel Mendez (Go AUTHORS mmendez534@...) Co-authored-by: Matt Layher <mdlayher@gmail.com> Co-authored-by: Noah Treuhaft <noah.treuhaft@gmail.com> (GitHub @nwt) Co-authored-by: Stefan Majer <stefan.majer@gmail.com> Co-authored-by: Terin Stock <terinjokes@gmail.com> (Cloudflare CLA) Co-authored-by: Tobias Klauser <tklauser@distanz.ch> Fixes #46518 Change-Id: I0041f9e1115d61fa6e95fcf32b01d9faee708712 Reviewed-on: https://go-review.googlesource.com/c/go/+/339309 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Trust: Brad Fitzpatrick <bradfitz@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-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-25net: prefer /etc/hosts over DNS when no /etc/nsswitch.conf is presentNatanael Copa
Do not mimic glibc behavior if /etc/nsswitch.conf is missing. This will will likely be missing on musl libc systems and glibc systems will likely always have it, resulting in localhost lookup being done over DNS rather than from /etc/hosts. Do what makes most sense rather than making any assumption about the libc. Fixes #35305 Change-Id: I20bd7e24131bba8eaa39a20c8950fe552364784d GitHub-Last-Rev: 119409839d37c8c7268f5f6db19c1789d9d96074 GitHub-Pull-Request: golang/go#39685 Reviewed-on: https://go-review.googlesource.com/c/go/+/238629 Run-TryBot: Dan Peterson <dpiddy@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Peterson <dpiddy@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
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>
2019-06-06net: remove non-cgo macOS resolver codeRuss Cox
The built-in Go resolver works significantly better. In particular, the use of res_search does not support CNAME or PTR queries and may not even be thread-safe. This CL is essentially a revert of CL 166297 plus fixes, including CL 180842. See CL 180842 for additional notes about problems with this approach. Fixes #31705. Change-Id: I0a30a0de2fbd04f6c461520fd34378c84aadf66c Reviewed-on: https://go-review.googlesource.com/c/go/+/180843 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2019-04-04net: use libSystem bindings for DNS resolution on macos if cgo is unavailablegrant
This change adds directives to link the res_search function in libSystem. The corresponding Go function is then used in `lookup_darwin.go` for resolution when cgo is disabled. This makes DNS resolution logic more reliable as macOS has some unique quirks such as the `/etc/resolver/` directory for specifying nameservers. Fixes #12524 Change-Id: I367263c4951383965b3ef6491196152f78e614b1 GitHub-Last-Rev: 3c3ff6bfa7e4811f206f3b119a867c841a016e10 GitHub-Pull-Request: golang/go#30686 Reviewed-on: https://go-review.googlesource.com/c/go/+/166297 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2018-10-10net: add AIX operating systemClément Chigot
This commit adds AIX operating system to net package for ppc64 architecture. Updates: #25893 Change-Id: I46bbc7b03931019beb969443cb3f9a756956c66c Reviewed-on: https://go-review.googlesource.com/c/138724 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-21net: use internal/bytealg insetad of linkname tricksIlya Tocar
We are currently using go:linkname for some algorithms from strings/bytes packages, to avoid importing strings/bytes. But strings/bytes are just wrappers around internal/bytealg, so we should use internal/bytealg directly. Change-Id: I2836f779b88bf8876d5fa725043a6042bdda0390 Reviewed-on: https://go-review.googlesource.com/130515 Run-TryBot: Ilya Tocar <ilya.tocar@intel.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-01all: update comment URLs from HTTP to HTTPS, where possibleTim Cooper
Each URL was manually verified to ensure it did not serve up incorrect content. Change-Id: I4dc846227af95a73ee9a3074d0c379ff0fa955df Reviewed-on: https://go-review.googlesource.com/115798 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2018-03-19net: treat a nil *Resolver as a zero one, as documentedBrad Fitzpatrick
Add accessors that handle nil without crashing. Fixes #24330 Change-Id: If5fbbb6015ca8d65f620a06bad6e52de8cd896ad Reviewed-on: https://go-review.googlesource.com/101315 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2018-03-16net: make Resolver.PreferGo work more as documentedBrad Fitzpatrick
Fixes #24393 Change-Id: I8bcee34cdf30472663d866ed6056301d8445215c Reviewed-on: https://go-review.googlesource.com/100875 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-29net: expand nss myhostname fallback detectionDan Peterson
Expand myhostname fallback detection to properly detect the local hostname in addition to other supported special names and suffixes. Fixes #17967 Change-Id: I1fe141fd9838b25886c08b6f2fd325e58be60457 Reviewed-on: https://go-review.googlesource.com/33550 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-17net: simplify internal dtoi and xtoi funcsDan Peterson
Callers pass strings sliced as necessary instead of giving an offset. Fixes #16350 Change-Id: I7ba896f6ff09e0fd0094ca6c5af5d9a81622f15e Reviewed-on: https://go-review.googlesource.com/27206 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-05net: fix hostLookupOrder("")Russ Cox
Fixes #13623. Change-Id: I1bd96aa7b6b715e4dbdcf0c37c2d29228df6565c Reviewed-on: https://go-review.googlesource.com/18329 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-04net: allow netgo to use lookup from nsswitch.confVishvananda Ishaya
Change https://golang.org/cl/8945 allowed Go to use its own DNS resolver instead of libc in a number of cases. The code parses nsswitch.conf and attempts to resolve things in the same order. Unfortunately, builds with netgo completely ignore this parsing and always search via hostLookupFilesDNS. This commit modifies the logic to allow binaries built with netgo to parse nsswitch.conf and attempt to resolve using the order specified there. If the parsing results in hostLookupCGo, it falls back to the original hostLookupFilesDNS. Tests are also added to ensure that both the parsing and the fallback work properly. Fixes #14354 Change-Id: Ib079ad03d7036a4ec57f18352a15ba55d933f261 Reviewed-on: https://go-review.googlesource.com/19523 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-02all: single space after period.Brad Fitzpatrick
The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-05net: remove imports of strconvIan Lance Taylor
The net package already has support for limited uses of the strconv package. Despite this, a few uses of strconv have crept in over time. Remove them and use the existing net support instead. Change-Id: Icdb4bdaa8e1197f1119a96cddcf548ed4a551b74 Reviewed-on: https://go-review.googlesource.com/15400 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-19net: respect go vs cgo resolver selection in all lookup routinesRuss Cox
This is especially important for LookupAddr, which used to be pure Go (lightweight, one goroutine per call) and without this CL is now unconditionally cgo (heavy, one thread per call). Fixes #12190. Change-Id: I43436a942bc1838b024225893e156f280a1e80cf Reviewed-on: https://go-review.googlesource.com/13698 Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-07-23net: make GODEBUG=netdns=cgo force cgo as documentedBrad Fitzpatrick
It wasn't working. The wrong variable was used. This would ideally have tests. It's also DEBUG. Fixes #11816 Change-Id: Iec42d229b81d78cece4ba5c73f3040e2356eb98f Reviewed-on: https://go-review.googlesource.com/12544 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-07-09net: add mechanisms to force go or cgo lookup, and to debug default strategyBrad Fitzpatrick
GODEBUG=netdns=1 prints a one-time strategy decision. (cgo or go DNS lookups) GODEBUG=netdns=2 prints the per-lookup strategy as a function of the hostname. The new "netcgo" build tag forces cgo DNS lookups. GODEBUG=netdns=go (or existing build tag "netgo") forces Go DNS resolution. GODEBUG=netdns=cgo (or new build tag "netcgo") forces libc DNS resolution. Options can be combined with e.g. GODEBUG=netdns=go+1 or GODEBUG=netdns=2+cgo. Fixes #11322 Fixes #11450 Change-Id: I7a67e9f759fd0a02320e7803f9ded1638b19e861 Reviewed-on: https://go-review.googlesource.com/11584 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-05-06net: always use cgo for DNS on AndroidBrad Fitzpatrick
Android has (had?) its own local DNS resolver daemon, also my fault: https://android.googlesource.com/platform/system/netd/+/007e987fee7e815e0c4bc820f434a632b7a69a9d And you access that via libc, not DNS. Fixes #10714 Change-Id: Iaff752872ce19bb5c7771ab048fd50e3f72cb73c Reviewed-on: https://go-review.googlesource.com/9793 Reviewed-by: David Crawshaw <crawshaw@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>