rfb

package
v0.0.0-...-dc5d5ba Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package rfb defines representations and serialization for messages in the RFB (Remote Framebuffer) protocol, which is used for VNC.

Types that do not not have a protocol version suffix such as "RFB33" are appropriate for use with all versions of the RFB protocol.

See the RFCs for details, but the initial handshake goes like this:

server sends ProtocolVersionMessage
client sends ProtocolVersionMessage
server sends AuthenticationSchemeMessageRFB33
	If AuthenticationSchemeVNC:
		server sends VNCAuthenticationChallengeMessage
		client sends VNCAuthenticationResponseMessage
		server sends VNCAuthenticationResultMessage
client sends ClientInitialisationMessage
server sends ServerInitialisationMessage

Thereafter, client and server enter message processing loops. The first byte identifies the message type, which dictates the length of the payload, so all clients and servers must process all event types.

Clients may send:

Type 0	SetPixelFormatMessage
Type 1	FixColourMapEntries — uncommon, not implemented by this library
Type 2	SetEncodingsMessage
Type 3	FramebufferUpdateRequestMessage
Type 4	KeyEventMessage
Type 5	PointerEventMessage
Type 6	ClientCutTextMessage

Servers may send:

Type 0	FramebufferUpdate
Type 1	SetColourMapEntries — uncommon, not implemented by this library
Type 2	BellMessage
Type 3	ServerCutTextMessage

Index

Constants

View Source
const (
	AuthenticationSchemeInvalid = AuthenticationScheme(0)
	AuthenticationSchemeNone    = AuthenticationScheme(1)
	AuthenticationSchemeVNC     = AuthenticationScheme(2)
)
View Source
const (
	VNCAuthenticationResultOK      = VNCAuthenticationResult(0)
	VNCAuthenticationResultFailed  = VNCAuthenticationResult(1)
	VNCAuthenticationResultTooMany = VNCAuthenticationResult(2)
)
View Source
const (
	EncodingTypeRaw           = uint32(0)
	EncodingTypeCopyRectangle = uint32(1)
	EncodingTypeRRE           = uint32(2)
	EncodingTypeCoRRE         = uint32(4)
	EncodingTypeHextile       = uint32(5)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationScheme

type AuthenticationScheme uint32

type AuthenticationSchemeMessageRFB33

type AuthenticationSchemeMessageRFB33 struct {
	Scheme AuthenticationScheme
}

func (*AuthenticationSchemeMessageRFB33) Read

func (*AuthenticationSchemeMessageRFB33) Write

type BellMessage

type BellMessage struct{}

func (*BellMessage) Read

func (m *BellMessage) Read(r io.Reader) error

func (*BellMessage) Write

func (m *BellMessage) Write(w io.Writer) error

type ClientCutTextMessage

type ClientCutTextMessage struct {
	Text string
}

func (*ClientCutTextMessage) Read

func (*ClientCutTextMessage) Write

type ClientInitialisationMessage

type ClientInitialisationMessage struct {
	// If true, share the desktop with other clients.
	// If false, disconnect all other clients.
	Shared bool
}

func (*ClientInitialisationMessage) Read

func (*ClientInitialisationMessage) Write

type FramebufferUpdateMessage

type FramebufferUpdateMessage struct {
	Rectangles []*FramebufferUpdateRect
}

func (*FramebufferUpdateMessage) Read

func (m *FramebufferUpdateMessage) Read(r io.Reader, bo binary.ByteOrder, pixelFormat PixelFormat) error

func (*FramebufferUpdateMessage) Write

type FramebufferUpdateRect

type FramebufferUpdateRect struct {
	X            uint16
	Y            uint16
	Width        uint16
	Height       uint16
	EncodingType uint32 // Unsigned per spec, but often interpreted signed
	PixelData    []byte
}

func (*FramebufferUpdateRect) Read

func (rect *FramebufferUpdateRect) Read(r io.Reader, bo binary.ByteOrder, pixelFormat PixelFormat) error

func (*FramebufferUpdateRect) Write

func (rect *FramebufferUpdateRect) Write(w io.Writer, bo binary.ByteOrder) error

type FramebufferUpdateRequestMessage

type FramebufferUpdateRequestMessage struct {
	// If true, only updates to changed portions of the framebuffer are requested.
	// If false, the entire region should be returned and EncodingTypeCopyRectangle is not supported.
	Incremental bool

	X      uint16
	Y      uint16
	Width  uint16
	Height uint16
}

func (*FramebufferUpdateRequestMessage) Read

func (*FramebufferUpdateRequestMessage) Write

type KeyEventMessage

type KeyEventMessage struct {
	Pressed bool
	KeySym  uint32 // Defined in Xlib Reference Manual and <X11/keysymdef.h>
}

func (*KeyEventMessage) Read

func (m *KeyEventMessage) Read(r io.Reader, bo binary.ByteOrder) error

func (*KeyEventMessage) Write

func (m *KeyEventMessage) Write(w io.Writer, bo binary.ByteOrder) error

type PixelFormat

type PixelFormat struct {
	BitsPerPixel uint8
	BitDepth     uint8
	BigEndian    bool
	TrueColor    bool

	RedMax     uint16
	GreenMax   uint16
	BlueMax    uint16
	RedShift   uint8
	GreenShift uint8
	BlueShift  uint8
}

func (*PixelFormat) Read

func (pf *PixelFormat) Read(buf []byte, bo binary.ByteOrder)

buf must contain at least 16 bytes.

func (*PixelFormat) Write

func (pf *PixelFormat) Write(buf []byte, bo binary.ByteOrder)

buf must contain at least 16 bytes.

type PixelFormatColor

type PixelFormatColor struct {
	Pixel       uint32
	PixelFormat PixelFormat
}

func (PixelFormatColor) RGBA

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

type PixelFormatImage

type PixelFormatImage struct {
	Pix         []uint8
	Rect        image.Rectangle
	PixelFormat PixelFormat
}

func NewPixelFormatImage

func NewPixelFormatImage(pixelFormat PixelFormat, bounds image.Rectangle) *PixelFormatImage

func (*PixelFormatImage) At

func (img *PixelFormatImage) At(x, y int) color.Color

func (*PixelFormatImage) Bounds

func (img *PixelFormatImage) Bounds() image.Rectangle

func (*PixelFormatImage) ColorModel

func (img *PixelFormatImage) ColorModel() color.Model

func (*PixelFormatImage) Set

func (img *PixelFormatImage) Set(x, y int, c color.Color)

type PointerEventMessage

type PointerEventMessage struct {
	ButtonMask uint8
	X          uint16
	Y          uint16
}

func (*PointerEventMessage) Read

func (*PointerEventMessage) Write

type ProtocolVersionMessage

type ProtocolVersionMessage struct {
	Major, Minor int
}

func (*ProtocolVersionMessage) Read

func (*ProtocolVersionMessage) Write

func (m *ProtocolVersionMessage) Write(w io.Writer) error

type ServerCutTextMessage

type ServerCutTextMessage struct {
	Text string
}

func (*ServerCutTextMessage) Read

func (*ServerCutTextMessage) Write

type ServerInitialisationMessage

type ServerInitialisationMessage struct {
	FramebufferWidth  uint16
	FramebufferHeight uint16
	PixelFormat       PixelFormat
	Name              string
}

func (*ServerInitialisationMessage) Read

func (*ServerInitialisationMessage) Write

type SetEncodingsMessage

type SetEncodingsMessage struct {
	EncodingTypes []uint32
}

func (*SetEncodingsMessage) Read

func (*SetEncodingsMessage) Write

type SetPixelFormatMessage

type SetPixelFormatMessage struct {
	PixelFormat PixelFormat
}

func (*SetPixelFormatMessage) Read

func (*SetPixelFormatMessage) Write

type VNCAuthenticationChallengeMessage

type VNCAuthenticationChallengeMessage [16]byte

func (*VNCAuthenticationChallengeMessage) Read

func (*VNCAuthenticationChallengeMessage) Write

type VNCAuthenticationResponseMessage

type VNCAuthenticationResponseMessage [16]byte

func (*VNCAuthenticationResponseMessage) Read

func (*VNCAuthenticationResponseMessage) Write

type VNCAuthenticationResult

type VNCAuthenticationResult uint32

type VNCAuthenticationResultMessage

type VNCAuthenticationResultMessage struct {
	Result VNCAuthenticationResult
}

func (*VNCAuthenticationResultMessage) Read

func (*VNCAuthenticationResultMessage) Write

Jump to

Keyboard shortcuts

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