quickproto

package module
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: GPL-2.0 Imports: 8 Imported by: 0

README

Fast golang protocol parser

Supports:

  • Headers (Support listed values, IE: Key=[Value, Value, Value])
  • Files (Supports multiple files)
  • Body (Can be encoded/decoded to any type)
    • !WARNING! !Make sure your delimiter not in the encoding's alphabet!
    • !WARNING! !Make sure your delimiter is not in the message headers, body or filenames!
  • Delimiters
    • No alphabetic characters from [A-Z a-z 0-9 =]

Data is split apart by the delimiter.

Say the delimiter is a $:

The body and header will be split by the delimiter * 4

Each key value pair will be split by the delimiter * 2

Then the key values will be split by the delimiter.

Example:

key1$value1&value2$$key2$value2$$$$BODYBODYBODY

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BANNED_DELIMITERS = []string{
	"=",
	"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",
}
View Source
var STANDARD_DELIM []byte = []byte("$")

Functions

func Base16Decoding added in v1.2.5

func Base16Decoding(data []byte) ([]byte, error)

func Base16Encoding added in v1.2.5

func Base16Encoding(data []byte) []byte

func Base64Decoding added in v1.2.5

func Base64Decoding(data []byte) ([]byte, error)

func Base64Encoding added in v1.2.5

func Base64Encoding(data []byte) []byte

func WriteConn added in v1.1.5

func WriteConn(conn net.Conn, msg *Message) error

Types

type Config added in v1.1.6

type Config struct {
	Delimiter   []byte
	UseEncoding bool
	BufSize     int
	Enc_func    func([]byte) []byte
	Dec_func    func([]byte) ([]byte, error)
}

func NewConfig added in v1.2.1

func NewConfig(delimiter []byte, useencoding bool, bufsize int, enc_f func([]byte) []byte, dec_f func([]byte) ([]byte, error)) *Config

NewConfig creates a new Config.

func (*Config) NewMessage added in v1.2.5

func (c *Config) NewMessage() *Message

type Message

type Message struct {
	Data        []byte
	Delimiter   []byte
	Headers     map[string][]string
	Body        []byte
	Files       map[string]MessageFile
	UseEncoding bool
	Enc_func    func([]byte) []byte
	Dec_func    func([]byte) ([]byte, error)
}

A Message is a protocol message.

func NewMessage

func NewMessage(delimiter []byte, useencoding bool, enc_func func([]byte) []byte, dec_func func([]byte) ([]byte, error)) *Message

NewMessage creates a new Message.

func ReadConn added in v1.1.5

func ReadConn(conn net.Conn, conf *Config) (*Message, error)

func (*Message) AddContent added in v1.1.7

func (m *Message) AddContent(content any) error

func (*Message) AddFile added in v1.1.7

func (m *Message) AddFile(file MessageFile) error

func (*Message) AddHeader added in v1.1.1

func (m *Message) AddHeader(key string, value string) error

func (*Message) AddRawFile added in v1.1.7

func (m *Message) AddRawFile(name string, data []byte) error

func (*Message) BodyDelimiter added in v1.1.4

func (m *Message) BodyDelimiter() []byte

func (*Message) ContentLength

func (m *Message) ContentLength() int

Get content length of the message.

func (*Message) EndingDelimiter added in v1.1.4

func (m *Message) EndingDelimiter() []byte

func (*Message) FileDelimiter added in v1.1.7

func (m *Message) FileDelimiter() []byte

func (*Message) Generate

func (m *Message) Generate() (*Message, error)

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

func (m *Message) HeaderDelimiter() []byte

func (*Message) Parse

func (m *Message) Parse() (*Message, error)

parses protocol messages. Header is a map of key/value pairs. Body is a base64 encoded byte slice.

type MessageFile added in v1.1.7

type MessageFile struct {
	Name string
	Data []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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