|
@@ -9,7 +9,8 @@ import (
|
|
"net"
|
|
"net"
|
|
"os"
|
|
"os"
|
|
"strconv"
|
|
"strconv"
|
|
-
|
|
|
|
|
|
+ "strings"
|
|
|
|
+ "encoding/base64"
|
|
"github.com/gravitl/netmaker/database"
|
|
"github.com/gravitl/netmaker/database"
|
|
"github.com/gravitl/netmaker/functions"
|
|
"github.com/gravitl/netmaker/functions"
|
|
"github.com/gravitl/netmaker/models"
|
|
"github.com/gravitl/netmaker/models"
|
|
@@ -201,7 +202,19 @@ func GetPeers(networkName string) (map[string]string, error) {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
for _, peer := range device.Peers {
|
|
for _, peer := range device.Peers {
|
|
- peers[peer.PublicKey.String()] = peer.Endpoint.String()
|
|
|
|
|
|
+ if isBase64(peer.PublicKey.String()) && checkEndpoint(peer.Endpoint.String()) {
|
|
|
|
+ peers[peer.PublicKey.String()] = peer.Endpoint.String()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return peers, nil
|
|
return peers, nil
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+func checkEndpoint(endpoint string) bool {
|
|
|
|
+ endpointarr := strings.Split(endpoint,":")
|
|
|
|
+ return net.ParseIP(endpointarr[0]) == nil
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func isBase64(s string) bool {
|
|
|
|
+ _, err := base64.StdEncoding.DecodeString(s)
|
|
|
|
+ return err == nil
|
|
|
|
+}
|