Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultPort is the port that the application will listen on unless otherwise specified. DefaultPort = "8080" // DefaultRedisURI is the default redis connection string. DefaultRedisURI = "redis://0.0.0.0:6379" // DefaultHostname is the default hostname that will be bound to. DefaultHostname = "0.0.0.0" )
View Source
const ( // ErrInvalidDeviceID is returned when a user submits an invalid device id to a route that requires one. ErrInvalidDeviceID = "invalid-device-id" // ErrInvalidDeviceTokenName is returned when a user submits an invalid token name. ErrInvalidDeviceTokenName = "invalid-name" // ErrInvalidTokenRequest is returned from the registry when allocation is requested with bad contents. ErrInvalidTokenRequest = "invalid-request" // ErrInvalidRegistrationRequest is returned from the registry when allocation is requested with bad contents. ErrInvalidRegistrationRequest = "invalid-registration" // ErrNotFound returned when the application is unable to find the record it is looking for. ErrNotFound = "not-found" // ErrBadRedisResponse returned when unable to parse data from redis response. ErrBadRedisResponse = "storage-error" // ErrBadRequestFormat returned when api receives invalid body. ErrBadRequestFormat = "invalid-request-format" // ErrBadInterchangeData returned when unable to unmarshal interchange data. ErrBadInterchangeData = "interchange-error" // ErrBadInterchangeAuthentication returned when an interchange message has bad auth. ErrBadInterchangeAuthentication = "interchange-auth" // ErrInvalidContentType returned when clients make requests to the api with invalid data. ErrInvalidContentType = "invalid-content-type" // ErrServerError returned when an interchange message has bad auth. ErrServerError = "server-error" // ErrInvalidBackgroundChannel returned when attempting to publish to an invalid background channel ErrInvalidBackgroundChannel = "invalid-background-channel" ErrInvalidDeviceSharedSecret = "invalid-shared-secret" // ErrDuplicateRegistrationName returned when registering a name that already exists. ErrDuplicateRegistrationName = "duplicate-name" // ErrInvalidColorShorthand returned when the color shorthand request by the client is invalid. ErrInvalidColorShorthand = "invalid-color-shorthand" )
View Source
const ( // APIContentTypeHeader is the content type header. APIContentTypeHeader = "Content-Type" // APIDeviceRegistrationHeader is the header key used by devices to send their shared secret when connecting. APIDeviceRegistrationHeader = "x-device-auth" // APIUserTokenHeader is the header key used by users to send a device token. APIUserTokenHeader = "x-user-auth" // APIFeedbackContentTypeHeader is the content type required for requests sent to the feedback api. APIFeedbackContentTypeHeader = "application/octet-stream" )
View Source
const ( // DebugLogLevelTag is used for debugf logger calls DebugLogLevelTag = "debug" // InfoLogLevelTag is used for infof logger calls InfoLogLevelTag = "info" // WarnLogLevelTag is used for errorf logger calls WarnLogLevelTag = "warn" // ErrorLogLevelTag is used for errorf logger calls ErrorLogLevelTag = "error" // MainLogPrefix is the log prefix for the main go routine MainLogPrefix = "[beacon api] " // RegistrationAPILogPrefix log prefix used by the registration api RegistrationAPILogPrefix = "[registrations api] " // FeedbackAPILogPrefix log prefix used by the feedback api FeedbackAPILogPrefix = "[feedback api] " // DeviceMessagesAPILogPrefix log prefix used by tokens api DeviceMessagesAPILogPrefix = "[device messages api] " // DevicesAPILogPrefix log prefix used by tokens api DevicesAPILogPrefix = "[devices api] " // TokensAPILogPrefix log prefix used by tokens api TokensAPILogPrefix = "[tokens api] " // ServerKeyLogPrefix log prefix used by server key ServerKeyLogPrefix = "[server key] " // RegistryLogPrefix is the log prefix for the device registry RegistryLogPrefix = "[device registry] " // ServerRuntimeLogPrefix is the log prefix for the http server runtime ServerRuntimeLogPrefix = "[server runtime] " // DeviceConnectionLogPrefix is the log prefix for the device connections DeviceConnectionLogPrefix = "[device connection] " // DeviceControlLogPrefix is the log prefix for the device control processor DeviceControlLogPrefix = "[device control] " // DeviceFeedbackLogPrefix is the log prefix for the device feeback processor DeviceFeedbackLogPrefix = "[device feedback] " // DefaultLoggerFlags is the bitmask used to create default logging DefaultLoggerFlags = log.Ldate | log.Ltime )
View Source
const ( // WelcomeMessageBody is the welcome text sent to deviceson registration WelcomeMessageBody = "welcome to beacon" // DeviceMessageLabel is used during RSA OAEP signing DeviceMessageLabel = "beacon" )
View Source
const ( // RedisDeviceIndexKey is the key used by the regis device registry to store device ids RedisDeviceIndexKey = "beacon:device-index" // RedisDeviceRegistryKey is the key used by the regis device registry to store device information RedisDeviceRegistryKey = "beacon:device-registry" // RedisDeviceFeedbackKey is the key used by the regis device registry to store device feedback RedisDeviceFeedbackKey = "beacon:device-feedback" // RedisRegistrationRequestListKey is the key used for registration requests RedisRegistrationRequestListKey = "beacon:registration-requests" // RedisDeviceIDField is the field that contains the unique id of the device RedisDeviceIDField = "device:uuid" // RedisDeviceNameField is the field that contains the unique name of the device RedisDeviceNameField = "device:name" // RedisDeviceTokenListKey is the field that contains the list of tokens associated w/ each device RedisDeviceTokenListKey = "device:token-list" // RedisDeviceTokenRegistrationKey field for device token information (name) RedisDeviceTokenRegistrationKey = "device:token" // RedisDeviceTokenNameField is the field that contains the unique name of the token RedisDeviceTokenNameField = "device-token:name" // RedisDeviceTokenDeviceIDField stores the token's device id RedisDeviceTokenDeviceIDField = "device-token:device-id" // RedisDeviceTokenIDField stores the unique id of the token RedisDeviceTokenIDField = "device-token:uuid" // RedisDeviceTokenPermissionField is the field that contains the permission of the token RedisDeviceTokenPermissionField = "device-token:permission" // RedisDeviceSecretField is the field that contains the unique secret of the device RedisDeviceSecretField = "device:secret" // RedisRegistrationNameField is the redis key used to store registration names RedisRegistrationNameField = "registration:name" // RedisRegistrationSecretField is the redis key used to store registration secrets RedisRegistrationSecretField = "registration:secret" // RedisMaxFeedbackEntries is the maximum amount of entries a device is allowed to have at any given time. RedisMaxFeedbackEntries = 100 )
View Source
const ( // SecurityUserDeviceTokenSize is the size of user device tokens SecurityUserDeviceTokenSize = 20 // SecurityUserDeviceNameMinLength is the size of user device tokens SecurityUserDeviceNameMinLength = 5 SecurityMinimumDeviceSharedSecretSize = 20 )
View Source
const ( // SecurityDeviceTokenPermissionViewer - get state SecurityDeviceTokenPermissionViewer = 1 << iota // SecurityDeviceTokenPermissionController - control lights SecurityDeviceTokenPermissionController // SecurityDeviceTokenPermissionAdmin - control lights + tokens SecurityDeviceTokenPermissionAdmin )
View Source
const ( // DeviceControlChannelName is the name of the stream that will be used to send device control messages along DeviceControlChannelName = "chan:device-control" // DeviceFeedbackChannelName is the name of the stream that will broacast messages received from devices DeviceFeedbackChannelName = "chan:device-feedback" )
View Source
const ( // SecurityDeviceTokenPermissionAll is all permissions SecurityDeviceTokenPermissionAll = SecurityDeviceTokenPermissionAdmin | SecurityDeviceTokenPermissionController | SecurityDeviceTokenPermissionViewer )
View Source
const ( // TextWriter asks the nextwriter for a text based writer TextWriter = websocket.TextMessage )
Variables ¶
View Source
var ( // DeviceListRoute is the regular expression used for the device list route DeviceListRoute = regexp.MustCompile("^/devices$") // DeviceShorthandRoute is the regular expression used for the device shorthand route DeviceShorthandRoute = regexp.MustCompile("^/devices/(?P<uuid>[\\d\\w\\-]+)/(?P<color>" + shorthandColors + ")$") // DeviceRegistrationRoute is used by devices to register with the server DeviceRegistrationRoute = regexp.MustCompile("^/register$") // DeviceTokensRoute is used to create device tokens for a given device. DeviceTokensRoute = regexp.MustCompile("^/device-tokens$") // DeviceFeedbackRoute is used to receive device feedback from clients. DeviceFeedbackRoute = regexp.MustCompile("^/device-feedback$") // DeviceMessagesRoute is used to create device messages. DeviceMessagesRoute = regexp.MustCompile("^/device-messages$") // SystemRoute prints out system information SystemRoute = regexp.MustCompile("^/system$") )
Functions ¶
This section is empty.
Types ¶
type DeviceTokenPermissions ¶
type DeviceTokenPermissions uint
DeviceTokenPermissions is a bitmask used to authorize device actions
Click to show internal directories.
Click to hide internal directories.