diff options
-rw-r--r-- | main.go | 27 | ||||
-rw-r--r-- | tinc.go | 11 |
2 files changed, 18 insertions, 20 deletions
@@ -17,9 +17,8 @@ import ( func fmtAddress(node, port string) string { if isIPv6(node) { return fmt.Sprintf("[%s]:%s", node, port) - } else { - return fmt.Sprintf("%s:%s", node, port) } + return fmt.Sprintf("%s:%s", node, port) } func isIPv6(node string) bool { @@ -72,29 +71,29 @@ func doAddress(host, network, address string) Point { var _wg sync.WaitGroup _wg.Add(2) - var result_name string - var result_version string - var result_error error + var resultName string + var resultVersion string + var resultError error go func() { defer _wg.Done() - result_name, result_version, result_error = hello(addr) + resultName, resultVersion, resultError = hello(addr) }() - var result_ping float64 + var resultPing float64 go func() { defer _wg.Done() - result_ping = Ping(addr.IP) + resultPing = Ping(addr.IP) }() _wg.Wait() result := map[string]interface{}{} - if result_error == nil { - result["name"] = result_name - result["version"] = result_version + if resultError == nil { + result["name"] = resultName + result["version"] = resultVersion } else { - result["error"] = result_error + result["error"] = resultError } - if result_ping >= 0 { - result["ping"] = result_ping + if resultPing >= 0 { + result["ping"] = resultPing } return NewPoint("public", tags, result) @@ -15,11 +15,10 @@ type Error struct { } func (e Error) Error() string { - if e.Line > 0 { - return fmt.Sprintf("%v:%v: %v", e.File, e.Line, e.Err) - } else { + if e.Line < 1 { return fmt.Sprintf("%v: %v", e.File, e.Err) } + return fmt.Sprintf("%v:%v: %v", e.File, e.Line, e.Err) } func parseConfigLine(line string) (key, val string) { @@ -43,7 +42,7 @@ func parseConfigLine(line string) (key, val string) { // a map of settings. Since Tinc setting names are case-insensitive, // the keys in the map are all lower-case. func ReadConfigFile(fname string) (map[string][]string, error) { - config_tree := make(map[string][]string) + cfg := make(map[string][]string) fp, err := os.Open(fname) if err != nil { @@ -83,14 +82,14 @@ func ReadConfigFile(fname string) (map[string][]string, error) { return nil, Error{File: fname, Line: lineno, Err: err} } variable = strings.ToLower(variable) - config_tree[variable] = append(config_tree[variable], value) + cfg[variable] = append(cfg[variable], value) } err = buffer.Err() if err != nil { return nil, Error{File: fname, Err: err} } - return config_tree, nil + return cfg, nil } // GetAddresses inspects a tinc host-confing settings object and |