Skip to content

v0.8.0

Latest

Choose a tag to compare

@cmj0121 cmj0121 released this 12 May 01:30
· 6 commits to main since this release

Highlights

  • GET /sysinfo — neofetch-style system banner — opt-in route (requires --sysinfo flag) that renders hostname, OS name + version, kernel version, CPU model + core count, total RAM, uptime, and load averages as a standard pylon multi-caption card. Data is collected by a platform-specific Collector (Linux reads /proc/*; Darwin shells out to sysctl with a 2 s timeout; other platforms return runtime stubs) and cached atomically every five seconds via a background refresher goroutine — the handler never blocks on syscalls. Cache-Control: max-age=5 on every response matches the refresh cadence. State-transition logging (log once on ok→fail, once on fail→ok) prevents log floods on sustained collection failures. /sysinfo is deliberately gated behind --sysinfo because hostname + OS + kernel + CPU model is enough to fingerprint an exact cloud instance type and cross-reference unpatched CVEs; see docs/security.md.

  • GET /metrics — always-on route analytics — renders per-route request counts since process start as a left-aligned tabular banner. Routes are sorted by count descending, with lexicographic tiebreaking. Counts are in-process only (no external store). The counter middleware is registered as the first r.Use() so every request — including htmlcache hits — is counted. /healthz and /robots.txt are registered in server.New() before the middleware and are intentionally excluded (infra-probe noise). Route patterns (e.g. /stock/:symbol) are visible in the output; unregistered paths are counted under the sentinel no-route. No flag required.

  • buildBlocks signature refactor — the 20-parameter buildBlocks function in service/stock is collapsed into a stockRenderInput struct. No behavior change; removes a class of call-site errors and makes the stock render pipeline easier to extend.

  • Locale regression testsTestBareZhResolvesToZhTW pins ?lang=zh → zh-TW (Traditional, not Simplified); TestCFIPCountryLocaleResolution pins TW/HK/MO → zh-TW and CN/SG → zh-CN via the CF-IPCountry header. Unit tests added for formatThousands, formatLargeNumber, and rocYearMonthLabel edge cases.

Other changes

  • middleware/reqcounter: sync.Map + *atomic.Int64 per-route counter, lock-free Snapshot() (sorted copy), Uptime() since process start. 50-goroutine concurrent increment test confirms no data race under -race.
  • Darwin sysinfo collector uses exec.CommandContext with a 2 s deadline instead of bare exec.Command — prevents the background refresher goroutine from blocking indefinitely on a hung sysctl subprocess.
  • .github/workflows/test.yml cross-compile step: GOOS=darwin go build ./... on the ubuntu-latest runner ensures darwin-tagged files compile cleanly in CI even without a macOS runner.
  • docs/security.md extended with /sysinfo (infrastructure disclosure, CVE fingerprinting risk, CDN caching caveat) and /metrics (route pattern disclosure) sections.

Container image

ghcr.io/cmj0121/imagelet:0.8.0