gossipd: handle wildcard addresses correctly.

If we're given a wildcard address, we can't announce it like that: we need
to try to turn it into a real address (using guess_address).  Then we
use that address.  As a side-effect of this cleanup, we only announce
*any* '--addr' if it's routable.

This fix means that our tests have to force '--announce-addr' because
otherwise localhost isn't routable.

This means that gossipd really controls the addresses now, and breaks
them into two arrays: what we bind to, and what we announce.  That is
now what we return to the master for json_getinfo(), which prints them
as 'bindings' and 'addresses' respectively.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2018-05-07 13:59:22 +09:30
committed by Christian Decker
parent 52917ff6c9
commit af065417e1
13 changed files with 181 additions and 149 deletions

View File

@@ -261,7 +261,9 @@ class LightningD(TailableProc):
opts = {
'bitcoin-datadir': bitcoin_dir,
'lightning-dir': lightning_dir,
'addr': '127.0.0.1:{}'.format(port),
'bind-addr': '127.0.0.1:{}'.format(port),
# lightningd won't announce non-routable addresses by default.
'announce-addr': '127.0.0.1:{}'.format(port),
'allow-deprecated-apis': 'false',
'override-fee-rates': '15000/7500/1000',
'network': 'regtest',
@@ -370,7 +372,7 @@ class LightningNode(object):
def start(self):
self.daemon.start()
# This shortcut is sufficient for our simple tests.
self.port = self.rpc.getinfo()['address'][0]['port']
self.port = self.rpc.getinfo()['binding'][0]['port']
def stop(self, timeout=10):
""" Attempt to do a clean shutdown, but kill if it hangs