|
@@ -57,7 +57,7 @@ type Node struct {
|
|
IsIngressGateway string `json:"isingressgateway" bson:"isingressgateway" yaml:"isingressgateway"`
|
|
IsIngressGateway string `json:"isingressgateway" bson:"isingressgateway" yaml:"isingressgateway"`
|
|
EgressGatewayRanges []string `json:"egressgatewayranges" bson:"egressgatewayranges" yaml:"egressgatewayranges"`
|
|
EgressGatewayRanges []string `json:"egressgatewayranges" bson:"egressgatewayranges" yaml:"egressgatewayranges"`
|
|
IngressGatewayRange string `json:"ingressgatewayrange" bson:"ingressgatewayrange" yaml:"ingressgatewayrange"`
|
|
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"`
|
|
UDPHolePunch string `json:"udpholepunch" bson:"udpholepunch" yaml:"udpholepunch" validate:"checkyesorno"`
|
|
PullChanges string `json:"pullchanges" bson:"pullchanges" yaml:"pullchanges" validate:"checkyesorno"`
|
|
PullChanges string `json:"pullchanges" bson:"pullchanges" yaml:"pullchanges" validate:"checkyesorno"`
|
|
DNSOn string `json:"dnson" bson:"dnson" yaml:"dnson" 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"`
|
|
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() {
|
|
func (node *Node) SetDefaultAction() {
|
|
if node.Action == "" {
|
|
if node.Action == "" {
|
|
node.Action = NODE_NOOP
|
|
node.Action = NODE_NOOP
|
|
@@ -235,6 +253,9 @@ func (node *Node) SetDefaults() {
|
|
node.SetID()
|
|
node.SetID()
|
|
node.SetIsServerDefault()
|
|
node.SetIsServerDefault()
|
|
node.SetIsStaticDefault()
|
|
node.SetIsStaticDefault()
|
|
|
|
+ node.SetDefaultEgressGateway()
|
|
|
|
+ node.SetDefaultIngressGateway()
|
|
|
|
+ node.SetDefaulIsPending()
|
|
node.KeyUpdateTimeStamp = time.Now().Unix()
|
|
node.KeyUpdateTimeStamp = time.Now().Unix()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -242,10 +263,10 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|
if newNode.ID == "" {
|
|
if newNode.ID == "" {
|
|
newNode.ID = currentNode.ID
|
|
newNode.ID = currentNode.ID
|
|
}
|
|
}
|
|
- if newNode.Address == "" && newNode.IsStatic != "yes"{
|
|
|
|
|
|
+ if newNode.Address == "" && newNode.IsStatic != "yes" {
|
|
newNode.Address = currentNode.Address
|
|
newNode.Address = currentNode.Address
|
|
}
|
|
}
|
|
- if newNode.Address6 == "" && newNode.IsStatic != "yes"{
|
|
|
|
|
|
+ if newNode.Address6 == "" && newNode.IsStatic != "yes" {
|
|
newNode.Address6 = currentNode.Address6
|
|
newNode.Address6 = currentNode.Address6
|
|
}
|
|
}
|
|
if newNode.LocalAddress == "" {
|
|
if newNode.LocalAddress == "" {
|
|
@@ -254,7 +275,7 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|
if newNode.Name == "" {
|
|
if newNode.Name == "" {
|
|
newNode.Name = currentNode.Name
|
|
newNode.Name = currentNode.Name
|
|
}
|
|
}
|
|
- if newNode.ListenPort == 0 && newNode.IsStatic != "yes"{
|
|
|
|
|
|
+ if newNode.ListenPort == 0 && newNode.IsStatic != "yes" {
|
|
newNode.ListenPort = currentNode.ListenPort
|
|
newNode.ListenPort = currentNode.ListenPort
|
|
}
|
|
}
|
|
if newNode.PublicKey == "" && newNode.IsStatic != "yes" {
|
|
if newNode.PublicKey == "" && newNode.IsStatic != "yes" {
|
|
@@ -262,7 +283,7 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|
} else {
|
|
} else {
|
|
newNode.KeyUpdateTimeStamp = time.Now().Unix()
|
|
newNode.KeyUpdateTimeStamp = time.Now().Unix()
|
|
}
|
|
}
|
|
- if newNode.Endpoint == "" && newNode.IsStatic != "yes"{
|
|
|
|
|
|
+ if newNode.Endpoint == "" && newNode.IsStatic != "yes" {
|
|
newNode.Endpoint = currentNode.Endpoint
|
|
newNode.Endpoint = currentNode.Endpoint
|
|
}
|
|
}
|
|
if newNode.PostUp == "" {
|
|
if newNode.PostUp == "" {
|