tdp

package
v1.2.3-fred.12 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package tdp implements the Teleport desktop protocol (TDP) encoder/decoder. See https://github.com/gravitational/teleport/blob/master/rfd/0037-desktop-access-protocol.md

Index

Constants

View Source
const (
	TypeClientScreenSpec              = MessageType(1)
	TypePNGFrame                      = MessageType(2)
	TypeMouseMove                     = MessageType(3)
	TypeMouseButton                   = MessageType(4)
	TypeKeyboardButton                = MessageType(5)
	TypeClipboardData                 = MessageType(6)
	TypeClientUsername                = MessageType(7)
	TypeMouseWheel                    = MessageType(8)
	TypeError                         = MessageType(9)
	TypeMFA                           = MessageType(10)
	TypeSharedDirectoryAnnounce       = MessageType(11)
	TypeSharedDirectoryAcknowledge    = MessageType(12)
	TypeSharedDirectoryInfoRequest    = MessageType(13)
	TypeSharedDirectoryInfoResponse   = MessageType(14)
	TypeSharedDirectoryCreateRequest  = MessageType(15)
	TypeSharedDirectoryCreateResponse = MessageType(16)
	TypeSharedDirectoryDeleteRequest  = MessageType(17)
	TypeSharedDirectoryDeleteResponse = MessageType(18)
	TypeSharedDirectoryReadRequest    = MessageType(19)
	TypeSharedDirectoryReadResponse   = MessageType(20)
	TypeSharedDirectoryWriteRequest   = MessageType(21)
	TypeSharedDirectoryWriteResponse  = MessageType(22)
	TypeSharedDirectoryMoveRequest    = MessageType(23)
	TypeSharedDirectoryMoveResponse   = MessageType(24)
	TypeSharedDirectoryListRequest    = MessageType(25)
	TypeSharedDirectoryListResponse   = MessageType(26)
	TypePNG2Frame                     = MessageType(27)
)

For descriptions of each message type see: https://github.com/gravitational/teleport/blob/master/rfd/0037-desktop-access-protocol.md#message-types

View Source
const (
	LeftMouseButton   = MouseButtonType(0)
	MiddleMouseButton = MouseButtonType(1)
	RightMouseButton  = MouseButtonType(2)
)
View Source
const (
	ButtonNotPressed = ButtonState(0)
	ButtonPressed    = ButtonState(1)
)
View Source
const (
	VerticalWheelAxis   = MouseWheelAxis(0)
	HorizontalWheelAxis = MouseWheelAxis(1)
)

Variables

This section is empty.

Functions

func PNGEncoder

func PNGEncoder() *png.Encoder

PNGEncoder returns the encoder used for PNG Frames. It is not safe for concurrent use.

Types

type ButtonState

type ButtonState byte

ButtonState is the press state of a keyboard or mouse button.

type ClientScreenSpec

type ClientScreenSpec struct {
	Width  uint32
	Height uint32
}

ClientScreenSpec is the client screen specification. https://github.com/gravitational/teleport/blob/master/rfd/0037-desktop-access-protocol.md#1---client-screen-spec

func (ClientScreenSpec) Encode

func (s ClientScreenSpec) Encode() ([]byte, error)

type ClientUsername

type ClientUsername struct {
	Username string
}

ClientUsername is the client username. https://github.com/gravitational/teleport/blob/master/rfd/0037-desktop-access-protocol.md#7---client-username

func (ClientUsername) Encode

func (r ClientUsername) Encode() ([]byte, error)

type ClipboardData

type ClipboardData []byte

ClipboardData represents shared clipboard data.

func (ClipboardData) Encode

func (c ClipboardData) Encode() ([]byte, error)

type Conn

type Conn struct {

	// OnSend is an optional callback that is invoked when a TDP message
	// is sent on the wire. It is passed both the raw bytes and the encoded
	// message.
	OnSend func(m Message, b []byte)

	// OnRecv is an optional callback that is invoked when a TDP message
	// is received on the wire.
	OnRecv func(m Message)
	// contains filtered or unexported fields
}

Conn is a desktop protocol connection. It converts between a stream of bytes (io.ReadWriter) and a stream of Teleport Desktop Protocol (TDP) messages.

func NewConn

func NewConn(rw io.ReadWriter) *Conn

NewConn creates a new Conn on top of a ReadWriter, for example a TCP connection. If the provided ReadWriter also implements srv.TrackingConn, then its LocalAddr() and RemoteAddr() will apply to this Conn.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection if the underlying reader can be closed.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr returns local address

func (*Conn) ReadMessage

func (c *Conn) ReadMessage() (Message, error)

ReadMessage reads the next incoming message from the connection.

func (*Conn) ReadRaw

func (c *Conn) ReadRaw() ([]byte, error)

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns remote address

func (*Conn) SendError

func (c *Conn) SendError(message string) error

SendError is a convenience function for sending an error message.

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(m Message) error

WriteMessage sends a message to the connection.

type Error

type Error struct {
	Message string
}

func (Error) Encode

func (m Error) Encode() ([]byte, error)

type FileSystemObject

type FileSystemObject struct {
	LastModified uint64
	Size         uint64
	FileType     uint32
	IsEmpty      uint8
	Path         string
}

func (FileSystemObject) Encode

func (f FileSystemObject) Encode() ([]byte, error)

type KeyboardButton

type KeyboardButton struct {
	KeyCode uint32
	State   ButtonState
}

KeyboardButton is the keyboard button press message. https://github.com/gravitational/teleport/blob/master/rfd/0037-desktop-access-protocol.md#4---keyboard-input

func (KeyboardButton) Encode

func (k KeyboardButton) Encode() ([]byte, error)

type MFA

type MFA struct {
	// Type should be defaults.WebsocketWebauthnChallenge
	Type byte
	// MFAAuthenticateChallenge is the challenge we send to the client.
	// Used for messages from Teleport to the user's browser.
	*client.MFAAuthenticateChallenge
	// MFAAuthenticateResponse is the response to the MFA challenge,
	// sent from the browser to Teleport.
	*authproto.MFAAuthenticateResponse
}

func DecodeMFA

func DecodeMFA(in byteReader) (*MFA, error)

func DecodeMFAChallenge

func DecodeMFAChallenge(in byteReader) (*MFA, error)

DecodeMFAChallenge is a helper function used in test purpose to decode MFA challenge payload because in real flow this logic is invoked by a fronted client.

func (MFA) Encode

func (m MFA) Encode() ([]byte, error)

type Message

type Message interface {
	Encode() ([]byte, error)
}

Message is a Go representation of a desktop protocol message.

func Decode

func Decode(buf []byte) (Message, error)

Decode decodes the wire representation of a message.

type MessageType

type MessageType byte

MessageType identifies the type of the message.

type MouseButton

type MouseButton struct {
	Button MouseButtonType
	State  ButtonState
}

MouseButton is the mouse button press message. https://github.com/gravitational/teleport/blob/master/rfd/0037-desktop-access-protocol.md#4---mouse-button

func (MouseButton) Encode

func (m MouseButton) Encode() ([]byte, error)

type MouseButtonType

type MouseButtonType byte

MouseButtonType identifies a specific button on the mouse.

type MouseMove

type MouseMove struct {
	X, Y uint32
}

MouseMove is the mouse movement message. https://github.com/gravitational/teleport/blob/master/rfd/0037-desktop-access-protocol.md#3---mouse-move

func (MouseMove) Encode

func (m MouseMove) Encode() ([]byte, error)

type MouseWheel

type MouseWheel struct {
	Axis  MouseWheelAxis
	Delta int16
}

MouseWheel is the mouse wheel scroll message. https://github.com/gravitational/teleport/blob/master/rfd/0037-desktop-access-protocol.md#8---mouse-wheel

func (MouseWheel) Encode

func (w MouseWheel) Encode() ([]byte, error)

type MouseWheelAxis

type MouseWheelAxis byte

MouseWheelAxis identifies a scroll axis on the mouse wheel.

type PNG2Frame

type PNG2Frame PNGFrame

PNG2Frame is a newer versin of PNGFrame that includes the length of the PNG data.

func NewPNG

func NewPNG(img image.Image, enc *png.Encoder) PNG2Frame

func (PNG2Frame) Encode

func (f PNG2Frame) Encode() ([]byte, error)

type PNGFrame

type PNGFrame struct {
	Img image.Image
	// contains filtered or unexported fields
}

PNGFrame is the PNG frame message https://github.com/gravitational/teleport/blob/master/rfd/0037-desktop-access-protocol.md#2---png-frame

func (PNGFrame) Encode

func (f PNGFrame) Encode() ([]byte, error)

type SharedDirectoryAcknowledge

type SharedDirectoryAcknowledge struct {
	ErrCode     uint32
	DirectoryID uint32
}

func (SharedDirectoryAcknowledge) Encode

func (s SharedDirectoryAcknowledge) Encode() ([]byte, error)

type SharedDirectoryAnnounce

type SharedDirectoryAnnounce struct {
	DirectoryID uint32
	Name        string
}

func (SharedDirectoryAnnounce) Encode

func (s SharedDirectoryAnnounce) Encode() ([]byte, error)

type SharedDirectoryCreateRequest

type SharedDirectoryCreateRequest struct {
	CompletionID uint32
	DirectoryID  uint32
	FileType     uint32
	Path         string
}

func (SharedDirectoryCreateRequest) Encode

func (s SharedDirectoryCreateRequest) Encode() ([]byte, error)

type SharedDirectoryCreateResponse

type SharedDirectoryCreateResponse struct {
	CompletionID uint32
	ErrCode      uint32
	Fso          FileSystemObject
}

func (SharedDirectoryCreateResponse) Encode

func (s SharedDirectoryCreateResponse) Encode() ([]byte, error)

type SharedDirectoryDeleteRequest

type SharedDirectoryDeleteRequest struct {
	CompletionID uint32
	DirectoryID  uint32
	Path         string
}

func (SharedDirectoryDeleteRequest) Encode

func (s SharedDirectoryDeleteRequest) Encode() ([]byte, error)

type SharedDirectoryDeleteResponse

type SharedDirectoryDeleteResponse struct {
	CompletionID uint32
	ErrCode      uint32
}

func (SharedDirectoryDeleteResponse) Encode

func (s SharedDirectoryDeleteResponse) Encode() ([]byte, error)

type SharedDirectoryInfoRequest

type SharedDirectoryInfoRequest struct {
	CompletionID uint32
	DirectoryID  uint32
	Path         string
}

func (SharedDirectoryInfoRequest) Encode

func (s SharedDirectoryInfoRequest) Encode() ([]byte, error)

type SharedDirectoryInfoResponse

type SharedDirectoryInfoResponse struct {
	CompletionID uint32
	ErrCode      uint32
	Fso          FileSystemObject
}

func (SharedDirectoryInfoResponse) Encode

func (s SharedDirectoryInfoResponse) Encode() ([]byte, error)

type SharedDirectoryListRequest

type SharedDirectoryListRequest struct {
	CompletionID uint32
	DirectoryID  uint32
	Path         string
}

func (SharedDirectoryListRequest) Encode

func (s SharedDirectoryListRequest) Encode() ([]byte, error)

type SharedDirectoryListResponse

type SharedDirectoryListResponse struct {
	CompletionID uint32
	ErrCode      uint32
	FsoList      []FileSystemObject
}

| message type (26) | completion_id uint32 | err_code uint32 | fso_list_length uint32 | fso_list fso[] |

func (SharedDirectoryListResponse) Encode

func (s SharedDirectoryListResponse) Encode() ([]byte, error)

type SharedDirectoryMoveRequest

type SharedDirectoryMoveRequest struct {
	CompletionID uint32
	DirectoryID  uint32
	OriginalPath string
	NewPath      string
}

SharedDirectoryMoveRequest is sent from the TDP server to the client to request a file at original_path be moved to new_path.

func (SharedDirectoryMoveRequest) Encode

func (s SharedDirectoryMoveRequest) Encode() ([]byte, error)

type SharedDirectoryMoveResponse

type SharedDirectoryMoveResponse struct {
	CompletionID uint32
	ErrCode      uint32
}

func (SharedDirectoryMoveResponse) Encode

func (s SharedDirectoryMoveResponse) Encode() ([]byte, error)

type SharedDirectoryReadRequest

type SharedDirectoryReadRequest struct {
	CompletionID uint32
	DirectoryID  uint32
	Path         string
	Offset       uint64
	Length       uint32
}

SharedDirectoryReadRequest is a message sent by the server to the client to request bytes to be read from the file at the path and starting at byte offset.

func (SharedDirectoryReadRequest) Encode

func (s SharedDirectoryReadRequest) Encode() ([]byte, error)

type SharedDirectoryReadResponse

type SharedDirectoryReadResponse struct {
	CompletionID   uint32
	ErrCode        uint32
	ReadDataLength uint32
	ReadData       []byte
}

SharedDirectoryReadResponse is a message sent by the client to the server in response to the SharedDirectoryReadRequest.

func (SharedDirectoryReadResponse) Encode

func (s SharedDirectoryReadResponse) Encode() ([]byte, error)

type SharedDirectoryWriteRequest

type SharedDirectoryWriteRequest struct {
	CompletionID    uint32
	DirectoryID     uint32
	Offset          uint64
	Path            string
	WriteDataLength uint32
	WriteData       []byte
}

SharedDirectoryWriteRequest is a message sent by the server to the client to request bytes to be written the file at the path and starting at byte offset.

func (SharedDirectoryWriteRequest) Encode

func (s SharedDirectoryWriteRequest) Encode() ([]byte, error)

type SharedDirectoryWriteResponse

type SharedDirectoryWriteResponse struct {
	CompletionID uint32
	ErrCode      uint32
	BytesWritten uint32
}

SharedDirectoryWriteResponse is a message sent by the client to the server in response to the SharedDirectoryWriteRequest.

func (SharedDirectoryWriteResponse) Encode

func (s SharedDirectoryWriteResponse) Encode() ([]byte, error)

Jump to

Keyboard shortcuts

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