message

package
v0.0.0-...-ee5af42 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

message package defines data channel messages structure.

message package defines data channel messages structure.

message package defines data channel messages structure.

Index

Constants

View Source
const (
	// InputStreamMessage represents message type for input data
	InputStreamMessage = "input_stream_data"

	// OutputStreamMessage represents message type for output data
	OutputStreamMessage = "output_stream_data"

	// AcknowledgeMessage represents message type for acknowledge
	AcknowledgeMessage = "acknowledge"

	// ChannelClosedMessage represents message type for ChannelClosed
	ChannelClosedMessage = "channel_closed"

	// StartPublicationMessage represents the message type that notifies the CLI to start sending stream messages
	StartPublicationMessage = "start_publication"

	// PausePublicationMessage represents the message type that notifies the CLI to pause sending stream messages
	// as the remote data channel is inactive
	PausePublicationMessage = "pause_publication"
)
View Source
const (
	ClientMessage_HLLength             = 4
	ClientMessage_MessageTypeLength    = 32
	ClientMessage_SchemaVersionLength  = 4
	ClientMessage_CreatedDateLength    = 8
	ClientMessage_SequenceNumberLength = 8
	ClientMessage_FlagsLength          = 8
	ClientMessage_MessageIdLength      = 16
	ClientMessage_PayloadDigestLength  = 32
	ClientMessage_PayloadTypeLength    = 4
	ClientMessage_PayloadLengthLength  = 4
)
View Source
const (
	ClientMessage_HLOffset             = 0
	ClientMessage_MessageTypeOffset    = ClientMessage_HLOffset + ClientMessage_HLLength
	ClientMessage_SchemaVersionOffset  = ClientMessage_MessageTypeOffset + ClientMessage_MessageTypeLength
	ClientMessage_CreatedDateOffset    = ClientMessage_SchemaVersionOffset + ClientMessage_SchemaVersionLength
	ClientMessage_SequenceNumberOffset = ClientMessage_CreatedDateOffset + ClientMessage_CreatedDateLength
	ClientMessage_FlagsOffset          = ClientMessage_SequenceNumberOffset + ClientMessage_SequenceNumberLength
	ClientMessage_MessageIdOffset      = ClientMessage_FlagsOffset + ClientMessage_FlagsLength
	ClientMessage_PayloadDigestOffset  = ClientMessage_MessageIdOffset + ClientMessage_MessageIdLength
	ClientMessage_PayloadTypeOffset    = ClientMessage_PayloadDigestOffset + ClientMessage_PayloadDigestLength
	ClientMessage_PayloadLengthOffset  = ClientMessage_PayloadTypeOffset + ClientMessage_PayloadTypeLength
	ClientMessage_PayloadOffset        = ClientMessage_PayloadLengthOffset + ClientMessage_PayloadLengthLength
)

Variables

This section is empty.

Functions

func SerializeClientMessagePayload

func SerializeClientMessagePayload(log log.T, obj interface{}) (reply []byte, err error)

SerializeClientMessagePayload marshals payloads for all session specific messages into bytes.

func SerializeClientMessageWithAcknowledgeContent

func SerializeClientMessageWithAcknowledgeContent(log log.T, acknowledgeContent AcknowledgeContent) (reply []byte, err error)

SerializeClientMessageWithAcknowledgeContent marshals client message with payloads of acknowledge contents into bytes.

Types

type AcknowledgeContent

type AcknowledgeContent struct {
	MessageType         string `json:"AcknowledgedMessageType"`
	MessageId           string `json:"AcknowledgedMessageId"`
	SequenceNumber      int64  `json:"AcknowledgedMessageSequenceNumber"`
	IsSequentialMessage bool   `json:"IsSequentialMessage"`
}

AcknowledgeContent is used to inform the sender of an acknowledge message that the message has been received. * MessageType is a 32 byte UTF-8 string containing the message type. * MessageId is a 40 byte UTF-8 string containing the UUID identifying this message being acknowledged. * SequenceNumber is an 8 byte integer containing the message sequence number for serialized message. * IsSequentialMessage is a boolean field representing whether the acknowledged message is part of a sequence

type ActionStatus

type ActionStatus int
const (
	Success     ActionStatus = 1
	Failed      ActionStatus = 2
	Unsupported ActionStatus = 3
)

type ActionType

type ActionType string

ActionType used in Handshake to determine action requested by the agent

const (
	KMSEncryption ActionType = "KMSEncryption"
	SessionType   ActionType = "SessionType"
)

type ChannelClosed

type ChannelClosed struct {
	MessageId     string `json:"MessageId"`
	CreatedDate   string `json:"CreatedDate"`
	DestinationId string `json:"DestinationId"`
	SessionId     string `json:"SessionId"`
	MessageType   string `json:"MessageType"`
	SchemaVersion int    `json:"SchemaVersion"`
	Output        string `json:"Output"`
}

ChannelClosed is used to inform the client to close the channel * MessageId is a 40 byte UTF-8 string containing the UUID identifying this message. * CreatedDate is a string field containing the message create epoch millis in UTC. * DestinationId is a string field containing the session target. * SessionId is a string field representing which session to close. * MessageType is a 32 byte UTF-8 string containing the message type. * SchemaVersion is a 4 byte integer containing the message schema version number. * Output is a string field containing the error message for channel close.

type ClientMessage

type ClientMessage struct {
	HeaderLength   uint32
	MessageType    string
	SchemaVersion  uint32
	CreatedDate    uint64
	SequenceNumber int64
	Flags          uint64
	MessageId      uuid.UUID
	PayloadDigest  []byte
	PayloadType    uint32
	PayloadLength  uint32
	Payload        []byte
}

ClientMessage represents a message for client to send/receive. ClientMessage Message in MGS is equivalent to MDS' InstanceMessage. All client messages are sent in this form to the MGS service.

func (*ClientMessage) DeserializeChannelClosedMessage

func (clientMessage *ClientMessage) DeserializeChannelClosedMessage(log log.T) (channelClosed ChannelClosed, err error)

DeserializeChannelClosedMessage parses channelClosed message from payload of ClientMessage.

func (*ClientMessage) DeserializeClientMessage

func (clientMessage *ClientMessage) DeserializeClientMessage(log log.T, input []byte) (err error)

DeserializeClientMessage deserializes the byte array into an ClientMessage message. * Payload is a variable length byte data. * | HL| MessageType |Ver| CD | Seq | Flags | * | MessageId | Digest | PayType | PayLen| * | Payload |

func (*ClientMessage) DeserializeDataStreamAcknowledgeContent

func (clientMessage *ClientMessage) DeserializeDataStreamAcknowledgeContent(log log.T) (dataStreamAcknowledge AcknowledgeContent, err error)

DeserializeDataStreamAcknowledgeContent parses acknowledge content from payload of ClientMessage.

func (*ClientMessage) DeserializeHandshakeComplete

func (clientMessage *ClientMessage) DeserializeHandshakeComplete(log log.T) (handshakeComplete HandshakeCompletePayload, err error)

func (*ClientMessage) DeserializeHandshakeRequest

func (clientMessage *ClientMessage) DeserializeHandshakeRequest(log log.T) (handshakeRequest HandshakeRequestPayload, err error)

func (*ClientMessage) SerializeClientMessage

func (clientMessage *ClientMessage) SerializeClientMessage(log log.T) (result []byte, err error)

SerializeClientMessage serializes ClientMessage message into a byte array. * Payload is a variable length byte data. * | HL| MessageType |Ver| CD | Seq | Flags | * | MessageId | Digest |PayType| PayLen| * | Payload |

func (*ClientMessage) Validate

func (clientMessage *ClientMessage) Validate() error

Validate returns error if the message is invalid

type EncryptionChallengeRequest

type EncryptionChallengeRequest struct {
	Challenge []byte `json:"Challenge"`
}

This is sent by the agent as a challenge to the client. The challenge field is some data that was encrypted by the agent. The client must be able to decrypt this and in turn encrypt it with its own key.

type EncryptionChallengeResponse

type EncryptionChallengeResponse struct {
	Challenge []byte `json:"Challenge"`
}

This is received by the agent from the client. The challenge field contains some data received, decrypted and then encrypted by the client. Agent must be able to decrypt this and verify it matches the original plaintext challenge.

type HandshakeCompletePayload

type HandshakeCompletePayload struct {
	HandshakeTimeToComplete time.Duration `json:"HandshakeTimeToComplete"`
	CustomerMessage         string        `json:"CustomerMessage"`
}

Handshake Complete indicates to client that handshake is complete. This signals the client to start the plugin and display a customer message where appropriate.

type HandshakeRequestPayload

type HandshakeRequestPayload struct {
	AgentVersion           string                  `json:"AgentVersion"`
	RequestedClientActions []RequestedClientAction `json:"RequestedClientActions"`
}

Handshake payload sent by the agent to the session manager plugin

type HandshakeResponsePayload

type HandshakeResponsePayload struct {
	ClientVersion          string                  `json:"ClientVersion"`
	ProcessedClientActions []ProcessedClientAction `json:"ProcessedClientActions"`
	Errors                 []string                `json:"Errors"`
}

Handshake Response sent by the plugin in response to the handshake request

type IClientMessage

type IClientMessage interface {
	Validate() error
	DeserializeClientMessage(log log.T, input []byte) (err error)
	SerializeClientMessage(log log.T) (result []byte, err error)
	DeserializeDataStreamAcknowledgeContent(log log.T) (dataStreamAcknowledge AcknowledgeContent, err error)
	DeserializeChannelClosedMessage(log log.T) (channelClosed ChannelClosed, err error)
	DeserializeHandshakeRequest(log log.T) (handshakeRequest HandshakeRequestPayload, err error)
	DeserializeHandshakeComplete(log log.T) (handshakeComplete HandshakeCompletePayload, err error)
}

type KMSEncryptionRequest

type KMSEncryptionRequest struct {
	KMSKeyID string `json:"KMSKeyId"`
}

This is sent by the agent to initialize KMS encryption

type KMSEncryptionResponse

type KMSEncryptionResponse struct {
	KMSCipherTextKey  []byte `json:"KMSCipherTextKey"`
	KMSCipherTextHash []byte `json:"KMSCipherTextHash"`
}

This is received by the agent to set up KMS encryption

type PayloadType

type PayloadType uint32
const (
	Output                       PayloadType = 1
	Error                        PayloadType = 2
	Size                         PayloadType = 3
	Parameter                    PayloadType = 4
	HandshakeRequestPayloadType  PayloadType = 5
	HandshakeResponsePayloadType PayloadType = 6
	HandshakeCompletePayloadType PayloadType = 7
	EncChallengeRequest          PayloadType = 8
	EncChallengeResponse         PayloadType = 9
	Flag                         PayloadType = 10
	StdErr                       PayloadType = 11
	ExitCode                     PayloadType = 12
)

type PayloadTypeFlag

type PayloadTypeFlag uint32
const (
	DisconnectToPort   PayloadTypeFlag = 1
	TerminateSession   PayloadTypeFlag = 2
	ConnectToPortError PayloadTypeFlag = 3
)

type ProcessedClientAction

type ProcessedClientAction struct {
	ActionType   ActionType   `json:"ActionType"`
	ActionStatus ActionStatus `json:"ActionStatus"`
	ActionResult interface{}  `json:"ActionResult"`
	Error        string       `json:"Error"`
}

The result of processing the action by the plugin

type RequestedClientAction

type RequestedClientAction struct {
	ActionType       ActionType      `json:"ActionType"`
	ActionParameters json.RawMessage `json:"ActionParameters"`
}

An action requested by the agent to the plugin

type SessionTypeRequest

type SessionTypeRequest struct {
	SessionType string      `json:"SessionType"`
	Properties  interface{} `json:"Properties"`
}

SessionType request contains type of the session that needs to be launched and properties for plugin

type SizeData

type SizeData struct {
	Cols uint32 `json:"cols"`
	Rows uint32 `json:"rows"`
}

Jump to

Keyboard shortcuts

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