vnc

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

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

Go to latest
Published: May 2, 2016 License: MIT Imports: 12 Imported by: 1

README

RFB Library for Go

go-vnc is a client-side RFB library for Go.

This library implements RFC 6143.

Usage & Installation

The library is installable via standard go get. The package name is vnc.

$ go get github.com/rnd-user/go-vnc

Documentation is available on GoDoc: http://godoc.org/github.com/rnd-user/go-vnc

Documentation

Overview

Package vnc implements the client side of the Remote Framebuffer protocol, typically used in VNC clients.

References:

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

Index

Constants

View Source
const (
	InvalidSecType = SecurityType(iota)
	NoneSecType
	VNCSecType
)
View Source
const (
	RawEncType                     = EncodingType(0)
	CopyRectEncType                = EncodingType(1)
	HextileEncType                 = EncodingType(5)
	TightEncType                   = EncodingType(7) //
	DesktopSizePseudoEncType       = EncodingType(-223)
	CursorPseudoEncType            = EncodingType(-239)
	TightPNGEncType                = EncodingType(-260) //
	ContinuousUpdatesPseudoEncType = EncodingType(-313) //
)
View Source
const (
	ProtocolVersion3_3 = "RFB 003.003\n"
	ProtocolVersion3_7 = "RFB 003.007\n"
	ProtocolVersion3_8 = "RFB 003.008\n"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BellMsg

type BellMsg struct{}

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

See RFC 6143 Section 7.6.3

func (*BellMsg) ID

func (*BellMsg) ID() MessageID

func (*BellMsg) Receive

func (*BellMsg) Receive(*ClientConn) (ServerMessage, error)

type ClientAuth

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

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

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

type ClientConn

type ClientConn struct {

	// 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
	// contains filtered or unexported fields
}

func NewClientConn

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

func (*ClientConn) Close

func (c *ClientConn) Close() error

func (*ClientConn) Handshake

func (c *ClientConn) Handshake() (err error)

func (*ClientConn) PixelFormat

func (c *ClientConn) PixelFormat() *PixelFormat

func (*ClientConn) ReceiveMsg

func (c *ClientConn) ReceiveMsg() (ServerMessage, error)

func (*ClientConn) SendMsg

func (c *ClientConn) SendMsg(m ClientMessage) error

type ClientConnConfig

type ClientConnConfig struct {
	Address string

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

	// A map 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 map[MessageID]ServerMessage
}

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

type ClientCutTextMsg

type ClientCutTextMsg struct {
	ID   MessageID
	Text string // Latin-1 (ISO 8859-1) characters only
}

func (*ClientCutTextMsg) Send

func (m *ClientCutTextMsg) Send(c *ClientConn) error

type ClientMessage

type ClientMessage interface {
	// Send writes the content of the message to the writer, including the message type.
	Send(*ClientConn) error
}

type Color

type Color struct {
	R, G, B uint16
}

type ColorMap

type ColorMap []Color

func (ColorMap) UpdateColorMap

func (cm ColorMap) UpdateColorMap(firstColor uint16, colors []Color) error

type CopyRectEncoding

type CopyRectEncoding struct {
	SX, SY uint16
}

func (*CopyRectEncoding) Read

func (*CopyRectEncoding) Read(c *ClientConn, rect *Rectangle) (Encoding, error)

func (*CopyRectEncoding) Type

type CursorPseudoEncoding

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

func (*CursorPseudoEncoding) PNG

func (enc *CursorPseudoEncoding) PNG(rect *Rectangle) ([]byte, error)

func (*CursorPseudoEncoding) RGBA

func (enc *CursorPseudoEncoding) RGBA(*Rectangle) ([]byte, error)

func (*CursorPseudoEncoding) Read

func (*CursorPseudoEncoding) Type

type DesktopSizePseudoEncoding

type DesktopSizePseudoEncoding struct{}

func (*DesktopSizePseudoEncoding) Read

func (*DesktopSizePseudoEncoding) Type

type Encoding

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

	// 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) (Encoding, error)
}

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

type EncodingType

type EncodingType int32

type FramebufferUpdateMsg

type FramebufferUpdateMsg struct {
	Rectangles []Rectangle
}

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

func (*FramebufferUpdateMsg) ID

func (*FramebufferUpdateMsg) Receive

type FramebufferUpdateRequestMsg

type FramebufferUpdateRequestMsg struct {
	ID          MessageID
	Incremental uint8
	X           uint16
	Y           uint16
	Width       uint16
	Height      uint16
}

func (*FramebufferUpdateRequestMsg) Send

type HextileEncoding

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

func (*HextileEncoding) PNG

func (enc *HextileEncoding) PNG(*Rectangle) ([]byte, error)

func (*HextileEncoding) Read

func (enc *HextileEncoding) Read(c *ClientConn, rect *Rectangle) (Encoding, error)

func (*HextileEncoding) Type

func (*HextileEncoding) Type() EncodingType

type KeyEventMsg

type KeyEventMsg struct {
	ID       MessageID
	DownFlag uint8

	Key uint32
	// contains filtered or unexported fields
}

func (*KeyEventMsg) Send

func (m *KeyEventMsg) Send(c *ClientConn) error

type MessageID

type MessageID uint8
const (
	SetPixelFormatMID MessageID = iota

	SetEncodingsMID
	FramebufferUpdateRequestMID
	KeyEventMID
	PointerEventMID
	ClientCutTextMID
)
const (
	FramebufferUpdateMID MessageID = iota
	SetColorMapEntriesMID
	BellMID
	ServerCutTextMID
)

type NoneAuth

type NoneAuth struct{}

NoneAuth is the "none" authentication. See 7.2.1

func (*NoneAuth) Handshake

func (*NoneAuth) Handshake(*ClientConn) error

func (*NoneAuth) Type

func (*NoneAuth) Type() SecurityType

type PixelFormat

type PixelFormat struct {
	ByPP      uint8
	ByteOrder binary.ByteOrder
	*RFBPixelFormat

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

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(rpf *RFBPixelFormat) *PixelFormat

func (*PixelFormat) ReadPixels

func (pf *PixelFormat) ReadPixels(r io.Reader, numPixels int) ([]byte, error)

type PointerEventMsg

type PointerEventMsg struct {
	ID         MessageID
	ButtonMask uint8
	X          uint16
	Y          uint16
}

func (*PointerEventMsg) Send

func (m *PointerEventMsg) Send(c *ClientConn) error

type RFBPixelFormat

type RFBPixelFormat struct {
	BPP        uint8
	Depth      uint8
	BigEndian  uint8
	TrueColor  uint8
	RedMax     uint16
	GreenMax   uint16
	BlueMax    uint16
	RedShift   uint8
	GreenShift uint8
	BlueShift  uint8
	// contains filtered or unexported fields
}

type RawEncoding

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

RawEncoding is raw pixel data sent by the server.

See RFC 6143 Section 7.7.1

func (*RawEncoding) PNG

func (enc *RawEncoding) PNG(rect *Rectangle) ([]byte, error)

func (*RawEncoding) RGBA

func (enc *RawEncoding) RGBA(*Rectangle) ([]byte, error)

func (*RawEncoding) Read

func (*RawEncoding) Read(c *ClientConn, rect *Rectangle) (Encoding, error)

func (*RawEncoding) Type

func (*RawEncoding) Type() EncodingType

type Rectangle

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

Rectangle represents a rectangle of pixel data.

type SecurityType

type SecurityType uint8

type ServerCutTextMsg

type ServerCutTextMsg struct {
	Text string
}

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

See RFC 6143 Section 7.6.4

func (*ServerCutTextMsg) ID

func (*ServerCutTextMsg) Receive

type ServerMessage

type ServerMessage interface {
	// ID returns the id of the message that is sent down on the wire.
	ID() MessageID

	// Receive reads the content 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 having the appropriate type.
	Receive(*ClientConn) (ServerMessage, error)
}

type SetColorMapEntriesMsg

type SetColorMapEntriesMsg struct {
	FirstColor uint16
	Colors     ColorMap
}

SetColorMapEntriesMsg 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 (*SetColorMapEntriesMsg) ID

func (*SetColorMapEntriesMsg) Receive

type SetEncodingsMsg

type SetEncodingsMsg struct {
	ID        MessageID
	Encodings []Encoding
}

func (*SetEncodingsMsg) Send

func (m *SetEncodingsMsg) Send(c *ClientConn) error

type SetPixelFormatMsg

type SetPixelFormatMsg struct {
	ID MessageID

	RFBPixelFormat
	// contains filtered or unexported fields
}

func (*SetPixelFormatMsg) Send

func (m *SetPixelFormatMsg) Send(c *ClientConn) error

type VNCAuth

type VNCAuth struct {
	Password string
}

VNCAuth is VNC authentication, 7.2.2

func (*VNCAuth) Handshake

func (a *VNCAuth) Handshake(c *ClientConn) error

func (*VNCAuth) Type

func (a *VNCAuth) Type() SecurityType

Jump to

Keyboard shortcuts

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