$ show productdevbook/port-killer
PortKiller is a cross-platform desktop application for developers to monitor, manage, and kill processes listening on TCP ports. It provides a unified interface across macOS (SwiftUI), Windows (.NET 9 / WinUI 3), and Linux (Python GTK3 + Rust core) with features including real-time port scanning, process type detection, favorites and watched ports with notifications, two-stage process termination (SIGTERM → SIGKILL), Kubernetes port-forward management with auto-reconnect, and Cloudflare tunnel integration (quick and named tunnels). The application also includes an onboarding wizard, sponsor/contributor display, Sparkle-based auto-updates (macOS), and extensive keyboard shortcut support. The architecture is platform-native with shared patterns: each platform implements its own UI layer, port scanner, and process killer, while a Rust core library (`portkiller-core`) provides scanning and process termination for Linux. The macOS version uses an actor-based `PortScanner` and observable state management (`AppState`), the Windows version follows MVVM with a system tray mini-window, and the Linux version uses a GTK3 system tray indicator. All platforms share a common feature set but with varying completeness (macOS is the most feature-rich). External dependencies include `lsof`/`ss` (Linux), `kubectl`, `cloudflared`, `socat`, and system utilities for process enumeration. Key data flows: port scanning via platform-specific commands (lsof, ss, GetExtendedTcpTable) → parsing into `PortInfo` models → filtering/searching → display in tree/table views → user actions (kill, watch, favorite, forward, tunnel). Kubernetes port-forwards and Cloudflare tunnels are managed as subprocesses with monitoring loops for reconnection and log streaming. The application persists user preferences (favorites, watched ports, customizations) using platform-native storage (Defaults on macOS, JSON on Windows/Linux).
The LLM identified 5 files worth highlighting for reuse:
Defines the application's color palette as a set of named constants (e.g., `brandGradient`, `surfaceBackground`, `textPrimary`). This module is self-contained, has no internal dependencies, and can be extracted into any SwiftUI project to enforce consistent theming. It demonstrates clean separation of design tokens from business logic.
Defines a Swift protocol (interface) for port scanning operations (`scan`, `killProcess`, `getProcessCommand`). This abstraction enables dependency injection, making the macOS app testable and allowing different scanner implementations (e.g., real vs. mock). It is isolated, imports only model types, and can be reused in any Swift application needing a pluggable port scanner.
Encapsulates the lifecycle of external subprocesses (kubectl, cloudflared, socat) with support for stdin/stdout piping, deadlock avoidance, and timeout handling. It is a self-contained service that can be extracted for any Swift application that needs robust subprocess management. The implementation uses Swift actors for thread-safe communication and demonstrates careful resource cleanup.
Defines a Rust trait (`ProcessManager`) with methods for killing a process by PID and checking if a process is alive, along with a Linux implementation using signals (SIGTERM → SIGKILL). The trait is platform-agnostic and can be implemented for other OSes. This module is standalone, has minimal dependencies, and can be reused in any Rust project needing process lifecycle management.
Provides static methods to parse output from `ss -tlnp` and `lsof -i -P -n` into structured `PortInfo` objects. It handles edge cases like hex-encoded process names and multiple listening sockets. This module is self-contained (only depends on standard library and a models module) and can be extracted into any Python project that needs to enumerate listening ports without external dependencies beyond system tools.