From 81e75c71457e6e122d9b298e077bfdd80c6d7c17 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sun, 28 Sep 2014 19:23:34 -0400 Subject: [PATCH] ipv6 support for DialArgs --- index.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.go b/index.go index a55fa66..903d65d 100644 --- a/index.go +++ b/index.go @@ -93,7 +93,14 @@ func (m *Multiaddr) DialArgs() (string, string, error) { parts := strings.Split(str, "/")[1:] network := parts[2] - host := strings.Join([]string{parts[1], parts[3]}, ":") + + var host string + switch parts[0] { + case "ip4": + host = strings.Join([]string{parts[1], parts[3]}, ":") + case "ip6": + host = fmt.Sprintf("[%s]:%s", parts[1], parts[3]) + } return network, host, nil }