|
|
@@ -364,10 +364,14 @@ func hostUpdateFallback(w http.ResponseWriter, r *http.Request) {
|
|
|
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
|
|
|
return
|
|
|
}
|
|
|
- slog.Info("recieved host update", "name", hostUpdate.Host.Name, "id", hostUpdate.Host.ID, "action", hostUpdate.Action)
|
|
|
+ fmt.Println("recieved host update", "name", hostUpdate.Host.Name, "id", hostUpdate.Host.ID, "action", hostUpdate.Action)
|
|
|
switch hostUpdate.Action {
|
|
|
case models.CheckIn:
|
|
|
sendPeerUpdate = mq.HandleHostCheckin(&hostUpdate.Host, currentHost)
|
|
|
+ changed := logic.CheckHostPorts(currentHost)
|
|
|
+ if changed {
|
|
|
+ mq.HostUpdate(&models.HostUpdate{Action: models.UpdateHost, Host: *currentHost})
|
|
|
+ }
|
|
|
case models.UpdateHost:
|
|
|
if hostUpdate.Host.PublicKey != currentHost.PublicKey {
|
|
|
//remove old peer entry
|
|
|
@@ -407,6 +411,7 @@ func hostUpdateFallback(w http.ResponseWriter, r *http.Request) {
|
|
|
mq.PublishDeletedNodePeerUpdate(&hostUpdate.Node)
|
|
|
}
|
|
|
if sendPeerUpdate {
|
|
|
+ fmt.Println("=====> Sending PEER UPDATE: ", hostUpdate.Action)
|
|
|
err := mq.PublishPeerUpdate(replacePeers)
|
|
|
if err != nil {
|
|
|
slog.Error("failed to publish peer update", "error", err)
|