|
@@ -133,19 +133,30 @@ func UpdateHost(newHost, currentHost *models.Host) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-func UpdateHostFromClient(newHost, currHost *models.Host) {
|
|
|
|
|
|
+// UpdateHostFromClient - used for host update recieved from netclient
|
|
|
|
+func UpdateHostFromClient(newHost, currHost *models.Host) (sendPeerUpdate bool) {
|
|
|
|
|
|
- if newHost.ListenPort != 0 {
|
|
|
|
|
|
+ if newHost.ListenPort != 0 && currHost.ListenPort != newHost.ListenPort {
|
|
currHost.ListenPort = newHost.ListenPort
|
|
currHost.ListenPort = newHost.ListenPort
|
|
|
|
+ sendPeerUpdate = true
|
|
}
|
|
}
|
|
- if newHost.ProxyListenPort != 0 {
|
|
|
|
|
|
+ if newHost.ProxyListenPort != 0 && currHost.ProxyListenPort != newHost.ProxyListenPort {
|
|
currHost.ProxyListenPort = newHost.ProxyListenPort
|
|
currHost.ProxyListenPort = newHost.ProxyListenPort
|
|
|
|
+ sendPeerUpdate = true
|
|
|
|
+ }
|
|
|
|
+ if currHost.ProxyEnabled != newHost.ProxyEnabled {
|
|
|
|
+ currHost.ProxyEnabled = newHost.ProxyEnabled
|
|
|
|
+ sendPeerUpdate = true
|
|
|
|
+ }
|
|
|
|
+ if currHost.EndpointIP.String() != newHost.EndpointIP.String() {
|
|
|
|
+ currHost.EndpointIP = newHost.EndpointIP
|
|
|
|
+ sendPeerUpdate = true
|
|
}
|
|
}
|
|
- currHost.ProxyEnabled = newHost.ProxyEnabled
|
|
|
|
currHost.DaemonInstalled = newHost.DaemonInstalled
|
|
currHost.DaemonInstalled = newHost.DaemonInstalled
|
|
currHost.Debug = newHost.Debug
|
|
currHost.Debug = newHost.Debug
|
|
currHost.Verbosity = newHost.Verbosity
|
|
currHost.Verbosity = newHost.Verbosity
|
|
currHost.Version = newHost.Version
|
|
currHost.Version = newHost.Version
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
// UpsertHost - upserts into DB a given host model, does not check for existence*
|
|
// UpsertHost - upserts into DB a given host model, does not check for existence*
|