Merge pull request #103 from oddstr13/pr-ipv6-input-brackets-1

Enclose address input in square brackets if it is an IPv6 address
This commit is contained in:
mcarlton00 2019-10-04 16:39:54 -04:00 committed by GitHub
commit 417d89f2ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -4,6 +4,7 @@
import logging import logging
import os import os
import ipaddress
import xbmcgui import xbmcgui
import xbmcaddon import xbmcaddon
@ -114,6 +115,12 @@ class ServerManual(xbmcgui.WindowXMLDialog):
return control return control
def _connect_to_server(self, server, port): def _connect_to_server(self, server, port):
try:
addr = ipaddress.ip_address(server.decode('utf-8') if not isinstance(server, type(u'')) else server)
if addr.version == 6:
server = u"[%s]" % (addr.compressed)
except ValueError:
pass
server_address = "%s:%s" % (server, port) if port else server server_address = "%s:%s" % (server, port) if port else server
self._message("%s %s..." % (_(30610), server_address)) self._message("%s %s..." % (_(30610), server_address))

View file

@ -456,6 +456,7 @@ class ConnectionManager(object):
else: else:
return servers return servers
# TODO: Make IPv6 compatable
def _convert_endpoint_address_to_manual_address(self, info): def _convert_endpoint_address_to_manual_address(self, info):
if info.get('Address') and info.get('EndpointAddress'): if info.get('Address') and info.get('EndpointAddress'):