summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-15 19:49:48 -0600
committerJeff Carr <[email protected]>2024-11-15 19:49:48 -0600
commit141d3024fd4a32d5485e873308ae6414c4867a28 (patch)
treec572c0523216751afc8aa8149c470b6c3f395ff2
parent9d265e0445164f6ef169bb490f3fe9d97a4ef473 (diff)
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.
-rw-r--r--http.go11
1 files changed, 10 insertions, 1 deletions
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
}