diff options
Diffstat (limited to 'vendor/golang.org/x/net/internal/netreflect')
5 files changed, 0 insertions, 186 deletions
diff --git a/vendor/golang.org/x/net/internal/netreflect/socket.go b/vendor/golang.org/x/net/internal/netreflect/socket.go deleted file mode 100644 index 1495b65f5..000000000 --- a/vendor/golang.org/x/net/internal/netreflect/socket.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 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 !go1.9 - -// Package netreflect implements run-time reflection for the -// facilities of net package. -// -// This package works only for Go 1.8 or below. -package netreflect - -import ( - "errors" - "net" -) - -var ( - errInvalidType = errors.New("invalid type") - errOpNoSupport = errors.New("operation not supported") -) - -// SocketOf returns the socket descriptor of c. -func SocketOf(c net.Conn) (uintptr, error) { - switch c.(type) { - case *net.TCPConn, *net.UDPConn, *net.IPConn, *net.UnixConn: - return socketOf(c) - default: - return 0, errInvalidType - } -} - -// PacketSocketOf returns the socket descriptor of c. -func PacketSocketOf(c net.PacketConn) (uintptr, error) { - switch c.(type) { - case *net.UDPConn, *net.IPConn, *net.UnixConn: - return socketOf(c.(net.Conn)) - default: - return 0, errInvalidType - } -} diff --git a/vendor/golang.org/x/net/internal/netreflect/socket_19.go b/vendor/golang.org/x/net/internal/netreflect/socket_19.go deleted file mode 100644 index 74df52e1a..000000000 --- a/vendor/golang.org/x/net/internal/netreflect/socket_19.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 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 go1.9 - -package netreflect - -import ( - "errors" - "net" -) - -var ( - errInvalidType = errors.New("invalid type") - errOpNoSupport = errors.New("operation not supported") -) - -// SocketOf returns the socket descriptor of c. -func SocketOf(c net.Conn) (uintptr, error) { - switch c.(type) { - case *net.TCPConn, *net.UDPConn, *net.IPConn, *net.UnixConn: - return 0, errOpNoSupport - default: - return 0, errInvalidType - } -} - -// PacketSocketOf returns the socket descriptor of c. -func PacketSocketOf(c net.PacketConn) (uintptr, error) { - switch c.(type) { - case *net.UDPConn, *net.IPConn, *net.UnixConn: - return 0, errOpNoSupport - default: - return 0, errInvalidType - } -} diff --git a/vendor/golang.org/x/net/internal/netreflect/socket_posix.go b/vendor/golang.org/x/net/internal/netreflect/socket_posix.go deleted file mode 100644 index 410c0924d..000000000 --- a/vendor/golang.org/x/net/internal/netreflect/socket_posix.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 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 !go1.9 -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package netreflect - -import ( - "net" - "reflect" - "runtime" -) - -func socketOf(c net.Conn) (uintptr, error) { - v := reflect.ValueOf(c) - switch e := v.Elem(); e.Kind() { - case reflect.Struct: - fd := e.FieldByName("conn").FieldByName("fd") - switch e := fd.Elem(); e.Kind() { - case reflect.Struct: - sysfd := e.FieldByName("sysfd") - if runtime.GOOS == "windows" { - return uintptr(sysfd.Uint()), nil - } - return uintptr(sysfd.Int()), nil - } - } - return 0, errInvalidType -} diff --git a/vendor/golang.org/x/net/internal/netreflect/socket_stub.go b/vendor/golang.org/x/net/internal/netreflect/socket_stub.go deleted file mode 100644 index 17b20c478..000000000 --- a/vendor/golang.org/x/net/internal/netreflect/socket_stub.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 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 !go1.9 -// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!windows - -package netreflect - -import "net" - -func socketOf(c net.Conn) (uintptr, error) { return 0, errOpNoSupport } diff --git a/vendor/golang.org/x/net/internal/netreflect/socket_test.go b/vendor/golang.org/x/net/internal/netreflect/socket_test.go deleted file mode 100644 index b3aad0d92..000000000 --- a/vendor/golang.org/x/net/internal/netreflect/socket_test.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2016 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 !go1.9 -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package netreflect_test - -import ( - "net" - "os" - "testing" - - "golang.org/x/net/internal/netreflect" - "golang.org/x/net/internal/nettest" -) - -func TestSocketOf(t *testing.T) { - for _, network := range []string{"tcp", "unix", "unixpacket"} { - if !nettest.TestableNetwork(network) { - continue - } - ln, err := nettest.NewLocalListener(network) - if err != nil { - t.Error(err) - continue - } - defer func() { - path := ln.Addr().String() - ln.Close() - if network == "unix" || network == "unixpacket" { - os.Remove(path) - } - }() - c, err := net.Dial(ln.Addr().Network(), ln.Addr().String()) - if err != nil { - t.Error(err) - continue - } - defer c.Close() - if _, err := netreflect.SocketOf(c); err != nil { - t.Error(err) - continue - } - } -} - -func TestPacketSocketOf(t *testing.T) { - for _, network := range []string{"udp", "unixgram"} { - if !nettest.TestableNetwork(network) { - continue - } - c, err := nettest.NewLocalPacketListener(network) - if err != nil { - t.Error(err) - continue - } - defer c.Close() - if _, err := netreflect.PacketSocketOf(c); err != nil { - t.Error(err) - continue - } - } -} |