diff options
author | Oleg Kovalov <iamolegkovalov@gmail.com> | 2018-07-30 17:30:09 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-07-30 17:30:09 +0800 |
commit | d42ce0f2c1b52e26cce475e411d97165fb975577 (patch) | |
tree | 03043c37becf49145b23f4824f563e3443335698 /p2p | |
parent | 273c7a9dc4e8961e96e51bd8274436ff983a21ef (diff) | |
download | go-tangerine-d42ce0f2c1b52e26cce475e411d97165fb975577.tar go-tangerine-d42ce0f2c1b52e26cce475e411d97165fb975577.tar.gz go-tangerine-d42ce0f2c1b52e26cce475e411d97165fb975577.tar.bz2 go-tangerine-d42ce0f2c1b52e26cce475e411d97165fb975577.tar.lz go-tangerine-d42ce0f2c1b52e26cce475e411d97165fb975577.tar.xz go-tangerine-d42ce0f2c1b52e26cce475e411d97165fb975577.tar.zst go-tangerine-d42ce0f2c1b52e26cce475e411d97165fb975577.zip |
all: simplify switches (#17267)
* all: simplify switches
* silly mistake
Diffstat (limited to 'p2p')
-rw-r--r-- | p2p/nat/natpmp.go | 3 | ||||
-rw-r--r-- | p2p/nat/natupnp.go | 7 | ||||
-rw-r--r-- | p2p/simulations/adapters/inproc.go | 3 |
3 files changed, 4 insertions, 9 deletions
diff --git a/p2p/nat/natpmp.go b/p2p/nat/natpmp.go index 577a424fb..8ba971472 100644 --- a/p2p/nat/natpmp.go +++ b/p2p/nat/natpmp.go @@ -115,8 +115,7 @@ func potentialGateways() (gws []net.IP) { return gws } for _, addr := range ifaddrs { - switch x := addr.(type) { - case *net.IPNet: + if x, ok := addr.(*net.IPNet); ok { if lan10.Contains(x.IP) || lan176.Contains(x.IP) || lan192.Contains(x.IP) { ip := x.IP.Mask(x.Mask).To4() if ip != nil { diff --git a/p2p/nat/natupnp.go b/p2p/nat/natupnp.go index 69099ac04..029143b7b 100644 --- a/p2p/nat/natupnp.go +++ b/p2p/nat/natupnp.go @@ -81,11 +81,8 @@ func (n *upnp) internalAddress() (net.IP, error) { return nil, err } for _, addr := range addrs { - switch x := addr.(type) { - case *net.IPNet: - if x.Contains(devaddr.IP) { - return x.IP, nil - } + if x, ok := addr.(*net.IPNet); ok && x.Contains(devaddr.IP) { + return x.IP, nil } } } diff --git a/p2p/simulations/adapters/inproc.go b/p2p/simulations/adapters/inproc.go index c1b032a0d..b0fdf49b9 100644 --- a/p2p/simulations/adapters/inproc.go +++ b/p2p/simulations/adapters/inproc.go @@ -353,8 +353,7 @@ func (sn *SimNode) NodeInfo() *p2p.NodeInfo { } func setSocketBuffer(conn net.Conn, socketReadBuffer int, socketWriteBuffer int) error { - switch v := conn.(type) { - case *net.UnixConn: + if v, ok := conn.(*net.UnixConn); ok { err := v.SetReadBuffer(socketReadBuffer) if err != nil { return err |