Skip to content

feat: add cmd/check-ip reference CLI#138

Open
coolaj86 wants to merge 9 commits into
mainfrom
feat-cmd-check-ip
Open

feat: add cmd/check-ip reference CLI#138
coolaj86 wants to merge 9 commits into
mainfrom
feat-cmd-check-ip

Conversation

@coolaj86

@coolaj86 coolaj86 commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Summary

CLI + HTTP server for checking IPs against blocklists with GeoIP enrichment.

Two modes:

  • CLI: check-ip <ip> [ip...] — look up IPs, output pretty/tsv/csv/json
  • Server: check-ip --serve :8080 — HTTP API with /check and /healthz endpoints

Features:

  • Blocklist loading from git repo (inbound + outbound IP cohorts)
  • GeoLite2 City + ASN via conditional HTTP GET (httpcache)
  • Whitelist override file
  • Hot-swap refresh via sync/dataset (blocklists, geoip, whitelist)
  • Auto-detect format (pretty on TTY, tsv when piped)
  • --geoip-url flag with trailing slash trimming

Usage:

# CLI mode
./check-ip --geoip-conf ./GeoIP.conf 8.8.8.8
./check-ip --format json 8.8.8.8 1.1.1.1

# Server mode
./check-ip --serve :8080 --geoip-conf ./GeoIP.conf
curl http://localhost:8080/check?ip=8.8.8.8
curl http://localhost:8080/healthz

Prerequisites:

Packages used

  • net/ipcohort — IP cohort filter
  • net/geoip — MaxMind GeoLite2 reader
  • net/gitshallow — git repo mirroring
  • net/httpcache — ETag/Last-Modified caching
  • sync/dataset — hot-swap refresh with atomic.Pointer

@coolaj86 coolaj86 force-pushed the feat-cmd-check-ip branch 2 times, most recently from 4cad73c to 4d13c4b Compare April 30, 2026 23:28
@coolaj86 coolaj86 force-pushed the feat-cmd-check-ip branch from 4d13c4b to a50fc99 Compare May 2, 2026 20:40
@coolaj86 coolaj86 force-pushed the feat-cmd-check-ip branch from a50fc99 to 213a219 Compare May 2, 2026 20:52
@coolaj86 coolaj86 force-pushed the feat-cmd-check-ip branch from 213a219 to 2740a50 Compare May 2, 2026 20:53
@coolaj86 coolaj86 force-pushed the feat-cmd-check-ip branch 2 times, most recently from 3ec50cc to 11d90cf Compare May 26, 2026 06:35
@coolaj86 coolaj86 changed the base branch from feat-net-geoip to feat-sync-dataset May 26, 2026 06:39
@coolaj86 coolaj86 force-pushed the feat-sync-dataset branch from 25df840 to 2273e7e Compare May 26, 2026 06:51
@coolaj86 coolaj86 force-pushed the feat-cmd-check-ip branch 3 times, most recently from 9afa9d0 to 575048d Compare May 26, 2026 07:08
@coolaj86 coolaj86 force-pushed the feat-sync-dataset branch from 2273e7e to 7dc6446 Compare May 27, 2026 04:10
@coolaj86 coolaj86 force-pushed the feat-cmd-check-ip branch from 575048d to 4723e81 Compare May 27, 2026 04:16
@coolaj86 coolaj86 force-pushed the feat-sync-dataset branch 2 times, most recently from 8b93a69 to 17d50e5 Compare May 27, 2026 04:26
@coolaj86 coolaj86 force-pushed the feat-cmd-check-ip branch from 4723e81 to 4272cfb Compare May 27, 2026 04:36
@coolaj86 coolaj86 force-pushed the feat-sync-dataset branch 2 times, most recently from 2b2b164 to a408dc8 Compare May 27, 2026 04:46
@coolaj86 coolaj86 force-pushed the feat-cmd-check-ip branch from 4272cfb to 8d12e66 Compare May 27, 2026 04:46
Base automatically changed from feat-sync-dataset to main May 27, 2026 04:49
@coolaj86 coolaj86 force-pushed the feat-cmd-check-ip branch from 8d12e66 to dfd2aec Compare May 27, 2026 04:59
@socket-security

socket-security Bot commented May 27, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgithub.com/​therootcompany/​golib/​net/​geoip@​v0.5.010010010010070
Addedgithub.com/​therootcompany/​golib/​sync/​dataset@​v0.5.010010010010070

View full report

Ties gitshallow, httpcache, geoip, ipcohort, and sync/dataset together
into a single tool that resolves an IP against the configured blocklist
and GeoIP databases, with optional --serve mode for production use.

Flags: --git, --blocklist, --whitelist, --geoip-conf, --serve,
--async-load, --format pretty|json, plus -V/--version and help.
Includes /healthz, http.Server timeouts, and stage-timing logs to stderr.
@coolaj86 coolaj86 force-pushed the feat-cmd-check-ip branch from dfd2aec to f81ff76 Compare May 27, 2026 05:38
coolaj86 added 7 commits May 27, 2026 01:29
…olution, and richer GeoIP data

- Embed web UI (index.html, app.js, style.css) via go:embed
- Title: 'IP Location & Status' instead of 'check-ip'
- 'Show my IP Info' link for lookups of the visitor's own IP
- Domain resolution with resolved_from field in JSON
- Richer GeoIP fields: region ISO, continent, coordinates, traits, etc.
- /api/raw debug endpoint for raw MaxMind records
- net/geoip: expand Info struct and add LookupRaw method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant