Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
3d3ffc45
Commit
3d3ffc45
authored
Jan 13, 2015
by
Juan Batiz-Benet
Browse files
p2p/net/swrm: InterfaceListenAddrs now method
parent
5de997f0
Changes
3
Hide whitespace changes
Inline
Side-by-side
net/swarm/swarm_addr.go
View file @
3d3ffc45
...
...
@@ -22,14 +22,14 @@ func (s *Swarm) ListenAddresses() []ma.Multiaddr {
// InterfaceListenAddresses returns a list of addresses at which this swarm
// listens. It expands "any interface" addresses (/ip4/0.0.0.0, /ip6/::) to
// use the known local interfaces.
func
InterfaceListenAddresses
(
s
*
Swarm
)
([]
ma
.
Multiaddr
,
error
)
{
func
(
s
*
Swarm
)
InterfaceListenAddresses
()
([]
ma
.
Multiaddr
,
error
)
{
return
addrutil
.
ResolveUnspecifiedAddresses
(
s
.
ListenAddresses
(),
nil
)
}
// checkNATWarning checks if our observed addresses differ. if so,
// informs the user that certain things might not work yet
func
checkNATWarning
(
s
*
Swarm
,
observed
ma
.
Multiaddr
,
expected
ma
.
Multiaddr
)
{
listen
,
err
:=
InterfaceListenAddresses
(
s
)
listen
,
err
:=
s
.
InterfaceListenAddresses
()
if
err
!=
nil
{
log
.
Errorf
(
"Error retrieving swarm.InterfaceListenAddresses: %s"
,
err
)
return
...
...
net/swarm/swarm_dial.go
View file @
3d3ffc45
...
...
@@ -252,7 +252,7 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) {
remoteAddrs
=
addrutil
.
FilterUsableAddrs
(
remoteAddrs
)
// drop out any addrs that would just dial ourselves. use ListenAddresses
// as that is a more authoritative view than localAddrs.
ila
,
_
:=
InterfaceListenAddresses
(
s
)
ila
,
_
:=
s
.
InterfaceListenAddresses
()
remoteAddrs
=
addrutil
.
Subtract
(
remoteAddrs
,
ila
)
remoteAddrs
=
addrutil
.
Subtract
(
remoteAddrs
,
s
.
peers
.
Addresses
(
s
.
local
))
log
.
Debugf
(
"%s swarm dialing %s -- remote:%s local:%s"
,
s
.
local
,
p
,
remoteAddrs
,
s
.
ListenAddresses
())
...
...
net/swarm/swarm_net.go
View file @
3d3ffc45
...
...
@@ -111,7 +111,7 @@ func (n *Network) ListenAddresses() []ma.Multiaddr {
// listens. It expands "any interface" addresses (/ip4/0.0.0.0, /ip6/::) to
// use the known local interfaces.
func
(
n
*
Network
)
InterfaceListenAddresses
()
([]
ma
.
Multiaddr
,
error
)
{
return
InterfaceListenAddresses
(
n
.
Swarm
()
)
return
n
.
Swarm
()
.
InterfaceListenAddresses
()
}
// Connectedness returns a state signaling connection capabilities
...
...
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