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
89aef893
Commit
89aef893
authored
Oct 20, 2018
by
vyzo
Browse files
don't adveretise unspecific relay addrs in RelayHost
parent
dcb8fd28
Changes
1
Hide whitespace changes
Inline
Side-by-side
p2p/host/relay/relay.go
View file @
89aef893
...
...
@@ -3,21 +3,34 @@ package relay
import
(
"context"
basic
"github.com/libp2p/go-libp2p/p2p/host/basic"
discovery
"github.com/libp2p/go-libp2p-discovery"
host
"github.com/libp2p/go-libp2p-host"
ma
"github.com/multiformats/go-multiaddr"
)
// RelayHost is a Host that provides Relay services.
type
RelayHost
struct
{
host
.
Host
*
basic
.
Basic
Host
advertise
discovery
.
Advertiser
addrsF
basic
.
AddrsFactory
}
// New constructs a new RelayHost
func
NewRelayHost
(
ctx
context
.
Context
,
host
host
.
Host
,
advertise
discovery
.
Advertiser
)
*
RelayHost
{
h
:=
&
RelayHost
{
Host
:
host
,
advertise
:
advertise
}
func
NewRelayHost
(
ctx
context
.
Context
,
bhost
*
basic
.
BasicHost
,
advertise
discovery
.
Advertiser
)
*
RelayHost
{
h
:=
&
RelayHost
{
BasicHost
:
bhost
,
addrsF
:
bhost
.
AddrsFactory
,
advertise
:
advertise
,
}
bhost
.
AddrsFactory
=
h
.
hostAddrs
discovery
.
Advertise
(
ctx
,
advertise
,
"/libp2p/relay"
)
return
h
}
func
(
h
*
RelayHost
)
hostAddrs
(
addrs
[]
ma
.
Multiaddr
)
[]
ma
.
Multiaddr
{
return
filterUnspecificRelay
(
h
.
addrsF
(
addrs
))
}
var
_
host
.
Host
=
(
*
RelayHost
)(
nil
)
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