diff options
Diffstat (limited to 'machine.go')
| -rw-r--r-- | machine.go | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -1,6 +1,11 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + package main import ( + "net/http" + "strings" "time" "go.wit.com/lib/protobuf/zoopb" @@ -8,6 +13,26 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" ) +func handleMachine(w http.ResponseWriter, hostname string, data []byte) { + hostname = strings.TrimSpace(hostname) + if hostname == "" { + log.Info("something went wrong. hostname is blank") + } + log.Info("lookoing for", hostname) + m := me.machines.FindByHostname(hostname) + if m == nil { + newm := new(zoopb.Machine) + err := newm.Unmarshal(data) + if err != nil { + log.Info("machine Unmarshal() failed", hostname) + return + } + me.machines.Append(newm) + return + } + log.Info("not new machine", hostname) +} + // someone sent machine 'u' is it new? // if not, update the record of it func updateMachine(u *zoopb.Machine) string { @@ -18,6 +43,8 @@ func updateMachine(u *zoopb.Machine) string { if m == nil { log.Info("adding new machine", u.Hostname) me.machines.Append(u) + log.Info("save machines pb file here...") + // me.machines.ConfigSave() return "new" } // log.Info("updating machine", m.Hostname) |
