MCPcopy Index your code
hub / github.com/amitbet/vncproxy

github.com/amitbet/vncproxy @v1.12

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.12 ↗ · + Follow
382 symbols 946 edges 48 files 57 documented · 15%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

VncProxy CircleCI MIT Licensed

An RFB proxy, written in go that can save and replay FBS files * Supports all modern encodings & most useful pseudo-encodings * Supports multiple VNC client connections & multi servers (chosen by sessionId) * Supports being a "websockify" proxy (for web clients like NoVnc) * Produces FBS files compatible with tightvnc's rfb player (while using tight's default 3Byte color format) * Can also be used as: * A screen recorder vnc-client * A replay server to show fbs recordings to connecting clients

  • Tested on tight encoding with:
    • Tightvnc (client + java client + server)
    • FBS player (tightVnc Java player)
    • NoVnc(web client) => use -wsPort to open a websocket
    • ChickenOfTheVnc(client)
    • VineVnc(server)
    • TigerVnc(client)
    • Qemu vnc(server)

Executables (see releases)

  • proxy - the actual recording proxy, supports listening to tcp & ws ports and recording traffic to fbs files
  • recorder - connects to a vnc server as a client and records the screen
  • player - a toy player that will replay a given fbs file to all incoming connections

Usage:

recorder -recFile=./recording.rbs -targHost=192.168.0.100 -targPort=5903 -targPass=@@@@@
player -fbsFile=./myrec.fbs -tcpPort=5905
proxy -recDir=./recordings/ -targHost=192.168.0.100 -targPort=5903 -targPass=@@@@@ -tcpPort=5903 -wsPort=5905 -vncPass=@!@!@!

Code usage examples

  • player/main.go (fbs recording vnc client)    * Connects as client, records to FBS file
  • proxy/proxy_test.go (vnc proxy with recording)
    • Listens to both Tcp and WS ports
    • Proxies connections to a hard-coded localhost vnc server
    • Records session to an FBS file
  • player/player_test.go (vnc replay server)
    • Listens to Tcp & WS ports
    • Replays a hard-coded FBS file in normal speed to all connecting vnc clients

Architecture

Image of Arch

Communication to vnc-server & vnc-client are done in the RFB binary protocol in the standard ways. Internal communication inside the proxy is done by listeners (a pub-sub system) that provide a stream of bytes, parsed by delimiters which provide information about RFB message start & type / rectangle start / communication closed, etc. This method allows for minimal delays in transfer, while retaining the ability to buffer and manipulate any part of the protocol.

For the client messages which are smaller, we send fully parsed messages going trough the same listener system. Currently client messages are used to determine the correct pixel format, since the client can change it by sending a SetPixelFormatMessage.

Tracking the bytes that are read from the actual vnc-server is made simple by using the RfbReadHelper (implements io.Reader) which sends the bytes to the listeners, this negates the need for manually keeping track of each byte read in order to write it into the recorder.

RFB Encoding-reader implementations do not decode pixel information, since this is not required for the proxy implementation.

This listener system was chosen over direct use of channels, since it allows the listening side to decide whether or not it wants to run in parallel, in contrast having channels inside the server/client objects which require you to create go routines (this creates problems when using go's native websocket implementation)

The Recorder uses channels and runs in parallel to avoid hampering the communication through the proxy.

Image of Arch

The code is based on several implementations of go-vnc including the original one by Mitchell Hashimoto, and the recentely active fork by Vasiliy Tolstov.

Extension points exported contracts — how you extend this code

IEncoding (Interface)
An IEncoding implements a method for encoding pixel data that is sent by the server to the client. [12 implementers]
common/encoding.go
ClientMessage (Interface)
ClientMessage is the interface [9 implementers]
common/client-message-type.go
SegmentConsumer (Interface)
(no doc) [7 implementers]
common/rfb-reader-helper.go
ClientAuth (Interface)
A ServerMessage implements a message sent from the server to the client. A ClientAuth implements a method of authenticat [1 …
client/client-conn.go
ServerMessage (Interface)
(no doc) [3 implementers]
common/server-message-type.go
IClientConn (Interface)
(no doc) [3 implementers]
common/conn-interfaces.go
SecurityHandler (Interface)
(no doc) [2 implementers]
server/security.go
Logger (Interface)
(no doc) [1 implementers]
logger/logger.go

Core symbols most depended-on inside this repo

Write
called by 115
common/client-message-type.go
Read
called by 81
common/encoding.go
Errorf
called by 41
logger/logger.go
Debugf
called by 38
logger/logger.go
Error
called by 32
logger/logger.go
String
called by 21
common/server-message-type.go
ReadBytes
called by 21
common/rfb-reader-helper.go
Errorf
called by 20
logger/logger.go

Shape

Method 245
Struct 55
Function 54
TypeAlias 16
Interface 10
FuncType 2

Languages

Go100%

Modules by API surface

logger/logger.go39 symbols
server/client-messages.go38 symbols
client/server-messages.go25 symbols
client/client-conn.go22 symbols
server/server-conn.go21 symbols
common/rfb-reader-helper.go21 symbols
server/security.go17 symbols
common/conn-interfaces.go17 symbols
client/client_auth_test.go12 symbols
server/handlers.go11 symbols
player/fbs-play-listener.go10 symbols
player/fbs-reader.go9 symbols

For agents

$ claude mcp add vncproxy \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact