https://github.com/macrat/hpipe
A simple tool for piping TCP connection over HTTP.
https://github.com/macrat/hpipe
Last synced: 12 months ago
JSON representation
A simple tool for piping TCP connection over HTTP.
- Host: GitHub
- URL: https://github.com/macrat/hpipe
- Owner: macrat
- License: mit
- Created: 2022-07-17T08:15:57.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-25T01:52:29.000Z (over 3 years ago)
- Last Synced: 2024-06-21T16:57:00.203Z (about 2 years ago)
- Language: Go
- Size: 18.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
hpipe
=====
A simple tool for piping TCP connection over HTTP.
This program can use WebSocket or pure TCP connection using [Upgrade header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Upgrade).
The pure TCP has smaller overhead than WebSocket, but it does not work well in some environments.
The WebSocket is more compatible to most environments such as behind of a fire-wall or proxies.
## Usage
### server: HTTP -> TCP
``` bash
$ hpipe -l :8080 example.com:22
```
```
+----------+ +----------------+ +------------------+
| | HTTP | | TCP | |
| client -----------> hpipe ----------> server |
| | | (0.0.0.0:8080) | | (example.com:22) |
+----------+ +----------------+ +------------------+
```
### client: TCP -> HTTP
``` bash
$ hpipe -l :1234 http://example.com:8080 # pure TCP mode
$ hpipe -l :1234 ws://example.com:8080 # WebSocket mode
```
```
+----------+ +----------------+ +--------------------+
| | TCP | | HTTP | |
| client ----------> hpipe -----------> hpipe |
| | | (0.0.0.0:1234) | | (example.com:8080) |
+----------+ +----------------+ +--------------------+
```
### client: stdio -> HTTP
``` bash
$ hpipe http://example.com:8080 # pure TCP mode
$ hpipe ws://example.com:8080 # WebSocket mode
```
```
+-----------------+ +--------------------+
stdin -----> | HTTP | |
| hpipe -----------> hpipe |
stdout <---- | | (example.com:8080) |
+-----------------+ +--------------------+
```
## Connect SSH over HTTP proxy
__NOTE__: This function is still work in progress.
```
HTTP Proxy
client +-+ server
+------------------------+ | | +-------------------------+
| | | | | |
| +----------+ +-----+ | | | | +-----+ +----------+ |
| |SSH client|-->|hpipe|--------| |-------->|hpipe|-->|SSH server| |
| +----------+ +-----+ | | | | +-----+ +----------+ |
| | | | | |
+------------------------+ | | +-------------------------+
+-+
```
### Server
Start Hpipe on your server.
``` shell
$ hpipe -l :8022 localhost:22
```
### Client
Setup ssh-config and HTTP proxy address.
``` shell
$ cat ~/.ssh/config
Host your-server.example.com
Port 8022
ProxyCommand hpipe http://%h:%p
#ProxyCommand hpipe ws://%h:%p
$ echo 'export HTTP_PROXY=http://your-proxy.example.com' >> ~/.bashrc
```
Connect SSH.
``` shell
$ ssh your-server.example.com
```