Merge pull request #117 from l-n-s/ipv6_support

Add IPv6 address support
This commit is contained in:
Thomas Jager 2019-04-04 16:52:36 +02:00 committed by GitHub
commit 0b3c53b324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

9
irc.go
View File

@ -428,17 +428,16 @@ func (irc *Connection) Connect(server string) error {
if len(irc.Server) == 0 {
return errors.New("empty 'server'")
}
if strings.Count(irc.Server, ":") != 1 {
return errors.New("wrong number of ':' in address")
}
if strings.Index(irc.Server, ":") == 0 {
return errors.New("hostname is missing")
}
if strings.Index(irc.Server, ":") == len(irc.Server)-1 {
return errors.New("port missing")
}
// check for valid range
ports := strings.Split(irc.Server, ":")[1]
_, ports, err := net.SplitHostPort(irc.Server)
if err != nil {
return errors.New("wrong address string")
}
port, err := strconv.Atoi(ports)
if err != nil {
return errors.New("extracting port failed")