Simple Socat Manager Web UI
A simple web application written in Go to manage socat TCP forwards through a user-friendly web interface. Start, stop, and monitor multiple socat listeners/forwards without needing complex command-line management.
This tool provides a web UI to dynamically create TCP forwards using socat. You provide a local IP and port for socat to listen on, and a remote IP and port for socat to forward traffic to. The application manages these socat processes, allows you to stop them individually, and keeps track of their status.
It's particularly useful for temporarily forwarding ports during development, testing, or network troubleshooting scenarios.
- Web Interface: Clean UI for managing forwards.
- Start Forwards: Easily start new
socat tcp4-listen <...> tcp4:<...>forwards. - Input Validation: Validates IP address formats and port ranges (1-65535) before attempting to start
socat. - List Active Forwards: Displays a table of currently running forwards managed by the application, including PIDs.
- Stop Forwards: Stop individual
socatprocesses with a button click. - Process Monitoring (Linux): Automatically checks if managed
socatprocesses are still running using the/procfilesystem. Dead processes are removed from the list. - Event Log: Displays a running log of events:
Start: A new forward was successfully started.Stop: A forward was manually stopped via the UI.Dead: A previously running forward's process was detected as no longer running.
- In-Memory State: Process list and event log are stored in memory (cleared on application restart).
- Single Binary: Compiles to a single executable for easy deployment.
- Go: Version 1.18 or later installed (https://go.dev/doc/install).
- Socat: The
socatutility must be installed on the host machine and accessible via the system'sPATH. You can usually install it via your package manager (e.g.,sudo apt install socatorsudo yum install socat). - Operating System: Linux is required for the automatic dead process detection feature, which relies on the
/procfilesystem. The core functionality might work on other Unix-like systems, but process monitoring may fail.
- Clone the repository:
git clone github.com/mubix/socatmanager cd socatmanager - Initialize Go Modules (if needed):
If you haven't already, initialize Go modules in the project directory:
go mod init mubix.com/socatmanager
- Fetch Dependencies:
The application uses
github.com/google/uuid. Fetch it:go mod tidy
Compile the application into a single binary:
go build -o socatmanager main.go
# Or simply:
# go buildThis will create an executable file named socatmanager in the current directory.
-
Execute the binary:
./socatmanager
-
Access the Web UI: Open your web browser and navigate to:
http://localhost:8080(or the appropriate hostname/IP if running remotely).
The server will start logging output to your console.
- Running in the Background (Optional): For longer-term use, you might want to run it using
nohup,screen,tmux, or set it up as asystemdservice:nohup ./socat-manager &
- Navigate to
http://localhost:8080or the IP of the server you are running it on. - Start a Forward:
- Fill in the "Base IP" (IP address for
socatto bind to, e.g.,0.0.0.0or192.168.1.100). This needs to be an IP address that the sever can actually bind to. - Fill in the "Base Port" (Port for
socatto listen on, e.g.,4444). - Fill in the "Remote IP" (Target IP address to forward traffic to).
- Fill in the "Remote Port" (Target port to forward traffic to).
- Click "Start Socat Forward".
- If successful, the page will refresh, and the new forward will appear in the "Running Forwards" table. Errors (validation or
socatstartup) will be displayed at the top.
- Fill in the "Base IP" (IP address for
- View Forwards: The "Running Forwards" table shows details (Base/Remote IPs & Ports, PID) for each active
socatprocess managed by this tool. - Stop a Forward: Click the "Stop" button next to the desired forward in the table. The page will refresh, the process will be terminated, and a "Stop" event will appear in the log.
- Monitor Events: The "Event Log" section shows a timestamped history of Start, Stop, and Missing events for the current application session.
- Port: The web server listens on port
8080by default. This is currently hardcoded inmain.go. To change it, modify theportvariable in themainfunction and rebuild.
- Error: "socat command not found": Ensure
socatis installed correctly and its location is included in your system'sPATHenvironment variable for the user runningsocat-manager. - Error: "Failed to start socat (check if address/port is already in use...)": The specified "Base IP" and "Base Port" combination is likely already being used by another application (or another
socatinstance). Choose a different Base Port or stop the conflicting process. It could also indicate a permissions issue preventingsocatfrom binding to the requested address/port. - Forwards marked "Dead" unexpectedly: This means the application checked
/proc/<PID>/cwdand found the process was gone. Check system logs (dmesg,/var/log/syslog, etc.) orsocat's behavior if it's crashing. This can happen is thesocatprocess is killed, segfaults, or fails to start (bad Base IP). - Application doesn't start / Port conflict: Ensure port
8080(or the configured port) is not already in use by another service.
This project is licensed under the BSD 3-clause License.