services

package module
v0.0.0-...-f144353 Latest Latest
Warning

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

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

README

Zilp-Zalp Services

This repository contains Zilp-Zalp's backend services:

  • A storage service that stores encrypted user & operator settings and temporary data.
  • A tracing service that stores encrypted contact data, publishes hashes and stores returned contact traces.
  • An operator service that stores encrypted contact traces and answers hash requests.

Installation

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

make

To run the development server(s) you also need TLS certificates. You can generate these using

make certs

Running

To run the development services is easy:

source .dev-setup
# run the tracing server
zilpzalp run tracing
# ...or run the operator server
zilpzalp run operator
# ...or run the storage server
zilpzalp run storage

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

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

This section is empty.

Types

type BaseDatabase

type BaseDatabase struct {
}

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, db Database) ([]cli.Command, error)

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
	Get(table string, key []byte) ([][]byte, error)
	Set(table string, key, value []byte, ttl time.Duration) error
	Append(table string, key, value []byte, ttl time.Duration) error
	DeleteAll(table string, key []byte) error
	DeleteByValue(table string, key, value []byte) error
	DeleteBySha256(table string, key, hash []byte) error
}

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 DatabaseSettings

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

type Definitions

type Definitions struct {
	CommandsDefinitions
	DatabaseDefinitions
}

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 HTTPServerSettings

type HTTPServerSettings struct {
	TLS         *TLSSettings `json:"tls"`
	BindAddress string       `json:"bind_address"`
}

Settings for the JSON-RPC server

type JSONRPCClientSettings

type JSONRPCClientSettings struct {
	TLS      *TLSSettings `json:"tls"`
	Endpoint string       `json:"endpoint"`
	Local    bool         `json:"local"`
}

Settings for the JSON-RPC server

type JSONRPCServerSettings

type JSONRPCServerSettings struct {
	Cors        *CorsSettings `json:"cors"`
	TLS         *TLSSettings  `json:"tls"`
	BindAddress string        `json:"bind_address"`
}

Settings for the JSON-RPC server

type Level

type Level log.Level

func ParseLevel

func ParseLevel(level string) (Level, 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) Warning

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

func (*Logger) Warningf

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

type OperatorSettings

type OperatorSettings struct {
	TracesTTLDays int64                  `json:"traces_ttl_days`
	RPC           *JSONRPCServerSettings `json:"rpc"`
}

type RPCSettings

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

type Settings

type Settings struct {
	Definitions *Definitions      `json:"definitions"`
	Storage     *StorageSettings  `json:"storage"`
	Operator    *OperatorSettings `json:"operator"`
	Tracing     *TracingSettings  `json:"tracing"`
	Database    *DatabaseSettings `json:"database"`
}

type SettingsValidator

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

type StorageSettings

type StorageSettings struct {
	SettingsTTLDays     int64                  `json:"settings_ttl_days"`
	TransferDataTTLDays int64                  `json:"transfer_data_ttl_days"`
	RPC                 *JSONRPCServerSettings `json:"rpc"`
}

type TLSSettings

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

type TracingSettings

type TracingSettings struct {
	AllHashesTTLDays   int64                  `json:"all_hashes_ttl_days"`
	OpenHashesTTLDays  int64                  `json:"open_hashes_ttl_days`
	ContactDataTTLDays int64                  `json:"contact_data_ttl_days`
	TracesTTLDays      int64                  `json:"traces_ttl_days`
	RPC                *JSONRPCServerSettings `json:"rpc"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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