rfb

package module
v0.0.0-...-b5a9437 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

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{},
	}
)

Functions

func AuthVNCEncode

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

func Mask

func Mask(button Button) uint8

Mask returns button mask

func ParseProtoVersion

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

ParseProtoVersion parse protocol version

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) 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) 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 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
	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 {
	// 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) 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) 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 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
}

Conn represents vnc conection

type CopyRectEncoding

type CopyRectEncoding struct {
	SX, SY uint16
}

func (*CopyRectEncoding) Read

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

func (*CopyRectEncoding) Supported

func (*CopyRectEncoding) Supported(Conn) bool

func (*CopyRectEncoding) Type

func (*CopyRectEncoding) Write

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

type CursorPseudoEncoding

type CursorPseudoEncoding struct {
	Colors  []Color
	BitMask []byte
}

func (*CursorPseudoEncoding) Read

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

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) 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) 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
}

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
	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
	EncLedStatePseudo                EncodingType = -261
	EncDesktopNamePseudo             EncodingType = -307
	EncExtendedDesktopSizePseudo     EncodingType = -308
	EncXvpPseudo                     EncodingType = -309
	EncClientRedirect                EncodingType = -311
	EncFencePseudo                   EncodingType = -312
	EncContinuousUpdatesPseudo       EncodingType = -313
)
const (
	EncAtenHermonSubrect EncodingType = 0
	EncAtenHermonRaw     EncodingType = 1
)

func (EncodingType) String

func (i EncodingType) String() string

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 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 LedStatePseudoEncoding

type LedStatePseudoEncoding struct {
	State uint8
}

func (*LedStatePseudoEncoding) Read

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

func (*LedStatePseudoEncoding) Supported

func (*LedStatePseudoEncoding) Supported(Conn) bool

func (*LedStatePseudoEncoding) Type

func (*LedStatePseudoEncoding) Write

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

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 RawEncoding

type RawEncoding struct {
	Colors []Color
}

func (*RawEncoding) Read

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

Read implements the Encoding interface.

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 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)
)

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) 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
const (
	TightCompressionBasic TightCompression = 0
	TightCompressionFill  TightCompression = 8
	TightCompressionJPEG  TightCompression = 9
	TightCompressionPNG   TightCompression = 10
)

func (TightCompression) String

func (i TightCompression) String() string

type TightEncoding

type TightEncoding struct{}

func (*TightEncoding) Read

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

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
const (
	TightFilterCopy     TightFilter = 0
	TightFilterPalette  TightFilter = 1
	TightFilterGradient TightFilter = 2
)

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   image.Image
}

func (*TightPngEncoding) Read

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

func (*TightPngEncoding) Supported

func (*TightPngEncoding) Supported(Conn) bool

func (*TightPngEncoding) Type

func (*TightPngEncoding) Write

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

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) Supported

func (*XCursorPseudoEncoding) Supported(Conn) bool

func (*XCursorPseudoEncoding) Type

func (*XCursorPseudoEncoding) Write

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

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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