mirror of
https://github.com/certbot/certbot.git
synced 2026-04-24 15:54:10 -04:00
correctly handle IPv6 and IPv4 addresses fix #1143
This commit correctly splits IPv6 addresses into the host and port parts. This will work for normal IPv4 and IPv6 addresses appended by a port number as well es for IPv6 addressess without a port, which should be the normal IPv6 usage.
This commit is contained in:
parent
9c7e99cbf5
commit
d48c560df1
1 changed files with 11 additions and 2 deletions
|
|
@ -110,8 +110,17 @@ class Addr(object):
|
|||
@classmethod
|
||||
def fromstring(cls, str_addr):
|
||||
"""Initialize Addr from string."""
|
||||
tup = str_addr.partition(':')
|
||||
return cls((tup[0], tup[2]))
|
||||
if str_addr.startswith('['):
|
||||
# ipv6 addresses starts with [
|
||||
endIndex = str_addr.rfind(']')
|
||||
host = str_addr[:endIndex + 1]
|
||||
port = ''
|
||||
if len(str_addr) > endIndex + 3 and str_addr[endIndex + 2] == ':':
|
||||
port = str_addr[endIndex + 3:]
|
||||
return cls((host, port))
|
||||
else:
|
||||
tup = str_addr.partition(':')
|
||||
return cls((tup[0], tup[2]))
|
||||
|
||||
def __str__(self):
|
||||
if self.tup[1]:
|
||||
|
|
|
|||
Loading…
Reference in a new issue