Documentation ¶
Index ¶
- Constants
- Variables
- type Channel
- type ChannelOption
- type ID
- type Key
- func (k Key) Contract() uint32
- func (k Key) Expires() time.Time
- func (k Key) HasPermission(flag uint8) bool
- func (k Key) IsEmpty() bool
- func (k Key) IsExpired() bool
- func (k Key) IsMaster() bool
- func (k Key) Master() uint16
- func (k Key) Permissions() uint8
- func (k Key) Salt() uint16
- func (k Key) SetContract(value uint32)
- func (k Key) SetExpires(value time.Time)
- func (k Key) SetMaster(value uint16)
- func (k Key) SetPermission(flag uint8, value bool)
- func (k Key) SetPermissions(value uint8)
- func (k Key) SetSalt(value uint16)
- func (k Key) SetSignature(value uint32)
- func (k Key) SetTarget(channel string) error
- func (k Key) Signature() uint32
- func (k Key) ValidateChannel(ch *Channel) bool
Constants ¶
const ( ChannelInvalid = uint8(iota) ChannelStatic ChannelWildcard )
Channel types
const ( MinTime = 1514764800 // 2018 MaxTime = 3029529600 // 2066 )
Minimum and maximum unix time stamp we can handle for options
const ( AllowNone = uint8(0) // Key has no privileges. AllowMaster = uint8(1 << 0) // Key should be allowed to generate other keys. AllowRead = uint8(1 << 1) // Key should be allowed to subscribe to the target channel. AllowWrite = uint8(1 << 2) // Key should be allowed to publish to the target channel. AllowStore = uint8(1 << 3) // Key should be allowed to write to the message history of the target channel. AllowLoad = uint8(1 << 4) // Key should be allowed to write to read the message history of the target channel. AllowPresence = uint8(1 << 5) // Key should be allowed to query the presence on the target channel. AllowExtend = uint8(1 << 6) // Key should be allowed to create sub-channels by extending an existing one. AllowExecute = uint8(1 << 7) // Key should be allowed to execute code. (RESERVED) AllowReadWrite = AllowRead | AllowWrite // Key should be allowed to read and write to the target channel. AllowStoreLoad = AllowStore | AllowLoad // Key should be allowed to read and write the message history. AllowAll = math.MaxUint8 &^ AllowMaster // Key allows everything except master )
Access types for a security key.
Variables ¶
var ( ErrTargetInvalid = errors.New("channel should end with `/` for strict types or `/#/` for multi level wildcard") ErrTargetTooLong = errors.New("channel can not have more than 23 parts") )
Key errors
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct { Key []byte // Gets or sets the API key of the channel. Channel []byte // Gets or sets the channel string. Query []uint32 // Gets or sets the full ssid. Options []ChannelOption // Gets or sets the options. ChannelType uint8 }
Channel represents a parsed MQTT topic.
func MakeChannel ¶
MakeChannel attempts to parse the channel from the key and channel strings.
func ParseChannel ¶
ParseChannel attempts to parse the channel from the underlying slice.
func (*Channel) SafeString ¶
SafeString returns a string representation of the channel without the key.
type ChannelOption ¶
ChannelOption represents a key/value pair option.
type Key ¶
type Key []byte
Key represents a security key.
func (Key) HasPermission ¶
HasPermission check whether the key provides some permission.
func (Key) SetExpires ¶
SetExpires sets the expiration date for the key.
func (Key) SetPermission ¶
SetPermission sets a permission to a value
func (Key) SetPermissions ¶
SetPermissions sets the permission flags.
func (Key) SetSignature ¶
SetSignature sets the signature of the contract.
func (Key) ValidateChannel ¶
ValidateChannel validates the channel string.