p2p: external address

* new config option for external address to advertise
* if blank, defaults to best guess from listener
* if laddr ip address is also blank, default to IPv4
This commit is contained in:
Ethan Buchman
2018-07-01 22:21:29 -04:00
parent 60f233a4bc
commit 1c018d3fd2
7 changed files with 49 additions and 16 deletions

View File

@ -109,7 +109,10 @@ func TestPEXReactorRunning(t *testing.T) {
addOtherNodeAddrToAddrBook(2, 1)
for i, sw := range switches {
sw.AddListener(p2p.NewDefaultListener("tcp", sw.NodeInfo().ListenAddr, false, logger.With("pex", i)))
cfg := &config.P2PConfig{
ListenAddress: fmt.Sprintf("tcp://%v", sw.NodeInfo().ListenAddr),
}
sw.AddListener(p2p.NewDefaultListener(cfg, logger.With("pex", i)))
err := sw.Start() // start switch and reactors
require.Nil(t, err)
@ -230,9 +233,9 @@ func TestPEXReactorUsesSeedsIfNeeded(t *testing.T) {
)
seed.AddListener(
p2p.NewDefaultListener(
"tcp",
seed.NodeInfo().ListenAddr,
false,
&config.P2PConfig{
ListenAddress: fmt.Sprintf("tcp://%v", seed.NodeInfo().ListenAddr),
},
log.TestingLogger(),
),
)