mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-12 16:14:37 +08:00
isStatic now only represents whether the Endpoint var is static
This commit is contained in:
parent
4b72a4e289
commit
3f038ab951
5 changed files with 60 additions and 59 deletions
|
@ -680,7 +680,7 @@ func networkNodesUpdateAction(networkName string, action string) error {
|
|||
fmt.Println("error in node address assignment!")
|
||||
return err
|
||||
}
|
||||
if action == models.NODE_UPDATE_KEY && node.IsStatic == "yes" {
|
||||
if action == models.NODE_UPDATE_KEY {
|
||||
continue
|
||||
}
|
||||
if node.Network == networkName {
|
||||
|
|
|
@ -80,7 +80,9 @@ func GetNodePeers(network *models.Network, nodeid string, excludeRelayed bool, i
|
|||
}
|
||||
}
|
||||
// if udp hole punching is on, but port is still set to default (e.g. 51821), use the LocalListenPort
|
||||
if node.UDPHolePunch == "yes" && node.IsStatic != "yes" && peer.ListenPort == node.ListenPort {
|
||||
// removing IsStatic check. IsStatic will now ONLY refer to endpoint.
|
||||
//if node.UDPHolePunch == "yes" && node.IsStatic != "yes" && peer.ListenPort == node.ListenPort {
|
||||
if node.UDPHolePunch == "yes" && peer.ListenPort == node.ListenPort {
|
||||
peer.ListenPort = node.LocalListenPort
|
||||
}
|
||||
if node.IsRelay == "yes" { // TODO, check if addressrange6 needs to be appended
|
||||
|
|
|
@ -406,8 +406,7 @@ func isDeleteError(err error) bool {
|
|||
}
|
||||
|
||||
func checkNodeActions(node *models.Node) string {
|
||||
if (node.Action == models.NODE_UPDATE_KEY) &&
|
||||
node.IsStatic != "yes" {
|
||||
if node.Action == models.NODE_UPDATE_KEY {
|
||||
err := setWGKeyConfig(node)
|
||||
if err != nil {
|
||||
logger.Log(1, "unable to process reset keys request:", err.Error())
|
||||
|
|
|
@ -69,6 +69,7 @@ type Node struct {
|
|||
EgressGatewayRanges []string `json:"egressgatewayranges" bson:"egressgatewayranges" yaml:"egressgatewayranges"`
|
||||
RelayAddrs []string `json:"relayaddrs" bson:"relayaddrs" yaml:"relayaddrs"`
|
||||
IngressGatewayRange string `json:"ingressgatewayrange" bson:"ingressgatewayrange" yaml:"ingressgatewayrange"`
|
||||
// IsStatic - refers to if the Endpoint is set manually or dynamically
|
||||
IsStatic string `json:"isstatic" bson:"isstatic" yaml:"isstatic" validate:"checkyesorno"`
|
||||
UDPHolePunch string `json:"udpholepunch" bson:"udpholepunch" yaml:"udpholepunch" validate:"checkyesorno"`
|
||||
DNSOn string `json:"dnson" bson:"dnson" yaml:"dnson" validate:"checkyesorno"`
|
||||
|
@ -255,10 +256,10 @@ func (node *Node) SetDefaultName() {
|
|||
func (newNode *Node) Fill(currentNode *Node) {
|
||||
newNode.ID = currentNode.ID
|
||||
|
||||
if newNode.Address == "" && newNode.IsStatic != "yes" {
|
||||
if newNode.Address == "" {
|
||||
newNode.Address = currentNode.Address
|
||||
}
|
||||
if newNode.Address6 == "" && newNode.IsStatic != "yes" {
|
||||
if newNode.Address6 == "" {
|
||||
newNode.Address6 = currentNode.Address6
|
||||
}
|
||||
if newNode.LocalAddress == "" {
|
||||
|
@ -267,16 +268,16 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|||
if newNode.Name == "" {
|
||||
newNode.Name = currentNode.Name
|
||||
}
|
||||
if newNode.ListenPort == 0 && newNode.IsStatic != "yes" {
|
||||
if newNode.ListenPort == 0 {
|
||||
newNode.ListenPort = currentNode.ListenPort
|
||||
}
|
||||
if newNode.LocalListenPort == 0 && newNode.IsStatic != "yes" {
|
||||
if newNode.LocalListenPort == 0 {
|
||||
newNode.LocalListenPort = currentNode.LocalListenPort
|
||||
}
|
||||
if newNode.PublicKey == "" && newNode.IsStatic != "yes" {
|
||||
if newNode.PublicKey == "" {
|
||||
newNode.PublicKey = currentNode.PublicKey
|
||||
}
|
||||
if newNode.Endpoint == "" && newNode.IsStatic != "yes" {
|
||||
if newNode.Endpoint == "" {
|
||||
newNode.Endpoint = currentNode.Endpoint
|
||||
}
|
||||
if newNode.PostUp == "" {
|
||||
|
|
|
@ -40,8 +40,7 @@ func ApplyWithoutWGQuick(node *models.Node, ifacename string, confPath string) e
|
|||
nodeport := int(node.ListenPort)
|
||||
if node.UDPHolePunch == "yes" &&
|
||||
node.IsServer == "no" &&
|
||||
node.IsIngressGateway != "yes" &&
|
||||
node.IsStatic != "yes" {
|
||||
node.IsIngressGateway != "yes" {
|
||||
conf = wgtypes.Config{
|
||||
PrivateKey: &key,
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue