portwatch-0.1.6 is not a library.
PortWatch
A cross-platform TUI (Terminal User Interface) for monitoring network ports and managing processes. Built with Rust for performance and portability.
Features
- 🔍 Real-time Port Monitoring - View all listening and established connections
- 🖥️ Process Details - Inspect memory, CPU, command line, and environment variables
- ⚡ Process Control - Gracefully terminate or force kill processes
- 🔎 Smart Filtering - Filter by port number, process name, protocol, or state
- 🎨 Rich TUI - Clean interface with color-coded states and intuitive navigation
- 🌍 Cross-Platform - Works on Linux, macOS, and Windows
Installation
From crates.io (Recommended)
From Source
Build from Repository
Usage
Basic Usage
# Start PortWatch with default settings
# Set custom refresh interval (in milliseconds)
# Start with a filter applied
Keyboard Shortcuts
Navigation
↑- Move up↓- Move downEnter- View detailed process information
Actions
r- Refresh port list/- Start filter mode (type to filter)Esc- Clear filterk- Graceful stop (SIGTERM on Unix, graceful termination on Windows)K- Force kill (SIGKILL on Unix, force termination on Windows)
Other
?- Toggle help screenq/Ctrl+C- Quit
Filtering
Press / to enter filter mode, then type:
- Port number:
3000 - Process name:
node - Protocol:
tcporudp - State:
listen,established, etc.
Press Enter to apply or Esc to cancel.
Platform-Specific Details
Linux
- Uses
/procfilesystem for native port-to-PID mapping - Parses
/proc/net/tcp,/proc/net/udpfor connection data - Requires read access to
/proc(usually available to all users)
macOS
- Uses
lsof -ifor port scanning - Requires
lsofto be available (standard on macOS)
Windows
- Uses
netstat -anofor port scanning - Requires
netstatto be available (standard on Windows)
Architecture
PortWatch uses a modular architecture with platform-specific backends:
src/
├── main.rs # Entry point and event loop
├── app.rs # Application state and reducer
├── events.rs # Input handling and actions
├── models.rs # Core data structures
├── backends/ # Platform-specific implementations
│ ├── mod.rs # Backend traits
│ ├── linux.rs # Linux /proc implementation
│ ├── macos.rs # macOS lsof implementation
│ └── windows.rs # Windows netstat implementation
└── ui/ # TUI components
├── mod.rs
├── theme.rs
├── layout.rs
├── ports_table.rs
├── details.rs
└── footer.rs
Requirements
- Rust 1.70 or later
- Platform-specific tools:
- Linux: Access to
/procfilesystem - macOS:
lsofcommand - Windows:
netstatcommand
- Linux: Access to
Permissions
Some operations may require elevated permissions:
- Viewing ports: Usually works without special permissions
- Killing processes: May require root/admin for processes owned by other users
Future Enhancements
- Stack sampling on Linux (perf/eBPF)
- Process tree view
- Export to JSON/CSV
- Configuration file support
- Container awareness
- Language-specific detection (Node.js, Python, Java)
- Network activity sparklines
License
MIT OR Apache-2.0
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.