https://github.com/mritd/socket2tcp
A simple tool for socket forwarding to remote tcp address
https://github.com/mritd/socket2tcp
Last synced: about 1 year ago
JSON representation
A simple tool for socket forwarding to remote tcp address
- Host: GitHub
- URL: https://github.com/mritd/socket2tcp
- Owner: mritd
- License: apache-2.0
- Created: 2020-02-22T15:40:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-09-26T17:13:57.000Z (almost 5 years ago)
- Last Synced: 2025-04-03T13:43:57.589Z (over 1 year ago)
- Language: Go
- Size: 46.9 KB
- Stars: 1
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# socket2tcp
> socket2tcp is a small tool that redirects local socket file traffic to the target tcp port;
> This tool is used for development and debugging purposes, and its stability and performance
> are not reliable in a production environment.
## Install
Download the pre-compiled executable bin file or execute the `go install github.com/mritd/socket2tcp@latest` command.
## Usage
```sh
➜ socket2tcp --help
A simple tool for socket forwarding to remote tcp address
Usage:
socket2tcp [flags]
Flags:
-h, --help help for socket2tcp
-r, --remote string remote tcp address
-s, --socket string unix socket address (default "/tmp/socket2tcp.sock")
```
## Example
```sh
# 1. Start a python simple http server(it listen on 0.0.0.0:8000 by default)
python3 -m http.server
# 2. Use socket2tcp to map the local socket file to port 8000 of the python3 simple http server
socket2tcp -s /tmp/test.sock -r 127.0.0.1:8000
# 3. Now use the curl command to access the local socket file,
# socket2tcp will forward the traffic to the python3 simple http server
#
# Note: Any traffic sent to "/tmp/test.sock" will be forwarded to the tcp address of the "-r" option;
# The "http://127.0.0.1:8000" address at the end is just for curl to set the correct HTTP header,
# In actual use, we may not send HTTP traffic, it may be pure TCP traffic or other TCP-based protocols,
# such as gRPC、FTP、SMTP, etc.
curl --no-buffer --unix-socket /tmp/test.sock http://127.0.0.1:8000
```