server: Sort ips based on their last octet value. (#2198)

This commit is contained in:
Harshavardhana
2016-07-13 06:34:59 -07:00
committed by Anand Babu (AB) Periasamy
parent 8c84df5e74
commit 0bd6b67ca5
3 changed files with 112 additions and 4 deletions

View File

@@ -21,7 +21,6 @@ import (
"net"
"net/http"
"os"
"sort"
"strconv"
"strings"
"time"
@@ -140,13 +139,14 @@ func finalizeEndpoints(tls bool, apiServer *http.Server) (endPoints []string) {
scheme = "https"
}
ips := getIPsFromHosts(hosts)
// Construct proper endpoints.
for _, host := range hosts {
endPoints = append(endPoints, fmt.Sprintf("%s://%s:%s", scheme, host, port))
for _, ip := range ips {
endPoints = append(endPoints, fmt.Sprintf("%s://%s:%s", scheme, ip.String(), port))
}
// Success.
sort.Strings(endPoints)
return endPoints
}