Skip to content

Commit

Permalink
use a global variable for default relays
Browse files Browse the repository at this point in the history
and rename DefaultRelays option to DefaultStaticRelays.
  • Loading branch information
vyzo committed Oct 8, 2019
1 parent 2358488 commit 9cd56c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
13 changes: 5 additions & 8 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
circuit "github.com/libp2p/go-libp2p-circuit"
config "github.com/libp2p/go-libp2p/config"
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
autorelay "github.com/libp2p/go-libp2p/p2p/host/relay"

filter "github.com/libp2p/go-maddr-filter"
ma "github.com/multiformats/go-multiaddr"
Expand Down Expand Up @@ -251,19 +252,15 @@ func EnableAutoRelay() Option {
// discover relays
func StaticRelays(relays []peer.AddrInfo) Option {
return func(cfg *Config) error {
cfg.StaticRelays = relays
cfg.StaticRelays = append(cfg.StaticRelays, relays...)
return nil
}
}

// DefaultRelays configures the static relays to use the known PL-operated relays
func DefaultRelays() Option {
// DefaultStaticRelays configures the static relays to use the known PL-operated relays
func DefaultStaticRelays() Option {
return func(cfg *Config) error {
for _, addr := range []string{
"/ip4/147.75.80.110/tcp/4001/p2p/QmbFgm5zan8P6eWWmeyfncR5feYEMPbht5b1FW1C37aQ7y",
"/ip4/147.75.195.153/tcp/4001/p2p/QmW9m57aiBDHAkKj9nmFSEn7ZqrcF1fZS4bipsTCHburei",
"/ip4/147.75.70.221/tcp/4001/p2p/Qme8g49gm3q4Acp7xWBKg3nAa9fxZ1YmyDJdyGgoG6LsXh",
} {
for _, addr := range autorelay.DefaultRelays {
a, err := ma.NewMultiaddr(addr)
if err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions p2p/host/relay/autorelay.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ var (
BootDelay = 20 * time.Second
)

// These are the known PL-operated relays
var DefaultRelays = []string{
"/ip4/147.75.80.110/tcp/4001/p2p/QmbFgm5zan8P6eWWmeyfncR5feYEMPbht5b1FW1C37aQ7y",
"/ip4/147.75.195.153/tcp/4001/p2p/QmW9m57aiBDHAkKj9nmFSEn7ZqrcF1fZS4bipsTCHburei",
"/ip4/147.75.70.221/tcp/4001/p2p/Qme8g49gm3q4Acp7xWBKg3nAa9fxZ1YmyDJdyGgoG6LsXh",
}

// AutoRelay is a Host that uses relays for connectivity when a NAT is detected.
type AutoRelay struct {
host *basic.BasicHost
Expand Down

0 comments on commit 9cd56c0

Please sign in to comment.