@cryptotaxi247 / kubo / commits / fc6bab7b7

net/conn: moved zero addr error

Juan Batiz-Benet committed Nov 20, 2014 at 01:27 UTC fc6bab7b7390f8262e865b6cca79ad34212725ef
2 files changed +5 -11
net/conn/dial.go
+5
@@ -2,6 +2,7 @@ package conn
2
3 import (
4 "fmt"
5 + "strings"
6
7 context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
8
@@ -23,6 +24,10 @@ func (d *Dialer) Dial(ctx context.Context, network string, remote peer.Peer) (Co
24 return nil, fmt.Errorf("No remote address for network %s", network)
25 }
26
27 + if strings.HasPrefix(raddr.String(), "/ip4/0.0.0.0") {
28 + return nil, fmt.Errorf("Attempted to connect to zero address: %s", raddr)
29 + }
30 +
31 remote.SetType(peer.Remote)
32 remote, err := d.Peerstore.Add(remote)
33 if err != nil {
net/swarm/swarm.go
-11
@@ -5,7 +5,6 @@ package swarm
5 import (
6 "errors"
7 "fmt"
8 - "strings"
8 "sync"
9
10 conn "github.com/jbenet/go-ipfs/net/conn"
@@ -133,16 +132,6 @@ func (s *Swarm) Dial(peer peer.Peer) (conn.Conn, error) {
132 Peerstore: s.peers,
133 }
134
136 - // If we are attempting to connect to the zero addr, fail out early
137 - raddr := peer.NetAddress("tcp")
138 - if raddr == nil {
139 - return nil, fmt.Errorf("No remote address for network tcp")
140 - }
141 -
142 - if strings.HasPrefix(raddr.String(), "/ip4/0.0.0.0") {
143 - return nil, fmt.Errorf("Attempted to connect to loopback address: %s", raddr)
144 - }
145 -
135 c, err = d.Dial(s.Context(), "tcp", peer)
136 if err != nil {
137 return nil, err