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
- func IsFatalErr(err error) bool
- func IsNonFatalErr(err error) bool
- func PNGEncoder() *png.Encoder
- type ButtonState
- type ClientScreenSpec
- type ClientUsername
- type ClipboardData
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) ReadClientScreenSpec() (*ClientScreenSpec, error)
- func (c *Conn) ReadMessage() (Message, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SendNotification(message string, severity Severity) error
- func (c *Conn) WriteMessage(m Message) error
- type ConnectionInitialized
- type Error
- type FileSystemObject
- type KeyboardButton
- type MFA
- type Message
- type MessageType
- type MouseButton
- type MouseButtonType
- type MouseMove
- type MouseWheel
- type MouseWheelAxis
- type Notification
- type PNG2Frame
- type PNGFrame
- type RDPFastPathPDU
- type RDPResponsePDU
- type Severity
- type SharedDirectoryAcknowledge
- type SharedDirectoryAnnounce
- type SharedDirectoryCreateRequest
- type SharedDirectoryCreateResponse
- type SharedDirectoryDeleteRequest
- type SharedDirectoryDeleteResponse
- type SharedDirectoryInfoRequest
- type SharedDirectoryInfoResponse
- type SharedDirectoryListRequest
- type SharedDirectoryListResponse
- type SharedDirectoryMoveRequest
- type SharedDirectoryMoveResponse
- type SharedDirectoryReadRequest
- type SharedDirectoryReadResponse
- type SharedDirectoryWriteRequest
- type SharedDirectoryWriteResponse
- type SyncKeys
Constants ¶
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) TypePNG2Frame = MessageType(27) TypeNotification = MessageType(28) TypeRDPFastPathPDU = MessageType(29) TypeRDPResponsePDU = MessageType(30) TypeRDPConnectionInitialized = MessageType(31) TypeSyncKeys = MessageType(32) )
For descriptions of each message type see: https://github.com/gravitational/teleport/blob/master/rfd/0037-desktop-access-protocol.md#message-types
const ( LeftMouseButton = MouseButtonType(0) MiddleMouseButton = MouseButtonType(1) RightMouseButton = MouseButtonType(2) )
const ( ButtonNotPressed = ButtonState(0) ButtonPressed = ButtonState(1) )
const ( VerticalWheelAxis = MouseWheelAxis(0) HorizontalWheelAxis = MouseWheelAxis(1) )
const ( ErrCodeNil uint32 = 0 ErrCodeFailed uint32 = 1 ErrCodeDoesNotExist uint32 = 2 ErrCodeAlreadyExists uint32 = 3 )
These correspond to TdpErrCode enum in the rust RDP client.
Variables ¶
This section is empty.
Functions ¶
func IsFatalErr ¶
IsFatalErr returns the inverse of IsNonFatalErr (except for if err == nil, for which both functions return false)
func IsNonFatalErr ¶
IsNonFatalErr returns whether or not an error arising from the tdp package should be interpreted as fatal or non-fatal for an ongoing TDP connection.
func PNGEncoder ¶
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 ¶
ClientScreenSpec is the client screen specification. | message type (1) | width uint32 | height uint32 |
func (ClientScreenSpec) Encode ¶
func (s ClientScreenSpec) Encode() ([]byte, error)
type ClientUsername ¶
type ClientUsername struct {
Username string
}
ClientUsername is the client username. | message type (7) | username_length uint32 | username []byte |
func (ClientUsername) Encode ¶
func (r ClientUsername) Encode() ([]byte, error)
type ClipboardData ¶
type ClipboardData []byte
ClipboardData represents shared clipboard data. | message type (6) | length uint32 | data []byte |
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(rwc io.ReadWriteCloser) *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) ReadClientScreenSpec ¶
func (c *Conn) ReadClientScreenSpec() (*ClientScreenSpec, error)
ReadClientScreenSpec reads the next message from the connection, expecting it to be a ClientScreenSpec. If it is not, an error is returned.
func (*Conn) ReadMessage ¶
ReadMessage reads the next incoming message from the connection.
func (*Conn) SendNotification ¶
SendNotification is a convenience function for sending a Notification message.
func (*Conn) WriteMessage ¶
WriteMessage sends a message to the connection.
type ConnectionInitialized ¶
type ConnectionInitialized struct { IOChannelID uint16 UserChannelID uint16 ScreenWidth uint16 ScreenHeight uint16 }
ConnectionInitialized is sent to the browser when an RDP session is fully initialized. It contains data that the browser needs in order to correctly handle the session.
See "3. Channel Connection" at https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/023f1e69-cfe8-4ee6-9ee0-7e759fb4e4ee
| message type (31) | io_channel_id uint16 | user_channel_id uint16 |
func (ConnectionInitialized) Encode ¶
func (c ConnectionInitialized) Encode() ([]byte, error)
type Error ¶
type Error struct {
Message string
}
Error is used to send a fatal error message to the browser. In Teleport 12 and up, Error is deprecated and Notification should be preferred. | message type (9) | message_length uint32 | message []byte |
type FileSystemObject ¶
type FileSystemObject struct { LastModified uint64 Size uint64 FileType uint32 IsEmpty uint8 Path string }
FileSystemObject represents a file or directory. | last_modified uint64 | size uint64 | file_type uint32 | is_empty bool | path_length uint32 | path byte[] |
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. | message type (5) | key_code uint32 | state byte |
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 }
MFA represents a MFA challenge or response. | message type (10) | mfa_type byte | length uint32 | JSON []byte |
func DecodeMFAChallenge ¶
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.
type MouseButton ¶
type MouseButton struct { Button MouseButtonType State ButtonState }
MouseButton is the mouse button press message. | message type (4) | button byte | state byte |
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. | message type (3) | x uint32 | y uint32 |
type MouseWheel ¶
type MouseWheel struct { Axis MouseWheelAxis Delta int16 }
MouseWheel is the mouse wheel scroll message. | message type (8) | axis byte | delta int16 |
func (MouseWheel) Encode ¶
func (w MouseWheel) Encode() ([]byte, error)
type MouseWheelAxis ¶
type MouseWheelAxis byte
MouseWheelAxis identifies a scroll axis on the mouse wheel.
type Notification ¶
Notification is an informational message sent from Teleport to the Web UI. It can be used for fatal errors or non-fatal warnings. | message type (28) | message_length uint32 | message []byte | severity byte |
func (Notification) Encode ¶
func (m Notification) Encode() ([]byte, error)
type PNG2Frame ¶
type PNG2Frame []byte
PNG2Frame is a newer version of PNGFrame that includes the length of the PNG data. It's represented as a fully encoded byte slice to optimize for speed and simplicity of encoding/decoding. | message type (27) | png_length uint32 | left uint32 | top uint32 | right uint32 | bottom uint32 | data []byte |
type PNGFrame ¶
PNGFrame is the PNG frame message | message type (2) | left uint32 | top uint32 | right uint32 | bottom uint32 | data []byte |
type RDPFastPathPDU ¶
type RDPFastPathPDU []byte
RDPFastPathPDU is an RDP Fast-Path PDU message. It carries a raw RDP Server Fast-Path Update PDU (https://tinyurl.com/3t2t6er8) which is used to transport image data to the frontend.
| message type (29) | data_length uint32 | data []byte |
Whenever you see this type itself, you can assume that it's just the | data []byte | part of the message. Calling Encode() on this type will return the full encoded message, including the | message type (29) | data_length uint32 | parts.
func (RDPFastPathPDU) Encode ¶
func (f RDPFastPathPDU) Encode() ([]byte, error)
type RDPResponsePDU ¶
type RDPResponsePDU []byte
RDPResponsePDU is an RDP Response PDU message. It carries a raw encoded RDP response PDU created by the ironrdp client on the frontend and sends it directly to the RDP server.
| message type (30) | data_length uint32 | data []byte |
Whenever you see this type itself, you can assume that it's just the | data []byte | section of the message. Calling Encode() on this type will return the full encoded message, including the | message type (30) | data_length uint32 | parts.
func (RDPResponsePDU) Encode ¶
func (r RDPResponsePDU) Encode() ([]byte, error)
type SharedDirectoryAcknowledge ¶
type SharedDirectoryAcknowledge struct {}
SharedDirectoryAcknowledge acknowledges a SharedDirectoryAnnounce was received. | message type (12) | err_code uint32 | directory_id uint32 |
func (SharedDirectoryAcknowledge) Encode ¶
func (s SharedDirectoryAcknowledge) Encode() ([]byte, error)
type SharedDirectoryAnnounce ¶
type SharedDirectoryAnnounce struct {}
SharedDirectoryAnnounce announces a new directory to be shared. | message type (11) | directory_id uint32 | name_length uint32 | name []byte |
func (SharedDirectoryAnnounce) Encode ¶
func (s SharedDirectoryAnnounce) Encode() ([]byte, error)
type SharedDirectoryCreateRequest ¶
type SharedDirectoryCreateRequest struct {}
SharedDirectoryCreateRequest is sent by the TDP server to the client to request the creation of a new file or directory. | message type (15) | completion_id uint32 | directory_id uint32 | file_type uint32 | path_length uint32 | path []byte |
func (SharedDirectoryCreateRequest) Encode ¶
func (s SharedDirectoryCreateRequest) Encode() ([]byte, error)
type SharedDirectoryCreateResponse ¶
type SharedDirectoryCreateResponse struct {}
SharedDirectoryCreateResponseis sent by the TDP client to the server with information from an executed SharedDirectoryCreateRequest. | message type (16) | completion_id uint32 | err_code uint32 | file_system_object fso |
func (SharedDirectoryCreateResponse) Encode ¶
func (s SharedDirectoryCreateResponse) Encode() ([]byte, error)
type SharedDirectoryDeleteRequest ¶
type SharedDirectoryDeleteRequest struct {}
SharedDirectoryDeleteRequest is sent by the TDP server to the client to request the deletion of a file or directory. | message type (17) | completion_id uint32 | directory_id uint32 | path_length uint32 | path []byte |
func (SharedDirectoryDeleteRequest) Encode ¶
func (s SharedDirectoryDeleteRequest) Encode() ([]byte, error)
type SharedDirectoryDeleteResponse ¶
type SharedDirectoryDeleteResponse struct {}
SharedDirectoryDeleteResponse is sent by the TDP client to the server with information from an executed SharedDirectoryDeleteRequest. | message type (18) | completion_id uint32 | err_code uint32 |
func (SharedDirectoryDeleteResponse) Encode ¶
func (s SharedDirectoryDeleteResponse) Encode() ([]byte, error)
type SharedDirectoryInfoRequest ¶
type SharedDirectoryInfoRequest struct {}
SharedDirectoryInfoRequest requests information about a file or directory. | message type (13) | completion_id uint32 | directory_id uint32 | path_length uint32 | path []byte |
func (SharedDirectoryInfoRequest) Encode ¶
func (s SharedDirectoryInfoRequest) Encode() ([]byte, error)
type SharedDirectoryInfoResponse ¶
type SharedDirectoryInfoResponse struct {}
SharedDirectoryInfoResponse returns information about a file or directory. | message type (14) | completion_id uint32 | err_code uint32 | file_system_object fso |
func (SharedDirectoryInfoResponse) Encode ¶
func (s SharedDirectoryInfoResponse) Encode() ([]byte, error)
type SharedDirectoryListRequest ¶
type SharedDirectoryListRequest struct {}
SharedDirectoryListRequest is sent by the TDP server to the client to request a directory listing. | message type (25) | completion_id uint32 | directory_id uint32 | path_length uint32 | path []byte |
func (SharedDirectoryListRequest) Encode ¶
func (s SharedDirectoryListRequest) Encode() ([]byte, error)
type SharedDirectoryListResponse ¶
type SharedDirectoryListResponse struct {}
SharedDirectoryListResponse is sent by the TDP client to the server with the information from an executed SharedDirectoryListRequest. | 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 {}
SharedDirectoryMoveRequest is sent from the TDP server to the client to request a file at original_path be moved to new_path. | message type (23) | completion_id uint32 | directory_id uint32 | original_path_length uint32 | original_path []byte | new_path_length uint32 | new_path []byte |
func (SharedDirectoryMoveRequest) Encode ¶
func (s SharedDirectoryMoveRequest) Encode() ([]byte, error)
type SharedDirectoryMoveResponse ¶
type SharedDirectoryMoveResponse struct {}
SharedDirectoryMoveResponse is sent from the TDP client to the server to acknowledge a SharedDirectoryMoveRequest was executed. | message type (24) | completion_id uint32 | err_code uint32 |
func (SharedDirectoryMoveResponse) Encode ¶
func (s SharedDirectoryMoveResponse) Encode() ([]byte, error)
type SharedDirectoryReadRequest ¶
type SharedDirectoryReadRequest struct {}
SharedDirectoryReadRequest is a message sent by the TDP server to the client to request bytes to be read from the file at the path and starting at byte offset. | message type (19) | completion_id uint32 | directory_id uint32 | path_length uint32 | path []byte | offset uint64 | length uint32 |
func (SharedDirectoryReadRequest) Encode ¶
func (s SharedDirectoryReadRequest) Encode() ([]byte, error)
type SharedDirectoryReadResponse ¶
type SharedDirectoryReadResponse struct {}
SharedDirectoryReadResponse is a message sent by the TDP client to the server in response to the SharedDirectoryReadRequest. | message type (20) | completion_id uint32 | err_code uint32 | read_data_length uint32 | read_data []byte |
func (SharedDirectoryReadResponse) Encode ¶
func (s SharedDirectoryReadResponse) Encode() ([]byte, error)
type SharedDirectoryWriteRequest ¶
type SharedDirectoryWriteRequest struct {}
SharedDirectoryWriteRequest is a message sent by the TDP server to the client to request bytes to be written the file at the path and starting at byte offset. | message type (21) | completion_id uint32 | directory_id uint32 | path_length uint32 | path []byte | offset uint64 | write_data_length uint32 | write_data []byte |
func (SharedDirectoryWriteRequest) Encode ¶
func (s SharedDirectoryWriteRequest) Encode() ([]byte, error)
type SharedDirectoryWriteResponse ¶
type SharedDirectoryWriteResponse struct {}
SharedDirectoryWriteResponse is a message sent by the TDP client to the server in response to the SharedDirectoryWriteRequest. | message type (22) | completion_id uint32 | err_code uint32 | bytes_written uint32 |
func (SharedDirectoryWriteResponse) Encode ¶
func (s SharedDirectoryWriteResponse) Encode() ([]byte, error)
type SyncKeys ¶
type SyncKeys struct { ScrollLockState ButtonState NumLockState ButtonState CapsLockState ButtonState KanaLockState ButtonState }
| message type (32) | scroll_lock_state byte | num_lock_state byte | caps_lock_state byte | kana_lock_state byte |