-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture
mendsec edited this page Jun 23, 2026
·
1 revision
- catnet is a consumer, not an engine. All network logic lives in catnet-core. catnet MUST NOT implement scanning logic directly.
- stdout is for data, stderr is for humans. Machine-readable output goes to stdout; progress, warnings, and lifecycle events go to stderr.
- Exit codes are a contract. See Output Reference.
cmd/catnet/main.go — entry point, ExitError unwrap
internal/cli/
root.go — Cobra root, persistent flags
scan.go — scan subcommand
export.go — export subcommand
version.go — version subcommand
signals.go — SIGINT/SIGTERM context wiring
errors.go — ExitError type, exit codes
output/
human.go — tabwriter + ANSI colour adapter
json.go — silent adapter (stderr only)
tests/
integration_test.go — subprocess-based E2E tests
testdata/
expected_output.json — canonical JSON fixture
User → catnet scan args
│
▼
targets.ParseRange (catnet-core)
│
▼
engine.StartScan (catnet-core)
│
▼
EventCallback → output adapter → stdout/stderr
│
▼
exporter.ExportJSON (catnet-core) → file or stdout
catnet
├── catnet-core v0.2.0 (zero external deps)
├── github.com/spf13/cobra v1.10.2
└── github.com/spf13/pflag v1.0.9 (indirect)
- Implement the
OutputHandlerinterface ininternal/cli/output/. - Register in
scan.goformat switch. - Add integration test case in
TestScanOutputJSON. - Document in Output Reference and CLI Reference.
signals.go uses signal.NotifyContext to wire SIGINT (all platforms) and SIGTERM (Unix) to a context cancellation. When the context is cancelled, engine.StartScan stops early and returns a partial report. The process exits with code 130.
© 2026 Fábio Mendes · MIT License · catnet · catnet-core · Report an issue
catnet Wiki
Getting Started
Reference
Guides
Project