mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-10 17:48:25 +08:00
cb4b99ffcb
* Move PKA field from models node to host level * Move PKA field from api models node to host level * Adapt logic package to node->host PKA * Adapt migration-related code to node->host PKA * Adapt cli code to node->host PKA * Change host PKA default to 20s * On IfaceDelta, check for PKA on host * On handleHostRegister, set default PKA * Use a default PKA * Use int64 for api host pka * Reorder imports * Don't use host pka in iface delta * Fix ConvertAPIHostToNMHost * Add swagger doc for host PKA field * Fix swagger.yml * Set default PKA only for new hosts * Remove TODO comment * Remove redundant check * Have api-host pka be specified in seconds
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package logic
|
|
|
|
import (
|
|
"github.com/gravitl/netmaker/models"
|
|
)
|
|
|
|
// IfaceDelta - checks if the new node causes an interface change
|
|
func IfaceDelta(currentNode *models.Node, newNode *models.Node) bool {
|
|
// single comparison statements
|
|
if newNode.Address.String() != currentNode.Address.String() ||
|
|
newNode.Address6.String() != currentNode.Address6.String() ||
|
|
newNode.IsEgressGateway != currentNode.IsEgressGateway ||
|
|
newNode.IsIngressGateway != currentNode.IsIngressGateway ||
|
|
newNode.IsRelay != currentNode.IsRelay ||
|
|
newNode.DNSOn != currentNode.DNSOn ||
|
|
newNode.Connected != currentNode.Connected {
|
|
return true
|
|
}
|
|
// multi-comparison statements
|
|
if newNode.IsEgressGateway {
|
|
if len(currentNode.EgressGatewayRanges) != len(newNode.EgressGatewayRanges) {
|
|
return true
|
|
}
|
|
for _, address := range newNode.EgressGatewayRanges {
|
|
if !StringSliceContains(currentNode.EgressGatewayRanges, address) {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
if newNode.IsRelay {
|
|
if len(currentNode.RelayedNodes) != len(newNode.RelayedNodes) {
|
|
return true
|
|
}
|
|
for _, node := range newNode.RelayedNodes {
|
|
if !StringSliceContains(currentNode.RelayedNodes, node) {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// == Private Functions ==
|