vncclient

package
v0.4.17-0...-cd529aa Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: MIT Imports: 16 Imported by: 0

README

VNC Library for Go

Client forked from:

$ go get github.com/mitchellh/vncclient

Documentation

Overview

Package vncclient implements a VNC client.

References:

[PROTOCOL]: http://tools.ietf.org/html/rfc6143

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseProtocolVersion

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

func ReadPixelFormat

func ReadPixelFormat(r io.Reader, result *PixelFormat) error

func WritePixelFormat

func WritePixelFormat(format *PixelFormat) ([]byte, error)

Types

type BellMessage

type BellMessage byte

BellMessage signals that an audible bell should be made on the client.

See RFC 6143 Section 7.6.3

func (*BellMessage) Read

func (*BellMessage) Type

func (*BellMessage) Type() uint8

type ButtonMask

type ButtonMask uint8

ButtonMask represents a mask of pointer presses/releases.

const (
	ButtonLeft ButtonMask = 1 << iota
	ButtonMiddle
	ButtonRight
	Button4
	Button5
	Button6
	Button7
	Button8
)

All available button mask components.

type ByteReader

type ByteReader struct {
	io.Reader
	// contains filtered or unexported fields
}

func NewByteReader

func NewByteReader(r io.Reader) *ByteReader

func (*ByteReader) ReadByte

func (br *ByteReader) ReadByte() (byte, error)

type ClientAuth

type ClientAuth interface {
	// SecurityType returns the byte identifier sent by the server to
	// identify this authentication scheme.
	SecurityType() uint8

	// Handshake is called when the authentication handshake should be
	// performed, as part of the general RFB handshake. (see 7.2.1)
	Handshake(net.Conn) error
}

A ClientAuth implements a method of authenticating with a remote server.

type ClientAuthNone

type ClientAuthNone byte

ClientAuthNone is the "none" authentication. See 7.2.1

func (*ClientAuthNone) Handshake

func (*ClientAuthNone) Handshake(net.Conn) error

func (*ClientAuthNone) SecurityType

func (*ClientAuthNone) SecurityType() uint8

type ClientConfig

type ClientConfig struct {
	// A slice of ClientAuth methods. Only the first instance that is
	// suitable by the server will be used to authenticate.
	Auth []ClientAuth

	// Exclusive determines whether the connection is shared with other
	// clients. If true, then all other clients connected will be
	// disconnected when a connection is established to the VNC server.
	Exclusive bool

	// The channel that all messages received from the server will be
	// sent on. If the channel blocks, then the goroutine reading data
	// from the VNC server may block indefinitely. It is up to the user
	// of the library to ensure that this channel is properly read.
	// If this is not set, then all messages will be discarded.
	ServerMessageCh chan<- ServerMessage

	// A slice of supported messages that can be read from the server.
	// This only needs to contain NEW server messages, and doesn't
	// need to explicitly contain the RFC-required messages.
	ServerMessages []ServerMessage

	ErrorCh chan error
}

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 {

	// If the pixel format uses a color map, then this is the color
	// map that is used. This should not be modified directly, since
	// the data comes from the server.
	ColorMap [256]Color

	// Encodings supported by the client. This should not be modified
	// directly. Instead, SetEncodings should be used.
	Encs []Encoding

	// Width of the frame buffer in pixels, sent from the server.
	FramebufferWidth uint16

	// Height of the frame buffer in pixels, sent from the server.
	FramebufferHeight uint16

	// Name associated with the desktop, sent from the server.
	DesktopName string

	// The pixel format associated with the connection. This shouldn't
	// be modified. If you wish to set a new pixel format, use the
	// SetPixelFormat method.
	PixelFormat PixelFormat
	// contains filtered or unexported fields
}

func Client

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

func (*ClientConn) Close

func (c *ClientConn) Close() error

func (*ClientConn) CutText

func (c *ClientConn) CutText(text string) error

CutText tells the server that the client has new text in its cut buffer. The text string MUST only contain Latin-1 characters. This encoding is compatible with Go's native string format, but can only use up to unicode.MaxLatin values.

See RFC 6143 Section 7.5.6

func (*ClientConn) FramebufferUpdateRequest

func (c *ClientConn) FramebufferUpdateRequest(incremental bool, x, y, width, height uint16) error

FramebufferUpdateRequest requests a framebuffer update from the server. There may be an indefinite time between the request and the actual framebuffer update being received.

See RFC 6143 Section 7.5.3

func (*ClientConn) KeyEvent

func (c *ClientConn) KeyEvent(keysym uint32, down bool) error

KeyEvent indiciates a key press or release and sends it to the server. The key is indicated using the X Window System "keysym" value. Use Google to find a reference of these values. To simulate a key press, you must send a key with both a down event, and a non-down event.

See 7.5.4.

func (*ClientConn) PointerEvent

func (c *ClientConn) PointerEvent(mask ButtonMask, x, y uint16) error

PointerEvent indicates that pointer movement or a pointer button press or release.

The mask is a bitwise mask of various ButtonMask values. When a button is set, it is pressed, when it is unset, it is released.

See RFC 6143 Section 7.5.5

func (*ClientConn) SetEncodings

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

SetEncodings sets the encoding types in which the pixel data can be sent from the server. After calling this method, the encs slice given should not be modified.

See RFC 6143 Section 7.5.2

func (*ClientConn) SetPixelFormat

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

SetPixelFormat sets the format in which pixel values should be sent in FramebufferUpdate messages from the server.

See RFC 6143 Section 7.5.1

type Color

type Color struct {
	R, G, B uint8
}

Color represents a single color in a color map.

type CompressLevel

type CompressLevel uint32

Compression level

func (CompressLevel) Read

func (l CompressLevel) Read(c *ClientConn, rect *Rectangle, r io.Reader) (Encoding, error)

func (CompressLevel) Size

func (l CompressLevel) Size() int

func (CompressLevel) Type

func (l CompressLevel) Type() int32

type Encoding

type Encoding interface {
	// The number that uniquely identifies this encoding type.
	Type() int32

	// Read reads the contents of the encoded pixel data from the reader.
	// This should return a new Encoding implementation that contains
	// the proper data.
	Read(*ClientConn, *Rectangle, io.Reader) (Encoding, error)

	Size() int
}

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

type FineQualityLevel

type FineQualityLevel uint32

func (FineQualityLevel) Read

func (f FineQualityLevel) Read(c *ClientConn, rect *Rectangle, r io.Reader) (Encoding, error)

func (FineQualityLevel) Size

func (f FineQualityLevel) Size() int

func (FineQualityLevel) Type

func (f FineQualityLevel) Type() int32

type FramebufferUpdateMessage

type FramebufferUpdateMessage struct {
	Rectangles []Rectangle
}

FramebufferUpdateMessage consists of a sequence of rectangles of pixel data that the client should put into its framebuffer.

func (*FramebufferUpdateMessage) Read

func (*FramebufferUpdateMessage) Type

type JPEGQuality

type JPEGQuality uint8

Superceded by the Fine Quality Level / Compress Level options

func (JPEGQuality) Read

func (JPEGQuality) Size

func (JPEGQuality) Size() int

func (JPEGQuality) Type

func (j JPEGQuality) Type() int32

type PasswordAuth

type PasswordAuth struct {
	Password string
}

PasswordAuth is VNC authentication, 7.2.2

func (*PasswordAuth) Handshake

func (p *PasswordAuth) Handshake(c net.Conn) error

func (*PasswordAuth) SecurityType

func (p *PasswordAuth) SecurityType() uint8

type PixelFormat

type PixelFormat struct {
	BPP        uint8
	Depth      uint8
	BigEndian  bool
	TrueColor  bool
	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.

type QualityLevel

type QualityLevel uint32

func (QualityLevel) Read

func (f QualityLevel) Read(c *ClientConn, rect *Rectangle, r io.Reader) (Encoding, error)

func (QualityLevel) Size

func (f QualityLevel) Size() int

func (QualityLevel) Type

func (f QualityLevel) Type() int32

type QuickBuf

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

func NewQuickBuf

func NewQuickBuf(buf []byte) *QuickBuf

func (*QuickBuf) Len

func (b *QuickBuf) Len() int

func (*QuickBuf) ReadByte

func (b *QuickBuf) ReadByte() (byte, error)

func (*QuickBuf) ReadColor

func (b *QuickBuf) ReadColor() (Color, error)

func (*QuickBuf) ReadColors

func (b *QuickBuf) ReadColors(n int) ([]Color, error)

type RawEncoding

type RawEncoding struct {
	Colors []Color
}

RawEncoding is raw pixel data sent by the server.

See RFC 6143 Section 7.7.1

func (*RawEncoding) Read

func (*RawEncoding) Read(c *ClientConn, rect *Rectangle, r io.Reader) (Encoding, error)

func (*RawEncoding) Size

func (r *RawEncoding) Size() int

func (*RawEncoding) Type

func (*RawEncoding) Type() int32

type Rectangle

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

Rectangle represents a rectangle of pixel data.

func (*Rectangle) Area

func (r *Rectangle) Area() int

type ServerCutTextMessage

type ServerCutTextMessage struct {
	Text string
}

ServerCutTextMessage indicates the server has new text in the cut buffer.

See RFC 6143 Section 7.6.4

func (*ServerCutTextMessage) Read

func (*ServerCutTextMessage) Type

func (*ServerCutTextMessage) Type() uint8

type ServerMessage

type ServerMessage interface {
	// The type of the message that is sent down on the wire.
	Type() uint8

	// Read reads the contents of the message from the reader. At the point
	// this is called, the message type has already been read from the reader.
	// This should return a new ServerMessage that is the appropriate type.
	Read(*ClientConn, io.Reader) (ServerMessage, error)
}

A ServerMessage implements a message sent from the server to the client.

type SetColorMapEntriesMessage

type SetColorMapEntriesMessage struct {
	FirstColor uint16
	Colors     []Color
}

SetColorMapEntriesMessage is sent by the server to set values into the color map. This message will automatically update the color map for the associated connection, but contains the color change data if the consumer wants to read it.

See RFC 6143 Section 7.6.2

func (*SetColorMapEntriesMessage) Read

func (*SetColorMapEntriesMessage) Type

type SubsampleLevel

type SubsampleLevel uint32

func (SubsampleLevel) Read

func (s SubsampleLevel) Read(c *ClientConn, rect *Rectangle, r io.Reader) (Encoding, error)

func (SubsampleLevel) Size

func (s SubsampleLevel) Size() int

func (SubsampleLevel) Type

func (s SubsampleLevel) Type() int32

type TightEncoding

type TightEncoding struct {
	Colors []Color
	// contains filtered or unexported fields
}

TightEncoding provides efficient compression for pixel data.

Spec:

https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#tight-encoding

func (*TightEncoding) Read

func (t *TightEncoding) Read(c *ClientConn, rect *Rectangle, r io.Reader) (Encoding, error)

func (*TightEncoding) Size

func (t *TightEncoding) Size() int

func (*TightEncoding) Type

func (*TightEncoding) Type() int32

type ZRLEEncoding

type ZRLEEncoding struct {
	Colors []Color
	// contains filtered or unexported fields
}

ZRLEEncoding is Zlib run-length encoded pixel data

See RFC 6143 Section 7.7.6

func (*ZRLEEncoding) Read

func (z *ZRLEEncoding) Read(c *ClientConn, rect *Rectangle, r io.Reader) (Encoding, error)

func (*ZRLEEncoding) Size

func (z *ZRLEEncoding) Size() int

func (*ZRLEEncoding) Type

func (*ZRLEEncoding) Type() int32

Jump to

Keyboard shortcuts

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