From 141d3024fd4a32d5485e873308ae6414c4867a28 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 15 Nov 2024 19:49:48 -0600 Subject: [PATCH] zoo daemon sends package list over wire man. long live google protobuf. It's amazing. This thing just sent all 3k of the package info over http in raw wire format. I'm sure this isn't neat to anyone young but to old hacks like me, it's fucking magic how wonderfully advanced the language and codebase is. It just reminds you how there are actually beautiful things in the world. --- http.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/http.go b/http.go index 6ff3bb1..af3d16f 100644 --- a/http.go +++ b/http.go @@ -6,6 +6,7 @@ import ( "net/http" "strings" + "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" ) @@ -37,7 +38,15 @@ func okHandler(w http.ResponseWriter, r *http.Request) { log.Info("hostname was blank") return } - log.Info("Got URL msg length:", len(msg)) + var packs *zoopb.Packages + packs = new(zoopb.Packages) + if err := packs.Unmarshal(msg); err != nil { + log.Info("proto.Unmarshal() failed on wire message len", len(msg), "from", hostname) + return + } + + log.Info("Unmarshal worked with msg len", len(msg), "from", hostname) + log.Info(hostname, "has", packs.Len(), "packages installed") return }