From d18e052e01ec6fa6df4165a409058fb81adf0555 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 17 Apr 2018 14:07:44 -0400 Subject: don't make tinc.go worry about net.Dial conventions --- tinc.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'tinc.go') diff --git a/tinc.go b/tinc.go index 76857cb..1bfefc6 100644 --- a/tinc.go +++ b/tinc.go @@ -3,7 +3,6 @@ package main import ( "bufio" "fmt" - "net" "os" "strings" ) @@ -92,8 +91,8 @@ func readConfigFile(fname string) (map[string][]string, error) { // Returns a list of public addresses for a host-config in Go // "net.Dial" format. -func getAddresses(cfg map[string][]string) []string { - var result []string +func getAddresses(cfg map[string][]string) []struct{ Node, Port string } { + var result []struct{ Node, Port string } for _, node := range cfg["address"] { var port string @@ -109,17 +108,8 @@ func getAddresses(cfg map[string][]string) []string { node = node[:space] } - if isIPv6(node) { - result = append(result, fmt.Sprintf("[%s]:%s", node, port)) - } else { - result = append(result, fmt.Sprintf("%s:%s", node, port)) - } + result = append(result, struct{ Node, Port string }{node, port}) } return result } - -func isIPv6(node string) bool { - ip := net.ParseIP(node) - return ip != nil && ip.To4() == nil -} -- cgit v1.2.3