mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-21 07:46:04 +08:00
changed stuff to make it work
This commit is contained in:
parent
19d0c3c5e9
commit
9b37940c1a
|
@ -57,7 +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"`
|
||||
IsStatic string `json:"isstatic" bson:"isstatic" yaml:"isstatic" 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"`
|
||||
|
@ -70,6 +70,24 @@ type Node struct {
|
|||
IPForwarding string `json:"ipforwarding" bson:"ipforwarding" yaml:"ipforwarding" validate:"checkyesorno"`
|
||||
}
|
||||
|
||||
func (node *Node) SetDefaulIsPending() {
|
||||
if node.IsPending == "" {
|
||||
node.IsPending = "no"
|
||||
}
|
||||
}
|
||||
|
||||
func (node *Node) SetDefaultEgressGateway() {
|
||||
if node.IsEgressGateway == "" {
|
||||
node.IsEgressGateway = "no"
|
||||
}
|
||||
}
|
||||
|
||||
func (node *Node) SetDefaultIngressGateway() {
|
||||
if node.IsIngressGateway == "" {
|
||||
node.IsIngressGateway = "no"
|
||||
}
|
||||
}
|
||||
|
||||
func (node *Node) SetDefaultAction() {
|
||||
if node.Action == "" {
|
||||
node.Action = NODE_NOOP
|
||||
|
@ -235,6 +253,9 @@ func (node *Node) SetDefaults() {
|
|||
node.SetID()
|
||||
node.SetIsServerDefault()
|
||||
node.SetIsStaticDefault()
|
||||
node.SetDefaultEgressGateway()
|
||||
node.SetDefaultIngressGateway()
|
||||
node.SetDefaulIsPending()
|
||||
node.KeyUpdateTimeStamp = time.Now().Unix()
|
||||
}
|
||||
|
||||
|
@ -242,10 +263,10 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|||
if newNode.ID == "" {
|
||||
newNode.ID = currentNode.ID
|
||||
}
|
||||
if newNode.Address == "" && newNode.IsStatic != "yes"{
|
||||
if newNode.Address == "" && newNode.IsStatic != "yes" {
|
||||
newNode.Address = currentNode.Address
|
||||
}
|
||||
if newNode.Address6 == "" && newNode.IsStatic != "yes"{
|
||||
if newNode.Address6 == "" && newNode.IsStatic != "yes" {
|
||||
newNode.Address6 = currentNode.Address6
|
||||
}
|
||||
if newNode.LocalAddress == "" {
|
||||
|
@ -254,7 +275,7 @@ 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.IsStatic != "yes" {
|
||||
newNode.ListenPort = currentNode.ListenPort
|
||||
}
|
||||
if newNode.PublicKey == "" && newNode.IsStatic != "yes" {
|
||||
|
@ -262,7 +283,7 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|||
} else {
|
||||
newNode.KeyUpdateTimeStamp = time.Now().Unix()
|
||||
}
|
||||
if newNode.Endpoint == "" && newNode.IsStatic != "yes"{
|
||||
if newNode.Endpoint == "" && newNode.IsStatic != "yes" {
|
||||
newNode.Endpoint = currentNode.Endpoint
|
||||
}
|
||||
if newNode.PostUp == "" {
|
||||
|
|
|
@ -80,10 +80,10 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
|
|||
nodeport = int(node.ListenPort)
|
||||
|
||||
conf := wgtypes.Config{}
|
||||
if nodecfg.UDPHolePunch == "yes" &&
|
||||
nodecfg.IsServer == "no" &&
|
||||
nodecfg.IsIngressGateway == "no" &&
|
||||
nodecfg.IsStatic != "yes" {
|
||||
if nodecfg.UDPHolePunch == "yes" &&
|
||||
nodecfg.IsServer == "no" &&
|
||||
nodecfg.IsIngressGateway != "yes" &&
|
||||
nodecfg.IsStatic != "yes" {
|
||||
conf = wgtypes.Config{
|
||||
PrivateKey: &key,
|
||||
ReplacePeers: true,
|
||||
|
|
Loading…
Reference in a new issue