vnc2video

package module
v0.0.0-...-06bfc06 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2019 License: MIT Imports: 26 Imported by: 0

README

A real wold implementation of vnc client for go

After searching the web for an vnc client in golang which is not a toy & support more than handshake + RAW encoding, I came up blank, so, I set out to write one myself.

The video encoding part means that something can be viewed, and since I don't really feel like writing GTK UIs in 2018 (plus VNC viewers are a dime a dozen), a video file will do. In actuality the images produced are go images and can easily be saved as JPEG, or displayed in any UI you want to create.

Encoding support:

  • Tight VNC
  • Hextile
  • ZLIB
  • CopyRect
  • Raw
  • RRE
  • ZRLE
  • Rich-cursor pseudo
  • Desktop Size Pseudo
  • Cursor pos Pseudo

Video codec support:

  • x264 (ffmpeg) - the market standard
  • dv8 (ffmpeg) - google encoding current standard for webm
  • dv9 (ffmpeg) - a stronger codec supported by webm format on most browsers
  • qtrle (ffmpeg) - the best losless encoding I could find. (10 - 20 MB/min)
  • huffyuv (ffmpeg) - a lossless encoding which is low-Cpu but less compressed (50-100 MB/min)
  • MJpeg (native golang implementation) - lossy intra frame only (every frame encoded separately)

Frame Buffer Stream file support (fbs)

  • Supports reading & rendering fbs files that can be created by vncProxy
  • This allows recording vnc without the cost of video encoding while retaining the ability to transcode it into video later if the vnc session is found to be important.

About

It may seem strange that I didn't use my previous vncproxy code in order to create this client, but since that code is highly optimized to be a proxy (never hold a full message in buffer & introduce no lags), it is not best suited to be a client, so instead of spending the time reverting all the proxy-specific code, I just started from the most advanced go vnc-client code I found.

Most of what I added is the rfb-encoder & video encoding implementations, there are naturally some additional changes in order to get a global canvas (draw.Image) to render on by all encodings.

The code for the encodings was gathered by peeking at several RFB source codes in cpp & some in java, reading the excellent documentation in rfbproto, and a lot of gritty bit-plucking, pixel jogging & code cajoling until everything fell into place on screen.

I did not include tightPng in the supported encoding list since I didn't find a server to test it with, so I can't vouch for the previous implementation, If you have such a server handy, please check and tell me if it works.

Documentation

Index

Constants

View Source
const (
	HextileRaw                 = 1
	HextileBackgroundSpecified = 2
	HextileForegroundSpecified = 4
	HextileAnySubrects         = 8
	HextileSubrectsColoured    = 16
)
View Source
const (
	TightCompressionBasic = 0
	TightCompressionFill  = 8
	TightCompressionJPEG  = 9
	TightCompressionPNG   = 10
)
View Source
const (
	TightFilterCopy     = 0
	TightFilterPalette  = 1
	TightFilterGradient = 2
)
View Source
const (
	BlockWidth  = 16
	BlockHeight = 16
)
View Source
const (
	// ProtoVersionUnknown unknown version
	ProtoVersionUnknown = ""
	// ProtoVersion33 sets if proto 003.003
	ProtoVersion33 = "RFB 003.003\n"
	// ProtoVersion38 sets if proto 003.008
	ProtoVersion38 = "RFB 003.008\n"
	// ProtoVersion37 sets if proto 003.007
	ProtoVersion37 = "RFB 003.007\n"
)
View Source
const ProtoVersionLength = 12

ProtoVersionLength protocol version length

Variables

View Source
var (
	// DefaultClientMessages slice of default client messages sent to server
	DefaultClientMessages = []ClientMessage{
		&SetPixelFormat{},
		&SetEncodings{},
		&FramebufferUpdateRequest{},
		&KeyEvent{},
		&PointerEvent{},
		&ClientCutText{},
	}

	// DefaultServerMessages slice of default server messages sent to client
	DefaultServerMessages = []ServerMessage{
		&FramebufferUpdate{},
		&SetColorMapEntries{},
		&Bell{},
		&ServerCutText{},
	}
)
View Source
var (
	// PixelFormat8bit returns 8 bit pixel format
	PixelFormat8bit = NewPixelFormat(8)
	// PixelFormat16bit returns 16 bit pixel format
	PixelFormat16bit = NewPixelFormat(16)
	// PixelFormat32bit returns 32 bit pixel format
	PixelFormat32bit = NewPixelFormat(32)
	// PixelFormatAten returns pixel format used in Aten IKVM
	PixelFormatAten = NewPixelFormatAten()
)
View Source
var (
	// DefaultClientHandlers represents default client handlers
	DefaultClientHandlers = []Handler{
		&DefaultClientVersionHandler{},
		&DefaultClientSecurityHandler{},
		&DefaultClientClientInitHandler{},
		&DefaultClientServerInitHandler{},
		&DefaultClientMessageHandler{},
	}
)
View Source
var (
	// DefaultServerHandlers uses default handlers for hanshake
	DefaultServerHandlers = []Handler{
		&DefaultServerVersionHandler{},
		&DefaultServerSecurityHandler{},
		&DefaultServerClientInitHandler{},
		&DefaultServerServerInitHandler{},
		&DefaultServerMessageHandler{},
	}
)
View Source
var TightMinToCompress int = 12

Functions

func AuthVNCEncode

func AuthVNCEncode(password []byte, challenge []byte) ([]byte, error)

func CalcBytesPerCPixel

func CalcBytesPerCPixel(pf *PixelFormat) int

func DecodeRaw

func DecodeRaw(reader io.Reader, pf *PixelFormat, rect *Rectangle, targetImage draw.Image) error

func DrawImage

func DrawImage(target draw.Image, imageToApply image.Image, pos image.Point)

func FillRect

func FillRect(img draw.Image, rect *image.Rectangle, c color.Color)

func IsCPixelSpecific

func IsCPixelSpecific(pf *PixelFormat) bool

func MakeRect

func MakeRect(x, y, width, height int) image.Rectangle

func MakeRectFromVncRect

func MakeRectFromVncRect(rect *Rectangle) image.Rectangle

func Mask

func Mask(button Button) uint8

Mask returns button mask

func Min

func Min(a, b int) int

func ParseProtoVersion

func ParseProtoVersion(pv []byte) (uint, uint, error)

ParseProtoVersion parse protocol version

func ReadBytes

func ReadBytes(count int, r io.Reader) ([]byte, error)

func ReadColor

func ReadColor(c io.Reader, pf *PixelFormat) (*color.RGBA, error)

Read unmarshal color from conn

func ReadUint16

func ReadUint16(r io.Reader) (uint16, error)

func ReadUint32

func ReadUint32(r io.Reader) (uint32, error)

func ReadUint8

func ReadUint8(r io.Reader) (uint8, error)

func Serve

func Serve(ctx context.Context, ln net.Listener, cfg *ServerConfig) error

Serve serves requests from net.Listener using ServerConfig

Types

type AtenHermon

type AtenHermon struct {
	AtenLength uint32
	AtenType   uint8

	AtenSubrects  uint32
	AtenRawLength uint32
	Encodings     []Encoding
	// contains filtered or unexported fields
}

func (*AtenHermon) Read

func (enc *AtenHermon) Read(c Conn, rect *Rectangle) error

func (*AtenHermon) Reset

func (*AtenHermon) Reset() error

func (*AtenHermon) Supported

func (*AtenHermon) Supported(Conn) bool

func (*AtenHermon) Type

func (*AtenHermon) Type() EncodingType

func (*AtenHermon) Write

func (enc *AtenHermon) Write(c Conn, rect *Rectangle) error

type AtenHermonSubrect

type AtenHermonSubrect struct {
	A    uint16
	B    uint16
	Y    uint8
	X    uint8
	Data []byte
}

func (*AtenHermonSubrect) Read

func (enc *AtenHermonSubrect) Read(c Conn, rect *Rectangle) error

func (*AtenHermonSubrect) Reset

func (*AtenHermonSubrect) Reset() error

func (*AtenHermonSubrect) Supported

func (*AtenHermonSubrect) Supported(Conn) bool

func (*AtenHermonSubrect) Type

func (enc *AtenHermonSubrect) Type() EncodingType

func (*AtenHermonSubrect) Write

func (enc *AtenHermonSubrect) Write(c Conn, rect *Rectangle) error

type AteniKVMFrontGroundEvent

type AteniKVMFrontGroundEvent struct {
	// contains filtered or unexported fields
}

AteniKVMFrontGroundEvent unknown aten ikvm message

func (*AteniKVMFrontGroundEvent) Read

Read unmarshal message from conn

func (*AteniKVMFrontGroundEvent) String

func (msg *AteniKVMFrontGroundEvent) String() string

String return string representation

func (*AteniKVMFrontGroundEvent) Supported

func (msg *AteniKVMFrontGroundEvent) Supported(c Conn) bool

func (*AteniKVMFrontGroundEvent) Type

Type return ServerMessageType

func (*AteniKVMFrontGroundEvent) Write

func (msg *AteniKVMFrontGroundEvent) Write(c Conn) error

Write marshal message to conn

type AteniKVMGetViewerLang

type AteniKVMGetViewerLang struct {
	// contains filtered or unexported fields
}

AteniKVMGetViewerLang unknown aten ikvm message

func (*AteniKVMGetViewerLang) Read

Read unmarshal message from conn

func (*AteniKVMGetViewerLang) String

func (msg *AteniKVMGetViewerLang) String() string

String return string representation

func (*AteniKVMGetViewerLang) Supported

func (msg *AteniKVMGetViewerLang) Supported(c Conn) bool

func (*AteniKVMGetViewerLang) Type

Type return ServerMessageType

func (*AteniKVMGetViewerLang) Write

func (msg *AteniKVMGetViewerLang) Write(c Conn) error

Write marshal message to conn

type AteniKVMKeepAliveEvent

type AteniKVMKeepAliveEvent struct {
	// contains filtered or unexported fields
}

AteniKVMKeepAliveEvent unknown aten ikvm message

func (*AteniKVMKeepAliveEvent) Read

Read unmarshal message from conn

func (*AteniKVMKeepAliveEvent) String

func (msg *AteniKVMKeepAliveEvent) String() string

String return string representation

func (*AteniKVMKeepAliveEvent) Supported

func (msg *AteniKVMKeepAliveEvent) Supported(c Conn) bool

func (*AteniKVMKeepAliveEvent) Type

Type return ServerMessageType

func (*AteniKVMKeepAliveEvent) Write

func (msg *AteniKVMKeepAliveEvent) Write(c Conn) error

Write marshal message to conn

type AteniKVMKeyEvent

type AteniKVMKeyEvent struct {
	Down uint8 // down-flag

	Key Key // key
	// contains filtered or unexported fields
}

AteniKVMKeyEvent holds the wire format message

func (*AteniKVMKeyEvent) Read

func (*AteniKVMKeyEvent) String

func (msg *AteniKVMKeyEvent) String() string

func (*AteniKVMKeyEvent) Supported

func (msg *AteniKVMKeyEvent) Supported(c Conn) bool

func (*AteniKVMKeyEvent) Type

func (msg *AteniKVMKeyEvent) Type() ClientMessageType

func (*AteniKVMKeyEvent) Write

func (msg *AteniKVMKeyEvent) Write(c Conn) error

type AteniKVMMouseGetInfo

type AteniKVMMouseGetInfo struct {
	// contains filtered or unexported fields
}

AteniKVMMouseGetInfo unknown aten ikvm message

func (*AteniKVMMouseGetInfo) Read

Read unmarshal message from conn

func (*AteniKVMMouseGetInfo) String

func (msg *AteniKVMMouseGetInfo) String() string

String return string representation

func (*AteniKVMMouseGetInfo) Supported

func (msg *AteniKVMMouseGetInfo) Supported(c Conn) bool

func (*AteniKVMMouseGetInfo) Type

Type return ServerMessageType

func (*AteniKVMMouseGetInfo) Write

func (msg *AteniKVMMouseGetInfo) Write(c Conn) error

Write marshal message to conn

type AteniKVMPointerEvent

type AteniKVMPointerEvent struct {
	Mask uint8  // mask
	X    uint16 // x
	Y    uint16 // y
	// contains filtered or unexported fields
}

AteniKVMPointerEvent holds the wire format message

func (*AteniKVMPointerEvent) Read

func (*AteniKVMPointerEvent) String

func (msg *AteniKVMPointerEvent) String() string

func (*AteniKVMPointerEvent) Supported

func (msg *AteniKVMPointerEvent) Supported(c Conn) bool

func (*AteniKVMPointerEvent) Type

func (*AteniKVMPointerEvent) Write

func (msg *AteniKVMPointerEvent) Write(c Conn) error

type AteniKVMSessionMessage

type AteniKVMSessionMessage struct {
	// contains filtered or unexported fields
}

AteniKVMSessionMessage unknown aten ikvm message

func (*AteniKVMSessionMessage) Read

Read unmarshal message from conn

func (*AteniKVMSessionMessage) String

func (msg *AteniKVMSessionMessage) String() string

String return string representation

func (*AteniKVMSessionMessage) Supported

func (msg *AteniKVMSessionMessage) Supported(c Conn) bool

func (*AteniKVMSessionMessage) Type

Type return ServerMessageType

func (*AteniKVMSessionMessage) Write

func (msg *AteniKVMSessionMessage) Write(c Conn) error

Write marshal message to conn

type AteniKVMVideoGetInfo

type AteniKVMVideoGetInfo struct {
	// contains filtered or unexported fields
}

AteniKVMVideoGetInfo unknown aten ikvm message

func (*AteniKVMVideoGetInfo) Read

Read unmarshal message from conn

func (*AteniKVMVideoGetInfo) String

func (msg *AteniKVMVideoGetInfo) String() string

String return string representation

func (*AteniKVMVideoGetInfo) Supported

func (msg *AteniKVMVideoGetInfo) Supported(c Conn) bool

func (*AteniKVMVideoGetInfo) Type

Type return ServerMessageType

func (*AteniKVMVideoGetInfo) Write

func (msg *AteniKVMVideoGetInfo) Write(c Conn) error

Write marshal message to conn

type Bell

type Bell struct{}

Bell server message

func (*Bell) Read

func (*Bell) Read(c Conn) (ServerMessage, error)

Read unmarshal message from conn

func (*Bell) String

func (*Bell) String() string

String return string

func (*Bell) Supported

func (*Bell) Supported(c Conn) bool

func (*Bell) Type

func (*Bell) Type() ServerMessageType

Type returns MessageType

func (*Bell) Write

func (msg *Bell) Write(c Conn) error

Write marshal message to conn

type Button

type Button uint8

Button represents a mask of pointer presses/releases.

const (
	BtnLeft Button = 1 << iota
	BtnMiddle
	BtnRight
	BtnFour
	BtnFive
	BtnSix
	BtnSeven
	BtnEight
	BtnNone Button = 0
)

All available button mask components.

func (Button) String

func (i Button) String() string

type ClientAuthATEN

type ClientAuthATEN struct {
	Username []byte
	Password []byte
}

func (*ClientAuthATEN) Auth

func (auth *ClientAuthATEN) Auth(c Conn) error

func (*ClientAuthATEN) SubType

func (*ClientAuthATEN) SubType() SecuritySubType

func (*ClientAuthATEN) Type

func (*ClientAuthATEN) Type() SecurityType

type ClientAuthNone

type ClientAuthNone struct{}

func (*ClientAuthNone) Auth

func (*ClientAuthNone) Auth(conn Conn) error

func (*ClientAuthNone) SubType

func (*ClientAuthNone) SubType() SecuritySubType

func (*ClientAuthNone) Type

func (*ClientAuthNone) Type() SecurityType

type ClientAuthUltraMsAutoLogon2

type ClientAuthUltraMsAutoLogon2 struct {
	Username []byte
	Password []byte
}

ClientAuthUltraMsAutoLogon2 is implemented by Ultra VNC when using the MS-Logon II authentication. see http://www.uvnc.com/features/authentication.html

func (*ClientAuthUltraMsAutoLogon2) Auth

func (auth *ClientAuthUltraMsAutoLogon2) Auth(c Conn) error

func (*ClientAuthUltraMsAutoLogon2) SubType

func (*ClientAuthUltraMsAutoLogon2) Type

type ClientAuthVNC

type ClientAuthVNC struct {
	Challenge []byte
	Password  []byte
}

ClientAuthVNC is the standard password authentication. See 7.2.2.

func (*ClientAuthVNC) Auth

func (auth *ClientAuthVNC) Auth(c Conn) error

func (*ClientAuthVNC) SubType

func (*ClientAuthVNC) SubType() SecuritySubType

func (*ClientAuthVNC) Type

func (*ClientAuthVNC) Type() SecurityType

type ClientAuthVeNCrypt02Plain

type ClientAuthVeNCrypt02Plain struct {
	Username []byte
	Password []byte
}

ClientAuthVeNCryptPlain see https://www.berrange.com/~dan/vencrypt.txt

func (*ClientAuthVeNCrypt02Plain) Auth

func (auth *ClientAuthVeNCrypt02Plain) Auth(c Conn) error

func (*ClientAuthVeNCrypt02Plain) SubType

func (*ClientAuthVeNCrypt02Plain) Type

type ClientConfig

type ClientConfig struct {
	Handlers         []Handler
	SecurityHandlers []SecurityHandler
	Encodings        []Encoding
	PixelFormat      PixelFormat
	ColorMap         ColorMap
	ClientMessageCh  chan ClientMessage
	ServerMessageCh  chan ServerMessage
	Exclusive        bool
	DrawCursor       bool
	Messages         []ServerMessage
	QuitCh           chan struct{}
	ErrorCh          chan error
	// contains filtered or unexported fields
}

A ClientConfig structure is used to configure a ClientConn. After one has been passed to initialize a connection, it must not be modified.

type ClientConn

type ClientConn struct {
	Canvas *VncCanvas
	// contains filtered or unexported fields
}

The ClientConn type holds client connection information

func Connect

func Connect(ctx context.Context, c net.Conn, cfg *ClientConfig) (*ClientConn, error)

Connect handshake with remote server using underlining net.Conn

func NewClientConn

func NewClientConn(c net.Conn, cfg *ClientConfig) (*ClientConn, error)

NewClientConn creates new client conn using config

func (*ClientConn) Close

func (c *ClientConn) Close() error

Close closing conn

func (*ClientConn) ColorMap

func (c *ClientConn) ColorMap() ColorMap

ColorMap returns color map

func (*ClientConn) Config

func (c *ClientConn) Config() interface{}

Config returns connection config

func (*ClientConn) Conn

func (c *ClientConn) Conn() net.Conn

Conn return underlining net.Conn

func (*ClientConn) DesktopName

func (c *ClientConn) DesktopName() []byte

DesktopName returns connection desktop name

func (*ClientConn) Encodings

func (c *ClientConn) Encodings() []Encoding

Encodings returns client encodings

func (*ClientConn) Flush

func (c *ClientConn) Flush() error

Flush flushes data to conn

func (*ClientConn) GetEncInstance

func (c *ClientConn) GetEncInstance(typ EncodingType) Encoding

func (*ClientConn) Height

func (c *ClientConn) Height() uint16

Height returns height

func (*ClientConn) PixelFormat

func (c *ClientConn) PixelFormat() PixelFormat

PixelFormat returns connection pixel format

func (*ClientConn) Protocol

func (c *ClientConn) Protocol() string

Protocol returns protocol

func (*ClientConn) Read

func (c *ClientConn) Read(buf []byte) (int, error)

Read reads data from conn

func (*ClientConn) ResetAllEncodings

func (cc *ClientConn) ResetAllEncodings()

func (*ClientConn) SecurityHandler

func (c *ClientConn) SecurityHandler() SecurityHandler

SecurityHandler returns security handler

func (*ClientConn) SetColorMap

func (c *ClientConn) SetColorMap(cm ColorMap)

SetColorMap sets color map

func (*ClientConn) SetDesktopName

func (c *ClientConn) SetDesktopName(name []byte)

SetDesktopName sets desktop name

func (*ClientConn) SetEncodings

func (c *ClientConn) SetEncodings(encs []EncodingType) error

SetEncodings write SetEncodings message

func (*ClientConn) SetHeight

func (c *ClientConn) SetHeight(height uint16)

SetHeight sets height of client conn

func (*ClientConn) SetPixelFormat

func (c *ClientConn) SetPixelFormat(pf PixelFormat) error

SetPixelFormat sets pixel format

func (*ClientConn) SetProtoVersion

func (c *ClientConn) SetProtoVersion(pv string)

SetProtoVersion sets proto version

func (*ClientConn) SetSecurityHandler

func (c *ClientConn) SetSecurityHandler(sechandler SecurityHandler) error

SetSecurityHandler sets security handler

func (*ClientConn) SetWidth

func (c *ClientConn) SetWidth(width uint16)

SetWidth sets width of client conn

func (*ClientConn) Wait

func (c *ClientConn) Wait()

Wait waiting for connection close

func (*ClientConn) Width

func (c *ClientConn) Width() uint16

Width returns width

func (*ClientConn) Write

func (c *ClientConn) Write(buf []byte) (int, error)

Write data to conn must be Flushed

type ClientCutText

type ClientCutText struct {
	Length uint32 // length
	Text   []byte
	// contains filtered or unexported fields
}

ClientCutText holds the wire format message, sans the text field.

func (*ClientCutText) Read

func (*ClientCutText) Read(c Conn) (ClientMessage, error)

Read unmarshal message from conn

func (*ClientCutText) String

func (msg *ClientCutText) String() string

String returns string

func (*ClientCutText) Supported

func (msg *ClientCutText) Supported(c Conn) bool

func (*ClientCutText) Type

Type returns MessageType

func (*ClientCutText) Write

func (msg *ClientCutText) Write(c Conn) error

Write marshal message to conn

type ClientMessage

type ClientMessage interface {
	String() string
	Type() ClientMessageType
	Read(Conn) (ClientMessage, error)
	Write(Conn) error
	Supported(Conn) bool
}

type ClientMessageType

type ClientMessageType uint8

ClientMessageType represents RFB message type

const (
	SetPixelFormatMsgType ClientMessageType = iota

	SetEncodingsMsgType
	FramebufferUpdateRequestMsgType
	KeyEventMsgType
	PointerEventMsgType
	ClientCutTextMsgType
)

Client-to-Server message types.

const (
	AteniKVMKeyEventMsgType     ClientMessageType = 4
	AteniKVMPointerEventMsgType ClientMessageType = 5
)

Aten IKVM client message types

func (ClientMessageType) String

func (i ClientMessageType) String() string

type CoRREEncoding

type CoRREEncoding struct {
	// contains filtered or unexported fields
}

func (*CoRREEncoding) Read

func (z *CoRREEncoding) Read(r Conn, rect *Rectangle) error

func (*CoRREEncoding) Type

func (z *CoRREEncoding) Type() int32

func (*CoRREEncoding) WriteTo

func (z *CoRREEncoding) WriteTo(w io.Writer) (n int, err error)

type Color

type Color struct {
	R, G, B uint16
	// contains filtered or unexported fields
}

Color represents a single color in a color map.

func NewColor

func NewColor(pf *PixelFormat, cm *ColorMap) *Color

NewColor returns a new Color object

func (*Color) Read

func (clr *Color) Read(c Conn) error

Read unmarshal color from conn

func (*Color) Write

func (clr *Color) Write(c Conn) error

Write marshal color to conn

type ColorMap

type ColorMap [256]Color

ColorMap represent color map

type Conn

type Conn interface {
	io.ReadWriteCloser
	Conn() net.Conn
	Config() interface{}
	Protocol() string
	PixelFormat() PixelFormat
	SetPixelFormat(PixelFormat) error
	ColorMap() ColorMap
	SetColorMap(ColorMap)
	Encodings() []Encoding
	SetEncodings([]EncodingType) error
	Width() uint16
	Height() uint16
	SetWidth(uint16)
	SetHeight(uint16)
	DesktopName() []byte
	SetDesktopName([]byte)
	Flush() error
	Wait()
	SetProtoVersion(string)
	SetSecurityHandler(SecurityHandler) error
	SecurityHandler() SecurityHandler
	GetEncInstance(EncodingType) Encoding
}

Conn represents vnc conection

type CopyRectEncoding

type CopyRectEncoding struct {
	SX, SY uint16
	Image  draw.Image
}

func (*CopyRectEncoding) Read

func (enc *CopyRectEncoding) Read(c Conn, rect *Rectangle) error

func (*CopyRectEncoding) Reset

func (*CopyRectEncoding) Reset() error

func (*CopyRectEncoding) SetTargetImage

func (enc *CopyRectEncoding) SetTargetImage(img draw.Image)

func (*CopyRectEncoding) Supported

func (*CopyRectEncoding) Supported(Conn) bool

func (*CopyRectEncoding) Type

func (*CopyRectEncoding) Write

func (enc *CopyRectEncoding) Write(c Conn, rect *Rectangle) error

type CursorPosPseudoEncoding

type CursorPosPseudoEncoding struct {
	Image draw.Image
	// contains filtered or unexported fields
}

func (*CursorPosPseudoEncoding) Read

func (enc *CursorPosPseudoEncoding) Read(c Conn, rect *Rectangle) error

func (*CursorPosPseudoEncoding) Reset

func (enc *CursorPosPseudoEncoding) Reset() error

func (*CursorPosPseudoEncoding) SetTargetImage

func (enc *CursorPosPseudoEncoding) SetTargetImage(img draw.Image)

func (*CursorPosPseudoEncoding) Supported

func (*CursorPosPseudoEncoding) Supported(Conn) bool

func (*CursorPosPseudoEncoding) Type

func (*CursorPosPseudoEncoding) Write

func (enc *CursorPosPseudoEncoding) Write(c Conn, rect *Rectangle) error

type CursorPseudoEncoding

type CursorPseudoEncoding struct {
	Colors  []Color
	BitMask []byte
	Image   draw.Image
}

func (*CursorPseudoEncoding) Read

func (enc *CursorPseudoEncoding) Read(c Conn, rect *Rectangle) error

func (*CursorPseudoEncoding) Reset

func (enc *CursorPseudoEncoding) Reset() error

func (*CursorPseudoEncoding) SetTargetImage

func (enc *CursorPseudoEncoding) SetTargetImage(img draw.Image)

func (*CursorPseudoEncoding) Supported

func (*CursorPseudoEncoding) Supported(Conn) bool

func (*CursorPseudoEncoding) Type

func (*CursorPseudoEncoding) Write

func (enc *CursorPseudoEncoding) Write(c Conn, rect *Rectangle) error

type DefaultClientClientInitHandler

type DefaultClientClientInitHandler struct{}

DefaultClientClientInitHandler default client client init handler

func (*DefaultClientClientInitHandler) Handle

Handle provide default client client init handler

type DefaultClientMessageHandler

type DefaultClientMessageHandler struct{}

DefaultClientMessageHandler represents default client message handler

func (*DefaultClientMessageHandler) Handle

Handle handles server messages.

type DefaultClientSecurityHandler

type DefaultClientSecurityHandler struct{}

DefaultClientSecurityHandler used for client security handler

func (*DefaultClientSecurityHandler) Handle

Handle provide client side security handler

type DefaultClientServerInitHandler

type DefaultClientServerInitHandler struct{}

DefaultClientServerInitHandler default client server init handler

func (*DefaultClientServerInitHandler) Handle

Handle provide default server init handler

type DefaultClientVersionHandler

type DefaultClientVersionHandler struct{}

DefaultClientVersionHandler represents default handler

func (*DefaultClientVersionHandler) Handle

Handle provide version handler for client side

type DefaultServerClientInitHandler

type DefaultServerClientInitHandler struct{}

DefaultServerClientInitHandler default server client init handler

func (*DefaultServerClientInitHandler) Handle

Handle provide default server client init handler

type DefaultServerMessageHandler

type DefaultServerMessageHandler struct{}

DefaultServerMessageHandler default package handler

func (*DefaultServerMessageHandler) Handle

Handle handles messages from clients

type DefaultServerSecurityHandler

type DefaultServerSecurityHandler struct{}

DefaultServerSecurityHandler used for server security handler

func (*DefaultServerSecurityHandler) Handle

Handle provide server side security handler

type DefaultServerServerInitHandler

type DefaultServerServerInitHandler struct{}

DefaultServerServerInitHandler default server server init handler

func (*DefaultServerServerInitHandler) Handle

Handle provide default server server init handler

type DefaultServerVersionHandler

type DefaultServerVersionHandler struct{}

DefaultServerVersionHandler represents default server handler

func (*DefaultServerVersionHandler) Handle

Handle provide server version handler

type DesktopNamePseudoEncoding

type DesktopNamePseudoEncoding struct {
	Name []byte
}

DesktopNamePseudoEncoding represents a desktop size message from the server.

func (*DesktopNamePseudoEncoding) Read

func (enc *DesktopNamePseudoEncoding) Read(c Conn, rect *Rectangle) error

Read implements the Encoding interface.

func (*DesktopNamePseudoEncoding) Reset

func (*DesktopNamePseudoEncoding) Supported

func (*DesktopNamePseudoEncoding) Supported(Conn) bool

func (*DesktopNamePseudoEncoding) Type

func (*DesktopNamePseudoEncoding) Write

func (enc *DesktopNamePseudoEncoding) Write(c Conn, rect *Rectangle) error

type DesktopSizePseudoEncoding

type DesktopSizePseudoEncoding struct{}

DesktopSizePseudoEncoding represents a desktop size message from the server.

func (*DesktopSizePseudoEncoding) Read

Read implements the Encoding interface.

func (*DesktopSizePseudoEncoding) Reset

func (*DesktopSizePseudoEncoding) Supported

func (*DesktopSizePseudoEncoding) Supported(Conn) bool

func (*DesktopSizePseudoEncoding) Type

func (*DesktopSizePseudoEncoding) Write

func (enc *DesktopSizePseudoEncoding) Write(c Conn, rect *Rectangle) error

type Encoding

type Encoding interface {
	Type() EncodingType
	Read(Conn, *Rectangle) error
	Write(Conn, *Rectangle) error
	Supported(Conn) bool
	Reset() error
}

Encoding represents interface for vnc encoding

type EncodingType

type EncodingType int32

EncodingType represents a known VNC encoding type.

const (
	// EncRaw raw encoding
	EncRaw EncodingType = 0
	// EncCopyRect copyrect encoding
	EncCopyRect EncodingType = 1

	EncRRE                           EncodingType = 2
	EncCoRRE                         EncodingType = 4
	EncHextile                       EncodingType = 5
	EncZlib                          EncodingType = 6
	EncTight                         EncodingType = 7
	EncZlibHex                       EncodingType = 8
	EncUltra1                        EncodingType = 9
	EncUltra2                        EncodingType = 10
	EncJPEG                          EncodingType = 21
	EncJRLE                          EncodingType = 22
	EncTRLE                          EncodingType = 15
	EncZRLE                          EncodingType = 16
	EncAtenAST2100                   EncodingType = 0x57
	EncAtenASTJPEG                   EncodingType = 0x58
	EncAtenHermon                    EncodingType = 0x59
	EncAtenYarkon                    EncodingType = 0x60
	EncAtenPilot3                    EncodingType = 0x61
	EncJPEGQualityLevelPseudo10      EncodingType = -23
	EncJPEGQualityLevelPseudo9       EncodingType = -24
	EncJPEGQualityLevelPseudo8       EncodingType = -25
	EncJPEGQualityLevelPseudo7       EncodingType = -26
	EncJPEGQualityLevelPseudo6       EncodingType = -27
	EncJPEGQualityLevelPseudo5       EncodingType = -28
	EncJPEGQualityLevelPseudo4       EncodingType = -29
	EncJPEGQualityLevelPseudo3       EncodingType = -30
	EncJPEGQualityLevelPseudo2       EncodingType = -31
	EncJPEGQualityLevelPseudo1       EncodingType = -32
	EncPointerPosPseudo              EncodingType = -232
	EncCursorPseudo                  EncodingType = -239
	EncXCursorPseudo                 EncodingType = -240
	EncDesktopSizePseudo             EncodingType = -223
	EncLastRectPseudo                EncodingType = -224
	EncCompressionLevel10            EncodingType = -247
	EncCompressionLevel9             EncodingType = -248
	EncCompressionLevel8             EncodingType = -249
	EncCompressionLevel7             EncodingType = -250
	EncCompressionLevel6             EncodingType = -251
	EncCompressionLevel5             EncodingType = -252
	EncCompressionLevel4             EncodingType = -253
	EncCompressionLevel3             EncodingType = -254
	EncCompressionLevel2             EncodingType = -255
	EncCompressionLevel1             EncodingType = -256
	EncQEMUPointerMotionChangePseudo EncodingType = -257
	EncQEMUExtendedKeyEventPseudo    EncodingType = -258
	EncTightPng                      EncodingType = -260
	EncDesktopNamePseudo             EncodingType = -307
	EncExtendedDesktopSizePseudo     EncodingType = -308
	EncXvpPseudo                     EncodingType = -309
	EncClientRedirect                EncodingType = -311
	EncFencePseudo                   EncodingType = -312
	EncContinuousUpdatesPseudo       EncodingType = -313
	EncExtendedClipboardPseudo       EncodingType = -1063131698 //C0A1E5CE
)
const (
	EncAtenHermonSubrect EncodingType = 0
	EncAtenHermonRaw     EncodingType = 1
)

func (EncodingType) String

func (i EncodingType) String() string

type FBSPlayHelper

type FBSPlayHelper struct {
	Conn *FbsConn
	// contains filtered or unexported fields
}

func NewFBSPlayHelper

func NewFBSPlayHelper(r *FbsConn) *FBSPlayHelper

func (*FBSPlayHelper) ReadFbsMessage

func (h *FBSPlayHelper) ReadFbsMessage(SyncWithTimestamps bool, SpeedFactor float64) (ServerMessage, error)

type FbsConn

type FbsConn struct {
	FbsReader
	// contains filtered or unexported fields
}

Conn represents vnc conection

func NewFbsConn

func NewFbsConn(filename string, encs []Encoding) (*FbsConn, error)

func (*FbsConn) ColorMap

func (c *FbsConn) ColorMap() ColorMap

func (*FbsConn) Config

func (c *FbsConn) Config() interface{}

func (*FbsConn) Conn

func (c *FbsConn) Conn() net.Conn

func (*FbsConn) DesktopName

func (c *FbsConn) DesktopName() []byte

func (*FbsConn) Encodings

func (c *FbsConn) Encodings() []Encoding

func (*FbsConn) Flush

func (c *FbsConn) Flush() error

func (*FbsConn) GetEncInstance

func (c *FbsConn) GetEncInstance(typ EncodingType) Encoding

func (*FbsConn) Height

func (c *FbsConn) Height() uint16

func (*FbsConn) PixelFormat

func (c *FbsConn) PixelFormat() PixelFormat

func (*FbsConn) Protocol

func (c *FbsConn) Protocol() string

func (*FbsConn) SecurityHandler

func (c *FbsConn) SecurityHandler() SecurityHandler

func (*FbsConn) SetColorMap

func (c *FbsConn) SetColorMap(cm ColorMap)

func (*FbsConn) SetDesktopName

func (c *FbsConn) SetDesktopName(d []byte)

func (*FbsConn) SetEncodings

func (c *FbsConn) SetEncodings([]EncodingType) error

func (*FbsConn) SetHeight

func (c *FbsConn) SetHeight(h uint16)

func (*FbsConn) SetPixelFormat

func (c *FbsConn) SetPixelFormat(pf PixelFormat) error

func (*FbsConn) SetProtoVersion

func (c *FbsConn) SetProtoVersion(string)

func (*FbsConn) SetSecurityHandler

func (c *FbsConn) SetSecurityHandler(SecurityHandler) error

func (*FbsConn) SetWidth

func (c *FbsConn) SetWidth(w uint16)

func (*FbsConn) Wait

func (c *FbsConn) Wait()

func (*FbsConn) Width

func (c *FbsConn) Width() uint16

func (*FbsConn) Write

func (c *FbsConn) Write(buf []byte) (int, error)

dummy, no writing to this conn...

type FbsReader

type FbsReader struct {
	// contains filtered or unexported fields
}

func NewFbsReader

func NewFbsReader(fbsFile string) (*FbsReader, error)

func (*FbsReader) Close

func (fbs *FbsReader) Close() error

func (*FbsReader) CurrentTimestamp

func (fbs *FbsReader) CurrentTimestamp() int

func (*FbsReader) Read

func (fbs *FbsReader) Read(p []byte) (n int, err error)

func (*FbsReader) ReadSegment

func (fbs *FbsReader) ReadSegment() (*FbsSegment, error)

func (*FbsReader) ReadStartSession

func (fbs *FbsReader) ReadStartSession() (*ServerInit, error)

type FbsSegment

type FbsSegment struct {
	// contains filtered or unexported fields
}

type FramebufferUpdate

type FramebufferUpdate struct {
	NumRect uint16       // number-of-rectangles
	Rects   []*Rectangle // rectangles
	// contains filtered or unexported fields
}

FramebufferUpdate holds a FramebufferUpdate wire format message.

func (*FramebufferUpdate) Read

Read unmarshal message from conn

func (*FramebufferUpdate) String

func (msg *FramebufferUpdate) String() string

String provide stringer

func (*FramebufferUpdate) Supported

func (msg *FramebufferUpdate) Supported(c Conn) bool

func (*FramebufferUpdate) Type

Type return MessageType

func (*FramebufferUpdate) Write

func (msg *FramebufferUpdate) Write(c Conn) error

Write marshals message to conn

type FramebufferUpdateRequest

type FramebufferUpdateRequest struct {
	Inc           uint8  // incremental
	X, Y          uint16 // x-, y-position
	Width, Height uint16 // width, height
}

FramebufferUpdateRequest holds the wire format message.

func (*FramebufferUpdateRequest) Read

Read unmarshal message from conn

func (*FramebufferUpdateRequest) String

func (msg *FramebufferUpdateRequest) String() string

String returns string

func (*FramebufferUpdateRequest) Supported

func (msg *FramebufferUpdateRequest) Supported(c Conn) bool

func (*FramebufferUpdateRequest) Type

Type returns MessageType

func (*FramebufferUpdateRequest) Write

func (msg *FramebufferUpdateRequest) Write(c Conn) error

Write marshal message to conn

type Handler

type Handler interface {
	Handle(Conn) error
}

Handler represents handler of handshake

type HextileEncoding

type HextileEncoding struct {
	Image draw.Image
	// contains filtered or unexported fields
}

func (*HextileEncoding) Read

func (z *HextileEncoding) Read(r Conn, rect *Rectangle) error

func (*HextileEncoding) Reset

func (enc *HextileEncoding) Reset() error

func (*HextileEncoding) SetTargetImage

func (enc *HextileEncoding) SetTargetImage(img draw.Image)

func (*HextileEncoding) Supported

func (*HextileEncoding) Supported(Conn) bool

func (*HextileEncoding) Type

func (z *HextileEncoding) Type() EncodingType

func (*HextileEncoding) Write

func (enc *HextileEncoding) Write(c Conn, rect *Rectangle) error

func (*HextileEncoding) WriteTo

func (z *HextileEncoding) WriteTo(w io.Writer) (n int, err error)

type Key

type Key uint32

Key represents a VNC key press.

const (
	Space   Key = iota + 0x0020
	Exclaim     // exclamation mark
	QuoteDbl
	NumberSign
	Dollar
	Percent
	Ampersand
	Apostrophe
	ParenLeft
	ParenRight
	Asterisk
	Plus
	Comma
	Minus
	Period
	Slash
	Digit0
	Digit1
	Digit2
	Digit3
	Digit4
	Digit5
	Digit6
	Digit7
	Digit8
	Digit9
	Colon
	Semicolon
	Less
	Equal
	Greater
	Question
	At
	A
	B
	C
	D
	E
	F
	G
	H
	I
	J
	K
	L
	M
	N
	O
	P
	Q
	R
	S
	T
	U
	V
	W
	X
	Y
	Z
	BracketLeft
	Backslash
	BracketRight
	AsciiCircum
	Underscore
	Grave
	SmallA
	SmallB
	SmallC
	SmallD
	SmallE
	SmallF
	SmallG
	SmallH
	SmallI
	SmallJ
	SmallK
	SmallL
	SmallM
	SmallN
	SmallO
	SmallP
	SmallQ
	SmallR
	SmallS
	SmallT
	SmallU
	SmallV
	SmallW
	SmallX
	SmallY
	SmallZ
	BraceLeft
	Bar
	BraceRight
	AsciiTilde
)

Latin 1 (byte 3 = 0) ISO/IEC 8859-1 = Unicode U+0020..U+00FF

const (
	BackSpace Key = iota + 0xff08
	Tab
	Linefeed
	Clear

	Return
)
const (
	Pause Key = iota + 0xff13
	ScrollLock
	SysReq
	Escape Key = 0xff1b
	Delete Key = 0xffff
)
const (
	Home Key = iota + 0xff50
	Left
	Up
	Right
	Down
	PageUp
	PageDown
	End
	Begin
)
const (
	Select Key = 0xff60
	Print
	Execute
	Insert
	Undo
	Redo
	Menu
	Find
	Cancel
	Help
	Break
	ModeSwitch Key = 0xff7e
	NumLock    Key = 0xff7f
)
const (
	KeypadSpace Key = 0xff80
	KeypadTab   Key = 0xff89
	KeypadEnter Key = 0xff8d
)
const (
	KeypadF1 Key = iota + 0xff91
	KeypadF2
	KeypadF3
	KeypadF4
	KeypadHome
	KeypadLeft
	KeypadUp
	KeypadRight
	KeypadDown
	KeypadPrior
	KeypadPageUp
	KeypadNext
	KeypadPageDown
	KeypadEnd
	KeypadBegin
	KeypadInsert
	KeypadDelete
	KeypadMultiply
	KeypadAdd
	KeypadSeparator
	KeypadSubtract
	KeypadDecimal
	KeypadDivide
	Keypad0
	Keypad1
	Keypad2
	Keypad3
	Keypad4
	Keypad5
	Keypad6
	Keypad7
	Keypad8
	Keypad9
	KeypadEqual Key = 0xffbd
)
const (
	F1 Key = iota + 0xffbe
	F2
	F3
	F4
	F5
	F6
	F7
	F8
	F9
	F10
	F11
	F12
)
const (
	ShiftLeft Key = iota + 0xffe1
	ShiftRight
	ControlLeft
	ControlRight
	CapsLock
	ShiftLock
	MetaLeft
	MetaRight
	AltLeft
	AltRight
	SuperLeft
	SuperRight
	HyperLeft
	HyperRight
)

func (Key) String

func (i Key) String() string

type KeyEvent

type KeyEvent struct {
	Down uint8 // down-flag

	Key Key // key
	// contains filtered or unexported fields
}

KeyEvent holds the wire format message.

func (*KeyEvent) Read

func (*KeyEvent) Read(c Conn) (ClientMessage, error)

Read unmarshal message from conn

func (*KeyEvent) String

func (msg *KeyEvent) String() string

String returns string

func (*KeyEvent) Supported

func (msg *KeyEvent) Supported(c Conn) bool

func (*KeyEvent) Type

func (*KeyEvent) Type() ClientMessageType

Type returns MessageType

func (*KeyEvent) Write

func (msg *KeyEvent) Write(c Conn) error

Write marshal message to conn

type Keys

type Keys []Key

Keys is a slice of Key values.

func IntToKeys

func IntToKeys(v int) Keys

IntToKeys returns Keys that represent the key presses required to type an int.

type PixelFormat

type PixelFormat struct {
	BPP                             uint8  // bits-per-pixel
	Depth                           uint8  // depth
	BigEndian                       uint8  // big-endian-flag
	TrueColor                       uint8  // true-color-flag
	RedMax, GreenMax, BlueMax       uint16 // red-, green-, blue-max (2^BPP-1)
	RedShift, GreenShift, BlueShift uint8  // red-, green-, blue-shift
	// contains filtered or unexported fields
}

PixelFormat describes the way a pixel is formatted for a VNC connection

func NewPixelFormat

func NewPixelFormat(bpp uint8) PixelFormat

NewPixelFormat returns a populated PixelFormat structure

func NewPixelFormatAten

func NewPixelFormatAten() PixelFormat

NewPixelFormatAten returns Aten IKVM pixel format

func (PixelFormat) Marshal

func (pf PixelFormat) Marshal() ([]byte, error)

Marshal implements the Marshaler interface

func (PixelFormat) Read

func (pf PixelFormat) Read(r io.Reader) error

Read reads from an io.Reader, and populates the PixelFormat

func (PixelFormat) String

func (pf PixelFormat) String() string

String implements the fmt.Stringer interface

func (PixelFormat) Unmarshal

func (pf PixelFormat) Unmarshal(data []byte) error

Unmarshal implements the Unmarshaler interface

type PointerEvent

type PointerEvent struct {
	Mask uint8  // button-mask
	X, Y uint16 // x-, y-position
}

PointerEvent message holds the wire format message

func (*PointerEvent) Read

func (*PointerEvent) Read(c Conn) (ClientMessage, error)

Read unmarshal message from conn

func (*PointerEvent) String

func (msg *PointerEvent) String() string

String returns string

func (*PointerEvent) Supported

func (msg *PointerEvent) Supported(c Conn) bool

func (*PointerEvent) Type

Type returns MessageType

func (*PointerEvent) Write

func (msg *PointerEvent) Write(c Conn) error

Write marshal message to conn

type RGBColor

type RGBColor struct {
	R, G, B uint8
}

func (RGBColor) RGBA

func (c RGBColor) RGBA() (r, g, b, a uint32)

type RGBImage

type RGBImage struct {
	// Pix holds the image's pixels, in R, G, B, A order. The pixel at
	// (x, y) starts at Pix[(y-Rect.Min.Y)*Stride + (x-Rect.Min.X)*3].
	Pix []uint8
	// Stride is the Pix stride (in bytes) between vertically adjacent pixels.
	Stride int
	// Rect is the image's bounds.
	Rect image.Rectangle
}

RGBA is an in-memory image whose At method returns color.RGBA values.

func NewRGBImage

func NewRGBImage(r image.Rectangle) *RGBImage

NewRGBA returns a new RGBA image with the given bounds.

func (*RGBImage) At

func (p *RGBImage) At(x, y int) color.Color

func (*RGBImage) Bounds

func (p *RGBImage) Bounds() image.Rectangle

func (*RGBImage) ColorModel

func (p *RGBImage) ColorModel() color.Model

func (*RGBImage) Opaque

func (p *RGBImage) Opaque() bool

Opaque scans the entire image and reports whether it is fully opaque.

func (*RGBImage) PixOffset

func (p *RGBImage) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*RGBImage) RGBAt

func (p *RGBImage) RGBAt(x, y int) *RGBColor

func (*RGBImage) Set

func (p *RGBImage) Set(x, y int, c color.Color)

func (*RGBImage) SetRGB

func (p *RGBImage) SetRGB(x, y int, c color.RGBA)

func (*RGBImage) SubImage

func (p *RGBImage) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

type RREEncoding

type RREEncoding struct {
	Image draw.Image
	// contains filtered or unexported fields
}

func (*RREEncoding) Read

func (enc *RREEncoding) Read(r Conn, rect *Rectangle) error

func (*RREEncoding) Reset

func (enc *RREEncoding) Reset() error

func (*RREEncoding) SetTargetImage

func (enc *RREEncoding) SetTargetImage(img draw.Image)

func (*RREEncoding) Supported

func (*RREEncoding) Supported(Conn) bool

func (*RREEncoding) Type

func (*RREEncoding) Type() EncodingType

func (*RREEncoding) Write

func (enc *RREEncoding) Write(c Conn, rect *Rectangle) error

func (*RREEncoding) WriteTo

func (z *RREEncoding) WriteTo(w io.Writer) (n int, err error)

type RawEncoding

type RawEncoding struct {
	Image draw.Image
}

func (*RawEncoding) Read

func (enc *RawEncoding) Read(c Conn, rect *Rectangle) error

Read implements the Encoding interface.

func (*RawEncoding) Reset

func (*RawEncoding) Reset() error

func (*RawEncoding) SetTargetImage

func (enc *RawEncoding) SetTargetImage(img draw.Image)

func (*RawEncoding) Supported

func (*RawEncoding) Supported(Conn) bool

func (*RawEncoding) Type

func (*RawEncoding) Type() EncodingType

func (*RawEncoding) Write

func (enc *RawEncoding) Write(c Conn, rect *Rectangle) error

type Rectangle

type Rectangle struct {
	X, Y          uint16
	Width, Height uint16
	EncType       EncodingType
	Enc           Encoding
}

Rectangle represents a rectangle of pixel data

func NewRectangle

func NewRectangle() *Rectangle

NewRectangle returns new rectangle

func (*Rectangle) Area

func (rect *Rectangle) Area() int

Area returns the total area in pixels of the Rectangle

func (*Rectangle) Read

func (rect *Rectangle) Read(c Conn) error

Read unmarshal rectangle from conn

func (*Rectangle) String

func (rect *Rectangle) String() string

String return string representation

func (*Rectangle) Write

func (rect *Rectangle) Write(c Conn) error

Write marshal rectangle to conn

type Renderer

type Renderer interface {
	SetTargetImage(draw.Image)
}

type SecurityHandler

type SecurityHandler interface {
	Type() SecurityType
	SubType() SecuritySubType
	Auth(Conn) error
}

type SecuritySubType

type SecuritySubType uint32
const (
	SecSubTypeVeNCrypt01Unknown   SecuritySubType = SecuritySubType(0)
	SecSubTypeVeNCrypt01Plain     SecuritySubType = SecuritySubType(19)
	SecSubTypeVeNCrypt01TLSNone   SecuritySubType = SecuritySubType(20)
	SecSubTypeVeNCrypt01TLSVNC    SecuritySubType = SecuritySubType(21)
	SecSubTypeVeNCrypt01TLSPlain  SecuritySubType = SecuritySubType(22)
	SecSubTypeVeNCrypt01X509None  SecuritySubType = SecuritySubType(23)
	SecSubTypeVeNCrypt01X509VNC   SecuritySubType = SecuritySubType(24)
	SecSubTypeVeNCrypt01X509Plain SecuritySubType = SecuritySubType(25)
)
const (
	SecSubTypeVeNCrypt02Unknown   SecuritySubType = SecuritySubType(0)
	SecSubTypeVeNCrypt02Plain     SecuritySubType = SecuritySubType(256)
	SecSubTypeVeNCrypt02TLSNone   SecuritySubType = SecuritySubType(257)
	SecSubTypeVeNCrypt02TLSVNC    SecuritySubType = SecuritySubType(258)
	SecSubTypeVeNCrypt02TLSPlain  SecuritySubType = SecuritySubType(259)
	SecSubTypeVeNCrypt02X509None  SecuritySubType = SecuritySubType(260)
	SecSubTypeVeNCrypt02X509VNC   SecuritySubType = SecuritySubType(261)
	SecSubTypeVeNCrypt02X509Plain SecuritySubType = SecuritySubType(262)
)
const (
	SecSubTypeUnknown SecuritySubType = SecuritySubType(0)
)

func (SecuritySubType) String

func (i SecuritySubType) String() string

type SecurityType

type SecurityType uint8
const (
	SecTypeUnknown           SecurityType = SecurityType(0)
	SecTypeNone              SecurityType = SecurityType(1)
	SecTypeVNC               SecurityType = SecurityType(2)
	SecTypeTight             SecurityType = SecurityType(16)
	SecTypeATEN              SecurityType = SecurityType(16)
	SecTypeVeNCrypt          SecurityType = SecurityType(19)
	SecTypeUltraMsAutoLogon2 SecurityType = SecurityType(113)
)

func (SecurityType) String

func (i SecurityType) String() string

type ServerAuthNone

type ServerAuthNone struct{}

ServerAuthNone is the "none" authentication. See 7.2.1.

func (*ServerAuthNone) Auth

func (*ServerAuthNone) Auth(c Conn) error

func (*ServerAuthNone) SubType

func (*ServerAuthNone) SubType() SecuritySubType

func (*ServerAuthNone) Type

func (*ServerAuthNone) Type() SecurityType

type ServerAuthVNC

type ServerAuthVNC struct {
	Challenge []byte
	Password  []byte
	Crypted   []byte
}

ServerAuthVNC is the standard password authentication. See 7.2.2.

func (*ServerAuthVNC) Auth

func (auth *ServerAuthVNC) Auth(c Conn) error

func (*ServerAuthVNC) ReadChallenge

func (auth *ServerAuthVNC) ReadChallenge(c Conn) error

func (*ServerAuthVNC) SubType

func (*ServerAuthVNC) SubType() SecuritySubType

func (*ServerAuthVNC) Type

func (*ServerAuthVNC) Type() SecurityType

func (*ServerAuthVNC) WriteChallenge

func (auth *ServerAuthVNC) WriteChallenge(c Conn) error

type ServerConfig

type ServerConfig struct {
	Handlers         []Handler
	SecurityHandlers []SecurityHandler
	Encodings        []Encoding
	PixelFormat      PixelFormat
	ColorMap         ColorMap
	ClientMessageCh  chan ClientMessage
	ServerMessageCh  chan ServerMessage
	Messages         []ClientMessage
	DesktopName      []byte
	Height           uint16
	Width            uint16
	ErrorCh          chan error
}

ServerConfig config struct

type ServerConn

type ServerConn struct {
	// contains filtered or unexported fields
}

ServerConn underlining server conn

func NewServerConn

func NewServerConn(c net.Conn, cfg *ServerConfig) (*ServerConn, error)

NewServerConn returns new Server connection fron net.Conn

func (*ServerConn) Close

func (c *ServerConn) Close() error

Close closing server conn

func (*ServerConn) ColorMap

func (c *ServerConn) ColorMap() ColorMap

ColorMap returns server connection color map

func (*ServerConn) Config

func (c *ServerConn) Config() interface{}

Config returns config for server conn

func (*ServerConn) Conn

func (c *ServerConn) Conn() net.Conn

Conn returns underlining server net.Conn

func (*ServerConn) DesktopName

func (c *ServerConn) DesktopName() []byte

DesktopName returns connection desktop name

func (*ServerConn) Encodings

func (c *ServerConn) Encodings() []Encoding

Encodings returns connection encodings

func (*ServerConn) Flush

func (c *ServerConn) Flush() error

Flush buffered data to server conn

func (*ServerConn) GetEncInstance

func (c *ServerConn) GetEncInstance(typ EncodingType) Encoding

func (*ServerConn) Height

func (c *ServerConn) Height() uint16

Height returns framebuffer height

func (*ServerConn) PixelFormat

func (c *ServerConn) PixelFormat() PixelFormat

PixelFormat return connection pixel format

func (*ServerConn) Protocol

func (c *ServerConn) Protocol() string

Protocol returns protocol

func (*ServerConn) Read

func (c *ServerConn) Read(buf []byte) (int, error)

Read reads data from net.Conn

func (*ServerConn) SecurityHandler

func (c *ServerConn) SecurityHandler() SecurityHandler

SecurityHandler returns security handler

func (*ServerConn) SetColorMap

func (c *ServerConn) SetColorMap(cm ColorMap)

SetColorMap sets connection color map

func (*ServerConn) SetDesktopName

func (c *ServerConn) SetDesktopName(name []byte)

SetDesktopName sets connection desktop name

func (*ServerConn) SetEncodings

func (c *ServerConn) SetEncodings(encs []EncodingType) error

SetEncodings ??? sets server connection encodings

func (*ServerConn) SetHeight

func (c *ServerConn) SetHeight(h uint16)

SetHeight sets framebuffer height

func (*ServerConn) SetPixelFormat

func (c *ServerConn) SetPixelFormat(pf PixelFormat) error

SetPixelFormat sets pixel format for server conn

func (*ServerConn) SetProtoVersion

func (c *ServerConn) SetProtoVersion(pv string)

SetProtoVersion ??? sets proto version

func (*ServerConn) SetSecurityHandler

func (c *ServerConn) SetSecurityHandler(sechandler SecurityHandler) error

SetSecurityHandler sets security handler

func (*ServerConn) SetWidth

func (c *ServerConn) SetWidth(w uint16)

SetWidth sets framebuffer width

func (*ServerConn) Wait

func (c *ServerConn) Wait()

Wait waits connection to close

func (*ServerConn) Width

func (c *ServerConn) Width() uint16

Width returns framebuffer width

func (*ServerConn) Write

func (c *ServerConn) Write(buf []byte) (int, error)

Write writes data to net.Conn, must be Flashed

type ServerCutText

type ServerCutText struct {
	Length uint32
	Text   []byte
	// contains filtered or unexported fields
}

ServerCutText represents server message

func (*ServerCutText) Read

func (*ServerCutText) Read(c Conn) (ServerMessage, error)

Read unmarshal message from conn

func (*ServerCutText) String

func (msg *ServerCutText) String() string

String returns string

func (*ServerCutText) Supported

func (msg *ServerCutText) Supported(c Conn) bool

func (*ServerCutText) Type

Type returns MessageType

func (*ServerCutText) Write

func (msg *ServerCutText) Write(c Conn) error

Write marshal message to conn

type ServerInit

type ServerInit struct {
	FBWidth, FBHeight uint16
	PixelFormat       PixelFormat
	NameLength        uint32
	NameText          []byte
}

ServerInit struct used in server init handshake

func (ServerInit) String

func (srvInit ServerInit) String() string

String provide stringer

type ServerMessage

type ServerMessage interface {
	String() string
	Type() ServerMessageType
	Read(Conn) (ServerMessage, error)
	Write(Conn) error
	Supported(Conn) bool
}

type ServerMessageType

type ServerMessageType uint8

ServerMessageType represents RFB message type

const (
	FramebufferUpdateMsgType ServerMessageType = iota
	SetColorMapEntriesMsgType
	BellMsgType
	ServerCutTextMsgType
)

Server-to-Client message types

const (
	AteniKVMFrontGroundEventMsgType ServerMessageType = 4
	AteniKVMKeepAliveEventMsgType   ServerMessageType = 22
	AteniKVMVideoGetInfoMsgType     ServerMessageType = 51
	AteniKVMMouseGetInfoMsgType     ServerMessageType = 55
	AteniKVMSessionMessageMsgType   ServerMessageType = 57
	AteniKVMGetViewerLangMsgType    ServerMessageType = 60
)

Aten IKVM server message types

type SetColorMapEntries

type SetColorMapEntries struct {
	FirstColor uint16
	ColorsNum  uint16
	Colors     []Color
	// contains filtered or unexported fields
}

SetColorMapEntries server message

func (*SetColorMapEntries) Read

Read unmrashal message from conn

func (*SetColorMapEntries) String

func (msg *SetColorMapEntries) String() string

String returns string

func (*SetColorMapEntries) Supported

func (msg *SetColorMapEntries) Supported(c Conn) bool

func (*SetColorMapEntries) Type

Type returns MessageType

func (*SetColorMapEntries) Write

func (msg *SetColorMapEntries) Write(c Conn) error

Write marshal message to conn

type SetEncodings

type SetEncodings struct {
	EncNum    uint16 // number-of-encodings
	Encodings []EncodingType
	// contains filtered or unexported fields
}

SetEncodings holds the wire format message, sans encoding-type field.

func (*SetEncodings) Read

func (*SetEncodings) Read(c Conn) (ClientMessage, error)

Read unmarshal message from conn

func (*SetEncodings) String

func (msg *SetEncodings) String() string

String return string

func (*SetEncodings) Supported

func (msg *SetEncodings) Supported(c Conn) bool

func (*SetEncodings) Type

Type returns MessageType

func (*SetEncodings) Write

func (msg *SetEncodings) Write(c Conn) error

Write marshal message to conn

type SetPixelFormat

type SetPixelFormat struct {
	PF PixelFormat // pixel-format
	// contains filtered or unexported fields
}

SetPixelFormat holds the wire format message.

func (*SetPixelFormat) Read

func (*SetPixelFormat) Read(c Conn) (ClientMessage, error)

Read unmarshal message from conn

func (*SetPixelFormat) String

func (msg *SetPixelFormat) String() string

String returns string

func (*SetPixelFormat) Supported

func (msg *SetPixelFormat) Supported(c Conn) bool

func (*SetPixelFormat) Type

Type returns MessageType

func (*SetPixelFormat) Write

func (msg *SetPixelFormat) Write(c Conn) error

Write marshal message to conn

type TightCC

type TightCC struct {
	Compression TightCompression
	Filter      TightFilter
}

type TightCompression

type TightCompression uint8

func (TightCompression) String

func (i TightCompression) String() string

type TightEncoding

type TightEncoding struct {
	Image draw.Image
	// contains filtered or unexported fields
}

func (*TightEncoding) GetInstance

func (*TightEncoding) GetInstance() *TightEncoding

func (*TightEncoding) Read

func (enc *TightEncoding) Read(c Conn, rect *Rectangle) error

func (*TightEncoding) ReadTightData

func (enc *TightEncoding) ReadTightData(dataSize int, c Conn, decoderId int) ([]byte, error)

func (*TightEncoding) Reset

func (enc *TightEncoding) Reset() error

func (*TightEncoding) SetTargetImage

func (enc *TightEncoding) SetTargetImage(img draw.Image)

func (*TightEncoding) Supported

func (*TightEncoding) Supported(Conn) bool

func (*TightEncoding) Type

func (*TightEncoding) Type() EncodingType

func (*TightEncoding) Write

func (enc *TightEncoding) Write(c Conn, rect *Rectangle) error

type TightFilter

type TightFilter uint8

func (TightFilter) String

func (i TightFilter) String() string

type TightPixel

type TightPixel struct {
	R uint8
	G uint8
	B uint8
}

type TightPngEncoding

type TightPngEncoding struct {
	TightCC *TightCC
	Image   draw.Image
}

func (*TightPngEncoding) Read

func (enc *TightPngEncoding) Read(c Conn, rect *Rectangle) error

func (*TightPngEncoding) Reset

func (*TightPngEncoding) Reset() error

func (*TightPngEncoding) SetTargetImage

func (enc *TightPngEncoding) SetTargetImage(img draw.Image)

func (*TightPngEncoding) Supported

func (*TightPngEncoding) Supported(Conn) bool

func (*TightPngEncoding) Type

func (*TightPngEncoding) Write

func (enc *TightPngEncoding) Write(c Conn, rect *Rectangle) error

type VncCanvas

type VncCanvas struct {
	draw.Image

	Cursor         draw.Image
	CursorMask     [][]bool
	CursorBackup   draw.Image
	CursorOffset   *image.Point
	CursorLocation *image.Point
	DrawCursor     bool
	Changed        map[string]bool
	// contains filtered or unexported fields
}

func NewVncCanvas

func NewVncCanvas(width, height int) *VncCanvas

func (*VncCanvas) PaintCursor

func (c *VncCanvas) PaintCursor() image.Image

func (*VncCanvas) RemoveCursor

func (c *VncCanvas) RemoveCursor() image.Image

func (*VncCanvas) Reset

func (c *VncCanvas) Reset(rect *Rectangle)

func (*VncCanvas) SetChanged

func (c *VncCanvas) SetChanged(rect *Rectangle)

type VncStreamFileReader

type VncStreamFileReader interface {
	io.Reader
	CurrentTimestamp() int
	ReadStartSession() (*ServerInit, error)
	CurrentPixelFormat() *PixelFormat
	Encodings() []Encoding
}

type XCursorPseudoEncoding

type XCursorPseudoEncoding struct {
	PrimaryR   uint8
	PrimaryG   uint8
	PrimaryB   uint8
	SecondaryR uint8
	SecondaryG uint8
	SecondaryB uint8
	Bitmap     []byte
	Bitmask    []byte
}

func (*XCursorPseudoEncoding) Read

func (enc *XCursorPseudoEncoding) Read(c Conn, rect *Rectangle) error

Read implements the Encoding interface.

func (*XCursorPseudoEncoding) Reset

func (*XCursorPseudoEncoding) Reset() error

func (*XCursorPseudoEncoding) Supported

func (*XCursorPseudoEncoding) Supported(Conn) bool

func (*XCursorPseudoEncoding) Type

func (*XCursorPseudoEncoding) Write

func (enc *XCursorPseudoEncoding) Write(c Conn, rect *Rectangle) error

type ZLibEncoding

type ZLibEncoding struct {
	Image draw.Image
	// contains filtered or unexported fields
}

func (*ZLibEncoding) Read

func (enc *ZLibEncoding) Read(r Conn, rect *Rectangle) error

func (*ZLibEncoding) Reset

func (enc *ZLibEncoding) Reset() error

func (*ZLibEncoding) SetTargetImage

func (enc *ZLibEncoding) SetTargetImage(img draw.Image)

func (*ZLibEncoding) Supported

func (*ZLibEncoding) Supported(Conn) bool

func (*ZLibEncoding) Type

func (*ZLibEncoding) Type() EncodingType

func (*ZLibEncoding) Write

func (enc *ZLibEncoding) Write(c Conn, rect *Rectangle) error

func (*ZLibEncoding) WriteTo

func (enc *ZLibEncoding) WriteTo(w io.Writer) (n int, err error)

type ZRLEEncoding

type ZRLEEncoding struct {
	Image draw.Image
	// contains filtered or unexported fields
}

func (*ZRLEEncoding) Read

func (enc *ZRLEEncoding) Read(r Conn, rect *Rectangle) error

func (*ZRLEEncoding) Reset

func (enc *ZRLEEncoding) Reset() error

func (*ZRLEEncoding) SetTargetImage

func (enc *ZRLEEncoding) SetTargetImage(img draw.Image)

func (*ZRLEEncoding) Supported

func (*ZRLEEncoding) Supported(Conn) bool

func (*ZRLEEncoding) Type

func (*ZRLEEncoding) Type() EncodingType

func (*ZRLEEncoding) Write

func (enc *ZRLEEncoding) Write(c Conn, rect *Rectangle) error

func (*ZRLEEncoding) WriteTo

func (z *ZRLEEncoding) WriteTo(w io.Writer) (n int, err error)

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL