mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 03:46:02 +08:00
added nil check for endpoint from API
This commit is contained in:
parent
81d9954f37
commit
029a194e46
1 changed files with 9 additions and 2 deletions
|
@ -1,6 +1,9 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import "net"
|
import (
|
||||||
|
"net"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
// ApiHost - the host struct for API usage
|
// ApiHost - the host struct for API usage
|
||||||
type ApiHost struct {
|
type ApiHost struct {
|
||||||
|
@ -76,7 +79,11 @@ func (a *ApiHost) ConvertAPIHostToNMHost(currentHost *Host) *Host {
|
||||||
h.ID = currentHost.ID
|
h.ID = currentHost.ID
|
||||||
h.HostPass = currentHost.HostPass
|
h.HostPass = currentHost.HostPass
|
||||||
h.DaemonInstalled = currentHost.DaemonInstalled
|
h.DaemonInstalled = currentHost.DaemonInstalled
|
||||||
h.EndpointIP = net.ParseIP(a.EndpointIP)
|
if len(a.EndpointIP) == 0 || strings.Contains(a.EndpointIP, "nil") {
|
||||||
|
h.EndpointIP = currentHost.EndpointIP
|
||||||
|
} else {
|
||||||
|
h.EndpointIP = net.ParseIP(a.EndpointIP)
|
||||||
|
}
|
||||||
h.Debug = a.Debug
|
h.Debug = a.Debug
|
||||||
h.FirewallInUse = a.FirewallInUse
|
h.FirewallInUse = a.FirewallInUse
|
||||||
h.IPForwarding = currentHost.IPForwarding
|
h.IPForwarding = currentHost.IPForwarding
|
||||||
|
|
Loading…
Add table
Reference in a new issue