mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-20 23:36:18 +08:00
removed localaddress
This commit is contained in:
parent
df614d6d4f
commit
368d01ff10
|
@ -116,10 +116,6 @@ func UpdateHost(newHost, currentHost *models.Host) {
|
||||||
newHost.Name = currentHost.Name
|
newHost.Name = currentHost.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
if newHost.LocalAddress.String() != currentHost.LocalAddress.String() {
|
|
||||||
newHost.LocalAddress = currentHost.LocalAddress
|
|
||||||
}
|
|
||||||
|
|
||||||
if newHost.LocalRange.String() != currentHost.LocalRange.String() {
|
if newHost.LocalRange.String() != currentHost.LocalRange.String() {
|
||||||
newHost.LocalRange = currentHost.LocalRange
|
newHost.LocalRange = currentHost.LocalRange
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ type ApiHost struct {
|
||||||
Debug bool `json:"debug"`
|
Debug bool `json:"debug"`
|
||||||
IsStatic bool `json:"isstatic"`
|
IsStatic bool `json:"isstatic"`
|
||||||
ListenPort int `json:"listenport"`
|
ListenPort int `json:"listenport"`
|
||||||
LocalAddress string `json:"localaddress"`
|
|
||||||
LocalRange string `json:"localrange"`
|
LocalRange string `json:"localrange"`
|
||||||
LocalListenPort int `json:"locallistenport"`
|
LocalListenPort int `json:"locallistenport"`
|
||||||
ProxyListenPort int `json:"proxy_listen_port"`
|
ProxyListenPort int `json:"proxy_listen_port"`
|
||||||
|
@ -42,10 +41,6 @@ func (h *Host) ConvertNMHostToAPI() *ApiHost {
|
||||||
}
|
}
|
||||||
a.IsStatic = h.IsStatic
|
a.IsStatic = h.IsStatic
|
||||||
a.ListenPort = h.ListenPort
|
a.ListenPort = h.ListenPort
|
||||||
a.LocalAddress = h.LocalAddress.String()
|
|
||||||
if isEmptyAddr(a.LocalAddress) {
|
|
||||||
a.LocalAddress = ""
|
|
||||||
}
|
|
||||||
a.LocalListenPort = h.LocalListenPort
|
a.LocalListenPort = h.LocalListenPort
|
||||||
a.LocalRange = h.LocalRange.String()
|
a.LocalRange = h.LocalRange.String()
|
||||||
if isEmptyAddr(a.LocalRange) {
|
if isEmptyAddr(a.LocalRange) {
|
||||||
|
@ -94,14 +89,7 @@ func (a *ApiHost) ConvertAPIHostToNMHost(currentHost *Host) *Host {
|
||||||
h.Nodes = currentHost.Nodes
|
h.Nodes = currentHost.Nodes
|
||||||
h.TrafficKeyPublic = currentHost.TrafficKeyPublic
|
h.TrafficKeyPublic = currentHost.TrafficKeyPublic
|
||||||
h.OS = currentHost.OS
|
h.OS = currentHost.OS
|
||||||
if len(a.LocalAddress) > 0 {
|
|
||||||
_, localAddr, err := net.ParseCIDR(a.LocalAddress)
|
|
||||||
if err == nil {
|
|
||||||
h.LocalAddress = *localAddr
|
|
||||||
}
|
|
||||||
} else if !isEmptyAddr(currentHost.LocalAddress.String()) {
|
|
||||||
h.LocalAddress = currentHost.LocalAddress
|
|
||||||
}
|
|
||||||
if len(a.LocalRange) > 0 {
|
if len(a.LocalRange) > 0 {
|
||||||
_, localRange, err := net.ParseCIDR(a.LocalRange)
|
_, localRange, err := net.ParseCIDR(a.LocalRange)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
@ -13,6 +13,7 @@ type ApiNode struct {
|
||||||
HostID string `json:"hostid,omitempty" validate:"required,min=5,id_unique"`
|
HostID string `json:"hostid,omitempty" validate:"required,min=5,id_unique"`
|
||||||
Address string `json:"address" validate:"omitempty,ipv4"`
|
Address string `json:"address" validate:"omitempty,ipv4"`
|
||||||
Address6 string `json:"address6" validate:"omitempty,ipv6"`
|
Address6 string `json:"address6" validate:"omitempty,ipv6"`
|
||||||
|
LocalAddress string `json:"localaddress" validate:"omitempty,ipv4"`
|
||||||
PostUp string `json:"postup"`
|
PostUp string `json:"postup"`
|
||||||
PostDown string `json:"postdown"`
|
PostDown string `json:"postdown"`
|
||||||
AllowedIPs []string `json:"allowedips"`
|
AllowedIPs []string `json:"allowedips"`
|
||||||
|
@ -50,7 +51,6 @@ func (a *ApiNode) ConvertToServerNode(currentNode *Node) *Node {
|
||||||
convertedNode.Server = a.Server
|
convertedNode.Server = a.Server
|
||||||
convertedNode.Action = currentNode.Action
|
convertedNode.Action = currentNode.Action
|
||||||
convertedNode.Connected = a.Connected
|
convertedNode.Connected = a.Connected
|
||||||
convertedNode.AllowedIPs = a.AllowedIPs
|
|
||||||
convertedNode.ID, _ = uuid.Parse(a.ID)
|
convertedNode.ID, _ = uuid.Parse(a.ID)
|
||||||
convertedNode.HostID, _ = uuid.Parse(a.HostID)
|
convertedNode.HostID, _ = uuid.Parse(a.HostID)
|
||||||
convertedNode.PostUp = a.PostUp
|
convertedNode.PostUp = a.PostUp
|
||||||
|
@ -81,6 +81,14 @@ func (a *ApiNode) ConvertToServerNode(currentNode *Node) *Node {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
convertedNode.NetworkRange6 = *networkRange6
|
convertedNode.NetworkRange6 = *networkRange6
|
||||||
}
|
}
|
||||||
|
if len(a.LocalAddress) > 0 {
|
||||||
|
_, localAddr, err := net.ParseCIDR(a.LocalAddress)
|
||||||
|
if err == nil {
|
||||||
|
convertedNode.LocalAddress = *localAddr
|
||||||
|
}
|
||||||
|
} else if !isEmptyAddr(currentNode.LocalAddress.String()) {
|
||||||
|
convertedNode.LocalAddress = currentNode.LocalAddress
|
||||||
|
}
|
||||||
udpAddr, err := net.ResolveUDPAddr("udp", a.InternetGateway)
|
udpAddr, err := net.ResolveUDPAddr("udp", a.InternetGateway)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
convertedNode.InternetGateway = udpAddr
|
convertedNode.InternetGateway = udpAddr
|
||||||
|
@ -114,9 +122,12 @@ func (nm *Node) ConvertToAPINode() *ApiNode {
|
||||||
if isEmptyAddr(apiNode.Address6) {
|
if isEmptyAddr(apiNode.Address6) {
|
||||||
apiNode.Address6 = ""
|
apiNode.Address6 = ""
|
||||||
}
|
}
|
||||||
|
apiNode.LocalAddress = nm.LocalAddress.String()
|
||||||
|
if isEmptyAddr(apiNode.LocalAddress) {
|
||||||
|
apiNode.LocalAddress = ""
|
||||||
|
}
|
||||||
apiNode.PostDown = nm.PostDown
|
apiNode.PostDown = nm.PostDown
|
||||||
apiNode.PostUp = nm.PostUp
|
apiNode.PostUp = nm.PostUp
|
||||||
apiNode.AllowedIPs = nm.AllowedIPs
|
|
||||||
apiNode.PersistentKeepalive = int32(nm.PersistentKeepalive)
|
apiNode.PersistentKeepalive = int32(nm.PersistentKeepalive)
|
||||||
apiNode.LastModified = nm.LastModified.Unix()
|
apiNode.LastModified = nm.LastModified.Unix()
|
||||||
apiNode.LastCheckIn = nm.LastCheckIn.Unix()
|
apiNode.LastCheckIn = nm.LastCheckIn.Unix()
|
||||||
|
|
|
@ -24,7 +24,6 @@ type Host struct {
|
||||||
Interface string `json:"interface" yaml:"interface"`
|
Interface string `json:"interface" yaml:"interface"`
|
||||||
Debug bool `json:"debug" yaml:"debug"`
|
Debug bool `json:"debug" yaml:"debug"`
|
||||||
ListenPort int `json:"listenport" yaml:"listenport"`
|
ListenPort int `json:"listenport" yaml:"listenport"`
|
||||||
LocalAddress net.IPNet `json:"localaddress" yaml:"localaddress"`
|
|
||||||
LocalRange net.IPNet `json:"localrange" yaml:"localrange"`
|
LocalRange net.IPNet `json:"localrange" yaml:"localrange"`
|
||||||
LocalListenPort int `json:"locallistenport" yaml:"locallistenport"`
|
LocalListenPort int `json:"locallistenport" yaml:"locallistenport"`
|
||||||
ProxyListenPort int `json:"proxy_listen_port" yaml:"proxy_listen_port"`
|
ProxyListenPort int `json:"proxy_listen_port" yaml:"proxy_listen_port"`
|
||||||
|
|
|
@ -69,6 +69,7 @@ type CommonNode struct {
|
||||||
PostUp string `json:"postup" yaml:"postup"`
|
PostUp string `json:"postup" yaml:"postup"`
|
||||||
PostDown string `json:"postdown" yaml:"postdown"`
|
PostDown string `json:"postdown" yaml:"postdown"`
|
||||||
Action string `json:"action" yaml:"action"`
|
Action string `json:"action" yaml:"action"`
|
||||||
|
LocalAddress net.IPNet `json:"localaddress" yaml:"localaddress"`
|
||||||
IsLocal bool `json:"islocal" yaml:"islocal"`
|
IsLocal bool `json:"islocal" yaml:"islocal"`
|
||||||
IsEgressGateway bool `json:"isegressgateway" yaml:"isegressgateway"`
|
IsEgressGateway bool `json:"isegressgateway" yaml:"isegressgateway"`
|
||||||
IsIngressGateway bool `json:"isingressgateway" yaml:"isingressgateway"`
|
IsIngressGateway bool `json:"isingressgateway" yaml:"isingressgateway"`
|
||||||
|
@ -85,7 +86,6 @@ type Node struct {
|
||||||
LastCheckIn time.Time `json:"lastcheckin" bson:"lastcheckin" yaml:"lastcheckin"`
|
LastCheckIn time.Time `json:"lastcheckin" bson:"lastcheckin" yaml:"lastcheckin"`
|
||||||
LastPeerUpdate time.Time `json:"lastpeerupdate" bson:"lastpeerupdate" yaml:"lastpeerupdate"`
|
LastPeerUpdate time.Time `json:"lastpeerupdate" bson:"lastpeerupdate" yaml:"lastpeerupdate"`
|
||||||
ExpirationDateTime time.Time `json:"expdatetime" bson:"expdatetime" yaml:"expdatetime"`
|
ExpirationDateTime time.Time `json:"expdatetime" bson:"expdatetime" yaml:"expdatetime"`
|
||||||
AllowedIPs []string `json:"allowedips" bson:"allowedips" yaml:"allowedips"`
|
|
||||||
EgressGatewayRanges []string `json:"egressgatewayranges" bson:"egressgatewayranges" yaml:"egressgatewayranges"`
|
EgressGatewayRanges []string `json:"egressgatewayranges" bson:"egressgatewayranges" yaml:"egressgatewayranges"`
|
||||||
EgressGatewayNatEnabled bool `json:"egressgatewaynatenabled" bson:"egressgatewaynatenabled" yaml:"egressgatewaynatenabled"`
|
EgressGatewayNatEnabled bool `json:"egressgatewaynatenabled" bson:"egressgatewaynatenabled" yaml:"egressgatewaynatenabled"`
|
||||||
EgressGatewayRequest EgressGatewayRequest `json:"egressgatewayrequest" bson:"egressgatewayrequest" yaml:"egressgatewayrequest"`
|
EgressGatewayRequest EgressGatewayRequest `json:"egressgatewayrequest" bson:"egressgatewayrequest" yaml:"egressgatewayrequest"`
|
||||||
|
@ -381,9 +381,6 @@ func (newNode *Node) Fill(currentNode *Node) { // TODO add new field for nftable
|
||||||
if newNode.PostDown == "" {
|
if newNode.PostDown == "" {
|
||||||
newNode.PostDown = currentNode.PostDown
|
newNode.PostDown = currentNode.PostDown
|
||||||
}
|
}
|
||||||
if newNode.AllowedIPs == nil {
|
|
||||||
newNode.AllowedIPs = currentNode.AllowedIPs
|
|
||||||
}
|
|
||||||
if newNode.PersistentKeepalive < 0 {
|
if newNode.PersistentKeepalive < 0 {
|
||||||
newNode.PersistentKeepalive = currentNode.PersistentKeepalive
|
newNode.PersistentKeepalive = currentNode.PersistentKeepalive
|
||||||
}
|
}
|
||||||
|
@ -503,7 +500,6 @@ func (ln *LegacyNode) ConvertToNewNode() (*Host, *Node) {
|
||||||
host.Name = ln.Name
|
host.Name = ln.Name
|
||||||
host.ListenPort = int(ln.ListenPort)
|
host.ListenPort = int(ln.ListenPort)
|
||||||
_, cidr, _ := net.ParseCIDR(ln.LocalAddress)
|
_, cidr, _ := net.ParseCIDR(ln.LocalAddress)
|
||||||
host.LocalAddress = *cidr
|
|
||||||
_, cidr, _ = net.ParseCIDR(ln.LocalRange)
|
_, cidr, _ = net.ParseCIDR(ln.LocalRange)
|
||||||
host.LocalRange = *cidr
|
host.LocalRange = *cidr
|
||||||
host.LocalListenPort = int(ln.LocalListenPort)
|
host.LocalListenPort = int(ln.LocalListenPort)
|
||||||
|
@ -552,7 +548,6 @@ func (n *Node) Legacy(h *Host, s *ServerConfig, net *Network) *LegacyNode {
|
||||||
l.HostID = h.ID.String()
|
l.HostID = h.ID.String()
|
||||||
l.Address = n.Address.String()
|
l.Address = n.Address.String()
|
||||||
l.Address6 = n.Address6.String()
|
l.Address6 = n.Address6.String()
|
||||||
l.LocalAddress = h.LocalAddress.String()
|
|
||||||
l.Interfaces = h.Interfaces
|
l.Interfaces = h.Interfaces
|
||||||
l.Name = h.Name
|
l.Name = h.Name
|
||||||
l.NetworkSettings = *net
|
l.NetworkSettings = *net
|
||||||
|
|
Loading…
Reference in a new issue