common

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TightMinToCompress = 12

Functions

This section is empty.

Types

type ClientMessage

type ClientMessage interface {
	Type() ClientMessageType
	Read(io.Reader) (ClientMessage, error)
	Write(io.Writer) error
}

ClientMessage is the interface

type ClientMessageType

type ClientMessageType uint8
const (
	SetPixelFormatMsgType ClientMessageType = iota

	SetEncodingsMsgType
	FramebufferUpdateRequestMsgType
	KeyEventMsgType
	PointerEventMsgType
	ClientCutTextMsgType
	ClientFenceMsgType          = 248
	QEMUExtendedKeyEventMsgType = 255
)

Client-to-Server message types.

func (ClientMessageType) String

func (cmt 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.

type ColorMap

type ColorMap [256]Color

type EncodingType

type EncodingType int32

EncodingType represents a known VNC encoding type.

const (
	EncRaw                           EncodingType = 0
	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
	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
	EncDesktopSizePseudo             EncodingType = -223
	EncLastRectPseudo                EncodingType = -224
	EncPointerPosPseudo              EncodingType = -232
	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
	EncExtendedDesktopSizePseudo     EncodingType = -308
	EncXvpPseudo                     EncodingType = -309
	EncFencePseudo                   EncodingType = -312
	EncContinuousUpdatesPseudo       EncodingType = -313
	EncClientRedirect                EncodingType = -311
	EncTightPNGBase64                EncodingType = 21 + 0x574d5600
	EncTightDiffComp                 EncodingType = 22 + 0x574d5600
	EncVMWDefineCursor               EncodingType = 100 + 0x574d5600
	EncVMWCursorState                EncodingType = 101 + 0x574d5600
	EncVMWCursorPosition             EncodingType = 102 + 0x574d5600
	EncVMWTypematicInfo              EncodingType = 103 + 0x574d5600
	EncVMWLEDState                   EncodingType = 104 + 0x574d5600
	EncVMWServerPush2                EncodingType = 123 + 0x574d5600
	EncVMWServerCaps                 EncodingType = 122 + 0x574d5600
	EncVMWFrameStamp                 EncodingType = 124 + 0x574d5600
	EncOffscreenCopyRect             EncodingType = 126 + 0x574d5600
)

func (EncodingType) String

func (enct EncodingType) String() string

type IClientConn

type IClientConn interface {
	CurrentPixelFormat() *PixelFormat
	//CurrentColorMap() *ColorMap
	Encodings() []IEncoding
}

type IEncoding

type IEncoding interface {
	// The number that uniquely identifies this encoding type.
	Type() int32
	WriteTo(w io.Writer) (n int, err error)
	// Read reads the contents of the encoded pixel data from the reader.
	// This should return a new IEncoding implementation that contains
	// the proper data.
	Read(*PixelFormat, *Rectangle, *RfbReadHelper) (IEncoding, error)
}

An IEncoding implements a method for encoding pixel data that is sent by the server to the client.

type IServerConn

type IServerConn interface {
	io.ReadWriter
	//IServerConn() io.ReadWriter
	Protocol() string
	CurrentPixelFormat() *PixelFormat
	SetPixelFormat(*PixelFormat) error
	//ColorMap() *ColorMap
	SetColorMap(*ColorMap)
	Encodings() []IEncoding
	SetEncodings([]EncodingType) error
	Width() uint16
	Height() uint16
	SetWidth(uint16)
	SetHeight(uint16)
	DesktopName() string
	SetDesktopName(string)
	//Flush() error
	SetProtoVersion(string)
}

type MultiListener

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

func (*MultiListener) AddListener

func (m *MultiListener) AddListener(listener SegmentConsumer)

func (*MultiListener) Consume

func (m *MultiListener) Consume(seg *RfbSegment) error

type PixelFormat

type PixelFormat struct {
	BPP        uint8
	Depth      uint8
	BigEndian  uint8
	TrueColor  uint8
	RedMax     uint16
	GreenMax   uint16
	BlueMax    uint16
	RedShift   uint8
	GreenShift uint8
	BlueShift  uint8
}

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

See RFC 6143 Section 7.4 for information on each of the fields.

func NewPixelFormat

func NewPixelFormat(bpp uint8) *PixelFormat

func (*PixelFormat) WriteTo

func (format *PixelFormat) WriteTo(w io.Writer) error

type Rectangle

type Rectangle struct {
	X      uint16
	Y      uint16
	Width  uint16
	Height uint16
	Enc    IEncoding
}

Rectangle represents a rectangle of pixel data.

func (*Rectangle) String

func (r *Rectangle) String() string

type RfbReadHelper

type RfbReadHelper struct {
	io.Reader
	Listeners *MultiListener
	// contains filtered or unexported fields
}

func NewRfbReadHelper

func NewRfbReadHelper(r io.Reader) *RfbReadHelper

func (*RfbReadHelper) EndByteCollection

func (r *RfbReadHelper) EndByteCollection() []byte

func (*RfbReadHelper) PublishBytes

func (r *RfbReadHelper) PublishBytes(p []byte) error

func (*RfbReadHelper) Read

func (r *RfbReadHelper) Read(p []byte) (n int, err error)

func (*RfbReadHelper) ReadBytes

func (r *RfbReadHelper) ReadBytes(count int) ([]byte, error)

func (*RfbReadHelper) ReadCompactLen

func (r *RfbReadHelper) ReadCompactLen() (int, error)

func (*RfbReadHelper) ReadDiscrete

func (r *RfbReadHelper) ReadDiscrete(p []byte) (int, error)

func (*RfbReadHelper) ReadTightData

func (r *RfbReadHelper) ReadTightData(dataSize int) ([]byte, error)

func (*RfbReadHelper) ReadUint16

func (r *RfbReadHelper) ReadUint16() (uint16, error)

func (*RfbReadHelper) ReadUint32

func (r *RfbReadHelper) ReadUint32() (uint32, error)

func (*RfbReadHelper) ReadUint8

func (r *RfbReadHelper) ReadUint8() (uint8, error)

func (*RfbReadHelper) SendMessageEnd

func (r *RfbReadHelper) SendMessageEnd(messageType ServerMessageType) error

func (*RfbReadHelper) SendMessageStart

func (r *RfbReadHelper) SendMessageStart(upcomingMessageType ServerMessageType) error

func (*RfbReadHelper) SendRectSeparator

func (r *RfbReadHelper) SendRectSeparator(upcomingRectType int) error

func (*RfbReadHelper) StartByteCollection

func (r *RfbReadHelper) StartByteCollection()

type RfbSegment

type RfbSegment struct {
	Bytes              []byte
	SegmentType        SegmentType
	UpcomingObjectType int
	Message            interface{}
}

type SegmentConsumer

type SegmentConsumer interface {
	Consume(*RfbSegment) error
}

type SegmentType

type SegmentType int
const (
	SegmentBytes SegmentType = iota
	SegmentMessageStart
	SegmentRectSeparator
	SegmentFullyParsedClientMessage
	SegmentFullyParsedServerMessage
	SegmentServerInitMessage
	SegmentConnectionClosed
	SegmentMessageEnd
)

func (SegmentType) String

func (seg SegmentType) String() string

type ServerInit

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

type ServerMessage

type ServerMessage interface {
	Type() uint8
	String() string
	CopyTo(r io.Reader, w io.Writer, c IClientConn) error
	Read(IClientConn, *RfbReadHelper) (ServerMessage, error)
}

type ServerMessageType

type ServerMessageType int8
const (
	FramebufferUpdate ServerMessageType = iota
	SetColourMapEntries
	Bell
	ServerCutText
	ServerFence = 248
)

func (ServerMessageType) String

func (typ ServerMessageType) String() string

Jump to

Keyboard shortcuts

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