summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tun/netstack/tun.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/tun/netstack/tun.go b/tun/netstack/tun.go
index 21f7cd5..8f5ae6e 100644
--- a/tun/netstack/tun.go
+++ b/tun/netstack/tun.go
@@ -595,6 +595,7 @@ func (tnet *Net) tryOneName(ctx context.Context, name string, qtype dnsmessage.T
func (tnet *Net) LookupContextHost(ctx context.Context, host string) ([]string, error) {
if host == "" || (!tnet.hasV6 && !tnet.hasV4) {
+ fmt.Printf("LookupContextHost: ", host, tnet.hasV4, tnet.hasV6)
return nil, &net.DNSError{Err: errNoSuchHost.Error(), Name: host, IsNotFound: true}
}
zlen := len(host)
@@ -608,6 +609,7 @@ func (tnet *Net) LookupContextHost(ctx context.Context, host string) ([]string,
}
if !isDomainName(host) {
+ fmt.Printf("LookupContextHost !isDomainName", host[:zlen])
return nil, &net.DNSError{Err: errNoSuchHost.Error(), Name: host, IsNotFound: true}
}
type result struct {
@@ -736,6 +738,7 @@ func partialDeadline(now, deadline time.Time, addrsRemaining int) (time.Time, er
}
func (tnet *Net) DialContext(ctx context.Context, network, address string) (net.Conn, error) {
+ fmt.Printf("tun_net.DialContext: ", network, address)
if ctx == nil {
panic("nil context")
}
@@ -748,23 +751,28 @@ func (tnet *Net) DialContext(ctx context.Context, network, address string) (net.
acceptV6 = network[3] == '6'
}
if !acceptV4 && !acceptV6 {
+ fmt.Printf("DialContext no v4 v6")
return nil, &net.OpError{Op: "dial", Err: net.UnknownNetworkError(network)}
}
if network[:3] == "udp" {
useUDP = true
} else if network[:3] != "tcp" {
+ fmt.Printf("DialContext no udp no tcp")
return nil, &net.OpError{Op: "dial", Err: net.UnknownNetworkError(network)}
}
host, sport, err := net.SplitHostPort(address)
if err != nil {
+ fmt.Printf("DialContext failed split", address, err)
return nil, &net.OpError{Op: "dial", Err: err}
}
port, err := strconv.Atoi(sport)
if err != nil || port < 0 || port > 65535 {
+ fmt.Printf("DialContext failed port", sport, err)
return nil, &net.OpError{Op: "dial", Err: errNumericPort}
}
allAddr, err := tnet.LookupContextHost(ctx, host)
if err != nil {
+ fmt.Printf("LookupContextHost failed: ", host, err)
return nil, &net.OpError{Op: "dial", Err: err}
}
var addrs []net.IP
@@ -776,6 +784,7 @@ func (tnet *Net) DialContext(ctx context.Context, network, address string) (net.
}
}
if len(addrs) == 0 && len(allAddr) != 0 {
+ fmt.Printf("DialContext failed no addr")
return nil, &net.OpError{Op: "dial", Err: errNoSuitableAddress}
}
@@ -789,6 +798,7 @@ func (tnet *Net) DialContext(ctx context.Context, network, address string) (net.
} else if err == context.DeadlineExceeded {
err = errTimeout
}
+ fmt.Printf("DialContext failed context done", err)
return nil, &net.OpError{Op: "dial", Err: err}
default:
}
@@ -816,6 +826,7 @@ func (tnet *Net) DialContext(ctx context.Context, network, address string) (net.
c, err = tnet.DialContextTCP(dialCtx, &net.TCPAddr{IP: addr, Port: port})
}
if err == nil {
+ fmt.Printf("DialContext success")
return c, nil
}
if firstErr == nil {
@@ -825,6 +836,7 @@ func (tnet *Net) DialContext(ctx context.Context, network, address string) (net.
if firstErr == nil {
firstErr = &net.OpError{Op: "dial", Err: errMissingAddress}
}
+ fmt.Printf("DialContext failed", firstErr)
return nil, firstErr
}