Browse Source
lnutil.split_host_port: fix for IPv6 connection string
hard-fail-on-bad-server-string
SomberNight
5 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
3 changed files with
4 additions and
2 deletions
-
electrum/gui/qt/main_window.py
-
electrum/lnutil.py
-
electrum/tests/test_lnutil.py
|
|
@ -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")) |
|
|
|