aboutsummaryrefslogtreecommitdiff
path: root/src/net/lookup.go
AgeCommit message (Collapse)Author
2021-07-08[release-branch.go1.15] net: filter bad names from Lookup functions instead ↵Roland Shoemaker
of hard failing Instead of hard failing on a single bad record, filter the bad records and return anything valid. This only applies to the methods which can return multiple records, LookupMX, LookupNS, LookupSRV, and LookupAddr. When bad results are filtered out, also return an error, indicating that this filtering has happened. Updates #46241 Updates #46979 Fixes #47012 Change-Id: I6493e0002beaf89f5a9795333a93605abd30d171 Reviewed-on: https://go-review.googlesource.com/c/go/+/332549 Trust: Roland Shoemaker <roland@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> (cherry picked from commit 296ddf2a936a30866303a64d49bc0e3e034730a8) Reviewed-on: https://go-review.googlesource.com/c/go/+/333331 Run-TryBot: Roland Shoemaker <roland@golang.org>
2021-07-08[release-branch.go1.15] net: don't reject null mx recordsRoland Shoemaker
Bypass hostname validity checking when a null mx record is returned as, defined in RFC 7505. Updates #46979 Updates #47012 Change-Id: Ibe683bd6b47333a8ff30909fb2680ec8e10696ef Reviewed-on: https://go-review.googlesource.com/c/go/+/332094 Trust: Roland Shoemaker <roland@golang.org> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> (cherry picked from commit 03761ede028d811dd7d7cf8a2690d4bfa2771d85) Reviewed-on: https://go-review.googlesource.com/c/go/+/332372 Run-TryBot: Katie Hockman <katie@golang.org>
2021-05-27[release-branch.go1.15] net: verify results from Lookup* are valid domain namesRoland Shoemaker
For the methods LookupCNAME, LookupSRV, LookupMX, LookupNS, and LookupAddr check that the returned domain names are in fact valid DNS names using the existing isDomainName function. Thanks to Philipp Jeitner and Haya Shulman from Fraunhofer SIT for reporting this issue. Updates #46241 Fixes #46356 Fixes CVE-2021-33195 Change-Id: I47a4f58c031cb752f732e88bbdae7f819f0af4f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/323131 Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> (cherry picked from commit cdcd02842da7c004efd023881e3719105209c908) Reviewed-on: https://go-review.googlesource.com/c/go/+/323269
2020-04-28net: add (*Resolver).LookupIPIan Gudger
Previously, looking up only IPv4 or IPv6 addresses was only possible with DefaultResolver via ResolveIPAddr. Add this functionality to the Resolver type with a new method, LookupIP. This largely brings Resolver functionally to parity with the global functions. The name LookupIP is used over ResolveIPAddr to be consistent with the other Resolver methods. There are two main benefits to (*Resolver).LookupIP over (*Resolver).LookupHost. First is an ergonomic benefit. Wanting a specific family of address is common enough to justify a method, evident by the existence of ResolveIPAddr. Second, this opens the possibility of not performing unnecessary DNS requests when only a specific family of addresses are needed. This optimization is left to follow up work. Updates #30452 Change-Id: I241f61019588022a39738f8920b0ddba900cecdd Reviewed-on: https://go-review.googlesource.com/c/go/+/228641 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@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-04-23net: add IsNotFound field to DNSErrorShubham Sharma
This adds the ability to determine if a lookup error was due to a non-existent hostname. Previously users needed to do string matching on the DNSError.Err value. Fixes #28635 Change-Id: If4bd3ad32cbc2db5614f2c6b72e0a9161d813efa Reviewed-on: https://go-review.googlesource.com/c/go/+/168597 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@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-03-08net: use network and host as singleflight key during lookupIPCezar Sa Espinola
In CL 120215 the cgo resolver was changed to have different logic based on the network being queried. However, the singleflight cache key wasn't updated to also include the network. This way it was possible for concurrent queries to return the result for the wrong network. This CL changes the key to include both network and host, fixing the problem. Fixes #30521 Change-Id: I8b41b0ce1d9a02d18876c43e347654312eba22fc Reviewed-on: https://go-review.googlesource.com/c/go/+/166037 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-12net: preserve unexpired context values for LookupIPAddrEmmanuel T Odeke
To avoid any cancelation of the parent context from affecting lookupGroup operations, Resolver.LookupIPAddr previously used an entirely new context created from context.Background(). However, this meant that all the values in the parent context with which LookupIPAddr was invoked were dropped. This change provides a custom context implementation that only preserves values of the parent context by composing context.Background() and the parent context. It only falls back to the parent context to perform value lookups if the parent context has not yet expired. This context is never canceled, and has no deadlines. Fixes #28600 Change-Id: If2f570caa26c65bad638b7102c35c79d5e429fea Reviewed-on: https://go-review.googlesource.com/c/148698 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> 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-06-27net: parse IPv6 address with zone using DefaultResolver.Lookup{Host,IPAddr}Michael Fraenkel
Allow a zone to be included with the ip address that is parsed when using DefaultResolver's LookupHost or LookupIPAddr Fixes #20790 Fixes #20767 Change-Id: I4e0baf9ade6a095af10a1b85ca6216788ba680ae Reviewed-on: https://go-review.googlesource.com/79935 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-27net: make concurrent resolver lookups independentGrégoire Delattre
The current resolver uses a global lookupGroup which merges LookupIPAddr calls together for lookups for the same hostname if used concurrently. As a result only one of the resolvers is actually used to perform the DNS lookup but the result is shared by all the resolvers. This commit limits the scope of the lookupGroup to the resolver itself allowing each resolver to make its own requests without sharing the result with other resolvers. Fixes #22908 Change-Id: Ibba896eebb05e59f18ce4132564ea1f2b4b6c6d9 Reviewed-on: https://go-review.googlesource.com/80775 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@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: don't let cancelation of a DNS lookup affect another lookupIan Lance Taylor
Updates #8602 Updates #20703 Fixes #22724 Change-Id: I27b72311b2c66148c59977361bd3f5101e47b51d Reviewed-on: https://go-review.googlesource.com/100840 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-13all: use HTTPS for iana.org linksKevin Burke
iana.org, www.iana.org and data.iana.org all present a valid TLS certificate, so let's use it when fetching data or linking to resources to avoid errors in transit. Change-Id: Ib3ce7c19789c4e9d982a776b61d8380ddc63194d Reviewed-on: https://go-review.googlesource.com/89416 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-12-08net: avoid race on test hooks with DNS goroutinesIan Lance Taylor
The DNS code can start goroutines and not wait for them to complete. This does no harm, but in tests this can cause a race condition with the test hooks that are installed and unintalled around the tests. Add a WaitGroup that tests of DNS can use to avoid the race. Fixes #21090 Change-Id: I6c1443a9c2378e8b89d0ab1d6390c0e3e726b0ce Reviewed-on: https://go-review.googlesource.com/82795 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-17Revert "net: Forget lookups for canceled contexts"Brad Fitzpatrick
This reverts commit 6a3d4be3b80054b1d802b73d5a519e252e0f82ed. Reason for revert: breaks various builds. See comments on CL 77670 Change-Id: Iaf3260319b560f49ace06af705a2114630f32063 Reviewed-on: https://go-review.googlesource.com/78515 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-15net: Forget lookups for canceled contextsTroels Thomsen
A sequential lookup using any non-canceled context has a risk of returning the result of the previous lookup for a canceled context (i.e. an error). This is already prevented for timed out context by forgetting the host immediately and extending this to also compare the error to `context.Canceled` resolves this issue. Fixes #22724 Change-Id: I7aafa1459a0de4dc5c4332988fbea23cbf4dba07 Reviewed-on: https://go-review.googlesource.com/77670 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-06net: clarify the length limit for service nameMikio Hara
Change-Id: If5495f66d175bdacebd599abf1e064d2343669c2 Reviewed-on: https://go-review.googlesource.com/34430 Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-22net: update documentation on Dial and its variantsMikio Hara
This change clarifies the documentation on Dial and its variants to avoid unnecessary confusion about how the arguments for the connection setup functions are used to make connections. Also replaces "name" or "hostname" with "host name" when the term implies the use of DNS. Updates #17613. Fixes #17614. Fixes #17738. Fixes #17956. Updates #18806. Change-Id: I6adb3f2ae04a3bf83b96016ed73d8e59926f3e8a Reviewed-on: https://go-review.googlesource.com/34875 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-16net: don't forget about ongoing DNS lookup if context canceledIan Lance Taylor
Only forget about it if the context timed out, as the comment says. Fixes #20703. Change-Id: Ie6234f1a32f85e6bfd052dc24a33aa63b8883c37 Reviewed-on: https://go-review.googlesource.com/45999 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-08net: support all PacketConn and Conn returned by Resolver.DialBen Burkert
Allow the Resolver.Dial func to return instances of Conn other than *TCPConn and *UDPConn. If the Conn is also a PacketConn, assume DNS messages transmitted over the Conn adhere to section 4.2.1. "UDP usage". Otherwise, follow section 4.2.2. "TCP usage". Provides a hook mechanism so that DNS queries generated by the net package may be answered or modified before being sent to over the network. Updates #19910 Change-Id: Ib089a28ad4a1848bbeaf624ae889f1e82d56655b Reviewed-on: https://go-review.googlesource.com/45153 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-12net: allow Resolver to use a custom dialerMatt Harden
In some cases it is desirable to customize the way the DNS server is contacted, for instance to use a specific LocalAddr. While most operating-system level resolvers do not allow this, we have the opportunity to do so with the Go resolver. Most of the code was already in place to allow tests to override the dialer. This exposes that functionality, and as a side effect eliminates the need for a testing hook. Fixes #17404 Change-Id: I1c5e570f8edbcf630090f8ec6feb52e379e3e5c0 Reviewed-on: https://go-review.googlesource.com/37260 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-09net: add Resolver.StrictErrorsPaul Marks
When LookupIP is performing multiple subqueries, this option causes a timeout/servfail affecting a single query to abort the whole operation, instead of returning a partial (IPv4/IPv6-only) result. Similarly, operations that walk the DNS search list will also abort when encountering one of these errors. Fixes #17448 Change-Id: Ice22e4aceb555c5a80d19bd1fde8b8fe87ac9517 Reviewed-on: https://go-review.googlesource.com/32572 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-12-20net: make LookupCNAME's native behavior match its cgo behaviorMatthew Dempsky
Fixes #18172. Change-Id: I4a21fb5c0753cced025a03d88a6dd1aa3ee01d05 Reviewed-on: https://go-review.googlesource.com/34650 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2016-10-22net: clarify LookupAddr docs on libc's behavior, and alternativesBrad Fitzpatrick
Text from rsc. Fixes #17093 Change-Id: I13c3018b1584f152b53f8576dd16ebef98aa5182 Reviewed-on: https://go-review.googlesource.com/31720 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-21net: make all Resolver methods respect Resolver.PreferGoBrad Fitzpatrick
Fixes #17532 Change-Id: Id62671d505c77ea924b3570a504cdc3b157e5a0d Reviewed-on: https://go-review.googlesource.com/31734 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-21net: add Resolver type, Dialer.Resolver, and DefaultResolverBrad Fitzpatrick
The new Resolver type (a struct) has 9 Lookup methods, all taking a context.Context. There's now a new DefaultResolver global, like http's DefaultTransport and DefaultClient. net.Dialer now has an optional Resolver field to set the Resolver. This also does finishes some resolver cleanup internally, deleting lookupIPMerge and renaming lookupIPContext into Resolver.LookupIPAddr. The Resolver currently doesn't let you tweak much, but it's a struct specifically so we can add knobs in the future. Currently I just added a bool to force the pure Go resolver. In the future we could let people provide an interface to implement the methods, or add a Timeout time.Duration, which would wrap all provided contexts in a context.WithTimeout. Fixes #16672 Change-Id: I7ba1f886704f06def7b6b5c4da9809db51bc1495 Reviewed-on: https://go-review.googlesource.com/29440 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-09-11net: make LookupPort and lookupProtocol work on naclBrad Fitzpatrick
Also, flesh out the baked-in /etc/services table for LookupPort a bit. This services map moves from a unix-specific file to a portable file where nacl can use it. Also, remove the duplicated entries in the protocol map in different cases, and just canonicalize the input before looking in the map. Now it handles any case, including MiXeD cAse. In the process, add a test that service names for LookupPort are case insensitive. They were on Windows, but not cgo. Now there's a test and they're case insensitive in all 3+ paths. Maybe it breaks plan9. We'll see. Fixes #17045 Change-Id: Idce7d68703f371727c7505cda03a32bd842298cd Reviewed-on: https://go-review.googlesource.com/28951 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Minux Ma <minux@golang.org>
2016-04-28net/http, net/http/httptrace: new package for tracing HTTP client requestsBrad Fitzpatrick
Updates #12580 Change-Id: I9f9578148ef2b48dffede1007317032d39f6af55 Reviewed-on: https://go-review.googlesource.com/22191 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tom Bergan <tombergan@google.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-18net: fix plan9 after context change, propagate contexts moreBrad Fitzpatrick
My previous https://golang.org/cl/22101 to add context throughout the net package broke Plan 9, which isn't currently tested (#15251). It also broke some old unsupported version of Windows (Windows 2000?) which doesn't have the ConnectEx function, but that was only found visually, since our minimum supported Windows version has ConnectEx. This change simplifies the Windows and deletes the non-ConnectEx code path. Windows 2000 will work even less now, if it even worked before. Windows XP remains our minimum supported version. Specifically, the previous CL stopped using the "dial" function, which 0intro noted: https://github.com/golang/go/issues/15333#issuecomment-210842761 This CL removes the dial function instead and makes plan9's net implementation respect contexts, which likely fixes a number of t.Skipped tests. I'm leaving that to 0intro to investigate. In the process of propagating and respecting contexts for plan9, I had to change some signatures to add contexts to more places and ended up pushing contexts down into the Go-based DNS resolution as well, replacing the pure-Go DNS implementation's use of "timeout time.Duration" with a context instead. Updates #11932 Updates #15328 Fixes #15333 Change-Id: I6ad1e62f38271cdd86b3f40921f2d0f23374936a Reviewed-on: https://go-review.googlesource.com/22144 Reviewed-by: David du Colombier <0intro@gmail.com> Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-15net: fix looking up port numbers starting with numbers.Morten Siebuhr
LookupPort() correctly parses service names beginning with numerals by implementing a new parser, mainly taken from strconv/atoi.go. Also testes some previously undefined behaviours around port numbers larger than 65535 that previously could lead to some tests fail with EOPNOTSUPP (Operation Not Supported). Fixes #14322 Change-Id: I1b90dbed434494723e261d84e73fe705e5c0507a Reviewed-on: https://go-review.googlesource.com/19720 Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-04-15net: context plumbing, add Dialer.DialContextBrad Fitzpatrick
For #12580 (http.Transport tracing/analytics) Updates #13021 Change-Id: I126e494a7bd872e42c388ecb58499ecbf0f014cc Reviewed-on: https://go-review.googlesource.com/22101 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.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>
2016-03-01all: make copyright headers consistent with one space after periodBrad Fitzpatrick
This is a subset of https://golang.org/cl/20022 with only the copyright header lines, so the next CL will be smaller and more reviewable. Go policy has been single space after periods in comments for some time. The copyright header template at: https://golang.org/doc/contribute.html#copyright also uses a single space. Make them all consistent. Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0 Reviewed-on: https://go-review.googlesource.com/20111 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-08Revert "net: ensure that malformed domain names report a consistent error"Russ Cox
This reverts commit bb8c2e19a7fe2ca2283eca44dba2047c9f4307fe. Change-Id: I9bc089e9f2296805ef055b98e8c86ba73af30226 Reviewed-on: https://go-review.googlesource.com/18439 Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-08net: ensure that malformed domain names report a consistent errorRuss Cox
Previously it depended on whether we were using the Go resolver or the Cgo resolver. Fixes #12421. Change-Id: Ib162e336f30f736d7244e29d96651c3be11fc3cd Reviewed-on: https://go-review.googlesource.com/18383 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-14net: make LookupPort with empty service mean 0Brad Fitzpatrick
Fixes #13610 Change-Id: I9c8f924dc1ad515a9697291e981ece34fdbec8b7 Reviewed-on: https://go-review.googlesource.com/17755 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-01net: make Dial, Listen{,Packet} for TCP/UDP with invalid port failMikio Hara
This change makes Dial, Listen and ListenPacket with invalid port fail whatever GODEBUG=netdns is. Please be informed that cgoLookupPort with an out of range literal number may return either the lower or upper bound value, 0 or 65535, with no error on some platform. Fixes #11715. Change-Id: I43f9c4fb5526d1bf50b97698e0eb39d29fd74c35 Reviewed-on: https://go-review.googlesource.com/12447 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-27net: restore LookupPort for integer stringsRuss Cox
This worked in Go 1.4 but was lost in the "pure Go" lookup routines substituted late in the Go 1.5 cycle. Fixes #12263. Change-Id: I77ec9d97cd8e67ace99d6ac965e5bc16c151ba83 Reviewed-on: https://go-review.googlesource.com/13915 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-06-24net: make LookupIP("1.2.3.4") behavior consistentRuss Cox
To date, the behavior has depended on whether we're using cgo and in turn what the host resolver does. Most host resolvers will "resolve" IP addresses, but the non-cgo pure Go path has not. This CL makes resolution of IP addresses always work, even if we're not using cgo and even if the host resolver does not "resolve" IP addresses. Fixes #11335. Change-Id: I19e82be968154d94904bb2f72e9c17893019a909 Reviewed-on: https://go-review.googlesource.com/11420 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-21net: fix inconsistent error values on LookupMikio Hara
This change fixes inconsistent error values on Lookup{Addr,CNAME,Host,IP.MX,NS,Port,SRV,TXT}. Updates #4856. Change-Id: I059bc8ffb96ee74dff8a8c4e8e6ae3e4a462a7ef Reviewed-on: https://go-review.googlesource.com/9108 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-13cmd/go: cache results of HTTP requests done during meta tag discoveryBrad Fitzpatrick
Previously, running $ go get -u -v golang.org/x/tools/cmd/godoc would results in dozens of HTTP requests for https://golang.org/x/tools?go-get=1 once per package under x/tools. Now it caches the results. We still end up doing one HTTP request for all the packages under x/tools, but this reduces the total number of HTTP requests in ~half. This also moves the singleflight package back into an internal package. singleflight was originally elsewhere as a package, then got copied into "net" (without its tests). But now that we have internal, put it in its own package, and restore its test. Fixes #9249 Change-Id: Ieb5cf04fc4d0a0c188cb957efdc7ea3068c34e3f Reviewed-on: https://go-review.googlesource.com/8727 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-07net: add lookup IP hook for testingMikio Hara
This change adds testHookLookIP to enable to inject DNS name to IP address mappings for Happ{y,yish,ier} Eyeballs dial testing. Change-Id: I8ac04a594e1e2bd77909528df0552889914a7790 Reviewed-on: https://go-review.googlesource.com/8399 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-08net: LookupHost and Resolve{TCP,UDP,IP}Addr should use zone from getaddrinfoAndrew Pilloud
The unix and windows getaddrinfo calls return a zone with IPv6 addresses. IPv6 link-local addresses returned are only valid on the given zone. When the zone is dropped, connections to the address will fail. This patch replaces IP with IPAddr in several internal resolver functions, and plumbs through the zone. Change-Id: Ifea891654f586f15b76988464f82e04a42ccff6d Reviewed-on: https://go-review.googlesource.com/5851 Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2014-10-27net: if a DNS lookup times out, forget that it is in flightIan Lance Taylor
Before this CL, if the system resolver does a very slow DNS lookup for a particular host, all subsequent requests for that host will hang waiting for that lookup to complete. That is more or less expected when Dial is called with no deadline. When Dial has a deadline, though, we can accumulate a large number of goroutines waiting for that slow DNS lookup. Try to avoid this problem by restarting the DNS lookup when it is redone after a deadline is passed. This CL also avoids creating an extra goroutine purely to handle the deadline. No test because we would have to simulate a slow DNS lookup followed by a fast DNS lookup. Fixes #8602. LGTM=bradfitz R=bradfitz, mikioh.mikioh CC=golang-codereviews, r, rsc https://golang.org/cl/154610044
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.