1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
10 "net/internal/socktest"
15 func enableSocketConnect() {
16 sw
.Set(socktest
.FilterConnect
, nil)
19 func disableSocketConnect(network
string) {
20 ss
:= strings
.Split(network
, ":")
21 sw
.Set(socktest
.FilterConnect
, func(so
*socktest
.Status
) (socktest
.AfterFilter
, error
) {
24 if so
.Cookie
.Family() == syscall
.AF_INET
&& so
.Cookie
.Type() == syscall
.SOCK_STREAM
{
25 return nil, syscall
.EHOSTUNREACH
28 if so
.Cookie
.Family() == syscall
.AF_INET
&& so
.Cookie
.Type() == syscall
.SOCK_DGRAM
{
29 return nil, syscall
.EHOSTUNREACH
32 if so
.Cookie
.Family() == syscall
.AF_INET
&& so
.Cookie
.Type() == syscall
.SOCK_RAW
{
33 return nil, syscall
.EHOSTUNREACH
36 if so
.Cookie
.Family() == syscall
.AF_INET6
&& so
.Cookie
.Type() == syscall
.SOCK_STREAM
{
37 return nil, syscall
.EHOSTUNREACH
40 if so
.Cookie
.Family() == syscall
.AF_INET6
&& so
.Cookie
.Type() == syscall
.SOCK_DGRAM
{
41 return nil, syscall
.EHOSTUNREACH
44 if so
.Cookie
.Family() == syscall
.AF_INET6
&& so
.Cookie
.Type() == syscall
.SOCK_RAW
{
45 return nil, syscall
.EHOSTUNREACH