mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 17:14:22 +01:00
connectd: fix binding to same port on IPv4 and IPv6.
1. If the IPv6 address was public, that changed the wireaddr and thus the ipv4 bind would not be to a wildcard and would fail. 2. Binding two fds to the same port on both wildcard IPv4 and IPv6 succeeds; we only fail when we try to listen, so allow error at this point. For some reason this triggered on my digital ocean machine. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
17f7f50814
commit
d8a6028214
@@ -3,7 +3,7 @@ from fixtures import * # noqa: F401,F403
|
||||
from flaky import flaky
|
||||
from lightning import RpcError
|
||||
from utils import DEVELOPER, sync_blockheight, only_one, wait_for
|
||||
|
||||
from ephemeral_port_reserve import reserve
|
||||
|
||||
import json
|
||||
import os
|
||||
@@ -772,3 +772,24 @@ def test_reserve_enforcement(node_factory, executor):
|
||||
'Peer permanent failure in CHANNELD_NORMAL: lightning_channeld: sent '
|
||||
'ERROR Bad peer_add_htlc: CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED'
|
||||
)
|
||||
|
||||
|
||||
def test_ipv4_and_ipv6(node_factory):
|
||||
"""Test we can bind to both IPv4 and IPv6 addresses (if supported)"""
|
||||
port = reserve()
|
||||
l1 = node_factory.get_node(options={'addr': ':{}'.format(port)})
|
||||
bind = l1.rpc.getinfo()['binding']
|
||||
|
||||
if len(bind) == 2:
|
||||
assert bind[0]['type'] == 'ipv6'
|
||||
assert bind[0]['address'] == '::'
|
||||
assert int(bind[0]['port']) == port
|
||||
assert bind[1]['type'] == 'ipv4'
|
||||
assert bind[1]['address'] == '0.0.0.0'
|
||||
assert int(bind[1]['port']) == port
|
||||
else:
|
||||
# Assume we're IPv4 only...
|
||||
assert len(bind) == 1
|
||||
assert bind[0]['type'] == 'ipv4'
|
||||
assert bind[0]['address'] == '0.0.0.0'
|
||||
assert int(bind[0]['port']) == port
|
||||
|
||||
Reference in New Issue
Block a user