Skip to content
a websocket to tcp proxy/bridge server
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dumper log tcpdump Feb 5, 2019
eg commit Apr 6, 2018
handler add seq id Feb 5, 2019
mapping
publickey devide to 3 pkgs Feb 4, 2019
seq
.gitignore ready to relaser Sep 26, 2018
.goreleaser.yml
Gopkg.lock log tcpdump Feb 5, 2019
Gopkg.toml commit Apr 6, 2018
LICENSE commit Apr 6, 2018
Makefile
README.md
sample-map.txt
wsgate-server.go log tcpdump Feb 5, 2019

README.md

wsgate-server - a websocket to tcp proxy/bridge server

[client]
|
| TCP
|
[wsgate-client] (https://github.com/kazeburo/wsgate-client)
|
| websocket (wss)
|
[reverse proxy] if required
|
| websocket (ws)
|
[wsgate-server] (https://github.com/kazeburo/wsgate-server)
|
| TCP
|
[server]

Example

wsgate-server

map-server.txt

mysql,127.0.0.1:3306
ssh,127.0.0.1:22

run server

$ wsgate-server --listen 0.0.0.0:8086 --map map-server.txt

wsgate-client

map-client.txt

127.0.0.1:8306,https://example.com/proxy/mysql
127.0.0.1:8022,https://example.com/proxy/ssh

run client server

$ wsgate-client --map map-client.txt

client

# mysql
$ mysql -h 127.0.0.1 --port 8306 --user ...

# ssh
ssh -p 8022 user@127.0.0.1

Using go-sql-driver/mysql

It's able to use RegisterDial to connect wsgate-server.

mysql.RegisterDial("websocket", func(url string) (net.Conn, error) {
	wsURL := strings.Replace(url, "http", "ws", 1)
	wsConf, err := websocket.NewConfig(wsURL, url)
	if err != nil {
		log.Fatalf("NewConfig failed: %v", err)
	}
	conn, err := websocket.DialConfig(wsConf)
	if err != nil {
		log.Fatalf("Dial to %q fail: %v", url, err)
	}
	conn.PayloadType = websocket.BinaryFrame
	return conn, err
})

db, err := sql.Open("mysql", "yyyy:xxx@websocket(https://example.com/proxy/mysql)/test")

Usage

Usage of ./wsgate-server:
-dial_timeout duration
	  Dial timeout. (default 10s)
-handshake_timeout duration
	  Handshake timeout. (default 10s)
-listen string
	  Address to listen to. (default "127.0.0.1:8086")
-map string
	  path and proxy host mapping file
-public-key string
	  public key for signing auth header
-version
	  show version
-write_timeout duration
	  Write timeout. (default 10s)
You can’t perform that action at this time.