Documentation ¶
Index ¶
Constants ¶
View Source
const ( Publish = "pub" Subscribe = "sub" )
all permit actions
Variables ¶
View Source
var ( ErrConnectionRefuse = errors.New("connection refuse on server side") ErrSessionClientAlreadyClosed = errors.New("session client is already closed") ErrSessionClientAlreadyConnecting = errors.New("session client is already connected") ErrSessionClientPacketUnexpected = errors.New("session client received unexpected packet") ErrSessionClientPacketIDConflict = errors.New("packet id conflict, to acknowledge old packet") ErrSessionClientPacketNotFound = errors.New("packet id is not found") ErrSessionClientIDInvalid = errors.New("client ID is invalid") ErrSessionProtocolVersionInvalid = errors.New("protocol version is invalid") ErrSessionUsernameNotSet = errors.New("username is not set") ErrSessionUsernameNotPermitted = errors.New("username or password is not permitted") ErrSessionCertificateCommonNameNotFound = errors.New("certificate common name is not found") ErrSessionCertificateCommonNameNotPermitted = errors.New("certificate common name is not permitted") ErrSessionMessageQosNotSupported = errors.New("message QOS is not supported") ErrSessionMessageTopicInvalid = errors.New("message topic is invalid") ErrSessionMessageTopicNotPermitted = errors.New("message topic is not permitted") ErrSessionMessagePayloadSizeExceedsLimit = errors.New("message payload exceeds the max limit") ErrSessionWillMessageQosNotSupported = errors.New("will QoS is not supported") ErrSessionWillMessageTopicInvalid = errors.New("will topic is invalid") ErrSessionWillMessageTopicNotPermitted = errors.New("will topic is not permitted") ErrSessionWillMessagePayloadSizeExceedsLimit = errors.New("will message payload exceeds the max limit") ErrSessionSubscribePayloadEmpty = errors.New("subscribe payload can't be empty") ErrSessionManagerClosed = errors.New("manager has closed") )
all errors
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
Authenticator authenticator
func NewAuthenticator ¶
func NewAuthenticator(principals []Principal) *Authenticator
NewAuthenticator creates a new Authenticator
func (*Authenticator) AuthenticateAccount ¶
func (a *Authenticator) AuthenticateAccount(username, password string) *Authorizer
AuthenticateAccount authenticates client account, then return authorizer if pass
func (*Authenticator) AuthenticateCertificate ¶
func (a *Authenticator) AuthenticateCertificate(commonName string) *Authorizer
AuthenticateCertificate authenticates client certificate, then return authorizer if pass
type Authorizer ¶
Authorizer checks topic permission
func (*Authorizer) Authorize ¶
func (p *Authorizer) Authorize(action, topic string) bool
Authorize auth action
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client the client of MQTT
type Config ¶
type Config struct { SessionConfig `yaml:"session,omitempty" json:"session,omitempty"` Principals []Principal `yaml:"principals,omitempty" json:"principals,omitempty" validate:"principals"` }
Config session config
type Info ¶
type Info struct { ID string `json:"id,omitempty"` WillMessage *mqtt.Message `json:"will,omitempty"` Subscriptions map[string]mqtt.QOS `json:"subs,omitempty"` CleanSession bool `json:"-"` }
Info session information
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager the manager of sessions
func NewManager ¶
NewManager create a new session manager
type Permission ¶
type Permission struct { Action string `yaml:"action" json:"action" validate:"regexp=^(p|s)ub$"` Permits []string `yaml:"permit,flow" json:"permit,flow"` }
Permission Permission
type Persistence ¶
type Principal ¶
type Principal struct { Username string `yaml:"username" json:"username"` Password string `yaml:"password" json:"password"` Permissions []Permission `yaml:"permissions" json:"permissions"` }
Principal Principal
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session session of a client
type SessionConfig ¶
type SessionConfig struct { MaxClients int `yaml:"maxClients,omitempty" json:"maxClients,omitempty"` MaxMessagePayloadSize utils.Size `yaml:"maxMessagePayloadSize,omitempty" json:"maxMessagePayloadSize,omitempty" default:"32768" validate:"min=1,max=268435455"` // max size of message payload is (256MB - 1) MaxInflightQOS0Messages int `yaml:"maxInflightQOS0Messages" json:"maxInflightQOS0Messages" default:"100" validate:"min=1"` MaxInflightQOS1Messages int `yaml:"maxInflightQOS1Messages" json:"maxInflightQOS1Messages" default:"20" validate:"min=1"` ResendInterval time.Duration `yaml:"resendInterval" json:"resendInterval" default:"20s"` Persistence Persistence `yaml:"persistence,omitempty" json:"persistence,omitempty"` SysTopics []string `yaml:"sysTopics,omitempty" json:"sysTopics,omitempty" default:"[\"$link\"]"` }
SessionConfig session config without principals
Source Files ¶
Click to show internal directories.
Click to hide internal directories.