Documentation ¶
Index ¶
- 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 GZIPcompress(data []byte) ([]byte, error)
- func GZIPdecompress(data []byte) ([]byte, error)
- func GobDecoding(data []byte) ([]byte, error)
- func GobEncoding(data []byte) []byte
- func KeyDecoder(data []byte) (*[32]byte, error)
- func KeyEncoder(key *[32]byte) []byte
- func NewmessageFile(name string, data []byte) messageFile
- func WriteConn(conn net.Conn, msg *Message, aes_key *[32]byte, compress bool) 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)
Constants ¶
This section is empty.
Variables ¶
var BANNED_DELIMITERS = []string{
"=", "_", "\x08", "\x1e", "\x00", "(", ")",
"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. Byte "\x00" is used as a body, when body is empty.
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.
func CraftAddr ¶ added in v1.3.7
Convenience function to craft an address from an IP and a port. Port could be string or int, IP must be string.
func GZIPcompress ¶ added in v1.5.3
func GZIPdecompress ¶ added in v1.5.3
func KeyDecoder ¶ added in v1.4.3
func KeyEncoder ¶ added in v1.4.3
func NewmessageFile ¶ added in v1.4.1
NewmessageFile creates a new messageFile.
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. // Compress the messages Compressed bool }
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