ruzhila / websockify-go

A pure Go implementation of novnc/websockify TCP to WebSocket proxy, SSL Work!

Home Page:https://ruzhila.cn/?from=github_websockify_go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Websockify with 100 lines of Golang code

websockify-go is a pure Go implementation of novnc/websockify TCP to WebSocket proxy with improved connection handling.

By ruzhila.cn, a campus for learning backend development through practice.

This is a tutorial code demonstrating how to use Golang write network proxy. Pull requests are welcome. ๐Ÿ‘

Features

  • ๐Ÿ‘ Simple and easy to use
  • ๐Ÿถ Pure Go implementation
  • ๐Ÿ” Support SSL
  • โŒจ๏ธ Support custom URL path
  • ๐Ÿšช Support custom target address

Build from source

$ git clone https://github.com/ruzhila/websockify-go.git
$ cd websockify-go/cmd
$ go build -o websockify main.go

Install from source

$ go get -u github.com/ruzhila/websockify-go
$ websockifygo -h

Usage

$ ./websockify -h
Usage of ./websockify:
  -addr string
        address to listen on (default ":8080")
  -cert string
        SSL cert.pem
  -key string
        SSL key.pem
  -target string
        target address (default "localhost:5900")
  -url string
        url path to proxy, e.g. /vnc

$ ./websockify -addr :8080 -target localhost:5900 -url /vnc

Connect to the proxy, via browser

const ws = new WebSocket('ws://localhost:8080/vnc');
ws.onopen = () => console.log('connected');
ws.onmessage = (e) => console.log('message', e.data);
ws.onclose = () => console.log('closed');

Build with Docker

$ docker build -t websockify-go .
$ docker run -p 8080:8080 websockify-go -target localhost:5900 -url /vnc

About

A pure Go implementation of novnc/websockify TCP to WebSocket proxy, SSL Work!

https://ruzhila.cn/?from=github_websockify_go

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Go 86.6%Language:Dockerfile 13.4%