|
@@ -38,17 +38,15 @@ type Node struct {
|
|
PostDown string `json:"postdown" bson:"postdown" yaml:"postdown"`
|
|
PostDown string `json:"postdown" bson:"postdown" yaml:"postdown"`
|
|
AllowedIPs []string `json:"allowedips" bson:"allowedips" yaml:"allowedips"`
|
|
AllowedIPs []string `json:"allowedips" bson:"allowedips" yaml:"allowedips"`
|
|
PersistentKeepalive int32 `json:"persistentkeepalive" bson:"persistentkeepalive" yaml:"persistentkeepalive" validate:"omitempty,numeric,max=1000"`
|
|
PersistentKeepalive int32 `json:"persistentkeepalive" bson:"persistentkeepalive" yaml:"persistentkeepalive" validate:"omitempty,numeric,max=1000"`
|
|
- SaveConfig string `json:"saveconfig" bson:"saveconfig" yaml:"saveconfig" validate:"checkyesorno"`
|
|
|
|
|
|
+ IsHub string `json:"ishub" bson:"ishub" yaml:"ishub" validate:"checkyesorno"`
|
|
AccessKey string `json:"accesskey" bson:"accesskey" yaml:"accesskey"`
|
|
AccessKey string `json:"accesskey" bson:"accesskey" yaml:"accesskey"`
|
|
Interface string `json:"interface" bson:"interface" yaml:"interface"`
|
|
Interface string `json:"interface" bson:"interface" yaml:"interface"`
|
|
LastModified int64 `json:"lastmodified" bson:"lastmodified" yaml:"lastmodified"`
|
|
LastModified int64 `json:"lastmodified" bson:"lastmodified" yaml:"lastmodified"`
|
|
- KeyUpdateTimeStamp int64 `json:"keyupdatetimestamp" bson:"keyupdatetimestamp" yaml:"keyupdatetimestamp"`
|
|
|
|
ExpirationDateTime int64 `json:"expdatetime" bson:"expdatetime" yaml:"expdatetime"`
|
|
ExpirationDateTime int64 `json:"expdatetime" bson:"expdatetime" yaml:"expdatetime"`
|
|
LastPeerUpdate int64 `json:"lastpeerupdate" bson:"lastpeerupdate" yaml:"lastpeerupdate"`
|
|
LastPeerUpdate int64 `json:"lastpeerupdate" bson:"lastpeerupdate" yaml:"lastpeerupdate"`
|
|
LastCheckIn int64 `json:"lastcheckin" bson:"lastcheckin" yaml:"lastcheckin"`
|
|
LastCheckIn int64 `json:"lastcheckin" bson:"lastcheckin" yaml:"lastcheckin"`
|
|
MacAddress string `json:"macaddress" bson:"macaddress" yaml:"macaddress" validate:"macaddress_unique"`
|
|
MacAddress string `json:"macaddress" bson:"macaddress" yaml:"macaddress" validate:"macaddress_unique"`
|
|
// checkin interval is depreciated at the network level. Set on server with CHECKIN_INTERVAL
|
|
// checkin interval is depreciated at the network level. Set on server with CHECKIN_INTERVAL
|
|
- CheckInInterval int32 `json:"checkininterval" bson:"checkininterval" yaml:"checkininterval"`
|
|
|
|
Password string `json:"password" bson:"password" yaml:"password" validate:"required,min=6"`
|
|
Password string `json:"password" bson:"password" yaml:"password" validate:"required,min=6"`
|
|
Network string `json:"network" bson:"network" yaml:"network" validate:"network_exists"`
|
|
Network string `json:"network" bson:"network" yaml:"network" validate:"network_exists"`
|
|
IsRelayed string `json:"isrelayed" bson:"isrelayed" yaml:"isrelayed"`
|
|
IsRelayed string `json:"isrelayed" bson:"isrelayed" yaml:"isrelayed"`
|
|
@@ -63,20 +61,18 @@ type Node struct {
|
|
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"`
|
|
|
|
- DNSOn string `json:"dnson" bson:"dnson" yaml:"dnson" validate:"checkyesorno"`
|
|
|
|
- IsDualStack string `json:"isdualstack" bson:"isdualstack" yaml:"isdualstack" validate:"checkyesorno"`
|
|
|
|
- IsServer string `json:"isserver" bson:"isserver" yaml:"isserver" validate:"checkyesorno"`
|
|
|
|
- Action string `json:"action" bson:"action" yaml:"action"`
|
|
|
|
- IsLocal string `json:"islocal" bson:"islocal" yaml:"islocal" validate:"checkyesorno"`
|
|
|
|
- LocalRange string `json:"localrange" bson:"localrange" yaml:"localrange"`
|
|
|
|
- //Roaming string `json:"roaming" bson:"roaming" yaml:"roaming" validate:"checkyesorno"`
|
|
|
|
- IPForwarding string `json:"ipforwarding" bson:"ipforwarding" yaml:"ipforwarding" validate:"checkyesorno"`
|
|
|
|
- OS string `json:"os" bson:"os" yaml:"os"`
|
|
|
|
- MTU int32 `json:"mtu" bson:"mtu" yaml:"mtu"`
|
|
|
|
- Version string `json:"version" bson:"version" yaml:"version"`
|
|
|
|
- ExcludedAddrs []string `json:"excludedaddrs" bson:"excludedaddrs" yaml:"excludedaddrs"`
|
|
|
|
- TrafficKeys TrafficKeys `json:"traffickeys" bson:"traffickeys" yaml:"traffickeys"`
|
|
|
|
|
|
+ //PullChanges string `json:"pullchanges" bson:"pullchanges" yaml:"pullchanges" validate:"checkyesorno"`
|
|
|
|
+ DNSOn string `json:"dnson" bson:"dnson" yaml:"dnson" validate:"checkyesorno"`
|
|
|
|
+ IsDualStack string `json:"isdualstack" bson:"isdualstack" yaml:"isdualstack" validate:"checkyesorno"`
|
|
|
|
+ IsServer string `json:"isserver" bson:"isserver" yaml:"isserver" validate:"checkyesorno"`
|
|
|
|
+ Action string `json:"action" bson:"action" yaml:"action"`
|
|
|
|
+ IsLocal string `json:"islocal" bson:"islocal" yaml:"islocal" validate:"checkyesorno"`
|
|
|
|
+ LocalRange string `json:"localrange" bson:"localrange" yaml:"localrange"`
|
|
|
|
+ IPForwarding string `json:"ipforwarding" bson:"ipforwarding" yaml:"ipforwarding" validate:"checkyesorno"`
|
|
|
|
+ OS string `json:"os" bson:"os" yaml:"os"`
|
|
|
|
+ MTU int32 `json:"mtu" bson:"mtu" yaml:"mtu"`
|
|
|
|
+ Version string `json:"version" bson:"version" yaml:"version"`
|
|
|
|
+ TrafficKeys TrafficKeys `json:"traffickeys" bson:"traffickeys" yaml:"traffickeys"`
|
|
}
|
|
}
|
|
|
|
|
|
// NodesArray - used for node sorting
|
|
// NodesArray - used for node sorting
|
|
@@ -118,6 +114,13 @@ func (node *Node) SetDefaultIsRelayed() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// Node.SetDefaultIsRelayed - set default is relayed
|
|
|
|
+func (node *Node) SetDefaultIsHub() {
|
|
|
|
+ if node.IsHub == "" {
|
|
|
|
+ node.IsHub = "no"
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
// Node.SetDefaultIsRelay - set default isrelay
|
|
// Node.SetDefaultIsRelay - set default isrelay
|
|
func (node *Node) SetDefaultIsRelay() {
|
|
func (node *Node) SetDefaultIsRelay() {
|
|
if node.IsRelay == "" {
|
|
if node.IsRelay == "" {
|
|
@@ -167,13 +170,6 @@ func (node *Node) SetDefaultAction() {
|
|
// }
|
|
// }
|
|
//}
|
|
//}
|
|
|
|
|
|
-// Node.SetPullChangesDefault - sets default pull changes status
|
|
|
|
-func (node *Node) SetPullChangesDefault() {
|
|
|
|
- if node.PullChanges == "" {
|
|
|
|
- node.PullChanges = "no"
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// Node.SetIPForwardingDefault - set ip forwarding default
|
|
// Node.SetIPForwardingDefault - set ip forwarding default
|
|
func (node *Node) SetIPForwardingDefault() {
|
|
func (node *Node) SetIPForwardingDefault() {
|
|
if node.IPForwarding == "" {
|
|
if node.IPForwarding == "" {
|
|
@@ -245,13 +241,6 @@ func (node *Node) SetDefaultName() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-// Node.SetDefaultExcludedAddrs - sets ExcludedAddrs to empty array if nil
|
|
|
|
-func (node *Node) SetDefaultExcludedAddrs() {
|
|
|
|
- if node.ExcludedAddrs == nil {
|
|
|
|
- node.ExcludedAddrs = make([]string, 0)
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// Node.Fill - fills other node data into calling node data if not set on calling node
|
|
// Node.Fill - fills other node data into calling node data if not set on calling node
|
|
func (newNode *Node) Fill(currentNode *Node) {
|
|
func (newNode *Node) Fill(currentNode *Node) {
|
|
newNode.ID = currentNode.ID
|
|
newNode.ID = currentNode.ID
|
|
@@ -273,8 +262,6 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|
}
|
|
}
|
|
if newNode.PublicKey == "" && newNode.IsStatic != "yes" {
|
|
if newNode.PublicKey == "" && newNode.IsStatic != "yes" {
|
|
newNode.PublicKey = currentNode.PublicKey
|
|
newNode.PublicKey = currentNode.PublicKey
|
|
- } else {
|
|
|
|
- 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
|
|
@@ -291,9 +278,6 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|
if newNode.PersistentKeepalive == 0 {
|
|
if newNode.PersistentKeepalive == 0 {
|
|
newNode.PersistentKeepalive = currentNode.PersistentKeepalive
|
|
newNode.PersistentKeepalive = currentNode.PersistentKeepalive
|
|
}
|
|
}
|
|
- if newNode.SaveConfig == "" {
|
|
|
|
- newNode.SaveConfig = currentNode.SaveConfig
|
|
|
|
- }
|
|
|
|
if newNode.AccessKey == "" {
|
|
if newNode.AccessKey == "" {
|
|
newNode.AccessKey = currentNode.AccessKey
|
|
newNode.AccessKey = currentNode.AccessKey
|
|
}
|
|
}
|
|
@@ -303,9 +287,6 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|
if newNode.LastModified == 0 {
|
|
if newNode.LastModified == 0 {
|
|
newNode.LastModified = currentNode.LastModified
|
|
newNode.LastModified = currentNode.LastModified
|
|
}
|
|
}
|
|
- if newNode.KeyUpdateTimeStamp == 0 {
|
|
|
|
- newNode.LastModified = currentNode.LastModified
|
|
|
|
- }
|
|
|
|
if newNode.ExpirationDateTime == 0 {
|
|
if newNode.ExpirationDateTime == 0 {
|
|
newNode.ExpirationDateTime = currentNode.ExpirationDateTime
|
|
newNode.ExpirationDateTime = currentNode.ExpirationDateTime
|
|
}
|
|
}
|
|
@@ -318,9 +299,6 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|
if newNode.MacAddress == "" {
|
|
if newNode.MacAddress == "" {
|
|
newNode.MacAddress = currentNode.MacAddress
|
|
newNode.MacAddress = currentNode.MacAddress
|
|
}
|
|
}
|
|
- if newNode.CheckInInterval == 0 {
|
|
|
|
- newNode.CheckInInterval = currentNode.CheckInInterval
|
|
|
|
- }
|
|
|
|
if newNode.Password != "" {
|
|
if newNode.Password != "" {
|
|
err := bcrypt.CompareHashAndPassword([]byte(newNode.Password), []byte(currentNode.Password))
|
|
err := bcrypt.CompareHashAndPassword([]byte(newNode.Password), []byte(currentNode.Password))
|
|
if err != nil && currentNode.Password != newNode.Password {
|
|
if err != nil && currentNode.Password != newNode.Password {
|
|
@@ -354,7 +332,7 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|
newNode.IsStatic = currentNode.IsStatic
|
|
newNode.IsStatic = currentNode.IsStatic
|
|
}
|
|
}
|
|
if newNode.UDPHolePunch == "" {
|
|
if newNode.UDPHolePunch == "" {
|
|
- newNode.UDPHolePunch = currentNode.SaveConfig
|
|
|
|
|
|
+ newNode.UDPHolePunch = currentNode.UDPHolePunch
|
|
}
|
|
}
|
|
if newNode.DNSOn == "" {
|
|
if newNode.DNSOn == "" {
|
|
newNode.DNSOn = currentNode.DNSOn
|
|
newNode.DNSOn = currentNode.DNSOn
|
|
@@ -368,9 +346,6 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|
if newNode.IPForwarding == "" {
|
|
if newNode.IPForwarding == "" {
|
|
newNode.IPForwarding = currentNode.IPForwarding
|
|
newNode.IPForwarding = currentNode.IPForwarding
|
|
}
|
|
}
|
|
- if newNode.PullChanges == "" {
|
|
|
|
- newNode.PullChanges = currentNode.PullChanges
|
|
|
|
- }
|
|
|
|
//if newNode.Roaming == "" {
|
|
//if newNode.Roaming == "" {
|
|
//newNode.Roaming = currentNode.Roaming
|
|
//newNode.Roaming = currentNode.Roaming
|
|
//}
|
|
//}
|
|
@@ -407,9 +382,6 @@ func (newNode *Node) Fill(currentNode *Node) {
|
|
if newNode.Version == "" {
|
|
if newNode.Version == "" {
|
|
newNode.Version = currentNode.Version
|
|
newNode.Version = currentNode.Version
|
|
}
|
|
}
|
|
- if newNode.ExcludedAddrs == nil || len(newNode.ExcludedAddrs) != len(currentNode.ExcludedAddrs) {
|
|
|
|
- newNode.ExcludedAddrs = currentNode.ExcludedAddrs
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// StringWithCharset - returns random string inside defined charset
|
|
// StringWithCharset - returns random string inside defined charset
|