Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
9b4d42f7
Commit
9b4d42f7
authored
Jan 12, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p/net/swarm: dial - filter out own addrs
parent
7aa4a83f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
p2p/net/swarm/swarm_dial.go
p2p/net/swarm/swarm_dial.go
+10
-4
No files found.
p2p/net/swarm/swarm_dial.go
View file @
9b4d42f7
...
...
@@ -39,16 +39,22 @@ func (s *Swarm) Dial(ctx context.Context, p peer.ID) (*Conn, error) {
log
.
Warning
(
"Dial not given PrivateKey, so WILL NOT SECURE conn."
)
}
// get our own addrs
localAddrs
:=
s
.
peers
.
Addresses
(
s
.
local
)
if
len
(
localAddrs
)
==
0
{
log
.
Debug
(
"Dialing out with no local addresses."
)
}
// get remote peer addrs
remoteAddrs
:=
s
.
peers
.
Addresses
(
p
)
// make sure we can use the addresses.
remoteAddrs
=
addrutil
.
FilterUsableAddrs
(
remoteAddrs
)
// drop out any addrs that would just dial ourselves. use ListenAddresses
// as that is a more authoritative view than localAddrs.
remoteAddrs
=
addrutil
.
Subtract
(
remoteAddrs
,
s
.
ListenAddresses
())
if
len
(
remoteAddrs
)
==
0
{
return
nil
,
errors
.
New
(
"peer has no addresses"
)
}
localAddrs
:=
s
.
peers
.
Addresses
(
s
.
local
)
if
len
(
localAddrs
)
==
0
{
log
.
Debug
(
"Dialing out with no local addresses."
)
}
// open connection to peer
d
:=
&
conn
.
Dialer
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment