mirror of
https://github.com/golang/go.git
synced 2025-11-07 12:11:00 +00:00
net: separate NaCl dependent placeholders from BSD's
To clarify the dependency of NaCl platform. LGTM=adg R=golang-codereviews, adg CC=golang-codereviews https://golang.org/cl/143830044
This commit is contained in:
parent
8c2484ec11
commit
484cc67151
23 changed files with 186 additions and 25 deletions
|
|
@ -465,6 +465,11 @@ func TestDialer(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDialDualStackLocalhost(t *testing.T) {
|
func TestDialDualStackLocalhost(t *testing.T) {
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "nacl":
|
||||||
|
t.Skipf("skipping test on %q", runtime.GOOS)
|
||||||
|
}
|
||||||
|
|
||||||
if ips, err := LookupIP("localhost"); err != nil {
|
if ips, err := LookupIP("localhost"); err != nil {
|
||||||
t.Fatalf("LookupIP failed: %v", err)
|
t.Fatalf("LookupIP failed: %v", err)
|
||||||
} else if len(ips) < 2 || !supportsIPv4 || !supportsIPv6 {
|
} else if len(ips) < 2 || !supportsIPv4 || !supportsIPv6 {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
// DNS client: see RFC 1035.
|
// DNS client: see RFC 1035.
|
||||||
// Has to be linked into package net for Dial.
|
// Has to be linked into package net for Dial.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
// Read system DNS config from /etc/resolv.conf
|
// Read system DNS config from /etc/resolv.conf
|
||||||
|
|
||||||
|
|
|
||||||
38
src/net/file_stub.go
Normal file
38
src/net/file_stub.go
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
// Copyright 2011 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.
|
||||||
|
|
||||||
|
// +build nacl
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FileConn returns a copy of the network connection corresponding to
|
||||||
|
// the open file f. It is the caller's responsibility to close f when
|
||||||
|
// finished. Closing c does not affect f, and closing f does not
|
||||||
|
// affect c.
|
||||||
|
func FileConn(f *os.File) (c Conn, err error) {
|
||||||
|
return nil, syscall.ENOPROTOOPT
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// FileListener returns a copy of the network listener corresponding
|
||||||
|
// to the open file f. It is the caller's responsibility to close l
|
||||||
|
// when finished. Closing l does not affect f, and closing f does not
|
||||||
|
// affect l.
|
||||||
|
func FileListener(f *os.File) (l Listener, err error) {
|
||||||
|
return nil, syscall.ENOPROTOOPT
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// FilePacketConn returns a copy of the packet network connection
|
||||||
|
// corresponding to the open file f. It is the caller's
|
||||||
|
// responsibility to close f when finished. Closing c does not affect
|
||||||
|
// f, and closing f does not affect c.
|
||||||
|
func FilePacketConn(f *os.File) (c PacketConn, err error) {
|
||||||
|
return nil, syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
@ -89,7 +89,7 @@ var fileListenerTests = []struct {
|
||||||
|
|
||||||
func TestFileListener(t *testing.T) {
|
func TestFileListener(t *testing.T) {
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "windows":
|
case "nacl", "windows":
|
||||||
t.Skipf("skipping test on %q", runtime.GOOS)
|
t.Skipf("skipping test on %q", runtime.GOOS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,11 @@ func skipRawSocketTest(t *testing.T) (skip bool, skipmsg string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestResolveIPAddr(t *testing.T) {
|
func TestResolveIPAddr(t *testing.T) {
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "nacl":
|
||||||
|
t.Skipf("skipping test on %q", runtime.GOOS)
|
||||||
|
}
|
||||||
|
|
||||||
for _, tt := range resolveIPAddrTests {
|
for _, tt := range resolveIPAddrTests {
|
||||||
addr, err := ResolveIPAddr(tt.net, tt.litAddrOrName)
|
addr, err := ResolveIPAddr(tt.net, tt.litAddrOrName)
|
||||||
if err != tt.err {
|
if err != tt.err {
|
||||||
|
|
|
||||||
49
src/net/lookup_stub.go
Normal file
49
src/net/lookup_stub.go
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
// Copyright 2011 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.
|
||||||
|
|
||||||
|
// +build nacl
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func lookupProtocol(name string) (proto int, err error) {
|
||||||
|
return 0, syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
||||||
|
func lookupHost(host string) (addrs []string, err error) {
|
||||||
|
return nil, syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
||||||
|
func lookupIP(host string) (ips []IP, err error) {
|
||||||
|
return nil, syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
||||||
|
func lookupPort(network, service string) (port int, err error) {
|
||||||
|
return 0, syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
||||||
|
func lookupCNAME(name string) (cname string, err error) {
|
||||||
|
return "", syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
||||||
|
func lookupSRV(service, proto, name string) (cname string, srvs []*SRV, err error) {
|
||||||
|
return "", nil, syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
||||||
|
func lookupMX(name string) (mxs []*MX, err error) {
|
||||||
|
return nil, syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
||||||
|
func lookupNS(name string) (nss []*NS, err error) {
|
||||||
|
return nil, syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
||||||
|
func lookupTXT(name string) (txts []string, err error) {
|
||||||
|
return nil, syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
||||||
|
func lookupAddr(addr string) (ptrs []string, err error) {
|
||||||
|
return nil, syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
package net
|
package net
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -43,6 +44,11 @@ var porttests = []portTest{
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLookupPort(t *testing.T) {
|
func TestLookupPort(t *testing.T) {
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "nacl":
|
||||||
|
t.Skipf("skipping test on %q", runtime.GOOS)
|
||||||
|
}
|
||||||
|
|
||||||
for i := 0; i < len(porttests); i++ {
|
for i := 0; i < len(porttests); i++ {
|
||||||
tt := porttests[i]
|
tt := porttests[i]
|
||||||
if port, err := LookupPort(tt.netw, tt.name); port != tt.port || (err == nil) != tt.ok {
|
if port, err := LookupPort(tt.netw, tt.name); port != tt.port || (err == nil) != tt.ok {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
// Read system port mappings from /etc/services
|
// Read system port mappings from /etc/services
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd nacl netbsd openbsd
|
// +build darwin dragonfly freebsd netbsd openbsd
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build nacl solaris
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
import "syscall"
|
import "syscall"
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd nacl netbsd openbsd
|
// +build darwin dragonfly freebsd netbsd openbsd
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
|
|
|
||||||
37
src/net/sockopt_stub.go
Normal file
37
src/net/sockopt_stub.go
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright 2011 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.
|
||||||
|
|
||||||
|
// +build nacl
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func setDefaultSockopts(s, family, sotype int, ipv6only bool) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func setDefaultListenerSockopts(s int) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func setDefaultMulticastSockopts(s int) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func setReadBuffer(fd *netFD, bytes int) error {
|
||||||
|
return syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
||||||
|
func setWriteBuffer(fd *netFD, bytes int) error {
|
||||||
|
return syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
||||||
|
func setKeepAlive(fd *netFD, keepalive bool) error {
|
||||||
|
return syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
||||||
|
func setLinger(fd *netFD, sec int) error {
|
||||||
|
return syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd nacl netbsd openbsd
|
// +build darwin dragonfly freebsd netbsd openbsd
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd windows
|
// +build darwin dragonfly freebsd linux netbsd openbsd windows
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build solaris
|
// +build nacl solaris
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
|
|
@ -10,30 +10,30 @@ import "syscall"
|
||||||
|
|
||||||
func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
|
func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
|
||||||
// See golang.org/issue/7399.
|
// See golang.org/issue/7399.
|
||||||
return syscall.EINVAL
|
return syscall.ENOPROTOOPT
|
||||||
}
|
}
|
||||||
|
|
||||||
func setIPv4MulticastLoopback(fd *netFD, v bool) error {
|
func setIPv4MulticastLoopback(fd *netFD, v bool) error {
|
||||||
// See golang.org/issue/7399.
|
// See golang.org/issue/7399.
|
||||||
return syscall.EINVAL
|
return syscall.ENOPROTOOPT
|
||||||
}
|
}
|
||||||
|
|
||||||
func joinIPv4Group(fd *netFD, ifi *Interface, ip IP) error {
|
func joinIPv4Group(fd *netFD, ifi *Interface, ip IP) error {
|
||||||
// See golang.org/issue/7399.
|
// See golang.org/issue/7399.
|
||||||
return syscall.EINVAL
|
return syscall.ENOPROTOOPT
|
||||||
}
|
}
|
||||||
|
|
||||||
func setIPv6MulticastInterface(fd *netFD, ifi *Interface) error {
|
func setIPv6MulticastInterface(fd *netFD, ifi *Interface) error {
|
||||||
// See golang.org/issue/7399.
|
// See golang.org/issue/7399.
|
||||||
return syscall.EINVAL
|
return syscall.ENOPROTOOPT
|
||||||
}
|
}
|
||||||
|
|
||||||
func setIPv6MulticastLoopback(fd *netFD, v bool) error {
|
func setIPv6MulticastLoopback(fd *netFD, v bool) error {
|
||||||
// See golang.org/issue/7399.
|
// See golang.org/issue/7399.
|
||||||
return syscall.EINVAL
|
return syscall.ENOPROTOOPT
|
||||||
}
|
}
|
||||||
|
|
||||||
func joinIPv6Group(fd *netFD, ifi *Interface, ip IP) error {
|
func joinIPv6Group(fd *netFD, ifi *Interface, ip IP) error {
|
||||||
// See golang.org/issue/7399.
|
// See golang.org/issue/7399.
|
||||||
return syscall.EINVAL
|
return syscall.ENOPROTOOPT
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
src/net/tcpsockopt_openbsd.go
Normal file
16
src/net/tcpsockopt_openbsd.go
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
// Copyright 2009 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.
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setKeepAlivePeriod(fd *netFD, d time.Duration) error {
|
||||||
|
// OpenBSD has no user-settable per-socket TCP keepalive
|
||||||
|
// options.
|
||||||
|
return syscall.ENOPROTOOPT
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build nacl openbsd
|
// +build nacl
|
||||||
|
|
||||||
package net
|
package net
|
||||||
|
|
||||||
|
|
@ -11,8 +11,10 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setKeepAlivePeriod(fd *netFD, d time.Duration) error {
|
func setNoDelay(fd *netFD, noDelay bool) error {
|
||||||
// NaCl and OpenBSD have no user-settable per-socket TCP
|
return syscall.ENOPROTOOPT
|
||||||
// keepalive options.
|
}
|
||||||
|
|
||||||
|
func setKeepAlivePeriod(fd *netFD, d time.Duration) error {
|
||||||
return syscall.ENOPROTOOPT
|
return syscall.ENOPROTOOPT
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -383,8 +383,9 @@ func TestExtraFilesFDShuffle(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExtraFiles(t *testing.T) {
|
func TestExtraFiles(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
switch runtime.GOOS {
|
||||||
t.Skip("no operating system support; skipping")
|
case "nacl", "windows":
|
||||||
|
t.Skipf("skipping test on %q", runtime.GOOS)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that file descriptors have not already been leaked into
|
// Ensure that file descriptors have not already been leaked into
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue