summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2021-01-21 16:52:25 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2021-02-02 23:56:45 +0100
commitfdeae087969bc44c6f3c71dbdd28dee95ea382a2 (patch)
treedf6d11a9791cc92c2e37fae19a5e0865e2072f91
parent48460703229d73fbacdd0d6b0d0f01a54f7ce751 (diff)
WIP debug tun
-rw-r--r--tun/netstack/tun.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/tun/netstack/tun.go b/tun/netstack/tun.go
index 6bdea23..50da0d7 100644
--- a/tun/netstack/tun.go
+++ b/tun/netstack/tun.go
@@ -721,6 +721,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.Warningf("tun_net.DialContext: ", network, address)
if ctx == nil {
panic("nil context")
}
@@ -733,23 +734,28 @@ func (tnet *Net) DialContext(ctx context.Context, network, address string) (net.
acceptV6 = network[3] == '6'
}
if !acceptV4 && !acceptV6 {
+ fmt.Warningf("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.Warningf("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.Warningf("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.Warningf("DialContext failed port", sport, err)
return nil, &net.OpError{Op: "dial", Err: errNumericPort}
}
allAddr, err := tnet.LookupContextHost(ctx, host)
if err != nil {
+ fmt.Warningf("LookupContextHost failed: ", host, err)
return nil, &net.OpError{Op: "dial", Err: err}
}
var addrs []net.IP
@@ -761,6 +767,7 @@ func (tnet *Net) DialContext(ctx context.Context, network, address string) (net.
}
}
if len(addrs) == 0 && len(allAddr) != 0 {
+ fmt.Warningf("DialContext failed no addr")
return nil, &net.OpError{Op: "dial", Err: errNoSuitableAddress}
}
@@ -774,6 +781,7 @@ func (tnet *Net) DialContext(ctx context.Context, network, address string) (net.
} else if err == context.DeadlineExceeded {
err = errTimeout
}
+ fmt.Warningf("DialContext failed context done", err)
return nil, &net.OpError{Op: "dial", Err: err}
default:
}
@@ -801,6 +809,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.Warningf("DialContext success")
return c, nil
}
if firstErr == nil {
@@ -810,6 +819,7 @@ func (tnet *Net) DialContext(ctx context.Context, network, address string) (net.
if firstErr == nil {
firstErr = &net.OpError{Op: "dial", Err: errMissingAddress}
}
+ fmt.Warningf("DialContext failed", firstErr)
return nil, firstErr
}