mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 09:21:39 +00:00
lnutil.split_host_port: fix for IPv6 connection string
This commit is contained in:
parent
0723355a0f
commit
16626a3386
3 changed files with 4 additions and 2 deletions
|
@ -1685,7 +1685,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
|
||||
def on_failure(exc_info):
|
||||
type_, e, traceback = exc_info
|
||||
self.show_error(_('Could not open channel: {}').format(e))
|
||||
self.show_error(_('Could not open channel: {}').format(repr(e)))
|
||||
WaitingDialog(self, _('Opening channel...'), task, on_success, on_failure)
|
||||
|
||||
def query_choice(self, msg, choices):
|
||||
|
|
|
@ -716,7 +716,7 @@ def make_closing_tx(local_funding_pubkey: bytes, remote_funding_pubkey: bytes,
|
|||
|
||||
|
||||
def split_host_port(host_port: str) -> Tuple[str, str]: # port returned as string
|
||||
ipv6 = re.compile(r'\[(?P<host>[:0-9]+)\](?P<port>:\d+)?$')
|
||||
ipv6 = re.compile(r'\[(?P<host>[:0-9a-f]+)\](?P<port>:\d+)?$')
|
||||
other = re.compile(r'(?P<host>[^:]+)(?P<port>:\d+)?$')
|
||||
m = ipv6.match(host_port)
|
||||
if not m:
|
||||
|
|
|
@ -693,6 +693,8 @@ class TestLNUtil(ElectrumTestCase):
|
|||
def test_split_host_port(self):
|
||||
self.assertEqual(split_host_port("[::1]:8000"), ("::1", "8000"))
|
||||
self.assertEqual(split_host_port("[::1]"), ("::1", "9735"))
|
||||
self.assertEqual(split_host_port("[2601:602:8800:9a:dc59:a4ff:fede:24a9]:9735"), ("2601:602:8800:9a:dc59:a4ff:fede:24a9", "9735"))
|
||||
self.assertEqual(split_host_port("[2601:602:8800::a4ff:fede:24a9]:9735"), ("2601:602:8800::a4ff:fede:24a9", "9735"))
|
||||
self.assertEqual(split_host_port("kæn.guru:8000"), ("kæn.guru", "8000"))
|
||||
self.assertEqual(split_host_port("kæn.guru"), ("kæn.guru", "9735"))
|
||||
self.assertEqual(split_host_port("127.0.0.1:8000"), ("127.0.0.1", "8000"))
|
||||
|
|
Loading…
Add table
Reference in a new issue