mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-12 16:14:37 +08:00
Merge pull request #1996 from gravitl/GRA-1091_better_default_exp
fixed default expiration date setting and removed unused func
This commit is contained in:
commit
c23f1cbf7a
2 changed files with 1 additions and 27 deletions
|
@ -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)
|
||||||
|
|
Loading…
Add table
Reference in a new issue