X7ROOT File Manager
Current Path:
/opt/golang/1.17.2/src/net
opt
/
golang
/
1.17.2
/
src
/
net
/
📁
..
📄
addrselect.go
(9.59 KB)
📄
addrselect_test.go
(6.28 KB)
📄
cgo_aix.go
(603 B)
📄
cgo_android.go
(293 B)
📄
cgo_bsd.go
(419 B)
📄
cgo_linux.go
(672 B)
📄
cgo_netbsd.go
(297 B)
📄
cgo_openbsd.go
(297 B)
📄
cgo_resnew.go
(668 B)
📄
cgo_resold.go
(654 B)
📄
cgo_socknew.go
(816 B)
📄
cgo_sockold.go
(937 B)
📄
cgo_solaris.go
(364 B)
📄
cgo_stub.go
(1.08 KB)
📄
cgo_unix.go
(9.65 KB)
📄
cgo_unix_test.go
(2.01 KB)
📄
cgo_windows.go
(423 B)
📄
conf.go
(8.78 KB)
📄
conf_netcgo.go
(387 B)
📄
conf_test.go
(9.76 KB)
📄
conn_test.go
(1.79 KB)
📄
dial.go
(22.72 KB)
📄
dial_test.go
(26.02 KB)
📄
dial_unix_test.go
(2.83 KB)
📄
dnsclient.go
(5.73 KB)
📄
dnsclient_test.go
(1.51 KB)
📄
dnsclient_unix.go
(22.12 KB)
📄
dnsclient_unix_test.go
(54.46 KB)
📄
dnsconfig_unix.go
(5.56 KB)
📄
dnsconfig_unix_test.go
(6.83 KB)
📄
dnsname_test.go
(1.99 KB)
📄
error_plan9.go
(224 B)
📄
error_plan9_test.go
(398 B)
📄
error_posix.go
(700 B)
📄
error_posix_test.go
(998 B)
📄
error_test.go
(19.59 KB)
📄
error_unix.go
(517 B)
📄
error_unix_test.go
(702 B)
📄
error_windows.go
(355 B)
📄
error_windows_test.go
(483 B)
📄
example_test.go
(3.88 KB)
📄
external_test.go
(4.08 KB)
📄
fcntl_libc_test.go
(400 B)
📄
fcntl_syscall_test.go
(545 B)
📄
fd_plan9.go
(3.56 KB)
📄
fd_posix.go
(2.58 KB)
📄
fd_unix.go
(5.54 KB)
📄
fd_windows.go
(4.62 KB)
📄
file.go
(1.69 KB)
📄
file_plan9.go
(2.68 KB)
📄
file_stub.go
(507 B)
📄
file_test.go
(6.55 KB)
📄
file_unix.go
(2.6 KB)
📄
file_windows.go
(521 B)
📄
hook.go
(628 B)
📄
hook_plan9.go
(283 B)
📄
hook_unix.go
(840 B)
📄
hook_windows.go
(875 B)
📄
hosts.go
(3.1 KB)
📄
hosts_test.go
(4.59 KB)
📁
http
📄
interface.go
(7.17 KB)
📄
interface_aix.go
(4.41 KB)
📄
interface_bsd.go
(2.8 KB)
📄
interface_bsd_test.go
(1.48 KB)
📄
interface_bsdvar.go
(753 B)
📄
interface_darwin.go
(1.29 KB)
📄
interface_freebsd.go
(1.42 KB)
📄
interface_linux.go
(6.9 KB)
📄
interface_linux_test.go
(3.65 KB)
📄
interface_plan9.go
(4.68 KB)
📄
interface_solaris.go
(2.07 KB)
📄
interface_stub.go
(830 B)
📄
interface_test.go
(9.68 KB)
📄
interface_unix_test.go
(4.79 KB)
📄
interface_windows.go
(5.41 KB)
📁
internal
📄
ip.go
(17.66 KB)
📄
ip_test.go
(25.33 KB)
📄
iprawsock.go
(7.08 KB)
📄
iprawsock_plan9.go
(874 B)
📄
iprawsock_posix.go
(3.56 KB)
📄
iprawsock_test.go
(5.63 KB)
📄
ipsock.go
(8.97 KB)
📄
ipsock_plan9.go
(7.5 KB)
📄
ipsock_plan9_test.go
(645 B)
📄
ipsock_posix.go
(6.28 KB)
📄
ipsock_test.go
(6.81 KB)
📄
listen_test.go
(21.34 KB)
📄
lookup.go
(21.33 KB)
📄
lookup_fake.go
(1.66 KB)
📄
lookup_plan9.go
(7.68 KB)
📄
lookup_test.go
(31.13 KB)
📄
lookup_unix.go
(8.89 KB)
📄
lookup_windows.go
(11.72 KB)
📄
lookup_windows_test.go
(8.02 KB)
📄
mac.go
(1.88 KB)
📄
mac_test.go
(3.26 KB)
📁
mail
📄
main_cloexec_test.go
(750 B)
📄
main_conf_test.go
(952 B)
📄
main_noconf_test.go
(537 B)
📄
main_plan9_test.go
(392 B)
📄
main_posix_test.go
(1.4 KB)
📄
main_test.go
(7.13 KB)
📄
main_unix_test.go
(1.33 KB)
📄
main_windows_test.go
(1.08 KB)
📄
mockserver_test.go
(11.39 KB)
📄
net.go
(22.37 KB)
📄
net_fake.go
(5.37 KB)
📄
net_test.go
(13.88 KB)
📄
net_windows_test.go
(15.94 KB)
📄
netgo_unix_test.go
(741 B)
📄
nss.go
(3.8 KB)
📄
nss_test.go
(3.42 KB)
📄
packetconn_test.go
(3.57 KB)
📄
parse.go
(7.33 KB)
📄
parse_test.go
(2.14 KB)
📄
pipe.go
(5.43 KB)
📄
pipe_test.go
(1.2 KB)
📄
platform_test.go
(4.57 KB)
📄
port.go
(1.46 KB)
📄
port_test.go
(1.34 KB)
📄
port_unix.go
(1.39 KB)
📄
protoconn_test.go
(7.24 KB)
📄
rawconn.go
(1.89 KB)
📄
rawconn_stub_test.go
(655 B)
📄
rawconn_test.go
(4.45 KB)
📄
rawconn_unix_test.go
(3.1 KB)
📄
rawconn_windows_test.go
(3.12 KB)
📁
rpc
📄
sendfile_linux.go
(1.1 KB)
📄
sendfile_stub.go
(391 B)
📄
sendfile_test.go
(6.91 KB)
📄
sendfile_unix_alt.go
(2.02 KB)
📄
sendfile_windows.go
(1.02 KB)
📄
server_test.go
(11.11 KB)
📁
smtp
📄
sock_bsd.go
(968 B)
📄
sock_cloexec.go
(1.53 KB)
📄
sock_linux.go
(1.53 KB)
📄
sock_linux_test.go
(545 B)
📄
sock_plan9.go
(262 B)
📄
sock_posix.go
(6.92 KB)
📄
sock_stub.go
(420 B)
📄
sock_windows.go
(1.16 KB)
📄
sockaddr_posix.go
(1.05 KB)
📄
sockopt_aix.go
(1.43 KB)
📄
sockopt_bsd.go
(2.26 KB)
📄
sockopt_linux.go
(1.25 KB)
📄
sockopt_plan9.go
(406 B)
📄
sockopt_posix.go
(2.76 KB)
📄
sockopt_solaris.go
(1.25 KB)
📄
sockopt_stub.go
(760 B)
📄
sockopt_windows.go
(1.51 KB)
📄
sockoptip_bsdvar.go
(929 B)
📄
sockoptip_linux.go
(735 B)
📄
sockoptip_posix.go
(1.53 KB)
📄
sockoptip_stub.go
(971 B)
📄
sockoptip_windows.go
(819 B)
📄
splice_linux.go
(1.09 KB)
📄
splice_stub.go
(304 B)
📄
splice_test.go
(10.51 KB)
📄
sys_cloexec.go
(1 KB)
📄
tcpsock.go
(9.88 KB)
📄
tcpsock_plan9.go
(2.13 KB)
📄
tcpsock_posix.go
(5.39 KB)
📄
tcpsock_test.go
(17.53 KB)
📄
tcpsock_unix_test.go
(2.41 KB)
📄
tcpsockopt_darwin.go
(770 B)
📄
tcpsockopt_dragonfly.go
(698 B)
📄
tcpsockopt_openbsd.go
(365 B)
📄
tcpsockopt_plan9.go
(525 B)
📄
tcpsockopt_posix.go
(592 B)
📄
tcpsockopt_solaris.go
(1.15 KB)
📄
tcpsockopt_stub.go
(415 B)
📄
tcpsockopt_unix.go
(757 B)
📄
tcpsockopt_windows.go
(741 B)
📁
testdata
📁
textproto
📄
timeout_test.go
(23.39 KB)
📄
udpsock.go
(9.19 KB)
📄
udpsock_plan9.go
(3.79 KB)
📄
udpsock_plan9_test.go
(1.31 KB)
📄
udpsock_posix.go
(4.27 KB)
📄
udpsock_test.go
(12.27 KB)
📄
unixsock.go
(10.17 KB)
📄
unixsock_linux_test.go
(2.29 KB)
📄
unixsock_plan9.go
(1.24 KB)
📄
unixsock_posix.go
(6.03 KB)
📄
unixsock_readmsg_cloexec.go
(691 B)
📄
unixsock_readmsg_cmsg_cloexec.go
(373 B)
📄
unixsock_readmsg_other.go
(301 B)
📄
unixsock_readmsg_test.go
(2.62 KB)
📄
unixsock_test.go
(10.56 KB)
📄
unixsock_windows_test.go
(2.09 KB)
📁
url
📄
write_unix_test.go
(1.67 KB)
📄
writev_test.go
(5.02 KB)
📄
writev_unix.go
(797 B)
Editing: conf_test.go
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package net import ( "io/fs" "strings" "testing" ) type nssHostTest struct { host string localhost string want hostLookupOrder } func nssStr(s string) *nssConf { return parseNSSConf(strings.NewReader(s)) } // represents a dnsConfig returned by parsing a nonexistent resolv.conf var defaultResolvConf = &dnsConfig{ servers: defaultNS, ndots: 1, timeout: 5, attempts: 2, err: fs.ErrNotExist, } func TestConfHostLookupOrder(t *testing.T) { tests := []struct { name string c *conf resolver *Resolver hostTests []nssHostTest }{ { name: "force", c: &conf{ forceCgoLookupHost: true, nss: nssStr("foo: bar"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"foo.local", "myhostname", hostLookupCgo}, {"google.com", "myhostname", hostLookupCgo}, }, }, { name: "netgo_dns_before_files", c: &conf{ netGo: true, nss: nssStr("hosts: dns files"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"x.com", "myhostname", hostLookupDNSFiles}, }, }, { name: "netgo_fallback_on_cgo", c: &conf{ netGo: true, nss: nssStr("hosts: dns files something_custom"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"x.com", "myhostname", hostLookupFilesDNS}, }, }, { name: "ubuntu_trusty_avahi", c: &conf{ nss: nssStr("hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"foo.local", "myhostname", hostLookupCgo}, {"foo.local.", "myhostname", hostLookupCgo}, {"foo.LOCAL", "myhostname", hostLookupCgo}, {"foo.LOCAL.", "myhostname", hostLookupCgo}, {"google.com", "myhostname", hostLookupFilesDNS}, }, }, { name: "freebsdlinux_no_resolv_conf", c: &conf{ goos: "freebsd", nss: nssStr("foo: bar"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupFilesDNS}}, }, // On OpenBSD, no resolv.conf means no DNS. { name: "openbsd_no_resolv_conf", c: &conf{ goos: "openbsd", resolv: defaultResolvConf, }, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupFiles}}, }, { name: "solaris_no_nsswitch", c: &conf{ goos: "solaris", nss: &nssConf{err: fs.ErrNotExist}, resolv: defaultResolvConf, }, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupCgo}}, }, { name: "openbsd_lookup_bind_file", c: &conf{ goos: "openbsd", resolv: &dnsConfig{lookup: []string{"bind", "file"}}, }, hostTests: []nssHostTest{ {"google.com", "myhostname", hostLookupDNSFiles}, {"foo.local", "myhostname", hostLookupDNSFiles}, }, }, { name: "openbsd_lookup_file_bind", c: &conf{ goos: "openbsd", resolv: &dnsConfig{lookup: []string{"file", "bind"}}, }, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupFilesDNS}}, }, { name: "openbsd_lookup_bind", c: &conf{ goos: "openbsd", resolv: &dnsConfig{lookup: []string{"bind"}}, }, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupDNS}}, }, { name: "openbsd_lookup_file", c: &conf{ goos: "openbsd", resolv: &dnsConfig{lookup: []string{"file"}}, }, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupFiles}}, }, { name: "openbsd_lookup_yp", c: &conf{ goos: "openbsd", resolv: &dnsConfig{lookup: []string{"file", "bind", "yp"}}, }, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupCgo}}, }, { name: "openbsd_lookup_two", c: &conf{ goos: "openbsd", resolv: &dnsConfig{lookup: []string{"file", "foo"}}, }, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupCgo}}, }, { name: "openbsd_lookup_empty", c: &conf{ goos: "openbsd", resolv: &dnsConfig{lookup: nil}, }, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupDNSFiles}}, }, { name: "linux_no_nsswitch.conf", c: &conf{ goos: "linux", nss: &nssConf{err: fs.ErrNotExist}, resolv: defaultResolvConf, }, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupFilesDNS}}, }, { name: "linux_empty_nsswitch.conf", c: &conf{ goos: "linux", nss: nssStr(""), resolv: defaultResolvConf, }, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupFilesDNS}}, }, { name: "files_mdns_dns", c: &conf{ nss: nssStr("hosts: files mdns dns"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"x.com", "myhostname", hostLookupFilesDNS}, {"x.local", "myhostname", hostLookupCgo}, }, }, { name: "dns_special_hostnames", c: &conf{ nss: nssStr("hosts: dns"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"x.com", "myhostname", hostLookupDNS}, {"x\\.com", "myhostname", hostLookupCgo}, // punt on weird glibc escape {"foo.com%en0", "myhostname", hostLookupCgo}, // and IPv6 zones }, }, { name: "mdns_allow", c: &conf{ nss: nssStr("hosts: files mdns dns"), resolv: defaultResolvConf, hasMDNSAllow: true, }, hostTests: []nssHostTest{ {"x.com", "myhostname", hostLookupCgo}, {"x.local", "myhostname", hostLookupCgo}, }, }, { name: "files_dns", c: &conf{ nss: nssStr("hosts: files dns"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"x.com", "myhostname", hostLookupFilesDNS}, {"x", "myhostname", hostLookupFilesDNS}, {"x.local", "myhostname", hostLookupCgo}, }, }, { name: "dns_files", c: &conf{ nss: nssStr("hosts: dns files"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"x.com", "myhostname", hostLookupDNSFiles}, {"x", "myhostname", hostLookupDNSFiles}, {"x.local", "myhostname", hostLookupCgo}, }, }, { name: "something_custom", c: &conf{ nss: nssStr("hosts: dns files something_custom"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"x.com", "myhostname", hostLookupCgo}, }, }, { name: "myhostname", c: &conf{ nss: nssStr("hosts: files dns myhostname"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"x.com", "myhostname", hostLookupFilesDNS}, {"myhostname", "myhostname", hostLookupCgo}, {"myHostname", "myhostname", hostLookupCgo}, {"myhostname.dot", "myhostname.dot", hostLookupCgo}, {"myHostname.dot", "myhostname.dot", hostLookupCgo}, {"gateway", "myhostname", hostLookupCgo}, {"Gateway", "myhostname", hostLookupCgo}, {"localhost", "myhostname", hostLookupCgo}, {"Localhost", "myhostname", hostLookupCgo}, {"anything.localhost", "myhostname", hostLookupCgo}, {"Anything.localhost", "myhostname", hostLookupCgo}, {"localhost.localdomain", "myhostname", hostLookupCgo}, {"Localhost.Localdomain", "myhostname", hostLookupCgo}, {"anything.localhost.localdomain", "myhostname", hostLookupCgo}, {"Anything.Localhost.Localdomain", "myhostname", hostLookupCgo}, {"somehostname", "myhostname", hostLookupFilesDNS}, {"", "myhostname", hostLookupFilesDNS}, // Issue 13623 }, }, { name: "ubuntu14.04.02", c: &conf{ nss: nssStr("hosts: files myhostname mdns4_minimal [NOTFOUND=return] dns mdns4"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"x.com", "myhostname", hostLookupFilesDNS}, {"somehostname", "myhostname", hostLookupFilesDNS}, {"myhostname", "myhostname", hostLookupCgo}, }, }, // Debian Squeeze is just "dns,files", but lists all // the default criteria for dns, but then has a // non-standard but redundant notfound=return for the // files. { name: "debian_squeeze", c: &conf{ nss: nssStr("hosts: dns [success=return notfound=continue unavail=continue tryagain=continue] files [notfound=return]"), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"x.com", "myhostname", hostLookupDNSFiles}, {"somehostname", "myhostname", hostLookupDNSFiles}, }, }, { name: "resolv.conf-unknown", c: &conf{ nss: nssStr("foo: bar"), resolv: &dnsConfig{servers: defaultNS, ndots: 1, timeout: 5, attempts: 2, unknownOpt: true}, }, hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupCgo}}, }, // Android should always use cgo. { name: "android", c: &conf{ goos: "android", nss: nssStr(""), resolv: defaultResolvConf, }, hostTests: []nssHostTest{ {"x.com", "myhostname", hostLookupCgo}, }, }, // Issue 24393: make sure "Resolver.PreferGo = true" acts like netgo. { name: "resolver-prefergo", resolver: &Resolver{PreferGo: true}, c: &conf{ goos: "darwin", forceCgoLookupHost: true, // always true for darwin resolv: defaultResolvConf, nss: nssStr(""), netCgo: true, }, hostTests: []nssHostTest{ {"localhost", "myhostname", hostLookupFilesDNS}, }, }, } origGetHostname := getHostname defer func() { getHostname = origGetHostname }() for _, tt := range tests { for _, ht := range tt.hostTests { getHostname = func() (string, error) { return ht.localhost, nil } gotOrder := tt.c.hostLookupOrder(tt.resolver, ht.host) if gotOrder != ht.want { t.Errorf("%s: hostLookupOrder(%q) = %v; want %v", tt.name, ht.host, gotOrder, ht.want) } } } } func TestSystemConf(t *testing.T) { systemConf() }
Upload File
Create Folder