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
5a1c09c4
Commit
5a1c09c4
authored
6 years ago
by
vyzo
Browse files
Options
Download
Email Patches
Plain Diff
use advertised addrs for autonat dial back, not all addrs
parent
5d8988f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
p2p/host/relay/autorelay.go
+6
-3
p2p/host/relay/autorelay.go
with
6 additions
and
3 deletions
+6
-3
p2p/host/relay/autorelay.go
View file @
5a1c09c4
...
...
@@ -55,15 +55,14 @@ type AutoRelayHost struct {
}
func
NewAutoRelayHost
(
ctx
context
.
Context
,
bhost
*
basic
.
BasicHost
,
discover
discovery
.
Discoverer
)
*
AutoRelayHost
{
autonat
:=
autonat
.
NewAutoNAT
(
ctx
,
bhost
,
bhost
.
AllAddrs
)
h
:=
&
AutoRelayHost
{
BasicHost
:
bhost
,
discover
:
discover
,
autonat
:
autonat
,
addrsF
:
bhost
.
AddrsFactory
,
relays
:
make
(
map
[
peer
.
ID
]
pstore
.
PeerInfo
),
disconnect
:
make
(
chan
struct
{},
1
),
}
h
.
autonat
=
autonat
.
NewAutoNAT
(
ctx
,
bhost
,
h
.
baseAddrs
)
bhost
.
AddrsFactory
=
h
.
hostAddrs
bhost
.
Network
()
.
Notify
(
h
)
go
h
.
background
(
ctx
)
...
...
@@ -80,6 +79,10 @@ func (h *AutoRelayHost) hostAddrs(addrs []ma.Multiaddr) []ma.Multiaddr {
}
}
func
(
h
*
AutoRelayHost
)
baseAddrs
()
[]
ma
.
Multiaddr
{
return
filterUnspecificRelay
(
h
.
addrsF
(
h
.
AllAddrs
()))
}
func
(
h
*
AutoRelayHost
)
background
(
ctx
context
.
Context
)
{
select
{
case
<-
time
.
After
(
autonat
.
AutoNATBootDelay
+
BootDelay
)
:
...
...
@@ -197,7 +200,7 @@ func (h *AutoRelayHost) doUpdateAddrs() {
h
.
mx
.
Lock
()
defer
h
.
mx
.
Unlock
()
addrs
:=
filterUnspecificRelay
(
h
.
addrsF
(
h
.
All
Addrs
()
))
addrs
:=
h
.
base
Addrs
()
raddrs
:=
make
([]
ma
.
Multiaddr
,
0
,
len
(
addrs
)
+
len
(
h
.
relays
))
// remove our public addresses from the list and replace them by just the public IP
...
...
This diff is collapsed.
Click to expand it.
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