adi-s / go-vncproxy

A tiny vnc websocket proxy written by golang supports noVNC client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-vncproxy

Go Report CardGitHub release

A tiny vnc websocket proxy written by golang supports noVNC client.

Feature

  • Token handler: like websockify, you can customlize the token handler to access multiple vnc backends by a single proxy instance.
  • Authentication: it depends on your vnc servers, since the proxy just copy the stream of both clients and servers.

Usage

package main

import (
	"net/http"

	"github.com/evangwt/go-vncproxy"

	"github.com/gin-gonic/gin"
	"golang.org/x/net/websocket"
)

func main() {
	r := gin.Default()

	vncProxy := NewVNCProxy()
	r.GET("/ws", func(ctx *gin.Context) {
		h := websocket.Handler(vncProxy.ServeWS)
		h.ServeHTTP(ctx.Writer, ctx.Request)
	})

	if err := r.Run(); err != nil {
		panic(err)
	}
}

func NewVNCProxy() *vncproxy.Proxy {
	return vncproxy.New(&vncproxy.Config{
		LogLevel: vncproxy.DebugLevel,
		TokenHandler: func(r *http.Request) (addr string, err error) {
			// validate token and get forward vnc addr
			// ...
			addr = ":5901"
			return
		},
	})
}

About

A tiny vnc websocket proxy written by golang supports noVNC client

License:MIT License


Languages

Language:Go 100.0%