mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 17:29:15 +08:00
fixed default expiration date setting and removed unused func
This commit is contained in:
@@ -239,7 +239,6 @@ func SetNodeDefaults(node *models.Node) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
node.NetworkRange6 = *cidr
|
node.NetworkRange6 = *cidr
|
||||||
}
|
}
|
||||||
node.ExpirationDateTime = time.Now().Add(models.TEN_YEARS_IN_SECONDS)
|
|
||||||
|
|
||||||
if node.DefaultACL == "" {
|
if node.DefaultACL == "" {
|
||||||
node.DefaultACL = parentNetwork.DefaultACL
|
node.DefaultACL = parentNetwork.DefaultACL
|
||||||
@@ -260,7 +259,6 @@ func SetNodeDefaults(node *models.Node) {
|
|||||||
node.SetLastCheckIn()
|
node.SetLastCheckIn()
|
||||||
node.SetDefaultConnected()
|
node.SetDefaultConnected()
|
||||||
node.SetExpirationDateTime()
|
node.SetExpirationDateTime()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRecordKey - get record key
|
// GetRecordKey - get record key
|
||||||
@@ -272,30 +270,6 @@ func GetRecordKey(id string, network string) (string, error) {
|
|||||||
return id + "###" + network, nil
|
return id + "###" + network, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNodeByMacAddress - gets a node by mac address
|
|
||||||
func GetNodeByMacAddress(network string, macaddress string) (models.Node, error) {
|
|
||||||
|
|
||||||
var node models.Node
|
|
||||||
|
|
||||||
key, err := GetRecordKey(macaddress, network)
|
|
||||||
if err != nil {
|
|
||||||
return node, err
|
|
||||||
}
|
|
||||||
|
|
||||||
record, err := database.FetchRecord(database.NODES_TABLE_NAME, key)
|
|
||||||
if err != nil {
|
|
||||||
return models.Node{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = json.Unmarshal([]byte(record), &node); err != nil {
|
|
||||||
return models.Node{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
SetNodeDefaults(&node)
|
|
||||||
|
|
||||||
return node, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetNodesByAddress - gets a node by mac address
|
// GetNodesByAddress - gets a node by mac address
|
||||||
func GetNodesByAddress(network string, addresses []string) ([]models.Node, error) {
|
func GetNodesByAddress(network string, addresses []string) ([]models.Node, error) {
|
||||||
var nodes []models.Node
|
var nodes []models.Node
|
||||||
|
@@ -15,7 +15,7 @@ const (
|
|||||||
// NODE_SERVER_NAME - the default server name
|
// NODE_SERVER_NAME - the default server name
|
||||||
NODE_SERVER_NAME = "netmaker"
|
NODE_SERVER_NAME = "netmaker"
|
||||||
// TEN_YEARS_IN_SECONDS - ten years in seconds
|
// TEN_YEARS_IN_SECONDS - ten years in seconds
|
||||||
TEN_YEARS_IN_SECONDS = 300000000
|
TEN_YEARS_IN_SECONDS = 315670000000000000
|
||||||
// MAX_NAME_LENGTH - max name length of node
|
// MAX_NAME_LENGTH - max name length of node
|
||||||
MAX_NAME_LENGTH = 62
|
MAX_NAME_LENGTH = 62
|
||||||
// == ACTIONS == (can only be set by server)
|
// == ACTIONS == (can only be set by server)
|
||||||
|
Reference in New Issue
Block a user