services

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

README

Kiebitz Services

This repository contains Kiebitz's backend services:

  • A storage service that stores encrypted user & operator settings and temporary data.
  • An appointments service that stores encrypted appointment data.

Dependencies

The Kiebitz backend services are written in Golang. Please install a recent version, preferably >=1.16.

By default, Kiebitz uses a Redis database to store data. Please make sure a Redis server is available. You can change the connection details in the settings/dev/001_default.yml settings file. The metering services (for statistics) also uses a Redis database by default and can be configured just like the main database. In addition, to generate TLS certificates (which is not always necessary) Kiebitz relies on the openssl CLI.

Installation

To build and install all services into your GOPATH, simply run

make

Basic Setup

Kiebitz needs cryptographic keys and some helper data to function correctly. All of these can be generated using the kiebitz command.

First things first: Kiebitz looks for settings in the path given by the KIEBITZ_SETTINGS environment variable. For development, settings are in the settings/dev subdirectory of the repository. To set up our development environment, we simply run

source .dev-setup

For the commands below we'll assume that KIEBITZ_SETTINGS points to the settings/dev directory.

Cryptographic Keys

Now, we need to generate various cryptographic keys for signing and encryption. To do this, we simply run

kiebitz admin keys setup

Warning: Running this command will overwrite existing key files, potentially rendering all your development data useless, so be careful.

This will generate two files in the Kiebitz settings directory, 002_admin.json and 003_appt.json. The former is only for administration purposes and should remain locked away. The latter is for use with the appointments server.

Now we can then generate mediator keys. To do this, we simply run

kiebitz admin keys mediator > data/secret-mediator-keys.json

This will create a JSON data structure with all necessary keys for the mediator. Please be aware that the provider keys are just copied from the 002_admin.json file generated before. These keys enable mediators to decrypt provider data.

For the next steps of the setup process we'll need a running backend, so let's start it via

kiebitz --level debug run all

That should start the appointments and storage services. Now we can tell the backend about the newly created mediator keys, which we do via

kiebitz admin mediators upload data/secret-mediator-keys.json

This will sign the public signing and encryption keys of the mediator with the root key and put the signed key material on the backend for publication. That's it! Now we should be able to go to the /mediator URL in the frontend, load our mediator key file and verify providers. Providers should be able to sign up, upload their data for verification and get tokens. Users should also be able to sign up and receive invitations.

ZIP Code Data

ZIP code data helps Kiebitz to estimate distances between zip code areas. There are two files data/distances.json and data/distances-areas.json that need to be uploaded. We can do this via

# upload distances for full ZIP codes (used when matching tokens to providers)
kiebitz admin distances upload data/distances.json
# upload distances for ZIP codes areas (used when filtering appointments for users)
kiebitz admin distances upload data/distances-areas.json

To generate the distances, we can use the make_distances.py and make_area_distances.py scripts from the .scripts folder (normally this is not necessary though):

python3 .scripts/make_distances.py
python3 .scripts/make_area_distances.py

Note: We can test the system without the ZIP code data, but tokens will then only be distributed to matching zip codes.

Signup Codes

We can also upload user & provider codes if we want to restrict who can register on the platform (this requires setting appointments.user_codes_enabled: true and appointments.provider_codes.enabled: true, respectively):

# upload user codes from a file
kiebitz admin codes upload data/secret-user-codes.json
# upload provider codes from a file
kiebitz admin codes upload data/secret-provider-codes.json

To generate codes, we simply run

# generate 10.000 user codes
kiebitz admin codes generate --actor user -n 10000 > data/secret-user-codes.json
# generate 10.000 provider codes
kiebitz admin codes generate --actor provider -n 10000 > data/secret-user-codes.json

Codes are just random 16 byte values, and the actor parameter just tells the backend for which actor the codes should be used.

TLS Certificates

Finally, if we want to run Kiebitz using a self-signed TLS certificate, we simply run

make certs

to generate these certificates, and then enable them by commenting out the tls section in the settings.

Running

Start redis:

docker run -d -p 6379:6379 redis

To run the development services we can then

# run the appointments service
kiebitz run appointments
# ...or run the storage service
kiebitz run storage
# ...or run all services
kiebitz run all

APIs

The Kiebitz services can be exposed as a JSON-RPC or REST service (or both). For example, if both API types are enabled, the getAppointmentsByZipCode endpoint with parameters zipCode=10707 and radius=20 can be reached via both of the following queries:

# REST endpoint
curl http://localhost:8888/appointments/zipCode/10707/20
# JSON-RPC endpoint
curl -X POST --header "Content-Type: application/json" http://localhost:8888/jsonrpc --data '{"jsonrpc": "2.0", "method": "getAppointmentsByZipCode", "params": {"zipCode": "10707", "radius": "20"}}' 

In general, the REST API is better for caching as it exposes cacheable endpoints via GET requests, while the JSON-RPC API provides a simpler and more natural interface.

Testing

Here's how you can send a request to the storage server via curl (this assumes you have jq installed for parsing of the JSON result):

curl --cacert settings/dev/certs/root.crt --resolve storage-1:9999:127.0.0.1 https://storage-1:9999/jsonrpc --header "Content-Type: application/json; charset=utf-8" --data '{"method": "getSettings", "id": "2", "params": {"key": "az4df7vjunsd6ad"}, "jsonrpc": "2.0"}' 2>/dev/null | jq 

To run all Go tests and benchmarks, simply

# run normal tests
make test
# run race-condition tests
make test-races
# run benchmarks
make bench
Load Testing

Careful, the following commands will create massive amounts of fake data via the API client, never run this against the production system, except for initial load testing!

You can simulate providers, appointments and bookings in the backend using the testing benchmark command. The following command will create 1.000 providers with 1.000 appointments with 20 slots each, hence a total of 20.000.000 appointments:

kiebitz testing benchmark --providers 1000 --appointments 1000 --slots 20

This command will use the given settings and connect to a running API server, hence to run it you need to also run the Kiebitz API. Probably you want to use the test settings for this

Development

To auto-generate copyright headers for Golang files, simply run

make copyright

Documentation

Index

Constants

View Source
const (
	PanicLogLevel = Level(log.PanicLevel)
	FatalLogLevel = Level(log.FatalLevel)
	ErrorLogLevel = Level(log.ErrorLevel)
	WarnLogLevel  = Level(log.WarnLevel)
	InfoLogLevel  = Level(log.InfoLevel)
	DebugLogLevel = Level(log.DebugLevel)
	TraceLogLevel = Level(log.TraceLevel)
)

Variables

View Source
var Log = Logger{}

Functions

func APIHandlerStruct added in v0.0.6

func APIHandlerStruct(handler interface{}) (interface{}, error)

returns a new struct that we can coerce the valid form parameters into

func Key added in v0.0.4

func Key(keys []*crypto.Key, name string) *crypto.Key

Types

type ActorKey

type ActorKey struct {
	Data      string `json:"data"`
	Signature []byte `json:"signature"`
	PublicKey []byte `json:"publicKey"`
	// contains filtered or unexported fields
}

func (*ActorKey) KeyData

func (a *ActorKey) KeyData() (*ActorKeyData, error)

func (*ActorKey) ProviderKeyData

func (a *ActorKey) ProviderKeyData() (*ProviderKeyData, error)

type ActorKeyData

type ActorKeyData struct {
	Encryption []byte     `json:"encryption"`
	Signing    []byte     `json:"signing"`
	Timestamp  *time.Time `json:"timestamp"`
}

type AddCodesParams

type AddCodesParams struct {
	JSON      string     `json:"data" coerce:"name:json"`
	Data      *CodesData `json:"-" coerce:"name:data"`
	Signature []byte     `json:"signature"`
	PublicKey []byte     `json:"publicKey"`
}

type AddMediatorPublicKeysParams

type AddMediatorPublicKeysParams struct {
	Timestamp  *time.Time `json:"timestamp"`
	Encryption []byte     `json:"encryption"`
	Signing    []byte     `json:"signing"`
}

type AddMediatorPublicKeysSignedParams

type AddMediatorPublicKeysSignedParams struct {
	JSON      string                       `json:"data" coerce:"name:json"`
	Data      *AddMediatorPublicKeysParams `json:"-" coerce:"name:data"`
	Signature []byte                       `json:"signature"`
	PublicKey []byte                       `json:"publicKey"`
}

type AdminSettings

type AdminSettings struct {
	Signing *SigningSettings `json:"signing,omitempty"`
	Client  *ClientSettings  `json:"client,omitempty"`
}

type Appointment

type Appointment struct {
	Timestamp  time.Time              `json:"timestamp"`
	Duration   int64                  `json:"duration"`
	Properties map[string]interface{} `json:"properties"`
	SlotData   []*Slot                `json:"slotData"`
	ID         []byte                 `json:"id"`
	PublicKey  []byte                 `json:"publicKey"`
}

func MakeAppointment

func MakeAppointment(timestamp time.Time, slots, duration int64) (*Appointment, error)

func (*Appointment) Sign

func (k *Appointment) Sign(key *crypto.Key) (*SignedAppointment, error)

type AppointmentsSettings

type AppointmentsSettings struct {
	DataTTLDays             int64                  `json:"data_ttl_days,omitempty"`
	HTTP                    *HTTPServerSettings    `json:"http,omitempty"`
	REST                    *RESTServerSettings    `json:"rest,omitempty"`
	JSONRPC                 *JSONRPCServerSettings `json:"jsonrpc,omitempty"`
	Keys                    []*crypto.Key          `json:"keys,omitempty"`
	Secret                  []byte                 `json:"secret,omitempty"`
	ProviderCodesEnabled    bool                   `json:"provider_codes_enabled,omitempty"`
	UserCodesEnabled        bool                   `json:"user_codes_enabled,omitempty"`
	UserCodesReuseLimit     int64                  `json:"user_codes_reuse_limit"`
	ProviderCodesReuseLimit int64                  `json:"provider_codes_reuse_limit"`
}

func (*AppointmentsSettings) Key

func (a *AppointmentsSettings) Key(name string) *crypto.Key

type BaseDatabase

type BaseDatabase struct {
}

type BookAppointmentParams

type BookAppointmentParams struct {
	ProviderID      []byte                    `json:"providerID"`
	ID              []byte                    `json:"id"`
	EncryptedData   *crypto.ECDHEncryptedData `json:"encryptedData"`
	SignedTokenData *SignedTokenData          `json:"signedTokenData"`
	Timestamp       *time.Time                `json:"timestamp"`
}

type BookAppointmentSignedParams

type BookAppointmentSignedParams struct {
	JSON      string                 `json:"data" coerce:"name:json"`
	Data      *BookAppointmentParams `json:"-" coerce:"name:data"`
	Signature []byte                 `json:"signature"`
	PublicKey []byte                 `json:"publicKey"`
}

type Booking

type Booking struct {
	ID            []byte                    `json:"id"`
	PublicKey     []byte                    `json:"publicKey"`
	Token         []byte                    `json:"token"`
	EncryptedData *crypto.ECDHEncryptedData `json:"encryptedData"`
}

type CancelAppointmentParams

type CancelAppointmentParams struct {
	ProviderID      []byte           `json:"providerID"`
	SignedTokenData *SignedTokenData `json:"signedTokenData"`
	ID              []byte           `json:"id"`
}

type CancelAppointmentSignedParams

type CancelAppointmentSignedParams struct {
	JSON      string                   `json:"data" coerce:"name:json"`
	Data      *CancelAppointmentParams `json:"-" coerce:"name:data"`
	Signature []byte                   `json:"signature"`
	PublicKey []byte                   `json:"publicKey"`
}

type CheckProviderDataParams

type CheckProviderDataParams struct {
	Timestamp *time.Time `json:"timestamp"`
}

type CheckProviderDataSignedParams

type CheckProviderDataSignedParams struct {
	JSON      string                   `json:"data" coerce:"name:json"`
	Data      *CheckProviderDataParams `json:"-" coerce:"name:data"`
	Signature []byte                   `json:"signature"`
	PublicKey []byte                   `json:"publicKey"`
}

type ClientSettings

type ClientSettings struct {
	StorageEndpoint      string `json:"storage_endpoint"`
	AppointmentsEndpoint string `json:"appointments_endpoint"`
}

type CodesData

type CodesData struct {
	Actor     string     `json:"actor"`
	Timestamp *time.Time `json:"timestamp"`
	Codes     [][]byte   `json:"codes"`
}

type CommandsDefinition

type CommandsDefinition struct {
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Maker       CommandsMaker `json:"-"`
}

type CommandsDefinitions

type CommandsDefinitions []CommandsDefinition

type CommandsMaker

type CommandsMaker func(settings *Settings) ([]cli.Command, error)

type ConfirmProviderParams

type ConfirmProviderParams struct {
	PublicProviderData    *SignedProviderData       `json:"publicProviderData"`
	EncryptedProviderData *crypto.ECDHEncryptedData `json:"encryptedProviderData"`
	SignedKeyData         *SignedKeyData            `json:"signedKeyData"`
}

this data is accessible to the provider, nothing "secret" should be stored here...

type ConfirmProviderSignedParams

type ConfirmProviderSignedParams struct {
	JSON      string                 `json:"data" coerce:"name:json"`
	Data      *ConfirmProviderParams `json:"-" coerce:"name:data"`
	Signature []byte                 `json:"signature"`
	PublicKey []byte                 `json:"publicKey"`
}

type Context added in v0.0.6

type Context interface {
	Params() map[string]interface{}
	Result(data interface{}) Response
	Error(code int, message string, data interface{}) Response
	InternalError() Response
	InvalidParams(err error) Response
	MethodNotFound() Response
	NotFound() Response
	Acknowledge() Response
	Nil() Response
}

type CorsSettings

type CorsSettings struct {
	AllowedHeaders []string `json:"allowed_headers"`
	AllowedHosts   []string `json:"allowed_hosts"`
	AllowedMethods []string `json:"allowed_methods"`
}

type Database

type Database interface {
	Close() error
	Open() error
	Reset() error
	Lock(lockKey string) (Lock, error)

	DatabaseOps
}

A database can deliver and accept message

type DatabaseDefinition

type DatabaseDefinition struct {
	Name              string            `json:"name"`
	Description       string            `json:"description"`
	Maker             DatabaseMaker     `json:"-"`
	SettingsValidator SettingsValidator `json:"-"`
}

type DatabaseDefinitions

type DatabaseDefinitions map[string]DatabaseDefinition

type DatabaseMaker

type DatabaseMaker func(settings interface{}) (Database, error)

type DatabaseOps

type DatabaseOps interface {
	Expire(table string, key []byte, ttl time.Duration) error
	Set(table string, key []byte) Set
	SortedSet(table string, key []byte) SortedSet
	List(table string, key []byte) List
	Map(table string, key []byte) Map
	Value(table string, key []byte) Value
}

type DatabaseSettings

type DatabaseSettings struct {
	Type     string `json:"type"`
	Settings interface{}
}

type Definitions

func MergeDefinitions

func MergeDefinitions(a, b Definitions) Definitions

func (Definitions) Marshal

func (d Definitions) Marshal() map[string]interface{}

func (Definitions) MarshalJSON

func (d Definitions) MarshalJSON() ([]byte, error)

We perform JSON marshalling manually to gain more flexibility...

type DeleteSettingsParams

type DeleteSettingsParams struct {
	ID []byte `json:"id"`
}

type Distance

type Distance struct {
	From     string  `json:"from"`
	To       string  `json:"to"`
	Distance float64 `json:"distance"`
}

type GetAppointmentParams

type GetAppointmentParams struct {
	ProviderID      []byte           `json:"providerID"`
	SignedTokenData *SignedTokenData `json:"signedTokenData"`
	ID              []byte           `json:"id"`
}

type GetAppointmentSignedParams

type GetAppointmentSignedParams struct {
	JSON      string                `json:"data" coerce:"name:json"`
	Data      *GetAppointmentParams `json:"-" coerce:"name:data"`
	Signature []byte                `json:"signature"`
	PublicKey []byte                `json:"publicKey"`
}

type GetAppointmentsByZipCodeParams

type GetAppointmentsByZipCodeParams struct {
	ZipCode string `json:"zipCode"`
	Radius  int64  `json:"radius"`
}

type GetKeysParams

type GetKeysParams struct {
}

type GetPendingProviderDataParams

type GetPendingProviderDataParams struct {
	N int64 `json:"n"`
}

type GetPendingProviderDataSignedParams

type GetPendingProviderDataSignedParams struct {
	JSON      string                        `json:"data" coerce:"name:json"`
	Data      *GetPendingProviderDataParams `json:"-" coerce:"name:data"`
	Signature []byte                        `json:"signature"`
	PublicKey []byte                        `json:"publicKey"`
}

type GetProviderAppointmentsParams

type GetProviderAppointmentsParams struct {
	Timestamp *time.Time `json:"timestamp"`
}

type GetProviderAppointmentsSignedParams

type GetProviderAppointmentsSignedParams struct {
	JSON      string                         `json:"data" coerce:"name:json"`
	Data      *GetProviderAppointmentsParams `json:"-" coerce:"name:data"`
	Signature []byte                         `json:"signature"`
	PublicKey []byte                         `json:"publicKey"`
}

type GetSettingsParams

type GetSettingsParams struct {
	ID []byte `json:"id"`
}

type GetStatsParams

type GetStatsParams struct {
	ID     string                 `json:"id"`
	Type   string                 `json:"type"`
	Filter map[string]interface{} `json:"filter"`
	Metric string                 `json:"metric"`
	Name   string                 `json:"name"`
	From   *time.Time             `json:"from"`
	To     *time.Time             `json:"to"`
	N      *int64                 `json:"n"`
}

type GetTokenParams

type GetTokenParams struct {
	Hash      []byte `json:"hash"`
	Code      []byte `json:"code"`
	PublicKey []byte `json:"publicKey"`
}

type GetVerifiedProviderDataParams

type GetVerifiedProviderDataParams struct {
	N int64 `json:"n"`
}

type GetVerifiedProviderDataSignedParams

type GetVerifiedProviderDataSignedParams struct {
	JSON      string                         `json:"data" coerce:"name:json"`
	Data      *GetVerifiedProviderDataParams `json:"-" coerce:"name:data"`
	Signature []byte                         `json:"signature"`
	PublicKey []byte                         `json:"publicKey"`
}

type HTTPServerSettings added in v0.0.6

type HTTPServerSettings struct {
	TLS           *TLSSettings `json:"tls,omitempty"`
	BindAddress   string       `json:"bind_address"`
	TCPRateLimits []*RateLimit `json:"tcp_rate_limits"`
}

type JSONRPCServerSettings

type JSONRPCServerSettings struct {
	Cors *CorsSettings       `json:"cors,omitempty"`
	HTTP *HTTPServerSettings `json:"http,omitempty"`
}

Settings for the JSON-RPC server

type KeyChain

type KeyChain struct {
	Provider *ActorKey `json:"provider"`
	Mediator *ActorKey `json:"mediator"`
}

type KeyData

type KeyData struct {
	Signing    []byte             `json:"signing"`
	Encryption []byte             `json:"encryption"`
	QueueData  *ProviderQueueData `json:"queueData"`
}

func (*KeyData) Sign

func (k *KeyData) Sign(key *crypto.Key) (*SignedKeyData, error)

type KeyLists

type KeyLists struct {
	Providers []*ActorKey `json:"providers"`
	Mediators []*ActorKey `json:"mediators"`
}

type Keys

type Keys struct {
	ProviderData []byte `json:"providerData"`
	RootKey      []byte `json:"rootKey"`
	TokenKey     []byte `json:"tokenKey"`
}

type Level

type Level log.Level

func ParseLevel

func ParseLevel(level string) (Level, error)

type List

type List interface {
	Object
}

type Lock

type Lock interface {
	Release() error
}

type Logger

type Logger struct {
}

func (*Logger) Debug

func (l *Logger) Debug(args ...interface{})

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(args ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

func (*Logger) Info

func (l *Logger) Info(args ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

func (*Logger) Trace

func (l *Logger) Trace(args ...interface{})

func (*Logger) Tracef

func (l *Logger) Tracef(format string, args ...interface{})

func (*Logger) Warning

func (l *Logger) Warning(args ...interface{})

func (*Logger) Warningf

func (l *Logger) Warningf(format string, args ...interface{})

type MailSettings

type MailSettings struct {
	SmtpHost     string `json:"smtp_host"`
	SmtpPort     int64  `json:"smtp_port"`
	SmtpUser     string `json:"smtp_user"`
	SmtpPassword string `json:"smtp_password"`
	Sender       string `json:"sender"`
	MailSubject  string `json:"mail_subject"`
	MailTemplate string `json:"mail_template"`
	MailDelay    int64  `json:"mail_delay"`
}

type Map

type Map interface {
	GetAll() (map[string][]byte, error)
	Get(key []byte) ([]byte, error)
	Del(key []byte) error
	Set(key []byte, value []byte) error
	Object
}

type Meter

type Meter interface {
	// Add the given value to the metric
	Add(id string, name string, data map[string]string, tw TimeWindow, value int64) error
	// Add the given value to the metric, but only if the given uid hasn't been counted yet
	AddOnce(id string, name string, uid string, data map[string]string, tw TimeWindow, value int64) error
	// Add the maximum value to the metric
	AddMax(id string, name string, uid string, data map[string]string, tw TimeWindow, value int64) error
	// Return the metric and its assigned quota
	Get(id string, name string, data map[string]string, tw TimeWindow) (*Metric, error)
	// Return metrics for a given ID and time interval
	Range(id string, from, to int64, name, twType string) ([]*Metric, error)
	N(id string, to int64, n int64, name, twType string) ([]*Metric, error)
}

type MeterDefinition

type MeterDefinition struct {
	Name              string            `json:"name"`
	Description       string            `json:"description"`
	Maker             MeterMaker        `json:"-"`
	SettingsValidator SettingsValidator `json:"-"`
}

type MeterDefinitions

type MeterDefinitions map[string]MeterDefinition

type MeterMaker

type MeterMaker func(settings interface{}) (Meter, error)

type MeterSettings

type MeterSettings struct {
	Type     string `json:"type"`
	Settings interface{}
}

type Metric

type Metric struct {
	Name       string
	TimeWindow TimeWindow
	Value      int64
	Data       map[string]string
}

type MetricSettings

type MetricSettings struct {
	BindAddress string `json:"bind_address"`
}

type MetricsServer

type MetricsServer interface {
	Start() error
	Stop() error
}

type Object

type Object interface {
}

type ProviderAppointments

type ProviderAppointments struct {
	Provider *SignedProviderData  `json:"provider"`
	Offers   []*SignedAppointment `json:"offers"`
	Booked   [][]byte             `json:"booked"`
	KeyChain *KeyChain            `json:"keyChain"`
}

type ProviderData

type ProviderData struct {
	Name        string `json:"name"`
	Street      string `json:"street"`
	City        string `json:"city"`
	ZipCode     string `json:"zipCode"`
	Description string `json:"description"`
}

func (*ProviderData) Sign

func (k *ProviderData) Sign(key *crypto.Key) (*SignedProviderData, error)

type ProviderKeyData

type ProviderKeyData struct {
	Encryption []byte             `json:"encryption"`
	Signing    []byte             `json:"signing"`
	QueueData  *ProviderQueueData `json:"queueData"`
	Timestamp  *time.Time         `json:"timestamp,omitempty"`
}

type ProviderQueueData

type ProviderQueueData struct {
	ZipCode    string `json:"zipCode"`
	Accessible bool   `json:"accessible"`
}

type PublishAppointmentsParams

type PublishAppointmentsParams struct {
	Timestamp *time.Time           `json:"timestamp"`
	Offers    []*SignedAppointment `json:"offers"`
}

type PublishAppointmentsSignedParams

type PublishAppointmentsSignedParams struct {
	JSON      string                     `json:"data" coerce:"name:json"`
	Data      *PublishAppointmentsParams `json:"-" coerce:"name:data"`
	Signature []byte                     `json:"signature"`
	PublicKey []byte                     `json:"publicKey"`
}

type RESTServerSettings added in v0.0.6

type RESTServerSettings struct {
	Cors *CorsSettings       `json:"cors,omitempty"`
	HTTP *HTTPServerSettings `json:"http,omitempty"`
}

Settings for the JSON-RPC server

type RPCSettings

type RPCSettings struct {
	BindAddress string `json:"bind_address"`
}

type RateLimit added in v0.0.6

type RateLimit struct {
	TimeWindow *TimeWindow `json:"timeWindow"`
	Type       string      `json:"type"`
	Limit      int64       `json:"limit"`
}

type Request added in v0.0.6

type Request interface {
}

type ResetDBParams added in v0.0.4

type ResetDBParams struct {
	Timestamp *time.Time `json:"timestamp"`
}

type ResetDBSignedParams added in v0.0.4

type ResetDBSignedParams struct {
	JSON      string         `json:"data" coerce:"name:json"`
	Data      *ResetDBParams `json:"-" coerce:"name:data"`
	Signature []byte         `json:"signature"`
	PublicKey []byte         `json:"publicKey"`
}

type Response added in v0.0.6

type Response interface {
}

func HandleAPICall added in v0.0.6

func HandleAPICall(handler interface{}, form *forms.Form, context Context) Response

type Set

type Set interface {
	Add([]byte) error
	Has([]byte) (bool, error)
	Del(key []byte) error
	Members() ([]*SetEntry, error)
	Object
}

type SetEntry

type SetEntry struct {
	Data []byte
}

type Settings

type Settings struct {
	Test         bool                  `json:"test,omitempty"`
	Admin        *AdminSettings        `json:"admin,omitempty"`
	Definitions  *Definitions          `json:"definitions,omitempty"`
	Storage      *StorageSettings      `json:"storage,omitempty"`
	Appointments *AppointmentsSettings `json:"appointments,omitempty"`
	Database     *DatabaseSettings     `json:"database,omitempty"`
	Meter        *MeterSettings        `json:"meter,omitempty"`
	Metrics      *MetricSettings       `json:"metrics,omitempty"`
	DatabaseObj  Database              `json:"-"`
	MeterObj     Meter                 `json:"-"`
	MetricsObj   MetricsServer         `json:"-"`
}

type SettingsValidator

type SettingsValidator func(settings map[string]interface{}) (interface{}, error)

type SignedAppointment

type SignedAppointment struct {
	UpdatedAt   time.Time    `json:"updatedAt"`
	Bookings    []*Booking   `json:"bookings"`    // only for providers
	BookedSlots []*Slot      `json:"bookedSlots"` // for users
	JSON        string       `json:"data" coerce:"name:json"`
	Data        *Appointment `json:"-" coerce:"name:data"`
	Signature   []byte       `json:"signature"`
	PublicKey   []byte       `json:"publicKey"`
}

type SignedKeyData

type SignedKeyData struct {
	JSON      string   `json:"data" coerce:"name:json"`
	Data      *KeyData `json:"-" coerce:"name:data"`
	Signature []byte   `json:"signature"`
	PublicKey []byte   `json:"publicKey"`
}

type SignedProviderData

type SignedProviderData struct {
	JSON      string        `json:"data" coerce:"name:json"`
	Data      *ProviderData `json:"-" coerce:"name:data"`
	Signature []byte        `json:"signature"`
	PublicKey []byte        `json:"publicKey"`
	ID        []byte        `json:"id"`
}

type SignedTokenData

type SignedTokenData struct {
	JSON      string     `json:"data" coerce:"name:json"`
	Data      *TokenData `json:"-" coerce:"name:data"`
	Signature []byte     `json:"signature"`
	PublicKey []byte     `json:"publicKey"`
}

type SigningSettings

type SigningSettings struct {
	Keys []*crypto.Key `json:"keys"`
}

func (*SigningSettings) Key

func (s *SigningSettings) Key(name string) *crypto.Key

type Slot

type Slot struct {
	ID []byte `json:"id"`
}

type SortedSet

type SortedSet interface {
	Object
	Del([]byte) (bool, error)
	Add([]byte, int64) error
	Range(int64, int64) ([]*SortedSetEntry, error)
	RangeByScore(int64, int64) ([]*SortedSetEntry, error)
	At(int64) (*SortedSetEntry, error)
	Score([]byte) (int64, error)
	PopMin(int64) ([]*SortedSetEntry, error)
	RemoveRangeByScore(int64, int64) error
}

type SortedSetEntry

type SortedSetEntry struct {
	Score int64
	Data  []byte
}

type StatsValue

type StatsValue struct {
	Name  string            `json:"name"`
	From  time.Time         `json:"from"`
	To    time.Time         `json:"to"`
	Data  map[string]string `json:"data"`
	Value int64             `json:"value"`
}

type StorageSettings

type StorageSettings struct {
	Keys            []*crypto.Key          `json:"keys,omitempty"`
	SettingsTTLDays int64                  `json:"settings_ttl_days"`
	HTTP            *HTTPServerSettings    `json:"http,omitempty"`
	JSONRPC         *JSONRPCServerSettings `json:"jsonrpc,omitempty"`
	REST            *RESTServerSettings    `json:"rest,omitempty"`
}

type StoreProviderDataParams

type StoreProviderDataParams struct {
	EncryptedData *crypto.ECDHEncryptedData `json:"encryptedData"`
	Code          []byte                    `json:"code"`
}

type StoreProviderDataSignedParams

type StoreProviderDataSignedParams struct {
	JSON      string                   `json:"data" coerce:"name:json"`
	Data      *StoreProviderDataParams `json:"-" coerce:"name:data"`
	Signature []byte                   `json:"signature"`
	PublicKey []byte                   `json:"publicKey"`
}

type StoreSettingsParams

type StoreSettingsParams struct {
	ID   []byte      `json:"id"`
	Data interface{} `json:"data"`
}

type TLSSettings

type TLSSettings struct {
	CACertificateFile string `json:"ca_certificate_file"`
	CertificateFile   string `json:"certificate_file"`
	KeyFile           string `json:"key_file"`
}

type TimeWindow

type TimeWindow struct {
	From int64
	To   int64
	Type string
}

func Day

func Day(value int64) TimeWindow

func Hour

func Hour(value int64) TimeWindow

func MakeTimeWindow

func MakeTimeWindow(t int64, twType string) TimeWindow

func Minute

func Minute(value int64) TimeWindow

func Month

func Month(value int64) TimeWindow

func QuarterHour

func QuarterHour(value int64) TimeWindow

func Second

func Second(value int64) TimeWindow

func Week

func Week(value int64) TimeWindow

func (*TimeWindow) Copy

func (t *TimeWindow) Copy() TimeWindow

func (*TimeWindow) EqualTo added in v0.0.6

func (t *TimeWindow) EqualTo(tw *TimeWindow) bool

func (*TimeWindow) IncreaseBy

func (t *TimeWindow) IncreaseBy(n int64)

type TimeWindowFunc

type TimeWindowFunc func(int64) TimeWindow

type TokenData

type TokenData struct {
	PublicKey []byte `json:"publicKey"`
	Token     []byte `json:"token"`
	Hash      []byte `json:"hash"`
}

func (*TokenData) Sign

func (k *TokenData) Sign(key *crypto.Key) (*SignedTokenData, error)

type UploadDistancesParams

type UploadDistancesParams struct {
	Timestamp *time.Time `json:"timestamp"`
	Type      string     `json:"type"`
	Distances []Distance `json:"distances"`
}

type UploadDistancesSignedParams

type UploadDistancesSignedParams struct {
	JSON      string                 `json:"data" coerce:"name:json"`
	Data      *UploadDistancesParams `json:"-" coerce:"name:data"`
	Signature []byte                 `json:"signature"`
	PublicKey []byte                 `json:"publicKey"`
}

type Value

type Value interface {
	Object
	Set(value []byte, ttl time.Duration) error
	Get() ([]byte, error)
	Del() error
}

Jump to

Keyboard shortcuts

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