sub

package
v0.0.0-...-a838072 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: Unlicense, Unlicense Imports: 8 Imported by: 0

README

sub

Publish/Subscribe short message protocol with Reed-Solomon FEC and UDP transport

This has been written for implementing ultra low latency short messages for a miner work delivery protocol for Parallelcoin DUO

Documentation

Overview

Package sub is a short message publication/subscription library that uses UDP transport, Reed Solomon erasure coding, ed25519 EC signatures for tamper-resistance, for allowing clients to subscribe to updates from a server for time-sensitive messaging, written to implement a low latency work delivery system for Parallelcoin miners.

To prevent retransmits for messages up to 3kb in size, data sent in a burst as 9 packets containing a 9/3 Reed Solomon encoding such that any 3 packets received guarantee retransmit-less delivery, covering the worst case for packet loss and corruption over a network

Payload can be encrypted via AES-256 encryption using a pre-shared key known by both ends to function as both access control and security against eavesdropping and spoofing attacks.

Authentication of data is done using an ED25119 EC key for which each known endpoint has shared the public key as part of the subscription request

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeAddrToBytes

func EncodeAddrToBytes(addr string) (out []byte)

EncodeAddrToBytes takes a string in the format xxx.xxx.xxx.xxx:xxxxx and converts it to the encoded bytes format

func EncodedAddrToString

func EncodedAddrToString(encoded string) (out string)

EncodedAddrToString takes a string from bytes on the prefix containing an IPv4 address (it is passed around as a string for easy comparison) and returns the format used by net.Dial

Types

type Base

type Base struct {
	// contains filtered or unexported fields
}

Base is the common structure between a worker and a node

func NewBase

func NewBase(cfg BaseCfg) (b *Base)

Implementations of common parts for node and worker NewBase creates a new base listener

func (*Base) Send

func (b *Base) Send(data []byte, addr *net.UDPAddr) (err error)

Send a message of up to maxMessageSize bytes to a given UDP address

func (*Base) Start

func (b *Base) Start() (err error)

Start attempts to open a listener and commences receiving packets and assembling them into messages

func (*Base) Stop

func (b *Base) Stop()

Stop shuts down the listener

type BaseCfg

type BaseCfg struct {
	Handler    func(message Message)
	Listener   string
	Password   []byte
	BufferSize int
}

BaseCfg is the configuration for a Base

type BaseInterface

type BaseInterface interface {
	SetupListener()
}

BaseInterface is the core functions required for a Base

type Bundle

type Bundle struct {
	// contains filtered or unexported fields
}

A Bundle is a collection of the received packets received from the same sender with up to 9 pieces.

type Confirmation

type Confirmation struct {
}

Confirmation is the reply message for a subscription request

type Message

type Message struct {
	// contains filtered or unexported fields
}

Message is the data reconstructed from a complete Bundle, containing data in messagepack format

type Node

type Node struct {
	Base
}

A Node is a server with some number of subscribers

type Packet

type Packet struct {
	// contains filtered or unexported fields
}

Packet is the structure of individual encoded packets of the message. These are made from a 9/3 Reed Solomon code and 9 are sent in distinct packets and only 3 are required to guarantee retransmit-free delivery.

type Subscription

type Subscription struct {
}

Subscription is the message sent by a worker node to request updates from the node

type Worker

type Worker struct {
	Base
}

A Worker is a node that subscribes to a Node's messages

Jump to

Keyboard shortcuts

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