Documentation
¶
Overview ¶
Package message defines data channel messages structure.
Package message defines data channel messages structure.
Package message defines data channel messages structure.
Index ¶
- Constants
- Variables
- func GetBytes(byteArray []byte, offset int, byteLength int) ([]byte, error)
- func GetInteger(byteArray []byte, offset int) (int32, error)
- func GetLong(byteArray []byte, offset int) (int64, error)
- func GetString(byteArray []byte, offset int, stringLength int) (string, error)
- func GetUInteger(byteArray []byte, offset int) (uint32, error)
- func GetULong(byteArray []byte, offset int) (uint64, error)
- func GetUUID(byteArray []byte, offset int) (uuid.UUID, error)
- func IntegerToBytes(input int32) ([]byte, error)
- func LongToBytes(input int64) ([]byte, error)
- func PutBytes(byteArray []byte, offsetStart int, offsetEnd int, inputBytes []byte) error
- func PutInteger(byteArray []byte, offset int, value int32) error
- func PutLong(byteArray []byte, offset int, value int64) error
- func PutString(byteArray []byte, offsetStart int, offsetEnd int, inputString string) error
- func PutUInteger(byteArray []byte, offset int, value uint32) error
- func PutULong(byteArray []byte, offset int, value uint64) error
- func PutUUID(byteArray []byte, offset int, input uuid.UUID) error
- func SerializeClientMessagePayload(obj any) ([]byte, error)
- func SerializeClientMessageWithAcknowledgeContent(acknowledgeContent AcknowledgeContent) ([]byte, error)
- type AcknowledgeContent
- type ActionStatus
- type ActionType
- type ChannelClosed
- type ClientMessage
- func (m *ClientMessage) DeserializeChannelClosedMessage() (ChannelClosed, error)
- func (m *ClientMessage) DeserializeClientMessage(input []byte) error
- func (m *ClientMessage) DeserializeDataStreamAcknowledgeContent() (AcknowledgeContent, error)
- func (m *ClientMessage) DeserializeHandshakeComplete() (HandshakeCompletePayload, error)
- func (m *ClientMessage) DeserializeHandshakeRequest() (HandshakeRequestPayload, error)
- func (m *ClientMessage) SerializeClientMessage() ([]byte, error)
- func (m *ClientMessage) Validate() error
- type EncryptionChallengeRequest
- type EncryptionChallengeResponse
- type HandshakeCompletePayload
- type HandshakeRequestPayload
- type HandshakeResponsePayload
- type IClientMessage
- type KMSEncryptionRequest
- type KMSEncryptionResponse
- type PayloadType
- type PayloadTypeFlag
- type ProcessedClientAction
- type RequestedClientAction
- type SessionTypeRequest
- type SizeData
Constants ¶
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" )
const ( // ClientMessageHLLength represents the length of the header length field in bytes. ClientMessageHLLength = 4 // ClientMessageMessageTypeLength represents the length of the message type field in bytes. ClientMessageMessageTypeLength = 32 // ClientMessageSchemaVersionLength represents the length of the schema version field in bytes. ClientMessageSchemaVersionLength = 4 // ClientMessageCreatedDateLength represents the length of the created date field in bytes. ClientMessageCreatedDateLength = 8 // ClientMessageSequenceNumberLength represents the length of the sequence number field in bytes. ClientMessageSequenceNumberLength = 8 // ClientMessageFlagsLength represents the length of the flags field in bytes. ClientMessageFlagsLength = 8 // ClientMessageMessageIDLength represents the length of the message ID field in bytes. ClientMessageMessageIDLength = 16 // ClientMessagePayloadDigestLength represents the length of the payload digest field in bytes. ClientMessagePayloadDigestLength = 32 // ClientMessagePayloadTypeLength represents the length of the payload type field in bytes. ClientMessagePayloadTypeLength = 4 // ClientMessagePayloadLengthLength represents the length of the payload length field in bytes. ClientMessagePayloadLengthLength = 4 )
const ( // ClientMessageHLOffset represents the offset of the header length field in the message. ClientMessageHLOffset = 0 // ClientMessageMessageTypeOffset represents the offset of the message type field in the message. ClientMessageMessageTypeOffset = ClientMessageHLOffset + ClientMessageHLLength // ClientMessageSchemaVersionOffset represents the offset of the schema version field in the message. ClientMessageSchemaVersionOffset = ClientMessageMessageTypeOffset + ClientMessageMessageTypeLength // ClientMessageCreatedDateOffset represents the offset of the created date field in the message. ClientMessageCreatedDateOffset = ClientMessageSchemaVersionOffset + ClientMessageSchemaVersionLength // ClientMessageSequenceNumberOffset represents the offset of the sequence number field in the message. ClientMessageSequenceNumberOffset = ClientMessageCreatedDateOffset + ClientMessageCreatedDateLength // ClientMessageFlagsOffset represents the offset of the flags field in the message. ClientMessageFlagsOffset = ClientMessageSequenceNumberOffset + ClientMessageSequenceNumberLength // ClientMessageMessageIDOffset represents the offset of the message ID field in the message. ClientMessageMessageIDOffset = ClientMessageFlagsOffset + ClientMessageFlagsLength // ClientMessagePayloadDigestOffset represents the offset of the payload digest field in the message. ClientMessagePayloadDigestOffset = ClientMessageMessageIDOffset + ClientMessageMessageIDLength // ClientMessagePayloadTypeOffset represents the offset of the payload type field in the message. ClientMessagePayloadTypeOffset = ClientMessagePayloadDigestOffset + ClientMessagePayloadDigestLength // ClientMessagePayloadLengthOffset represents the offset of the payload length field in the message. ClientMessagePayloadLengthOffset = ClientMessagePayloadTypeOffset + ClientMessagePayloadTypeLength // ClientMessagePayloadOffset represents the offset of the payload data in the message. ClientMessagePayloadOffset = ClientMessagePayloadLengthOffset + ClientMessagePayloadLengthLength )
Variables ¶
var ( ErrOffsetOutside = errors.New("offset outside") ErrNotEnoughSpace = errors.New("not enough space") ErrNegative = errors.New("cannot convert negative number to unsigned") ErrNil = errors.New("input is nil") ErrInvalid = errors.New("invalid input") )
Error messages.
Functions ¶
func GetInteger ¶
GetInteger gets an integer value from a byte array starting from the specified offset.
func GetLong ¶
GetLong gets a long integer value from a byte array starting from the specified offset. 64 bit.
func GetString ¶
GetString gets a string value from the byte array starting from the specified offset to the defined length.
func GetUInteger ¶
GetUInteger gets an unsigned integer.
func IntegerToBytes ¶
IntegerToBytes gets bytes array from an integer.
func LongToBytes ¶
LongToBytes gets bytes array from a long integer.
func PutInteger ¶
PutInteger puts an int32 into a byte array starting from the specified offset.
func PutLong ¶
PutLong puts a long integer value to a byte array starting from the specified offset.
func PutUInteger ¶
PutUInteger puts a uint32 into a byte array starting from the specified offset.
func SerializeClientMessagePayload ¶
SerializeClientMessagePayload marshals payloads for all session specific messages into bytes.
func SerializeClientMessageWithAcknowledgeContent ¶
func SerializeClientMessageWithAcknowledgeContent(acknowledgeContent AcknowledgeContent) ([]byte, 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
ActionStatus represents the status of a client action.
const ( // Success indicates that the action was successful. Success ActionStatus = 1 // Failed indicates that the action failed. Failed ActionStatus = 2 // Unsupported indicates that the action is not supported. Unsupported ActionStatus = 3 )
type ActionType ¶
type ActionType string
ActionType used in Handshake to determine action requested by the agent.
const ( // KMSEncryption represents the KMS encryption action type. KMSEncryption ActionType = "KMSEncryption" // SessionType represents the session type action type. 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 (m *ClientMessage) DeserializeChannelClosedMessage() (ChannelClosed, error)
DeserializeChannelClosedMessage parses channelClosed message from payload of ClientMessage.
func (*ClientMessage) DeserializeClientMessage ¶
func (m *ClientMessage) DeserializeClientMessage(input []byte) 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 (m *ClientMessage) DeserializeDataStreamAcknowledgeContent() (AcknowledgeContent, error)
DeserializeDataStreamAcknowledgeContent parses acknowledge content from payload of ClientMessage.
func (*ClientMessage) DeserializeHandshakeComplete ¶
func (m *ClientMessage) DeserializeHandshakeComplete() (HandshakeCompletePayload, error)
DeserializeHandshakeComplete deserializes the handshake complete payload from the client message.
func (*ClientMessage) DeserializeHandshakeRequest ¶
func (m *ClientMessage) DeserializeHandshakeRequest() (HandshakeRequestPayload, error)
DeserializeHandshakeRequest deserializes the handshake request payload from the client message.
func (*ClientMessage) SerializeClientMessage ¶
func (m *ClientMessage) SerializeClientMessage() ([]byte, 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 (m *ClientMessage) Validate() error
Validate returns error if the message is invalid.
type EncryptionChallengeRequest ¶
type EncryptionChallengeRequest struct {
Challenge []byte `json:"Challenge"`
}
EncryptionChallengeRequest represents a challenge sent by the agent to the client.
type EncryptionChallengeResponse ¶
type EncryptionChallengeResponse struct {
Challenge []byte `json:"Challenge"`
}
EncryptionChallengeResponse represents the client's response to the encryption challenge.
type HandshakeCompletePayload ¶
type HandshakeCompletePayload struct {
HandshakeTimeToComplete time.Duration `json:"HandshakeTimeToComplete"`
CustomerMessage string `json:"CustomerMessage"`
}
HandshakeCompletePayload represents the completion of the handshake process.
type HandshakeRequestPayload ¶
type HandshakeRequestPayload struct {
AgentVersion string `json:"AgentVersion"`
RequestedClientActions []RequestedClientAction `json:"RequestedClientActions"`
}
HandshakeRequestPayload represents the 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"`
}
HandshakeResponsePayload represents the response sent by the plugin in response to the handshake request.
type IClientMessage ¶
type IClientMessage interface {
Validate() error
DeserializeClientMessage(input []byte) (err error)
SerializeClientMessage() (result []byte, err error)
DeserializeDataStreamAcknowledgeContent() (dataStreamAcknowledge AcknowledgeContent, err error)
DeserializeChannelClosedMessage() (channelClosed ChannelClosed, err error)
DeserializeHandshakeRequest() (handshakeRequest HandshakeRequestPayload, err error)
DeserializeHandshakeComplete() (handshakeComplete HandshakeCompletePayload, err error)
}
IClientMessage defines the interface for client message operations.
type KMSEncryptionRequest ¶
type KMSEncryptionRequest struct {
KMSKeyID string `json:"KMSKeyId"`
}
KMSEncryptionRequest represents a request to initialize KMS encryption.
type KMSEncryptionResponse ¶
type KMSEncryptionResponse struct {
KMSCipherTextKey []byte `json:"KMSCipherTextKey"`
KMSCipherTextHash []byte `json:"KMSCipherTextHash"`
}
KMSEncryptionResponse represents the response containing KMS encryption setup data.
type PayloadType ¶
type PayloadType uint32
PayloadType represents the type of payload in a client message.
const ( // Output represents a standard output payload type. Output PayloadType = 1 // Error represents an error payload type. Error PayloadType = 2 // Size represents a size data payload type. Size PayloadType = 3 // Parameter represents a parameter payload type. Parameter PayloadType = 4 // HandshakeRequestPayloadType represents a handshake request payload type. HandshakeRequestPayloadType PayloadType = 5 // HandshakeResponsePayloadType represents a handshake response payload type. HandshakeResponsePayloadType PayloadType = 6 // HandshakeCompletePayloadType represents a handshake complete payload type. HandshakeCompletePayloadType PayloadType = 7 // EncChallengeRequest is the payload type for encryption challenge requests. EncChallengeRequest PayloadType = 8 // EncChallengeResponse is the payload type for encryption challenge responses. EncChallengeResponse PayloadType = 9 // Flag is the payload type for flag messages. Flag PayloadType = 10 // StdErr is the payload type for standard error messages. StdErr PayloadType = 11 // ExitCode is the payload type for exit code messages. ExitCode PayloadType = 12 )
type PayloadTypeFlag ¶
type PayloadTypeFlag uint32
PayloadTypeFlag represents flags that can be set in a client message payload.
const ( // DisconnectToPort indicates that the port connection should be disconnected. DisconnectToPort PayloadTypeFlag = 1 // TerminateSession indicates that the session should be terminated. TerminateSession PayloadTypeFlag = 2 // ConnectToPortError indicates that there was an error connecting to the port. ConnectToPortError PayloadTypeFlag = 3 )
type ProcessedClientAction ¶
type ProcessedClientAction struct {
ActionType ActionType `json:"ActionType"`
ActionStatus ActionStatus `json:"ActionStatus"`
ActionResult any `json:"ActionResult"`
Error string `json:"Error"`
}
ProcessedClientAction represents the result of processing an action by the plugin.
type RequestedClientAction ¶
type RequestedClientAction struct {
ActionType ActionType `json:"ActionType"`
ActionParameters json.RawMessage `json:"ActionParameters"`
}
RequestedClientAction represents an action requested by the agent to the plugin.
type SessionTypeRequest ¶
type SessionTypeRequest struct {
SessionType string `json:"SessionType"`
Properties any `json:"Properties"`
}
SessionTypeRequest represents a request containing session type and plugin properties.