{"id":46604813,"url":"https://github.com/0x1f6/dashcap","last_synced_at":"2026-03-10T20:01:53.305Z","repository":{"id":342024864,"uuid":"1172491134","full_name":"0x1f6/dashcap","owner":"0x1f6","description":"A network packet dashcam — continuous full-packet capture with on-demand persistence","archived":false,"fork":false,"pushed_at":"2026-03-09T13:30:26.000Z","size":387,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-09T22:45:07.620Z","etag":null,"topics":["cli","dashcam","forensics","go","golang","gopacket","incident-response","network-monitoring","network-security","packet-capture","pcap","pcapng","ring-buffer","wireshark"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0x1f6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-04T11:19:06.000Z","updated_at":"2026-03-09T13:30:29.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/0x1f6/dashcap","commit_stats":null,"previous_names":["0x1f6/dashcap"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/0x1f6/dashcap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x1f6%2Fdashcap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x1f6%2Fdashcap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x1f6%2Fdashcap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x1f6%2Fdashcap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0x1f6","download_url":"https://codeload.github.com/0x1f6/dashcap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0x1f6%2Fdashcap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30351711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T15:55:29.454Z","status":"ssl_error","status_checked_at":"2026-03-10T15:54:58.440Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","dashcam","forensics","go","golang","gopacket","incident-response","network-monitoring","network-security","packet-capture","pcap","pcapng","ring-buffer","wireshark"],"created_at":"2026-03-07T17:11:37.828Z","updated_at":"2026-03-10T20:01:53.254Z","avatar_url":"https://github.com/0x1f6.png","language":"Go","readme":"# dashcap\n\nA network packet dashcam — continuous full-packet capture with on-demand persistence.\n\n\u003e **Work in progress.** dashcap is under active development and not yet stable or suitable for production use. APIs, CLI flags, and on-disk formats may change without notice.\n\ndashcap continuously captures all network traffic into a pre-allocated ring buffer of pcapng segments. When triggered (via the REST API), it saves the relevant capture window — including traffic from *before* the trigger — for later analysis. Think of it as a dashcam for your network: always recording, only saving when something happens.\n\n## How It Works\n\n```\nNetwork Interface → Capture Engine → Segment Writer → Ring Buffer (fixed size, overwrites oldest)\n                                                            ↓ on trigger\n                                                      Saved Captures (pcapng + metadata.json)\n```\n\n- Packets are captured via libpcap (Linux/macOS) or Npcap (Windows) and written into fixed-size pcapng segment files\n- Segments rotate in a ring — when the buffer is full, the oldest segment is overwritten\n- All disk space is pre-allocated at startup; the footprint is constant at `segment_count * segment_size`\n- A trigger merges the relevant time window into a single `capture.pcapng` in a `saved/` directory with metadata\n\n## Status\n\n**Phase 1 (MVP) is complete.** The core capture-to-disk pipeline with REST API triggers works on Linux. See [DESIGN.md](DESIGN.md) for the full roadmap.\n\nWhat's implemented:\n- `gopacket/pcap` capture backend (cross-platform)\n- pcapng segment writer with accurate byte tracking\n- Ring buffer with pre-allocated segments and rotation\n- REST API with `/trigger`, `/status`, `/health`, `/ring`, `/triggers` endpoints\n- Bearer-token API authentication (enabled by default, auto-generated token)\n- TLS support for the API server (`--tls-cert` / `--tls-key`)\n- Built-in CLI client (`dashcap client`) with human-readable and JSON output modes\n- Triggered saves merge segments into a single `capture.pcapng` file\n- Interface locking (one instance per interface)\n- Disk safety checks (absolute + percentage-based free space thresholds)\n- Platform-aware paths (Linux, macOS, Windows)\n\n## Prerequisites\n\n| Platform | Requirement |\n|----------|-------------|\n| Linux    | `libpcap-dev` (`apt install libpcap-dev` or `dnf install libpcap-devel`) |\n| Windows  | [Npcap](https://npcap.com/) installed (same as Wireshark) |\n| macOS    | libpcap (ships with Xcode Command Line Tools) |\n| All      | Go 1.25+ with CGO enabled |\n\n## Building\n\n```bash\nmake build          # → bin/dashcap\n```\n\nThe binary requires `CGO_ENABLED=1` because gopacket links against libpcap. This is handled automatically by the Makefile.\n\nFor cross-compilation (requires platform-specific libpcap/Npcap SDK):\n\n```bash\nmake cross          # → dist/dashcap-linux-amd64, dist/dashcap-windows-amd64.exe, dist/dashcap-darwin-arm64\n```\n\n## Quick Start\n\nThis example uses the loopback interface (`lo`) so you can try it without any special hardware or permissions beyond `CAP_NET_RAW`.\n\n### 1. Build and start dashcap\n\n```bash\nmake build\n\n# Start with a small ring buffer (10 MB total, 1 MB segments = 10 segments)\nsudo bin/dashcap -i lo --buffer-size 10MB --segment-size 1MB --api-port 9800\n```\n\nYou should see:\n\n```\ntime=... level=INFO msg=\"API token generated\" token=\u003cgenerated-token\u003e\ntime=... level=INFO msg=\"dashcap starting\" version=dev interface=lo\ntime=... level=INFO msg=\"ring buffer configured\" segments=10 segment_mb=1 total_mb=10\ntime=... level=INFO msg=\"ring pre-allocated\" path=/var/lib/dashcap/lo\ntime=... level=WARN msg=\"API auth enabled without TLS — tokens sent in cleartext\"\ntime=... level=INFO msg=\"REST API listening\" port=9800 proto=HTTP\n```\n\nCopy the API token from the output — you'll need it for all API requests (except `/health`). To use a predictable token, pass `--api-token \u003cvalue\u003e` or set `DASHCAP_API_TOKEN=\u003cvalue\u003e`.\n\n### 2. Generate some traffic\n\nIn a second terminal:\n\n```bash\nping -c 100 127.0.0.1\n# or\ncurl http://127.0.0.1:9800/api/v1/health\n```\n\n### 3. Check status\n\nUsing the built-in client (recommended):\n\n```bash\ndashcap client status --token \u003ctoken\u003e\n```\n\nOr with curl:\n\n```bash\ncurl -s -H \"Authorization: Bearer \u003ctoken\u003e\" http://127.0.0.1:9800/api/v1/status | python3 -m json.tool\n```\n\n```json\n{\n    \"interface\": \"lo\",\n    \"uptime\": \"42s\",\n    \"segment_count\": 10,\n    \"total_packets\": 200,\n    \"total_bytes\": 19600\n}\n```\n\n### 4. Trigger a save\n\n```bash\ndashcap client trigger --token \u003ctoken\u003e\n```\n\nOr with curl:\n\n```bash\ncurl -s -X POST -H \"Authorization: Bearer \u003ctoken\u003e\" http://127.0.0.1:9800/api/v1/trigger | python3 -m json.tool\n```\n\n```json\n{\n    \"id\": \"1740960600000000000-1\",\n    \"timestamp\": \"2026-03-02T22:30:00Z\",\n    \"source\": \"api\",\n    \"status\": \"pending\"\n}\n```\n\n### 5. Inspect the saved capture\n\n```bash\nls /var/lib/dashcap/lo/saved/\n# → 2026-03-02T22-30-00_api/\n\ncat /var/lib/dashcap/lo/saved/2026-03-02T22-30-00_api/metadata.json\n# → trigger metadata with capture path\n\n# Open in Wireshark (all segments merged into one file):\nwireshark /var/lib/dashcap/lo/saved/2026-03-02T22-30-00_api/capture.pcapng\n```\n\n### 6. View ring buffer state\n\n```bash\ndashcap client ring --token \u003ctoken\u003e\n```\n\nOr with curl:\n\n```bash\ncurl -s -H \"Authorization: Bearer \u003ctoken\u003e\" http://127.0.0.1:9800/api/v1/ring | python3 -m json.tool\n```\n\n### 7. Stop dashcap\n\nPress `Ctrl+C` or send `SIGTERM` — dashcap flushes the active segment and exits cleanly.\n\n## CLI Reference\n\n### Server Flags\n\nThese flags configure the capture daemon (the root `dashcap` command):\n\n| Flag | Default | Description |\n|------|---------|-------------|\n| `-i`, `--interface` | *(required)* | Network interface to capture on |\n| `--buffer-size` | `2GB` | Total ring buffer size (e.g. `2GB`, `500MB`) |\n| `--segment-size` | `100MB` | Size of each ring segment (e.g. `100MB`, `1MB`) |\n| `--data-dir` | `/var/lib/dashcap/\u003cinterface\u003e` | Data directory for ring and saved captures |\n| `--api-port` | `9800` | TCP port for REST API (`0` = disabled) |\n| `--api-token` | *(auto-generated)* | Bearer token for API authentication |\n| `--no-auth` | `false` | Disable API authentication entirely |\n| `--tls-cert` | | Path to TLS certificate file (requires `--tls-key`) |\n| `--tls-key` | | Path to TLS private key file (requires `--tls-cert`) |\n| `--default-duration` | `5m` | Default time window to save on trigger |\n| `--promiscuous` | `true` | Enable promiscuous mode on the interface |\n| `--snaplen` | `0` | Snapshot length (`0` = full packets) |\n| `--debug` | `false` | Enable debug-level logging (ring rotations, packet details) |\n\n### Client Flags\n\nThese flags configure the `dashcap client` subcommand group for interacting with a running dashcap instance:\n\n| Flag | Default | Description |\n|------|---------|-------------|\n| `--host` | `localhost` | API server host |\n| `--port` | `9800` | API server port |\n| `--token` | | Bearer token (falls back to `$DASHCAP_API_TOKEN`) |\n| `--tls` | `false` | Use HTTPS |\n| `--tls-skip-verify` | `false` | Skip TLS certificate verification |\n| `--pretty` | *(auto)* | Force human-readable output |\n| `--json` | *(auto)* | Force JSON output |\n\nOutput mode is auto-detected: pretty when stdout is a TTY, JSON when piped. Use `--pretty` or `--json` to override.\n\n### Environment Variables\n\n| Variable | Description |\n|----------|-------------|\n| `DASHCAP_API_TOKEN` | API token — used by both server (overridden by `--api-token`) and client (overridden by `--token`) |\n\n### Subcommands\n\n```bash\ndashcap version                # Print version, commit, and build time\ndashcap client health          # Check server health\ndashcap client status          # Show capture status (interface, uptime, packets, bytes)\ndashcap client trigger         # Trigger a capture save\ndashcap client trigger --duration 30s   # Trigger with custom duration\ndashcap client trigger --since 2024-01-01T00:00:00Z  # Trigger from specific time\ndashcap client triggers        # List trigger history\ndashcap client ring            # Show ring buffer segment metadata\n```\n\n## REST API\n\nAll endpoints return JSON. The API listens on the port specified by `--api-port`.\n\n**Authentication:** All endpoints except `/health` require a bearer token. Include the header `Authorization: Bearer \u003ctoken\u003e` with every request. The token is printed to stderr at startup. Disable auth with `--no-auth`.\n\n**TLS:** Pass `--tls-cert` and `--tls-key` to enable HTTPS. Without TLS, tokens are sent in cleartext (a warning is logged).\n\n| Method | Endpoint | Auth | Description |\n|--------|----------|------|-------------|\n| `GET` | `/api/v1/health` | No | Liveness check — returns `{\"status\": \"ok\"}` |\n| `GET` | `/api/v1/status` | Yes | Instance status: interface, uptime, packet/byte counts |\n| `POST` | `/api/v1/trigger` | Yes | Trigger a save of the pre-trigger window |\n| `GET` | `/api/v1/triggers` | Yes | List all trigger records (newest first) |\n| `GET` | `/api/v1/ring` | Yes | Per-segment metadata: index, path, timestamps, packet/byte counts |\n\n## Configuration\n\ndashcap is configured via CLI flags. YAML configuration file support is planned for Phase 2.\n\nAn example configuration file is provided at [`configs/dashcap.example.yaml`](configs/dashcap.example.yaml) for reference.\n\n## Project Structure\n\n```\ndashcap/\n├── cmd/dashcap/           # CLI entry point (Cobra)\n├── internal/\n│   ├── api/               # REST API server (net/http)\n│   ├── buffer/            # Ring manager + pcapng segment writer\n│   ├── capture/           # Packet capture abstraction (gopacket/pcap)\n│   ├── client/            # HTTP client for the REST API (used by `dashcap client`)\n│   ├── config/            # Runtime configuration + validation\n│   ├── persist/           # Save triggered captures to disk\n│   ├── storage/           # Platform-specific disk ops (prealloc, flock, free space)\n│   └── trigger/           # Trigger dispatcher (API-triggered saves)\n├── configs/               # Example configuration\n├── DESIGN.md              # Full architecture and design document\n├── Makefile               # Build, test, lint, cross-compile targets\n└── go.mod\n```\n\n## CI/CD\n\nGitHub Actions runs on every push and PR to `main`:\n\n- **CI** (`.github/workflows/ci.yml`): lint (`golangci-lint`), test (race detector + coverage), build verification\n- **Release** (`.github/workflows/release.yml`): triggered on `v*` tags or manually. Builds Linux amd64 and Windows amd64 binaries, creates a GitHub Release with SHA256 checksums.\n- **Dependabot** (`.github/dependabot.yml`): weekly updates for Go modules and GitHub Actions versions.\n\n## Development\n\n```bash\nmake test           # Run tests with race detector\nmake lint           # Run golangci-lint\nmake fmt            # Format code (gofmt + goimports)\nmake cover          # Generate coverage report (coverage.html)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0x1f6%2Fdashcap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0x1f6%2Fdashcap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0x1f6%2Fdashcap/lists"}