mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 03:46:02 +08:00
Merge branch 'develop' of https://github.com/gravitl/netmaker into GRA-988/delete_host_from_network
This commit is contained in:
commit
eee352fa4b
4 changed files with 34 additions and 28 deletions
|
@ -111,7 +111,7 @@ func updateHost(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// publish host update through MQ
|
// publish host update through MQ
|
||||||
if mq.HostUpdate(&models.HostUpdate{
|
if err := mq.HostUpdate(&models.HostUpdate{
|
||||||
Action: models.UpdateHost,
|
Action: models.UpdateHost,
|
||||||
Host: *newHost,
|
Host: *newHost,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
|
|
@ -4,31 +4,32 @@ import "net"
|
||||||
|
|
||||||
// ApiHost - the host struct for API usage
|
// ApiHost - the host struct for API usage
|
||||||
type ApiHost struct {
|
type ApiHost struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Verbosity int `json:"verbosity"`
|
Verbosity int `json:"verbosity"`
|
||||||
FirewallInUse string `json:"firewallinuse"`
|
FirewallInUse string `json:"firewallinuse"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
OS string `json:"os"`
|
OS string `json:"os"`
|
||||||
Debug bool `json:"debug"`
|
Debug bool `json:"debug"`
|
||||||
IsStatic bool `json:"isstatic"`
|
IsStatic bool `json:"isstatic"`
|
||||||
ListenPort int `json:"listenport"`
|
ListenPort int `json:"listenport"`
|
||||||
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"`
|
||||||
MTU int `json:"mtu" yaml:"mtu"`
|
MTU int `json:"mtu" yaml:"mtu"`
|
||||||
Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
|
Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
|
||||||
EndpointIP string `json:"endpointip" yaml:"endpointip"`
|
DefaultInterface string `json:"defaultinterface" yaml:"defautlinterface"`
|
||||||
PublicKey string `json:"publickey"`
|
EndpointIP string `json:"endpointip" yaml:"endpointip"`
|
||||||
MacAddress string `json:"macaddress"`
|
PublicKey string `json:"publickey"`
|
||||||
InternetGateway string `json:"internetgateway"`
|
MacAddress string `json:"macaddress"`
|
||||||
Nodes []string `json:"nodes"`
|
InternetGateway string `json:"internetgateway"`
|
||||||
ProxyEnabled bool `json:"proxy_enabled" yaml:"proxy_enabled"`
|
Nodes []string `json:"nodes"`
|
||||||
IsDefault bool `json:"isdefault" yaml:"isdefault"`
|
ProxyEnabled bool `json:"proxy_enabled" yaml:"proxy_enabled"`
|
||||||
IsRelayed bool `json:"isrelayed" bson:"isrelayed" yaml:"isrelayed"`
|
IsDefault bool `json:"isdefault" yaml:"isdefault"`
|
||||||
RelayedBy string `json:"relayed_by" bson:"relayed_by" yaml:"relayed_by"`
|
IsRelayed bool `json:"isrelayed" bson:"isrelayed" yaml:"isrelayed"`
|
||||||
IsRelay bool `json:"isrelay" bson:"isrelay" yaml:"isrelay"`
|
RelayedBy string `json:"relayed_by" bson:"relayed_by" yaml:"relayed_by"`
|
||||||
RelayedHosts []string `json:"relay_hosts" bson:"relay_hosts" yaml:"relay_hosts"`
|
IsRelay bool `json:"isrelay" bson:"isrelay" yaml:"isrelay"`
|
||||||
|
RelayedHosts []string `json:"relay_hosts" bson:"relay_hosts" yaml:"relay_hosts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Host.ConvertNMHostToAPI - converts a Netmaker host to an API editable host
|
// Host.ConvertNMHostToAPI - converts a Netmaker host to an API editable host
|
||||||
|
@ -42,6 +43,7 @@ func (h *Host) ConvertNMHostToAPI() *ApiHost {
|
||||||
for i := range a.Interfaces {
|
for i := range a.Interfaces {
|
||||||
a.Interfaces[i].AddressString = a.Interfaces[i].Address.String()
|
a.Interfaces[i].AddressString = a.Interfaces[i].Address.String()
|
||||||
}
|
}
|
||||||
|
a.DefaultInterface = h.DefaultInterface
|
||||||
a.InternetGateway = h.InternetGateway.String()
|
a.InternetGateway = h.InternetGateway.String()
|
||||||
if isEmptyAddr(a.InternetGateway) {
|
if isEmptyAddr(a.InternetGateway) {
|
||||||
a.InternetGateway = ""
|
a.InternetGateway = ""
|
||||||
|
@ -83,6 +85,7 @@ func (a *ApiHost) ConvertAPIHostToNMHost(currentHost *Host) *Host {
|
||||||
h.IPForwarding = currentHost.IPForwarding
|
h.IPForwarding = currentHost.IPForwarding
|
||||||
h.Interface = currentHost.Interface
|
h.Interface = currentHost.Interface
|
||||||
h.Interfaces = currentHost.Interfaces
|
h.Interfaces = currentHost.Interfaces
|
||||||
|
h.DefaultInterface = currentHost.DefaultInterface
|
||||||
h.InternetGateway = currentHost.InternetGateway
|
h.InternetGateway = currentHost.InternetGateway
|
||||||
h.IsDocker = currentHost.IsDocker
|
h.IsDocker = currentHost.IsDocker
|
||||||
h.IsK8S = currentHost.IsK8S
|
h.IsK8S = currentHost.IsK8S
|
||||||
|
|
|
@ -92,13 +92,15 @@ func (a *ApiNode) ConvertToServerNode(currentNode *Node) *Node {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
convertedNode.InternetGateway = udpAddr
|
convertedNode.InternetGateway = udpAddr
|
||||||
}
|
}
|
||||||
_, addr, err := net.ParseCIDR(a.Address)
|
ip, addr, err := net.ParseCIDR(a.Address)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
convertedNode.Address = *addr
|
convertedNode.Address = *addr
|
||||||
|
convertedNode.Address.IP = ip
|
||||||
}
|
}
|
||||||
_, addr6, err := net.ParseCIDR(a.Address6)
|
ip6, addr6, err := net.ParseCIDR(a.Address6)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
convertedNode.Address = *addr6
|
convertedNode.Address = *addr6
|
||||||
|
convertedNode.Address.IP = ip6
|
||||||
}
|
}
|
||||||
convertedNode.FailoverNode, _ = uuid.Parse(a.FailoverNode)
|
convertedNode.FailoverNode, _ = uuid.Parse(a.FailoverNode)
|
||||||
convertedNode.LastModified = time.Unix(a.LastModified, 0)
|
convertedNode.LastModified = time.Unix(a.LastModified, 0)
|
||||||
|
|
|
@ -39,6 +39,7 @@ type Host struct {
|
||||||
IsRelay bool `json:"isrelay" yaml:"isrelay"`
|
IsRelay bool `json:"isrelay" yaml:"isrelay"`
|
||||||
RelayedHosts []string `json:"relay_hosts" yaml:"relay_hosts"`
|
RelayedHosts []string `json:"relay_hosts" yaml:"relay_hosts"`
|
||||||
Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
|
Interfaces []Iface `json:"interfaces" yaml:"interfaces"`
|
||||||
|
DefaultInterface string `json:"defaultinterface" yaml:"defautlinterface"`
|
||||||
EndpointIP net.IP `json:"endpointip" yaml:"endpointip"`
|
EndpointIP net.IP `json:"endpointip" yaml:"endpointip"`
|
||||||
ProxyEnabled bool `json:"proxy_enabled" yaml:"proxy_enabled"`
|
ProxyEnabled bool `json:"proxy_enabled" yaml:"proxy_enabled"`
|
||||||
IsDocker bool `json:"isdocker" yaml:"isdocker"`
|
IsDocker bool `json:"isdocker" yaml:"isdocker"`
|
||||||
|
|
Loading…
Add table
Reference in a new issue