mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-20 15:26:04 +08:00
static configs
This commit is contained in:
parent
f8df4b571b
commit
aae89cbaca
|
@ -59,7 +59,7 @@ func GetPeersList(networkName string) ([]models.Node, error) {
|
|||
}
|
||||
}
|
||||
}
|
||||
functions.PrintUserLog(models.NODE_SERVER_NAME, "sending peer "+peer.MacAddress+" "+peer.Endpoint, 2)
|
||||
functions.PrintUserLog(models.NODE_SERVER_NAME, "adding to peer list: "+peer.MacAddress+" "+peer.Endpoint, 3)
|
||||
peers = append(peers, peer)
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,6 @@ func CreateNode(node models.Node, networkName string) (models.Node, error) {
|
|||
node.Password = string(hash)
|
||||
|
||||
node.Network = networkName
|
||||
|
||||
if node.Name == models.NODE_SERVER_NAME {
|
||||
if node.CheckIsServer() {
|
||||
node.IsServer = "yes"
|
||||
|
|
|
@ -252,7 +252,7 @@ func NetworkNodesUpdateAction(networkName string, action string) error {
|
|||
fmt.Println("error in node address assignment!")
|
||||
return err
|
||||
}
|
||||
if action == models.NODE_UPDATE_KEY && node.StaticPubKey == "yes" {
|
||||
if action == models.NODE_UPDATE_KEY && node.IsStatic == "yes" {
|
||||
continue
|
||||
}
|
||||
if node.Network == networkName {
|
||||
|
|
|
@ -57,8 +57,7 @@ type Node struct {
|
|||
IsIngressGateway string `json:"isingressgateway" bson:"isingressgateway" yaml:"isingressgateway"`
|
||||
EgressGatewayRanges []string `json:"egressgatewayranges" bson:"egressgatewayranges" yaml:"egressgatewayranges"`
|
||||
IngressGatewayRange string `json:"ingressgatewayrange" bson:"ingressgatewayrange" yaml:"ingressgatewayrange"`
|
||||
StaticPubKey string `json:"staticpubkey" bson:"staticpubkey" yaml:"staticpubkey" validate:"checkyesorno"`
|
||||
StaticIP string `json:"staticip" bson:"staticip" yaml:"staticip" validate:"checkyesorno"`
|
||||
IsStatic string `json:"isstatic" bson:"isstatic" yaml:"isstatic" validate:"checkyesorno"`
|
||||
UDPHolePunch string `json:"udpholepunch" bson:"udpholepunch" yaml:"udpholepunch" validate:"checkyesorno"`
|
||||
PullChanges string `json:"pullchanges" bson:"pullchanges" yaml:"pullchanges" validate:"checkyesorno"`
|
||||
DNSOn string `json:"dnson" bson:"dnson" yaml:"dnson" validate:"checkyesorno"`
|
||||
|
@ -204,11 +203,8 @@ func (node *Node) SetDefaults() {
|
|||
postup := parentNetwork.DefaultPostUp
|
||||
node.PostUp = postup
|
||||
}
|
||||
if node.StaticIP == "" {
|
||||
node.StaticIP = "no"
|
||||
}
|
||||
if node.StaticPubKey == "" {
|
||||
node.StaticPubKey = "no"
|
||||
if node.IsStatic == "" {
|
||||
node.IsStatic = "no"
|
||||
}
|
||||
if node.UDPHolePunch == "" {
|
||||
node.UDPHolePunch = parentNetwork.DefaultUDPHolePunch
|
||||
|
@ -237,10 +233,10 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|||
if newNode.ID == "" {
|
||||
newNode.ID = currentNode.ID
|
||||
}
|
||||
if newNode.Address == "" {
|
||||
if newNode.Address == "" && newNode.IsStatic != "yes"{
|
||||
newNode.Address = currentNode.Address
|
||||
}
|
||||
if newNode.Address6 == "" {
|
||||
if newNode.Address6 == "" && newNode.IsStatic != "yes"{
|
||||
newNode.Address6 = currentNode.Address6
|
||||
}
|
||||
if newNode.LocalAddress == "" {
|
||||
|
@ -249,15 +245,15 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|||
if newNode.Name == "" {
|
||||
newNode.Name = currentNode.Name
|
||||
}
|
||||
if newNode.ListenPort == 0 {
|
||||
if newNode.ListenPort == 0 && newNode.IsStatic != "yes"{
|
||||
newNode.ListenPort = currentNode.ListenPort
|
||||
}
|
||||
if newNode.PublicKey == "" {
|
||||
if newNode.PublicKey == "" && newNode.IsStatic != "yes" {
|
||||
newNode.PublicKey = currentNode.PublicKey
|
||||
} else {
|
||||
newNode.KeyUpdateTimeStamp = time.Now().Unix()
|
||||
}
|
||||
if newNode.Endpoint == "" {
|
||||
if newNode.Endpoint == "" && newNode.IsStatic != "yes"{
|
||||
newNode.Endpoint = currentNode.Endpoint
|
||||
}
|
||||
if newNode.PostUp == "" {
|
||||
|
@ -331,14 +327,8 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|||
if newNode.IngressGatewayRange == "" {
|
||||
newNode.IngressGatewayRange = currentNode.IngressGatewayRange
|
||||
}
|
||||
if newNode.StaticIP == "" {
|
||||
newNode.StaticIP = currentNode.StaticIP
|
||||
}
|
||||
if newNode.StaticIP == "" {
|
||||
newNode.StaticIP = currentNode.StaticIP
|
||||
}
|
||||
if newNode.StaticPubKey == "" {
|
||||
newNode.StaticPubKey = currentNode.StaticPubKey
|
||||
if newNode.IsStatic == "" {
|
||||
newNode.IsStatic = currentNode.IsStatic
|
||||
}
|
||||
if newNode.UDPHolePunch == "" {
|
||||
newNode.UDPHolePunch = currentNode.SaveConfig
|
||||
|
@ -364,6 +354,7 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|||
if newNode.Action == "" {
|
||||
newNode.Action = currentNode.Action
|
||||
}
|
||||
newNode.IsServer = currentNode.IsServer
|
||||
}
|
||||
|
||||
func (currentNode *Node) Update(newNode *Node) error {
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
func checkIP(node *models.Node, servercfg config.ServerConfig, cliconf config.ClientConfig, network string) bool {
|
||||
ipchange := false
|
||||
var err error
|
||||
if node.Roaming == "yes" {
|
||||
if node.Roaming == "yes" && node.IsStatic != "yes" {
|
||||
if node.IsLocal == "no" {
|
||||
log.Println("Checking to see if public addresses have changed")
|
||||
extIP, err := getPublicIP()
|
||||
|
@ -88,12 +88,9 @@ func setDNS(node *models.Node, servercfg config.ServerConfig, nodecfg *models.No
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
func checkNodeActions(node *models.Node, network string, servercfg config.ServerConfig, localNode *models.Node) string {
|
||||
if node.Action == models.NODE_UPDATE_KEY || localNode.Action == models.NODE_UPDATE_KEY {
|
||||
if (node.Action == models.NODE_UPDATE_KEY || localNode.Action == models.NODE_UPDATE_KEY) &&
|
||||
node.IsStatic != "yes" {
|
||||
err := wireguard.SetWGKeyConfig(network, servercfg.GRPCAddress)
|
||||
if err != nil {
|
||||
log.Println("Unable to process reset keys request:", err)
|
||||
|
|
|
@ -82,7 +82,8 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
|
|||
conf := wgtypes.Config{}
|
||||
if nodecfg.UDPHolePunch == "yes" &&
|
||||
nodecfg.IsServer == "no" &&
|
||||
nodecfg.IsIngressGateway == "no" {
|
||||
nodecfg.IsIngressGateway == "no" &&
|
||||
nodecfg.IsStatic != "yes" {
|
||||
conf = wgtypes.Config{
|
||||
PrivateKey: &key,
|
||||
ReplacePeers: true,
|
||||
|
|
Loading…
Reference in a new issue