2016-03-01 15:57:46 -07:00
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
2014-09-18 04:17:55 -06:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2019-10-08 13:19:13 -06:00
|
|
|
// +build js,wasm
|
2014-09-18 04:17:55 -06:00
|
|
|
|
|
|
|
package net
|
|
|
|
|
2016-04-14 18:47:25 -06:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"syscall"
|
|
|
|
)
|
2014-09-18 04:17:55 -06:00
|
|
|
|
net: fix plan9 after context change, propagate contexts more
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-16 15:17:40 -06:00
|
|
|
func lookupProtocol(ctx context.Context, name string) (proto int, err error) {
|
2016-09-09 16:51:11 -06:00
|
|
|
return lookupProtocolMap(name)
|
2014-09-18 04:17:55 -06:00
|
|
|
}
|
|
|
|
|
2016-10-21 11:27:57 -06:00
|
|
|
func (*Resolver) lookupHost(ctx context.Context, host string) (addrs []string, err error) {
|
2014-09-18 04:17:55 -06:00
|
|
|
return nil, syscall.ENOPROTOOPT
|
|
|
|
}
|
|
|
|
|
2018-06-20 16:23:37 -06:00
|
|
|
func (*Resolver) lookupIP(ctx context.Context, network, host string) (addrs []IPAddr, err error) {
|
2016-09-20 13:45:37 -06:00
|
|
|
return nil, syscall.ENOPROTOOPT
|
|
|
|
}
|
|
|
|
|
2016-10-21 11:27:57 -06:00
|
|
|
func (*Resolver) lookupPort(ctx context.Context, network, service string) (port int, err error) {
|
2016-09-09 16:51:11 -06:00
|
|
|
return goLookupPort(network, service)
|
2014-09-18 04:17:55 -06:00
|
|
|
}
|
|
|
|
|
2016-10-21 11:27:57 -06:00
|
|
|
func (*Resolver) lookupCNAME(ctx context.Context, name string) (cname string, err error) {
|
2014-09-18 04:17:55 -06:00
|
|
|
return "", syscall.ENOPROTOOPT
|
|
|
|
}
|
|
|
|
|
2016-10-21 11:27:57 -06:00
|
|
|
func (*Resolver) lookupSRV(ctx context.Context, service, proto, name string) (cname string, srvs []*SRV, err error) {
|
2014-09-18 04:17:55 -06:00
|
|
|
return "", nil, syscall.ENOPROTOOPT
|
|
|
|
}
|
|
|
|
|
2016-10-21 11:27:57 -06:00
|
|
|
func (*Resolver) lookupMX(ctx context.Context, name string) (mxs []*MX, err error) {
|
2014-09-18 04:17:55 -06:00
|
|
|
return nil, syscall.ENOPROTOOPT
|
|
|
|
}
|
|
|
|
|
2016-10-21 11:27:57 -06:00
|
|
|
func (*Resolver) lookupNS(ctx context.Context, name string) (nss []*NS, err error) {
|
2014-09-18 04:17:55 -06:00
|
|
|
return nil, syscall.ENOPROTOOPT
|
|
|
|
}
|
|
|
|
|
2016-10-21 11:27:57 -06:00
|
|
|
func (*Resolver) lookupTXT(ctx context.Context, name string) (txts []string, err error) {
|
2014-09-18 04:17:55 -06:00
|
|
|
return nil, syscall.ENOPROTOOPT
|
|
|
|
}
|
|
|
|
|
2016-10-21 11:27:57 -06:00
|
|
|
func (*Resolver) lookupAddr(ctx context.Context, addr string) (ptrs []string, err error) {
|
2014-09-18 04:17:55 -06:00
|
|
|
return nil, syscall.ENOPROTOOPT
|
|
|
|
}
|
2018-06-27 08:08:41 -06:00
|
|
|
|
|
|
|
// concurrentThreadsLimit returns the number of threads we permit to
|
|
|
|
// run concurrently doing DNS lookups.
|
|
|
|
func concurrentThreadsLimit() int {
|
|
|
|
return 500
|
|
|
|
}
|