Skip to content

Commit ce49044

Browse files
vyzoStebalien
authored andcommitted
use a global variable for default relays
and rename DefaultRelays option to DefaultStaticRelays.
1 parent 4b2c585 commit ce49044

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

options.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
config "github.com/libp2p/go-libp2p/config"
1111
bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
12+
autorelay "github.com/libp2p/go-libp2p/p2p/host/relay"
1213

1314
circuit "github.com/libp2p/go-libp2p-circuit"
1415
crypto "github.com/libp2p/go-libp2p-crypto"
@@ -249,19 +250,15 @@ func EnableAutoRelay() Option {
249250
// discover relays
250251
func StaticRelays(relays []pstore.PeerInfo) Option {
251252
return func(cfg *Config) error {
252-
cfg.StaticRelays = relays
253+
cfg.StaticRelays = append(cfg.StaticRelays, relays...)
253254
return nil
254255
}
255256
}
256257

257-
// DefaultRelays configures the static relays to use the known PL-operated relays
258-
func DefaultRelays() Option {
258+
// DefaultStaticRelays configures the static relays to use the known PL-operated relays
259+
func DefaultStaticRelays() Option {
259260
return func(cfg *Config) error {
260-
for _, addr := range []string{
261-
"/ip4/147.75.80.110/tcp/4001/p2p/QmbFgm5zan8P6eWWmeyfncR5feYEMPbht5b1FW1C37aQ7y",
262-
"/ip4/147.75.195.153/tcp/4001/p2p/QmW9m57aiBDHAkKj9nmFSEn7ZqrcF1fZS4bipsTCHburei",
263-
"/ip4/147.75.70.221/tcp/4001/p2p/Qme8g49gm3q4Acp7xWBKg3nAa9fxZ1YmyDJdyGgoG6LsXh",
264-
} {
261+
for _, addr := range autorelay.DefaultRelays {
265262
a, err := ma.NewMultiaddr(addr)
266263
if err != nil {
267264
return err

p2p/host/relay/autorelay.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ var (
3030
BootDelay = 20 * time.Second
3131
)
3232

33+
// These are the known PL-operated relays
34+
var DefaultRelays = []string{
35+
"/ip4/147.75.80.110/tcp/4001/p2p/QmbFgm5zan8P6eWWmeyfncR5feYEMPbht5b1FW1C37aQ7y",
36+
"/ip4/147.75.195.153/tcp/4001/p2p/QmW9m57aiBDHAkKj9nmFSEn7ZqrcF1fZS4bipsTCHburei",
37+
"/ip4/147.75.70.221/tcp/4001/p2p/Qme8g49gm3q4Acp7xWBKg3nAa9fxZ1YmyDJdyGgoG6LsXh",
38+
}
39+
3340
// AutoRelay is a Host that uses relays for connectivity when a NAT is detected.
3441
type AutoRelay struct {
3542
host *basic.BasicHost

0 commit comments

Comments
 (0)