ipc

package
v0.0.0-...-7e438e6 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AF_UNIX  = "unix"     // UNIX domain sockets
	AF_DGRAM = "unixgram" // UNIX domain datagram sockets as specified in net package

	STREAM = "SOCK_STREAM" // Stream socket 		(like TCP)
	DGRAM  = "SOCK_DGRAM"  // Datagram socket 		(like UDP)

	// Network values if applicable
	Network = "tcp"
	Address = "localhost:50052"
	Timeout = 1 * time.Second
)
View Source
const (
	MSG_CONN    = 0x01 // Connection message
	MSG_ACK     = 0x02 // Acknowledgement message
	MSG_CONNACK = 0x03 // Connection acknowledgement message
	MSG_MSG     = 0x04 // Message
	MSG_MSGACK  = 0x05 // Message acknowledgement

	MSG_PING = 0x08 // Ping message
	MSG_PONG = 0x09 // Pong message

	MSG_DISCONNECT = 0xD1 // Disconnect message

	// Error message
	// The sender is obviously still connected, but something went wrong and the message was not handled
	MSG_ERROR = 0xEE

	MSG_UNKNOWN = 0xFF // Unknown message - for signifying unknown type, maybe an error, but the receiver will try to wing it
)
View Source
const (
	DATA_TEXT = 0x01 // Text data
	DATA_INT  = 0x02 // Integer data
	DATA_JSON = 0x03 // JSON data	(used for structured data)
	DATA_YAML = 0x04 // YAML data	(used for configuration files)
	DATA_BIN  = 0x05 // Binary data	(such as images, files, etc.)
)

Variables

View Source
var IDENTIFIERS = map[string][4]byte{}
View Source
var IPCID []byte // Identifier of the IPC communication
View Source
var MSGTYPE = map[string]byte{
	"conn":       byte(MSG_CONN),
	"ack":        byte(MSG_ACK),
	"connack":    byte(MSG_CONNACK),
	"msg":        byte(MSG_MSG),
	"msgack":     byte(MSG_MSGACK),
	"ping":       byte(MSG_PING),
	"pong":       byte(MSG_PONG),
	"disconnect": byte(MSG_DISCONNECT),
	"error":      byte(MSG_ERROR),
	"unknown":    byte(MSG_UNKNOWN),
}

Functions

func DefaultSock

func DefaultSock(name string) string

func GetIPCStrID

func GetIPCStrID() string

func SetIPCID

func SetIPCID(id []byte)

func SetIdentifier

func SetIdentifier(name string, id [4]byte)

Types

type DataType

type DataType int

type Database

type Database struct {
	Name  string `json:"name"`
	Table string `json:"table"`
	RowID string `json:"row_id"` // Row ID - fetch anything after this ID
}

type Destination

type Destination struct {
	Object Object `json:"destination" yaml:"destination"` // should unmarsal as Destination
}

type GenericData

type GenericData map[string]interface{}

GenericData is a generic map for data. It can be used to store any data type.

type GetJSON

type GetJSON struct {
	Metadata    Metadata `json:"metadata"`
	Description string   `json:"description"`
}

type IPCHeader

type IPCHeader struct {
	Identifier  [4]byte // Identifier of the module - available from the IPCClient for qol purposes
	MessageType byte    // Type of the message
}

type IPCMessage

type IPCMessage struct {
	Datatype   DataType // Type of the data ("json", "string", "int", etc.)
	Data       []byte   // The actual data
	StringData string   // String representation of the data if applicable
}

type IPCMessageId

type IPCMessageId []byte // Identifier of the message

type IPCRequest

type IPCRequest struct {
	MessageSignature []byte     // The message signature, used to declare an ipcRequest
	Header           IPCHeader  // The header - containing type and identifier
	Message          IPCMessage // The message
	Timestamp        int64      // Timestamp of the message
	Checksum32       int        // Checksum of the message byte data
}

func (*IPCRequest) Stringify

func (r *IPCRequest) Stringify() string

type IPCResponse

type IPCResponse struct {
	Request    IPCRequest // The request that was sent
	Success    bool       // Was the request successful
	Message    string     // Message from the server
	Checksum32 int        // Checksum of the message byte data
}

type Metadata

type Metadata struct {
	Source      string      `json:"source"`      // Source. Ex: sigma
	Destination Destination `json:"destination"` // Destination. Ex: { name: database, info: "table=threat_intel" }
	Method      string      `json:"method"`      // Using HTTP verbs to differentiate between requests (ps: this got nothing to do with actual HTTP)
}

type MsgType

type MsgType int

type Object

type Object struct {
	Id       string   `json:"id"`
	Name     string   `json:"name"`
	Database Database `json:"database"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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