server

package
v0.0.0-...-aec44c9 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtoVersionUnknown = ""
	ProtoVersion33      = "RFB 003.003\n"
	ProtoVersion38      = "RFB 003.008\n"
)
View Source
const (
	StandardVendor  = "STDV"
	TridiaVncVendor = "TRDV"
	TightVncVendor  = "TGHT"
)
View Source
const (
	SecTypeUnknown  = SecurityType(0)
	SecTypeNone     = SecurityType(1)
	SecTypeVNC      = SecurityType(2)
	SecTypeVeNCrypt = SecurityType(19)
)
View Source
const (
	SecSubTypeVeNCrypt01Unknown   = SecuritySubType(0)
	SecSubTypeVeNCrypt01Plain     = SecuritySubType(19)
	SecSubTypeVeNCrypt01TLSNone   = SecuritySubType(20)
	SecSubTypeVeNCrypt01TLSVNC    = SecuritySubType(21)
	SecSubTypeVeNCrypt01TLSPlain  = SecuritySubType(22)
	SecSubTypeVeNCrypt01X509None  = SecuritySubType(23)
	SecSubTypeVeNCrypt01X509VNC   = SecuritySubType(24)
	SecSubTypeVeNCrypt01X509Plain = SecuritySubType(25)
)
View Source
const (
	SecSubTypeVeNCrypt02Unknown   = SecuritySubType(0)
	SecSubTypeVeNCrypt02Plain     = SecuritySubType(256)
	SecSubTypeVeNCrypt02TLSNone   = SecuritySubType(257)
	SecSubTypeVeNCrypt02TLSVNC    = SecuritySubType(258)
	SecSubTypeVeNCrypt02TLSPlain  = SecuritySubType(259)
	SecSubTypeVeNCrypt02X509None  = SecuritySubType(260)
	SecSubTypeVeNCrypt02X509VNC   = SecuritySubType(261)
	SecSubTypeVeNCrypt02X509Plain = SecuritySubType(262)
)
View Source
const AUTH_FAIL = "Authentication Failure"
View Source
const ProtoVersionLength = 12
View Source
const (
	SecSubTypeUnknown = SecuritySubType(0)
)

Variables

Functions

func ParseProtoVersion

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

func ServerClientInitHandler

func ServerClientInitHandler(cfg *ServerConfig, c *ServerConn) error

func ServerSecurityHandler

func ServerSecurityHandler(cfg *ServerConfig, c *ServerConn) error

func ServerServerInitHandler

func ServerServerInitHandler(cfg *ServerConfig, c *ServerConn) error

func ServerVersionHandler

func ServerVersionHandler(cfg *ServerConfig, c *ServerConn) error

func SetUint32

func SetUint32(buf []byte, pos int, val uint32)

SetUint32 set 4 bytes at pos in buf to the val (in big endian format) A test is done to ensure there are 4 bytes available at pos in the buffer

func TcpServe

func TcpServe(url string, cfg *ServerConfig) error

func WsServe

func WsServe(url string, cfg *ServerConfig, server **WsServer) error

Types

type FramebufferUpdate

type FramebufferUpdate struct {
	NumRect uint16              // number-of-rectangles
	Rects   []*common.Rectangle // rectangles
	// contains filtered or unexported fields
}

FramebufferUpdate holds a FramebufferUpdate wire format message.

type Key

type Key uint32

Key represents a VNC key press.

type Keys

type Keys []Key

Keys is a slice of Key values.

type MsgClientCutText

type MsgClientCutText struct {
	Length uint32 // length
	Text   []byte
	// contains filtered or unexported fields
}

MsgClientCutText holds the wire format message, sans the text field.

func (*MsgClientCutText) Read

func (*MsgClientCutText) Type

func (*MsgClientCutText) Write

func (msg *MsgClientCutText) Write(c io.Writer) error

type MsgClientFence

type MsgClientFence struct {
}

func (*MsgClientFence) Read

func (*MsgClientFence) Type

func (*MsgClientFence) Write

func (msg *MsgClientFence) Write(c io.Writer) error

type MsgClientQemuExtendedKey

type MsgClientQemuExtendedKey struct {
	SubType uint8  // sub type
	IsDown  uint16 // button down indicator
	KeySym  uint32 // key symbol
	KeyCode uint32 // key code
}

MsgClientQemuExtendedKey holds the wire format message, for qemu keys

func (*MsgClientQemuExtendedKey) Read

func (*MsgClientQemuExtendedKey) Type

func (*MsgClientQemuExtendedKey) Write

func (msg *MsgClientQemuExtendedKey) Write(c io.Writer) error

type MsgFramebufferUpdateRequest

type MsgFramebufferUpdateRequest struct {
	Inc           uint8  // incremental
	X, Y          uint16 // x-, y-position
	Width, Height uint16 // width, height
}

MsgFramebufferUpdateRequest holds the wire format message.

func (*MsgFramebufferUpdateRequest) Read

func (*MsgFramebufferUpdateRequest) Type

func (*MsgFramebufferUpdateRequest) Write

type MsgKeyEvent

type MsgKeyEvent struct {
	Down uint8 // down-flag

	Key Key // key
	// contains filtered or unexported fields
}

MsgKeyEvent holds the wire format message.

func (*MsgKeyEvent) Read

func (*MsgKeyEvent) Type

func (*MsgKeyEvent) Write

func (msg *MsgKeyEvent) Write(c io.Writer) error

type MsgPointerEvent

type MsgPointerEvent struct {
	Mask uint8  // button-mask
	X, Y uint16 // x-, y-position
}

PointerEventMessage holds the wire format message.

func (*MsgPointerEvent) Read

func (*MsgPointerEvent) Type

func (*MsgPointerEvent) Write

func (msg *MsgPointerEvent) Write(c io.Writer) error

type MsgQEMUExtKeyEvent

type MsgQEMUExtKeyEvent struct {
	SubmessageType uint8  // submessage type
	DownFlag       uint16 // down-flag
	KeySym         Key    // key symbol
	KeyCode        uint32 // scan code
}

MsgKeyEvent holds the wire format message.

func (*MsgQEMUExtKeyEvent) Read

func (*MsgQEMUExtKeyEvent) Type

func (*MsgQEMUExtKeyEvent) Write

func (msg *MsgQEMUExtKeyEvent) Write(c io.Writer) error

type MsgSetEncodings

type MsgSetEncodings struct {
	EncNum    uint16 // number-of-encodings
	Encodings []common.EncodingType
	// contains filtered or unexported fields
}

MsgSetEncodings holds the wire format message, sans encoding-type field.

func (*MsgSetEncodings) Read

func (*MsgSetEncodings) Type

func (*MsgSetEncodings) Write

func (msg *MsgSetEncodings) Write(c io.Writer) error

type MsgSetPixelFormat

type MsgSetPixelFormat struct {
	PF common.PixelFormat // pixel-format
	// contains filtered or unexported fields
}

MsgSetPixelFormat holds the wire format message.

func (*MsgSetPixelFormat) Read

func (*MsgSetPixelFormat) Type

func (*MsgSetPixelFormat) Write

func (msg *MsgSetPixelFormat) Write(c io.Writer) error

type SecurityHandler

type SecurityHandler interface {
	Type() SecurityType
	SubType() SecuritySubType
	Auth(common.IServerConn) error
}

type SecuritySubType

type SecuritySubType uint32

type SecurityType

type SecurityType uint8

type ServerAuthNone

type ServerAuthNone struct{}

ServerAuthNone is the "none" authentication. See 7.2.1.

func (*ServerAuthNone) Auth

func (*ServerAuthNone) SubType

func (*ServerAuthNone) SubType() SecuritySubType

func (*ServerAuthNone) Type

func (*ServerAuthNone) Type() SecurityType

type ServerAuthVNC

type ServerAuthVNC struct {
	Pass string
}

ServerAuthVNC is the standard password authentication. See 7.2.2.

func (*ServerAuthVNC) Auth

func (auth *ServerAuthVNC) Auth(c common.IServerConn) error

func (*ServerAuthVNC) SubType

func (*ServerAuthVNC) SubType() SecuritySubType

func (*ServerAuthVNC) Type

func (*ServerAuthVNC) Type() SecurityType

type ServerConfig

type ServerConfig struct {
	SecurityHandlers []SecurityHandler
	Encodings        []common.IEncoding
	PixelFormat      *common.PixelFormat
	ColorMap         *common.ColorMap
	ClientMessages   []common.ClientMessage
	DesktopName      []byte
	Height           uint16
	Width            uint16
	UseDummySession  bool

	//handler to allow for registering for messages, this can't be a channel
	//because of the websockets handler function which will kill the connection on exit if conn.handle() is run on another thread
	NewConnHandler ServerHandler
}

type ServerConn

type ServerConn struct {

	// a consumer for the parsed messages, to allow for recording and proxy
	Listeners *common.MultiListener

	SessionId string
	// contains filtered or unexported fields
}

func NewServerConn

func NewServerConn(c io.ReadWriter, cfg *ServerConfig) (*ServerConn, error)

func (*ServerConn) Close

func (c *ServerConn) Close() error

func (*ServerConn) ColorMap

func (c *ServerConn) ColorMap() *common.ColorMap

func (*ServerConn) Conn

func (c *ServerConn) Conn() io.ReadWriter

func (*ServerConn) CurrentPixelFormat

func (c *ServerConn) CurrentPixelFormat() *common.PixelFormat

func (*ServerConn) DesktopName

func (c *ServerConn) DesktopName() string

func (*ServerConn) Encodings

func (c *ServerConn) Encodings() []common.IEncoding

func (*ServerConn) Height

func (c *ServerConn) Height() uint16

func (*ServerConn) Protocol

func (c *ServerConn) Protocol() string

func (*ServerConn) Read

func (c *ServerConn) Read(buf []byte) (int, error)

func (*ServerConn) SetColorMap

func (c *ServerConn) SetColorMap(cm *common.ColorMap)

func (*ServerConn) SetDesktopName

func (c *ServerConn) SetDesktopName(name string)

func (*ServerConn) SetEncodings

func (c *ServerConn) SetEncodings(encs []common.EncodingType) error

func (*ServerConn) SetHeight

func (c *ServerConn) SetHeight(h uint16)

func (*ServerConn) SetPixelFormat

func (c *ServerConn) SetPixelFormat(pf *common.PixelFormat) error

func (*ServerConn) SetProtoVersion

func (c *ServerConn) SetProtoVersion(pv string)

func (*ServerConn) SetWidth

func (c *ServerConn) SetWidth(w uint16)

func (*ServerConn) Width

func (c *ServerConn) Width() uint16

func (*ServerConn) Write

func (c *ServerConn) Write(buf []byte) (int, error)

type ServerHandler

type ServerHandler func(*ServerConfig, *ServerConn) error

type TightCapability

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

func (*TightCapability) ReadFrom

func (t *TightCapability) ReadFrom(r io.Reader) error

func (*TightCapability) WriteTo

func (t *TightCapability) WriteTo(w io.Writer) error

type TightServerInit

type TightServerInit struct {
	ServerMessageCaps []TightCapability
	ClientMessageCaps []TightCapability
	EncodingCaps      []TightCapability
}
  void initCapabilities() {
    tunnelCaps    = new CapsContainer();
    authCaps      = new CapsContainer();
    serverMsgCaps = new CapsContainer();
    clientMsgCaps = new CapsContainer();
    encodingCaps  = new CapsContainer();

    // Supported authentication methods
    authCaps.add(AuthNone, StandardVendor, SigAuthNone,
		 "No authentication");
    authCaps.add(AuthVNC, StandardVendor, SigAuthVNC,
		 "Standard VNC password authentication");

    // Supported non-standard server-to-client messages
    // [NONE]

    // Supported non-standard client-to-server messages
    // [NONE]

    // Supported encoding types
    encodingCaps.add(EncodingCopyRect, StandardVendor,
		     SigEncodingCopyRect, "Standard CopyRect encoding");
    encodingCaps.add(EncodingRRE, StandardVendor,
		     SigEncodingRRE, "Standard RRE encoding");
    encodingCaps.add(EncodingCoRRE, StandardVendor,
		     SigEncodingCoRRE, "Standard CoRRE encoding");
    encodingCaps.add(EncodingHextile, StandardVendor,
		     SigEncodingHextile, "Standard Hextile encoding");
    encodingCaps.add(EncodingZRLE, StandardVendor,
		     SigEncodingZRLE, "Standard ZRLE encoding");
    encodingCaps.add(EncodingZlib, TridiaVncVendor,
		     SigEncodingZlib, "Zlib encoding");
    encodingCaps.add(EncodingTight, TightVncVendor,
		     SigEncodingTight, "Tight encoding");

    // Supported pseudo-encoding types
    encodingCaps.add(EncodingCompressLevel0, TightVncVendor,
		     SigEncodingCompressLevel0, "Compression level");
    encodingCaps.add(EncodingQualityLevel0, TightVncVendor,
		     SigEncodingQualityLevel0, "JPEG quality level");
    encodingCaps.add(EncodingXCursor, TightVncVendor,
		     SigEncodingXCursor, "X-style cursor shape update");
    encodingCaps.add(EncodingRichCursor, TightVncVendor,
		     SigEncodingRichCursor, "Rich-color cursor shape update");
    encodingCaps.add(EncodingPointerPos, TightVncVendor,
		     SigEncodingPointerPos, "Pointer position update");
    encodingCaps.add(EncodingLastRect, TightVncVendor,
		     SigEncodingLastRect, "LastRect protocol extension");
    encodingCaps.add(EncodingNewFBSize, TightVncVendor,
		     SigEncodingNewFBSize, "Framebuffer size change");
  }

func (*TightServerInit) ReadFrom

func (t *TightServerInit) ReadFrom(r io.Reader) error

func (*TightServerInit) WriteTo

func (t *TightServerInit) WriteTo(w io.Writer) error

type WsHandler

type WsHandler func(io.ReadWriter, *ServerConfig, string)

type WsServer

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

func (*WsServer) Listen

func (wsServer *WsServer) Listen(urlStr string, handlerFunc WsHandler)

func (*WsServer) Shutdown

func (wsServer *WsServer) Shutdown()

Jump to

Keyboard shortcuts

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