Documentation
¶
Index ¶
- Constants
- Variables
- func Base16Decoding(data []byte) ([]byte, error)
- func Base16Encoding(data []byte) []byte
- func Base32Decoding(data []byte) ([]byte, error)
- func Base32Encoding(data []byte) []byte
- func Base64Decoding(data []byte) ([]byte, error)
- func Base64Encoding(data []byte) []byte
- func CraftAddr(ip string, port any) string
- func WriteConn(conn net.Conn, msg *Message, aes_key *[32]byte) error
- type Config
- type Message
- func (m *Message) AddContent(content any) error
- func (m *Message) AddFile(file *MessageFile)
- func (m *Message) AddHeader(key string, value string) error
- func (m *Message) AddRawFile(name string, data []byte)
- func (m *Message) BodyDelimiter() []byte
- func (m *Message) ContentLength() int
- func (m *Message) EndingDelimiter() []byte
- func (m *Message) FileDelimiter() []byte
- func (m *Message) FileSizes() map[string]int
- func (m *Message) Generate() (*Message, error)
- func (m *Message) HeaderDelimiter() []byte
- func (m *Message) Parse() (*Message, error)
- type MessageFile
Constants ¶
const ( INCLUDE_HOSTNAME = sysinfo.INC_HOSTNAME INCLUDE_PLATFORM = sysinfo.INC_PLATFORM INCLUDE_CPU = sysinfo.INC_CPU INCLUDE_MEM = sysinfo.INC_MEM INCLUDE_DISK = sysinfo.INC_DISK INCLUDE_MACADDR = sysinfo.INC_MACADDR )
Variables ¶
var BANNED_DELIMITERS = []string{
"=", "_", "\x08", "\x1e",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
}
These are tested not to work.
var IncludeAll = []int{INCLUDE_HOSTNAME, INCLUDE_PLATFORM, INCLUDE_CPU, INCLUDE_MEM, INCLUDE_DISK, INCLUDE_MACADDR}
var STANDARD_DELIM []byte = []byte("$")
Standard delimiter.
Functions ¶
func Base16Decoding ¶ added in v1.2.5
Hex decoding.
func Base32Decoding ¶ added in v1.3.5
Base 32 decoding.
func Base64Decoding ¶ added in v1.2.5
Base 64 decoding.
Types ¶
type Config ¶ added in v1.1.6
type Config struct { // Delimiter used for separating message data. Delimiter []byte // Use encoding? UseEncoding bool // Use crypto? UseCrypto bool // Buffer size. BufSize int // Encoding/Decoding functions. Encode_func func([]byte) []byte Decode_func func([]byte) ([]byte, error) // RSA keys PrivateKey *rsa.PrivateKey // Server-side. PublicKey *rsa.PublicKey // Client-side. // SendSysinfo Included_info []int // System information to include. }
General configuration to use for client and server.
func NewConfig ¶ added in v1.2.1
func NewConfig(delimiter []byte, useencoding bool, usecrypto bool, bufsize int, encode_f func([]byte) []byte, decode_f func([]byte) ([]byte, error)) *Config
NewConfig creates a new Config.
func (*Config) NewMessage ¶ added in v1.2.5
Generate a new message with default configuration options.
type Message ¶
type Message struct { Data []byte Delimiter []byte Headers map[string][]string Body []byte Files map[string]*MessageFile UseEncoding bool Encode_func func([]byte) []byte Decode_func func([]byte) ([]byte, error) F_Encoder func([]byte) []byte F_Decoder func([]byte) ([]byte, error) }
A Message is a protocol message.
func NewMessage ¶
func NewMessage(delimiter []byte, useencoding bool, encode_func func([]byte) []byte, decode_func func([]byte) ([]byte, error)) *Message
NewMessage creates a new Message.
func (*Message) AddContent ¶ added in v1.1.7
Add content to the message. Either add []bytes, or a string.
func (*Message) AddFile ¶ added in v1.1.7
func (m *Message) AddFile(file *MessageFile)
Add a MessageFile to the message.
func (*Message) AddRawFile ¶ added in v1.1.7
Create a MessageFile, and add it to the message.
func (*Message) BodyDelimiter ¶ added in v1.1.4
Body delimiter, returns HEADER_DELIMITER + HEADER_DELIMITER
func (*Message) ContentLength ¶
Get content length of the message.
func (*Message) EndingDelimiter ¶ added in v1.1.4
End delimiter, returns BODY_DELIMITER + BODY_DELIMITER
func (*Message) FileDelimiter ¶ added in v1.1.7
File delimiter, returns BODY_DELIMITER + HEADER_DELIMITER
func (*Message) Generate ¶
creates a protocol message. Header is a map of key/value pairs. Body is a base64 encoded byte slice.
func (*Message) HeaderDelimiter ¶ added in v1.1.4
Header delimiter, returns DELIMITER + DELIMITER
type MessageFile ¶ added in v1.1.7
Message file used for storing files sent inside the Message struct
func NewMessageFile ¶ added in v1.3.9
func NewMessageFile(name string, data []byte) MessageFile
NewMessageFile creates a new MessageFile.
func (*MessageFile) Save ¶ added in v1.3.9
func (f *MessageFile) Save(path string) error
Save the file to a path.
func (*MessageFile) Size ¶ added in v1.3.9
func (f *MessageFile) Size() int
Size returns the size of the file.
func (*MessageFile) String ¶ added in v1.3.9
func (f *MessageFile) String() string
String returns the name of the file.