92 lines
3.0 KiB
Markdown
92 lines
3.0 KiB
Markdown
# fo — (FUCK OFF) for ports
|
||
|
||
|
||
## What is this?
|
||
`fo` is a cross-platform command-line tool that:
|
||
- Detects which process is hogging a TCP port (e.g., `3000`).
|
||
- Tries to end it gracefully; if it plays tough, we go full send (`kill -9` / `taskkill /F`).
|
||
- Prompts for `sudo` if your mortal shell lacks the power.
|
||
- Prints a colorful report with PID, name, and how long it’s been loitering.
|
||
- Drops a few lighthearted quips, and yes, the occasional fuck.
|
||
|
||
In short: `fo 3000` → Port 3000 is yours again.
|
||
|
||
## Demo
|
||
```
|
||
$ fo 3000
|
||
Scanning for suspicious activity on port 3000...
|
||
Found PID 1234 (node) possibly hogging port 3000 for 2h 13m 05s.
|
||
Process survived the gentle nudge. Time for the big red button.
|
||
Killed process 1234 (node) which was partying on port 3000 for 2h 13m 05s.
|
||
Port 3000’s unwanted guest has been evicted with extreme prejudice!
|
||
```
|
||
|
||
## Installation
|
||
- Go 1.21+
|
||
- Linux/macOS/Windows
|
||
|
||
### go install
|
||
```
|
||
go install git.gostacks.org/iwasforcedtobehere/fo/cmd/fo@latest
|
||
```
|
||
This will give you a `fo` binary in your `$GOPATH/bin` or `$GOBIN`.
|
||
|
||
### From source
|
||
```
|
||
git clone https://git.gostacks.org/iwasforcedtobehere/fo
|
||
cd fo
|
||
make build # or go build ./cmd/fo
|
||
```
|
||
|
||
## Usage
|
||
```
|
||
fo <port>
|
||
|
||
Examples:
|
||
fo 3000 # tell 3000 to fuck off
|
||
fo 8080 # 8080 is not a personality trait
|
||
fo --help # usage info
|
||
```
|
||
|
||
## How it works
|
||
- Input validation: accepts only ports 1–65535.
|
||
- Process detection:
|
||
- Linux/macOS: prefers `lsof`, falls back to `ss` or `netstat`.
|
||
- Windows: uses `netstat -ano` + process introspection.
|
||
- Duration: approximates how long the process has been up via `gopsutil` (process create time). If we can’t be sure, we try to be honest and say “unknown duration”.
|
||
- Killing strategy:
|
||
- Gentle: `kill -TERM` or `taskkill /PID`.
|
||
- Force: `kill -KILL` or `taskkill /F`.
|
||
- Permissions: if the OS says “nope”, we’ll prompt for `sudo` and try again.
|
||
- Output: colorful, readable, and a bit cheeky.
|
||
|
||
## Philosophy (polite satire included)
|
||
- Ports are public spaces. If your process is double-parking on `:3000`, it can fuck off.
|
||
- We try kindness first, then consequences. It’s DevOps, not diplomacy.
|
||
- Tooling should be honest, helpful, and slightly entertaining when it fails.
|
||
|
||
## Dev plan (tl;dr of the build)
|
||
- CLI parsing with `flag`.
|
||
- Cross-platform port → PID resolution.
|
||
- Uptime via `gopsutil`.
|
||
- Elevation fallback via `sudo` where needed.
|
||
- Colorful output via `fatih/color`.
|
||
|
||
## Notes
|
||
- On Linux/macOS, you may need `lsof`, `ss`, or `netstat` installed.
|
||
- On Windows, `netstat` and `taskkill` are built-in.
|
||
- `sudo` prompts are interactive in your terminal.
|
||
|
||
## Roadmap
|
||
- Add `--json` output for scripts and CI.
|
||
- Add `--udp` support.
|
||
- Add `--ask` mode to confirm before killing when multiple contenders exist.
|
||
- Homebrew/Scoop packaging for easy install.
|
||
|
||
## License
|
||
MIT. Be kind. Don’t be reckless in production unless your SLAs can take a hit.
|
||
|
||
## Credits
|
||
- Built in Go. Colored by `fatih/color`. Informed by `gopsutil`.
|
||
- Proudly hosted under: https://git.gostacks.org/iwasforcedtobehere/fo
|