mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 16:57:51 +08:00
began refactoring of client
This commit is contained in:
@@ -21,7 +21,7 @@ import (
|
||||
)
|
||||
|
||||
func CheckEndpoint(endpoint string) bool {
|
||||
endpointarr := strings.Split(endpoint,":")
|
||||
endpointarr := strings.Split(endpoint, ":")
|
||||
return net.ParseIP(endpointarr[0]) == nil
|
||||
}
|
||||
|
||||
@@ -200,9 +200,6 @@ func GetRecordKey(id string, network string) (string, error) {
|
||||
return id + "###" + network, nil
|
||||
}
|
||||
|
||||
//TODO: This is very inefficient (N-squared). Need to find a better way.
|
||||
//Takes a list of nodes in a network and iterates through
|
||||
//for each node, it gets a unique address. That requires checking against all other nodes once more
|
||||
func UpdateNetworkNodeAddresses(networkName string) error {
|
||||
|
||||
collections, err := database.FetchRecords(database.NODES_TABLE_NAME)
|
||||
@@ -235,6 +232,33 @@ func UpdateNetworkNodeAddresses(networkName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NetworkNodesUpdateKey(networkName string) error {
|
||||
|
||||
collections, err := database.FetchRecords(database.NODES_TABLE_NAME)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, value := range collections {
|
||||
|
||||
var node models.Node
|
||||
err := json.Unmarshal([]byte(value), &node)
|
||||
if err != nil {
|
||||
fmt.Println("error in node address assignment!")
|
||||
return err
|
||||
}
|
||||
|
||||
node.Action = models.NODE_UPDATE_KEY
|
||||
data, err := json.Marshal(&node)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
database.Insert(node.MacAddress, string(data), database.NODES_TABLE_NAME)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateNetworkLocalAddresses(networkName string) error {
|
||||
|
||||
collection, err := database.FetchRecords(database.NODES_TABLE_NAME)
|
||||
|
Reference in New Issue
Block a user