objects

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2015 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

This file is autogenerated from https://github.com/immesys/bw2_pid/blob/master/allocations.yaml

Index

Constants

View Source
const (
	ROAccessDChainHash     = 0x01
	ROPermissionDChainHash = 0x11
	ROAccessDChain         = 0x02
	ROPermissionDChain     = 0x12
	ROAccessDOT            = 0x20
	ROPermissionDOT        = 0x21
	ROEntity               = 0x30
	ROEntityWKey           = 0x32
	ROOriginVK             = 0x31
	ROExpiry               = 0x40
)
View Source
const (
	CmdHello        = "helo"
	CmdPublish      = "publ"
	CmdSubscribe    = "subs"
	CmdPersist      = "pers"
	CmdList         = "list"
	CmdQuery        = "quer"
	CmdTapSubscribe = "tsub"
	CmdTapQuery     = "tque"
	CmdPutDot       = "putd"
	CmdPutEntity    = "pute"
	CmdPutChain     = "putc"
	CmdMakeDot      = "makd"
	CmdMakeEntity   = "make"
	CmdMakeChain    = "makc"
	CmdBuildChain   = "bldc"
	CmdAddPrefDot   = "adpd"
	CmdAddPrefChain = "adpc"
	CmdDelPrefDot   = "dlpd"
	CmdDelPrefChain = "dlpc"
	CmdSetEntity    = "sete"

	CmdResponse = "resp"
	CmdResult   = "rslt"
)
View Source
const PODFBWRoutingObject = `0.0.0.0`
View Source
const PODFBinary = `0.0.0.0`
View Source
const PODFBlob = `1.0.0.0`
View Source
const PODFCapnP = `3.0.0.0`
View Source
const PODFJSON = `65.0.0.0`
View Source
const PODFMaskBWRoutingObject = `0.0.0.0/8`
View Source
const PODFMaskBinary = `0.0.0.0/4`
View Source
const PODFMaskBlob = `1.0.0.0/8`
View Source
const PODFMaskCapnP = `3.0.0.0/8`
View Source
const PODFMaskJSON = `65.0.0.0/8`
View Source
const PODFMaskMsgPack = `2.0.0.0/8`
View Source
const PODFMaskSpawnpointConfig = `67.0.2.0/32`
View Source
const PODFMaskSpawnpointHeartbeat = `67.0.2.1/32`
View Source
const PODFMaskSpawnpointLog = `2.0.2.0/32`
View Source
const PODFMaskString = `64.0.1.0/32`
View Source
const PODFMaskText = `64.0.0.0/4`
View Source
const PODFMaskXML = `66.0.0.0/8`
View Source
const PODFMaskYAML = `67.0.0.0/8`
View Source
const PODFMsgPack = `2.0.0.0`
View Source
const PODFSpawnpointConfig = `67.0.2.0`
View Source
const PODFSpawnpointHeartbeat = `67.0.2.1`
View Source
const PODFSpawnpointLog = `2.0.2.0`
View Source
const PODFString = `64.0.1.0`
View Source
const PODFText = `64.0.0.0`
View Source
const PODFXML = `66.0.0.0`
View Source
const PODFYAML = `67.0.0.0`
View Source
const POMaskBWRoutingObject = 8
View Source
const POMaskBinary = 4
View Source
const POMaskBlob = 8
View Source
const POMaskCapnP = 8
View Source
const POMaskJSON = 8
View Source
const POMaskMsgPack = 8
View Source
const POMaskSpawnpointConfig = 32
View Source
const POMaskSpawnpointHeartbeat = 32
View Source
const POMaskSpawnpointLog = 32
View Source
const POMaskString = 32
View Source
const POMaskText = 4
View Source
const POMaskXML = 8
View Source
const POMaskYAML = 8
View Source
const PONumBWRoutingObject = 0

BWRoutingObject (0.0.0.0/8): Bosswave Routing Object This class and schema block is reserved for bosswave routing objects represented using the full PID.

View Source
const PONumBinary = 0

Binary (0.0.0.0/4): Binary protocols This is a superclass for classes that are generally unreadable in their plain form and require translation.

View Source
const PONumBlob = 16777216

Blob (1.0.0.0/8): Blob This is a class for schemas that do not use a public encoding format. In general it should be avoided. Schemas below this should include the key "readme" with a url to a description of the schema that is sufficiently detailed to allow for a developer to reverse engineer the protocol if required.

View Source
const PONumCapnP = 50331648

CapnP (3.0.0.0/8): Captain Proto This class is for captain proto interfaces. Schemas below this should include the key "schema" with a url to their .capnp file

View Source
const PONumJSON = 1090519040

JSON (65.0.0.0/8): JSON This class is for schemas that are represented in JSON

View Source
const PONumMsgPack = 33554432

MsgPack (2.0.0.0/8): MsgPack This class is for schemas that are represented in MsgPack

View Source
const PONumSpawnpointConfig = 1124073984

SpawnpointConfig (67.0.2.0/32): SpawnPoint config A configuration file for SpawnPoint (github.com/immesys/spawnpoint)

View Source
const PONumSpawnpointHeartbeat = 1124073985

SpawnpointHeartbeat (67.0.2.1/32): SpawnPoint heartbeat A heartbeat message from spawnpoint

View Source
const PONumSpawnpointLog = 33554944

SpawnpointLog (2.0.2.0/32): Spawnpoint stdout This contains stdout data from a spawnpoint container

View Source
const PONumString = 1073742080

String (64.0.1.0/32): String A plain string with no rigid semantic meaning. This can be thought of as a print statement. Anything that has semantic meaning like a process log should use a different schema.

View Source
const PONumText = 1073741824

Text (64.0.0.0/4): Human readable text This is a superclass for classes that are moderately understandable if they are read directly in their binary form. Generally these are protocols that were designed specifically to be human readable.

View Source
const PONumXML = 1107296256

XML (66.0.0.0/8): XML This class is for schemas that are represented in XML

View Source
const PONumYAML = 1124073472

YAML (67.0.0.0/8): YAML This class is for schemas that are represented in YAML

View Source
const SaneObjectSize = 16 * 1024 * 1024

We allocate buffers for objects. Lets not get too exciteable about how big an object we are willing to accept

Variables

View Source
var RoutingObjectConstructor = map[int]func(ronum int, content []byte) (RoutingObject, error){
	ROAccessDChain:         NewDChain,
	ROAccessDChainHash:     NewDChain,
	ROPermissionDChain:     NewDChain,
	ROPermissionDChainHash: NewDChain,
	ROAccessDOT:            NewDOT,
	ROPermissionDOT:        NewDOT,
	ROEntity:               NewEntity,
	ROOriginVK:             NewOriginVK,
	ROExpiry:               NewExpiry,
}

RoutingObjectConstruct allows you to map a ROnum into a constructor that takes a binary representation and returns a Routing Object

Functions

func IsEveryoneVK

func IsEveryoneVK(vk []byte) bool

Check is vk is all zeroes

func NewObjectError

func NewObjectError(oid int, msg string) error

NewObjectError constructs an ObjectError

func PONumDotForm

func PONumDotForm(ponum int) string

func PONumFromDotForm

func PONumFromDotForm(dotform string) (int, error)

func ReadExactly

func ReadExactly(s *bufio.Reader, to []byte) error

Types

type AccessDOTPermissionSet

type AccessDOTPermissionSet struct {
	CanPublish     bool
	CanConsume     bool
	CanConsumePlus bool
	CanConsumeStar bool
	CanTap         bool
	CanTapPlus     bool
	CanTapStar     bool
	CanList        bool
}

func GetADPSFromPermString

func GetADPSFromPermString(v string) *AccessDOTPermissionSet

func (*AccessDOTPermissionSet) GetPermString

func (ps *AccessDOTPermissionSet) GetPermString() string

func (*AccessDOTPermissionSet) IsSubsetOf

func (ps *AccessDOTPermissionSet) IsSubsetOf(rhs *AccessDOTPermissionSet) bool

func (*AccessDOTPermissionSet) ReduceBy

type BossWaveObject

type BossWaveObject interface {
	IsPayloadObject() bool
}

func LoadBosswaveObject

func LoadBosswaveObject(s io.Reader) (BossWaveObject, error)

LoadBosswaveObject loads an object from a reader. all objects will need to have the full length header

type DChain

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

DChain is a list of DOT hashes

func CreateDChain

func CreateDChain(access bool, dots ...*DOT) (*DChain, error)

CreateDChain creates a dot chain from the given DOTs. The DOTs must have the hash field populated

func (*DChain) AugmentBy

func (ro *DChain) AugmentBy(d *DOT)

AugmentBy fills the given dot into the right position in the chain assuming it is referred to at all

func (*DChain) CheckAllSigs

func (ro *DChain) CheckAllSigs() bool

func (*DChain) ConvertToDChainHash

func (ro *DChain) ConvertToDChainHash() (*DChain, error)

ConvertToDChainHash creates a hash RO from a dchain RO that may or may not be fully elaborated. Note that there are shared resources in the result

func (*DChain) GetAccessURIPermString

func (ro *DChain) GetAccessURIPermString() string

func (*DChain) GetAccessURISuffix

func (ro *DChain) GetAccessURISuffix() (string, error)

func (*DChain) GetChainHash

func (ro *DChain) GetChainHash() []byte

GetChainHash returns the hash of the chain

func (*DChain) GetContent

func (ro *DChain) GetContent() []byte

GetContent returns the serialised content for this object

func (*DChain) GetDOT

func (ro *DChain) GetDOT(num int) *DOT

GetDOT returns the DOT at the given index if it has been stored in the chain, otherwise nil

func (*DChain) GetDotHash

func (ro *DChain) GetDotHash(num int) []byte

GetDotHash returns the dot hash at the specific index

func (*DChain) GetGiverVK

func (ro *DChain) GetGiverVK() []byte

func (*DChain) GetMVK

func (ro *DChain) GetMVK() []byte

func (*DChain) GetRONum

func (ro *DChain) GetRONum() int

GetRONum returns the RONum for this object

func (*DChain) GetReceiverVK

func (ro *DChain) GetReceiverVK() []byte

func (*DChain) GetTTL

func (ro *DChain) GetTTL() int

func (*DChain) IsAccess

func (ro *DChain) IsAccess() bool

func (*DChain) IsElaborated

func (ro *DChain) IsElaborated() bool

IsElaborated returns true if the dot hashes are populated

func (*DChain) IsPayloadObject

func (ro *DChain) IsPayloadObject() bool

func (*DChain) NumHashes

func (ro *DChain) NumHashes() int

NumHashes returns the length of the chain

func (*DChain) SetDOT

func (ro *DChain) SetDOT(num int, d *DOT)

SetDOT sets the specific DOT

func (*DChain) UnElaborate

func (ro *DChain) UnElaborate()

func (*DChain) WriteToStream

func (ro *DChain) WriteToStream(s io.Writer, fullObjNum bool) error

type DOT

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

DOT is a declaration of trust. This is a shared object that implements both an access dot and a permission dot

func CreateDOT

func CreateDOT(isAccess bool, giverVK []byte, receiverVK []byte) *DOT

CreateDOT is used to create a DOT from scratch. The DOT is incomplete until Encode() is called later.

func (*DOT) AddRevoker

func (ro *DOT) AddRevoker(rvk []byte)

func (*DOT) Encode

func (ro *DOT) Encode(sk []byte)

Encode will work out the content of the DOT based on the fields that have been set, and sign it with the given sk (must match the vk)

func (*DOT) GetAccessURIMVK

func (ro *DOT) GetAccessURIMVK() []byte

GetAccessURIMVK gets the mvk if this is an access DOT

func (*DOT) GetAccessURISuffix

func (ro *DOT) GetAccessURISuffix() string

GetAccessURISuffix returns the suffix if this is an access DOT

func (*DOT) GetComment

func (ro *DOT) GetComment() string

func (*DOT) GetContact

func (ro *DOT) GetContact() string

func (*DOT) GetContent

func (ro *DOT) GetContent() []byte

GetContent returns the binary representation of the DOT if Encode has been called

func (*DOT) GetCreated

func (ro *DOT) GetCreated() *time.Time

func (*DOT) GetExpiry

func (ro *DOT) GetExpiry() *time.Time

func (*DOT) GetGiverVK

func (ro *DOT) GetGiverVK() []byte

GetGiverVK returns the verifying key of the entity that created this DOT

func (*DOT) GetHash

func (ro *DOT) GetHash() []byte

GetHash returns the dot hash or panics if it has not been set by encoding/reading from stream etc.

func (*DOT) GetPermString

func (ro *DOT) GetPermString() string

GetPermString gets the human readable permission string for an access dot

func (*DOT) GetPermissionSet

func (ro *DOT) GetPermissionSet() *AccessDOTPermissionSet

func (*DOT) GetRONum

func (ro *DOT) GetRONum() int

GetRONum returns the ronum of the dot

func (*DOT) GetReceiverVK

func (ro *DOT) GetReceiverVK() []byte

GetReceiverVK gets the verifying key of the entity that is the recipient of trust in this DOT

func (*DOT) GetRevokers

func (ro *DOT) GetRevokers() [][]byte

func (*DOT) GetTTL

func (ro *DOT) GetTTL() int

GetTTL gets the TTL of a DOT

func (*DOT) IsAccess

func (ro *DOT) IsAccess() bool

func (*DOT) IsPayloadObject

func (ro *DOT) IsPayloadObject() bool

func (*DOT) OverrideSetSignatureValid

func (ro *DOT) OverrideSetSignatureValid()

OverrideSetSigValid sets this dots signature as valid without checking it this is used if the DOT is known good (say from the store)

func (*DOT) SetAccessURI

func (ro *DOT) SetAccessURI(mvk []byte, suffix string)

SetAccessURI sets the URI of an Access DOT

func (*DOT) SetCanConsume

func (ro *DOT) SetCanConsume(normal bool, plus bool, star bool)

SetCanConsume sets the consume privileges on an access dot

func (*DOT) SetCanList

func (ro *DOT) SetCanList(value bool)

SetCanList sets the list capability on an access DOT

func (*DOT) SetCanPublish

func (ro *DOT) SetCanPublish(value bool)

SetCanPublish sets the publish capability on an access DOT

func (*DOT) SetCanTap

func (ro *DOT) SetCanTap(normal bool, plus bool, star bool)

SetCanTap sets the tap capability on an access dot

func (*DOT) SetComment

func (ro *DOT) SetComment(v string)

func (*DOT) SetContact

func (ro *DOT) SetContact(v string)

func (*DOT) SetCreation

func (ro *DOT) SetCreation(time time.Time)

SetCreation sets the creation timestamp on the DOT

func (*DOT) SetCreationToNow

func (ro *DOT) SetCreationToNow()

SetCreationToNow sets the creation timestamp to the current time

func (*DOT) SetExpireFromNow

func (ro *DOT) SetExpireFromNow(delta time.Duration)

SetExpireFromNow is a convenience function that sets the creation time to now, and sets the expiry to the given delta from the creation time

func (*DOT) SetExpiry

func (ro *DOT) SetExpiry(time time.Time)

SetExpiry sets the expiry time to the given time

func (*DOT) SetPermString

func (ro *DOT) SetPermString(v string) bool

SetPermString sets the permissions of this (access) dot. it returns true on success, false if the string is bad or this was not an access dot

func (*DOT) SetPermission

func (ro *DOT) SetPermission(key string, value string)

SetPermission sets the given key in a Permission DOT's table

func (*DOT) SetTTL

func (ro *DOT) SetTTL(v int)

SetTTL sets the TTL of a dot

func (*DOT) SigValid

func (ro *DOT) SigValid() bool

SigValid returns if the DOT's signature is valid. This only checks the signature on the first call, so the content must not change after encoding for this to be valid. As a plus it also verifies that the topic is sane

func (*DOT) String

func (ro *DOT) String() string

String returns a string representation of the DOT

func (*DOT) WriteToStream

func (ro *DOT) WriteToStream(s io.Writer, fullObjNum bool) error

type Entity

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

func CreateLightEntity

func CreateLightEntity(vk, sk []byte) *Entity

func CreateNewEntity

func CreateNewEntity(contact, comment string, revokers [][]byte) *Entity

func (*Entity) AddRevoker

func (ro *Entity) AddRevoker(rvk []byte)

func (*Entity) Encode

func (ro *Entity) Encode()

func (*Entity) FullString

func (ro *Entity) FullString() string

func (*Entity) GetComment

func (ro *Entity) GetComment() string

func (*Entity) GetContact

func (ro *Entity) GetContact() string

func (*Entity) GetContent

func (ro *Entity) GetContent() []byte

func (*Entity) GetCreated

func (ro *Entity) GetCreated() *time.Time

func (*Entity) GetExpiry

func (ro *Entity) GetExpiry() *time.Time

func (*Entity) GetRONum

func (ro *Entity) GetRONum() int

func (*Entity) GetRevokers

func (ro *Entity) GetRevokers() [][]byte

func (*Entity) GetSK

func (ro *Entity) GetSK() []byte

func (*Entity) GetSigningBlob

func (ro *Entity) GetSigningBlob() []byte

GetSigningBlob returns the full entity, including the private key

func (*Entity) GetVK

func (ro *Entity) GetVK() []byte

func (*Entity) IsPayloadObject

func (ro *Entity) IsPayloadObject() bool

func (*Entity) OverrideSetSignatureValid

func (ro *Entity) OverrideSetSignatureValid()

func (*Entity) SetCreationToNow

func (ro *Entity) SetCreationToNow()

func (*Entity) SetExpiry

func (ro *Entity) SetExpiry(t time.Time)

func (*Entity) SetSK

func (ro *Entity) SetSK(sk []byte)

func (*Entity) SetVK

func (ro *Entity) SetVK(vk []byte)

func (*Entity) SigValid

func (ro *Entity) SigValid() bool

SigValid returns if the Entity's signature is valid. This only checks the signature on the first call, so the content must not change after encoding for this to be valid

func (*Entity) StringKey

func (ro *Entity) StringKey() string

func (*Entity) WriteToStream

func (ro *Entity) WriteToStream(s io.Writer, fullObjNum bool) error

type Expiry

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

func CreateNewExpiry

func CreateNewExpiry(expiry time.Time) *Expiry

func CreateNewExpiryFromNow

func CreateNewExpiryFromNow(expiry time.Duration) *Expiry

func (*Expiry) GetContent

func (ro *Expiry) GetContent() []byte

func (*Expiry) GetExpiry

func (ro *Expiry) GetExpiry() time.Time

func (*Expiry) GetRONum

func (ro *Expiry) GetRONum() int

func (*Expiry) IsPayloadObject

func (ro *Expiry) IsPayloadObject() bool

func (*Expiry) WriteToStream

func (ro *Expiry) WriteToStream(s io.Writer, fullObjNum bool) error

type Frame

type Frame struct {
	SeqNo   int
	Headers []Header
	Cmd     string
	ROs     []ROEntry
	POs     []POEntry
	Length  int
}

func CreateFrame

func CreateFrame(cmd string, seqno int) *Frame

func LoadFrameFromStream

func LoadFrameFromStream(s *bufio.Reader) (f *Frame, e error)

func (*Frame) AddHeader

func (f *Frame) AddHeader(k string, v string)

func (*Frame) AddHeaderB

func (f *Frame) AddHeaderB(k string, v []byte)

func (*Frame) AddPayloadObject

func (f *Frame) AddPayloadObject(po PayloadObject)

func (*Frame) AddRoutingObject

func (f *Frame) AddRoutingObject(ro RoutingObject)

func (*Frame) GetAllHeaders

func (f *Frame) GetAllHeaders(k string) []string

func (*Frame) GetAllHeadersB

func (f *Frame) GetAllHeadersB(k string) [][]byte

func (*Frame) GetAllPOs

func (f *Frame) GetAllPOs() []PayloadObject

func (*Frame) GetAllROs

func (f *Frame) GetAllROs() []RoutingObject

func (*Frame) GetFirstHeader

func (f *Frame) GetFirstHeader(k string) (string, bool)

func (*Frame) GetFirstHeaderB

func (f *Frame) GetFirstHeaderB(k string) ([]byte, bool)

func (*Frame) ParseFirstHeaderAsBool

func (f *Frame) ParseFirstHeaderAsBool(k string, def bool) (bool, bool, *string)

func (*Frame) ParseFirstHeaderAsInt

func (f *Frame) ParseFirstHeaderAsInt(k string, def int) (int, bool, *string)

func (*Frame) WriteToStream

func (f *Frame) WriteToStream(s *bufio.Writer)

type GenericPO

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

func (*GenericPO) GetContent

func (po *GenericPO) GetContent() []byte

func (*GenericPO) GetPONum

func (po *GenericPO) GetPONum() int
type Header struct {
	Content []byte
	Key     string
	Length  string
	ILength int
}

type ObjectError

type ObjectError struct {
	ObjectID int
	Message  string
}

ObjectError is thrown by object parsing function

func (ObjectError) Error

func (oe ObjectError) Error() string

type OriginVK

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

func CreateOriginVK

func CreateOriginVK(vk []byte) *OriginVK

func (*OriginVK) GetContent

func (ro *OriginVK) GetContent() []byte

func (*OriginVK) GetRONum

func (ro *OriginVK) GetRONum() int

func (*OriginVK) GetVK

func (ro *OriginVK) GetVK() []byte

func (*OriginVK) IsPayloadObject

func (ro *OriginVK) IsPayloadObject() bool

func (*OriginVK) WriteToStream

func (ro *OriginVK) WriteToStream(s io.Writer, fullObjNum bool) error

type POEntry

type POEntry struct {
	PO     PayloadObject
	IntNum string
	DotNum string
	Length string
}

type PayloadObject

type PayloadObject interface {
	GetPONum() int
	GetContent() []byte
}

PayloadObject is the interface that is common among all objects that appear in the payload block

func CreateOpaquePayloadObject

func CreateOpaquePayloadObject(ponum int, content []byte) (PayloadObject, error)

func CreateOpaquePayloadObjectDF

func CreateOpaquePayloadObjectDF(dotform string, content []byte) (PayloadObject, error)

func LoadPayloadObject

func LoadPayloadObject(ponum int, content []byte) (PayloadObject, error)

type PublishLimits

type PublishLimits struct {
	TxLimit    int64
	StoreLimit int64
	Retain     int
}

PublishLimits is an option found in an AccessDOT that governs the resources that may be used by messages authorised via the DOT

type ROEntry

type ROEntry struct {
	RO     RoutingObject
	RONum  string
	Length string
}

type RoutingObject

type RoutingObject interface {
	GetRONum() int
	GetContent() []byte
	WriteToStream(w io.Writer, fullObjNum bool) error
	IsPayloadObject() bool
}

RoutingObject is the interface that is common among all objects that appear in the routing object block

func LoadRoutingObject

func LoadRoutingObject(ronum int, content []byte) (RoutingObject, error)

LoadRoutingObject takes the ronum and the content and returns the object

func NewDChain

func NewDChain(ronum int, content []byte) (rv RoutingObject, err error)

NewDChain deserialises a DChain from a byte array

func NewDOT

func NewDOT(ronum int, content []byte) (rv RoutingObject, err error)

NewDOT constructs a DOT from its packed form

func NewEntity

func NewEntity(ronum int, content []byte) (RoutingObject, error)

func NewExpiry

func NewExpiry(ronum int, content []byte) (RoutingObject, error)

func NewOriginVK

func NewOriginVK(ronum int, content []byte) (RoutingObject, error)

Jump to

Keyboard shortcuts

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