##
##  patts-qt - Qt GUI client for PATTS
##  Copyright (C) 2015 Delwink, LLC
##
##  This program is free software: you can redistribute it and/or modify
##  it under the terms of the GNU Affero General Public License as published by
##  the Free Software Foundation, version 3 only.
##
##  This program is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##  GNU Affero General Public License for more details.
##
##  You should have received a copy of the GNU Affero General Public License
##  along with this program.  If not, see <http://www.gnu.org/licenses/>.
##

def split_host(host):
    srv = host
    port = '0'

    if ':' in host:
        split = host.split(':')
        srv = split[0]
        port = split[1]

    return (srv, port)

@@ -57,16 +57,21 @@
 (C) 2015
+-2016
  Delwink
@@ -765,19 +765,482 @@
 if '
-:' in host:
+%5B' in host and '%5D' in host:%0A        if host%5B0%5D != '%5B' or host.count('%5B') %3E 1 or host.count('%5D') %3E 1:%0A            raise ValueError('Invalid brackets in IPv6 address')%0A%0A        bracket_index = host.index('%5D')%0A        srv = host%5B1:bracket_index%5D%0A%0A        post = host%5Bbracket_index + 1:%5D%0A        if post and post%5B0%5D == ':':%0A            port = str(int(post%5B1:%5D))%0A    elif ':' in host:%0A        if host.count(':') %3E 1:%0A            raise ValueError('Invalid colon in IPv4 address')%0A
 %0A   

Improve hostname parser for IPv6