New implementation of ConnectionMaker just periodically scanning who we need to connect to

This commit is contained in:
Bryan Boreham committed 2014-09-10 12:08:49 +01:00
1 parent 42ce45dd55
commit 84aeaf340a
4 files changed
+98 -61

No files matched your search

+15
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"net"
"strconv"
)
func checkFatal(e error) {
@@ -106,6 +107,20 @@ func StripPortFromAddr(address string) string {
return address
}
// given an address like '1.2.3.4:567', return the host and port number,
// given an address like '1.2.3.4', return the host and weave's standard port number
func ExtractHostPort(address string) (host string, port int, err error) {
if host, port, err := net.SplitHostPort(address); err == nil {
if portnum, err := strconv.Atoi(port); err == nil {
return host, portnum, nil
} else {
return host, 0, err
}
} else {
return host, Port, nil
}
}
// given an address like '1.2.3.4:567', return the address if it has a port,
// otherwise return the address with weave's standard port number
func NormalisePeerAddr(peerAddr string) string {