mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-10-15 19:51:24 +00:00
## Summary The README is the repo's front page. I checked each claim against `master` and fixed what no longer holds. | README said | Now | Source | |---|---|---| | `POST /api/packets` for manual injection | route is GET only; points at `POST /api/decode` | `cmd/server/routes.go:317`, `:320` | | `PORT` env var overrides the port | not read anywhere; documents `port` and `-port` | `cmd/server/main.go:96` | | 5 store indexes | 7 (`byPathHop`, `byPayloadType` added) | `cmd/server/store.go:222-231` | | 11 analytics tabs | 17 `data-tab` values | `public/analytics.js` | | VCR up to 4× | up to 8× | `public/live.js:681` | | 14 Go modules | 16 `go.mod` files (also fixed in the `Makefile` header comment) | | | 327 / 53 / 380 Go tests, 150+ Node, 49 Playwright | 1827 / 710 / 2742 `func Test`, 199 unit files, 131 `test(` calls; counts removed so they stop going stale | | | live instance + Swagger on analyzer.00id.net | times out (from two networks, 2026-10-13); links analyzer.on8ar.eu, `/api/docs` and `/api/spec` return 200 there | curl | Added: Scope Audit in the feature list, and an "Optional Features" section for user accounts and mobile RX coverage, each linking its existing doc. ## Not checked - the performance figures (~300 MB for 56K packets, < 1 ms queries) - the "AES-128-ECB with rainbow table" line - whether the screenshots still match the current UI - the "-or-later" in the license line (`LICENSE` is GPL v3) Docs only, no tests run. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
140 lines
5.3 KiB
Makefile
140 lines
5.3 KiB
Makefile
# corescope build entry point.
|
|
#
|
|
# This repo is 16 Go modules wired with `replace ../../internal/*` and no
|
|
# go.work, so every recipe changes into its module. The build flags live here
|
|
# because the SQLite driver is cgo now (github.com/mattn/go-sqlite3) and the
|
|
# flags stopped being something you can safely retype at each call site.
|
|
#
|
|
# Cross-compilation uses `zig cc` as the C toolchain, targeting musl so the
|
|
# binaries are fully static and run on the alpine runtime image (or scratch)
|
|
# with no libc dependency at all.
|
|
#
|
|
# Quick reference:
|
|
# make build # all four binaries for the host
|
|
# make build-server # just one
|
|
# make crossbuild # linux/amd64 + linux/arm64, static, into dist/
|
|
# make test / vet / fmt-check # across all modules
|
|
# make docker-build # multi-arch image via buildx
|
|
|
|
GO ?= $(shell command -v go)
|
|
GIT_VERSION ?= $(shell git describe --tags --match "v*" 2>/dev/null || echo unknown)
|
|
GIT_COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
|
BUILD_TIME ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
|
|
GOENV_GOOS := $(shell $(GO) env GOOS)
|
|
GOENV_GOARCH := $(shell $(GO) env GOARCH)
|
|
GOOS ?= $(GOENV_GOOS)
|
|
GOARCH ?= $(GOENV_GOARCH)
|
|
|
|
# Exported: a bare make variable never reaches the go toolchain.
|
|
export CGO_ENABLED ?= 1
|
|
|
|
# netgo/osusergo keep the pure-Go resolver and user lookup the binaries had
|
|
# under CGO_ENABLED=0, so enabling cgo for SQLite does not quietly switch DNS
|
|
# resolution to the C resolver. sqlite_omit_load_extension drops the dlopen
|
|
# path, which is what lets -extldflags -static link cleanly. -Wl,-s on the
|
|
# cross builds strips the musl objects zig links in: Go's own -s -w does not
|
|
# reach them, and they account for well over half the binary.
|
|
GO_BUILD_TAGS ?= netgo,osusergo,sqlite_omit_load_extension
|
|
GO_BUILD_FLAGS ?= -trimpath
|
|
GO_LDFLAGS_OPTIMS ?= -s -w
|
|
|
|
CMDS := server ingestor decrypt migrate
|
|
DIST := dist
|
|
|
|
# Per-binary version stamping. Only these two read build metadata; ingestor and
|
|
# migrate take none. Kept as make variables so crossbuild and the host build
|
|
# cannot drift apart.
|
|
LDFLAGS_server := -X main.Version=$(GIT_VERSION) -X main.Commit=$(GIT_COMMIT) -X main.BuildTime=$(BUILD_TIME)
|
|
LDFLAGS_ingestor :=
|
|
LDFLAGS_decrypt := -X main.version=$(GIT_VERSION)
|
|
LDFLAGS_migrate :=
|
|
|
|
# zig target triples for the platforms we ship. musl, so the result is static.
|
|
ZIG_TARGET_linux_amd64 := x86_64-linux-musl
|
|
ZIG_TARGET_linux_arm64 := aarch64-linux-musl
|
|
CROSS_PLATFORMS := linux/amd64 linux/arm64
|
|
|
|
DOCKER_IMAGE ?= ghcr.io/kpa-clawbot/corescope
|
|
DOCKER_TAG ?= $(GIT_VERSION)
|
|
DOCKER_PLATFORMS ?= linux/amd64,linux/arm64
|
|
|
|
.PHONY: all build crossbuild test vet fmt-check tidy clean docker-build docker-push help
|
|
|
|
all: build
|
|
|
|
help:
|
|
@echo "targets: build crossbuild test vet fmt-check tidy clean docker-build docker-push"
|
|
@echo " build-{$(shell echo $(CMDS) | tr ' ' ',')}"
|
|
|
|
# -- host builds ---------------------------------------------------------------
|
|
|
|
build: $(addprefix build-,$(CMDS))
|
|
|
|
build-%:
|
|
@mkdir -p $(DIST)
|
|
cd cmd/$* && GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) build \
|
|
-tags $(GO_BUILD_TAGS) $(GO_BUILD_FLAGS) \
|
|
-ldflags "$(GO_LDFLAGS_OPTIMS) $(LDFLAGS_$*)" \
|
|
-o ../../$(DIST)/corescope-$* .
|
|
|
|
# -- cross builds --------------------------------------------------------------
|
|
#
|
|
# The host build above deliberately leaves CC alone: native builds, `go vet` and
|
|
# `-race` must use the host compiler. Only these recipes hand the build to zig.
|
|
|
|
crossbuild: $(foreach p,$(CROSS_PLATFORMS),$(foreach c,$(CMDS),crossbuild-$(c)-$(subst /,-,$(p))))
|
|
|
|
define CROSSBUILD_RULE
|
|
.PHONY: crossbuild-$(2)-$(3)-$(4)
|
|
crossbuild-$(2)-$(3)-$(4):
|
|
@mkdir -p $$(DIST)
|
|
@command -v zig >/dev/null || { echo "zig not found: needed to cross-compile cgo. See https://ziglang.org/download/"; exit 1; }
|
|
cd cmd/$(2) && CGO_ENABLED=1 GOOS=$(3) GOARCH=$(4) CC="zig cc -target $(1)" \
|
|
$$(GO) build -tags $$(GO_BUILD_TAGS) $$(GO_BUILD_FLAGS) \
|
|
-ldflags '$$(GO_LDFLAGS_OPTIMS) -extldflags "-static -Wl,-s" $$(LDFLAGS_$(2))' \
|
|
-o ../../$$(DIST)/corescope-$(2)-$(3)-$(4) .
|
|
endef
|
|
|
|
$(foreach c,$(CMDS),\
|
|
$(eval $(call CROSSBUILD_RULE,$(ZIG_TARGET_linux_amd64),$(c),linux,amd64))\
|
|
$(eval $(call CROSSBUILD_RULE,$(ZIG_TARGET_linux_arm64),$(c),linux,arm64)))
|
|
|
|
# -- checks --------------------------------------------------------------------
|
|
|
|
test:
|
|
bash scripts/allmod.sh test ./...
|
|
|
|
vet:
|
|
bash scripts/allmod.sh vet ./...
|
|
|
|
fmt-check:
|
|
@unformatted=$$(gofmt -l $$(git ls-files '*.go' | grep -vi 'Dockerfile.go')); \
|
|
if [ -n "$$unformatted" ]; then echo "gofmt required on:"; echo "$$unformatted"; exit 1; fi; \
|
|
echo "gofmt: clean"
|
|
|
|
tidy:
|
|
bash scripts/allmod.sh mod tidy
|
|
|
|
clean:
|
|
rm -rf $(DIST)
|
|
|
|
# -- docker --------------------------------------------------------------------
|
|
|
|
docker-build:
|
|
docker buildx build . \
|
|
--platform=$(DOCKER_PLATFORMS) \
|
|
--build-arg=APP_VERSION=$(GIT_VERSION) \
|
|
--build-arg=GIT_COMMIT=$(GIT_COMMIT) \
|
|
--build-arg=BUILD_TIME=$(BUILD_TIME) \
|
|
-t $(DOCKER_IMAGE):$(DOCKER_TAG)
|
|
|
|
docker-push: DOCKER_PUSH_FLAG := --push
|
|
docker-push:
|
|
docker buildx build . \
|
|
--platform=$(DOCKER_PLATFORMS) \
|
|
--build-arg=APP_VERSION=$(GIT_VERSION) \
|
|
--build-arg=GIT_COMMIT=$(GIT_COMMIT) \
|
|
--build-arg=BUILD_TIME=$(BUILD_TIME) \
|
|
-t $(DOCKER_IMAGE):$(DOCKER_TAG) $(DOCKER_PUSH_FLAG)
|