resolver

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigNotFound = errors.New("configuration not found")

ErrConfigNotFound is returned when no resolver configuration could be found

View Source
var ErrKeyNotFound = errors.New("record not found")

ErrKeyNotFound is returened when a key is not found

Functions

This section is empty.

Types

type AddressDownload

type AddressDownload struct {
	Hash      string          `json:"hash"`
	PublicKey bmcrypto.PubKey `json:"public_key"`
	RoutingID string          `json:"routing_id"`
	Serial    uint64          `json:"serial_number"`
}

AddressDownload is a JSON structure we download from a resolver server

type AddressInfo

type AddressInfo struct {
	Hash        string          `json:"hash"`       // Hash of the email address
	PublicKey   bmcrypto.PubKey `json:"public_key"` // PublicKey of the user
	RoutingID   string          `json:"routing"`    // Routing ID
	Pow         string          `json:"pow"`        // Proof of work
	RoutingInfo RoutingInfo     `json:"_"`          // Don't store
}

AddressInfo is a structure returned by the external resolver system

type AddressRepository

type AddressRepository interface {
	ResolveAddress(hash hash.Hash) (*AddressInfo, error)
	UploadAddress(addr address.Address, info *AddressInfo, privKey bmcrypto.PrivKey, pow proofofwork.ProofOfWork, orgToken string) error
	DeleteAddress(info *AddressInfo, privKey bmcrypto.PrivKey) error
}

AddressRepository is the interface to manage address resolving

type ChainRepository

type ChainRepository struct {
	// contains filtered or unexported fields
}

ChainRepository holds a list of multiple repositories which can all be tried to resolve addresses and keys

func NewChainRepository

func NewChainRepository() *ChainRepository

NewChainRepository Return a new chain repository

func (*ChainRepository) Add

func (r *ChainRepository) Add(repo Repository) error

Add a new repository to the chain

func (*ChainRepository) DeleteAddress

func (r *ChainRepository) DeleteAddress(info *AddressInfo, privKey bmcrypto.PrivKey) error

DeleteAddress from repos

func (*ChainRepository) DeleteOrganisation

func (r *ChainRepository) DeleteOrganisation(info *OrganisationInfo, privKey bmcrypto.PrivKey) error

DeleteOrganisation from repos

func (*ChainRepository) DeleteRouting

func (r *ChainRepository) DeleteRouting(info *RoutingInfo, privKey bmcrypto.PrivKey) error

DeleteRouting from repos

func (*ChainRepository) GetConfig

func (r *ChainRepository) GetConfig() (*ProofOfWorkConfig, error)

GetConfig will return the resolver configuration from the repos

func (*ChainRepository) ResolveAddress

func (r *ChainRepository) ResolveAddress(addr hash.Hash) (*AddressInfo, error)

ResolveAddress an address through the chained repos

func (*ChainRepository) ResolveOrganisation

func (r *ChainRepository) ResolveOrganisation(hash hash.Hash) (*OrganisationInfo, error)

ResolveOrganisation resolves organisation

func (*ChainRepository) ResolveRouting

func (r *ChainRepository) ResolveRouting(routingID string) (*RoutingInfo, error)

ResolveRouting resolves routing

func (*ChainRepository) UploadAddress

func (r *ChainRepository) UploadAddress(addr address.Address, info *AddressInfo, privKey bmcrypto.PrivKey, pow proofofwork.ProofOfWork, orgToken string) error

UploadAddress public key through the chained repos

func (*ChainRepository) UploadOrganisation

func (r *ChainRepository) UploadOrganisation(info *OrganisationInfo, privKey bmcrypto.PrivKey, pow proofofwork.ProofOfWork) error

UploadOrganisation uploads organisation information

func (*ChainRepository) UploadRouting

func (r *ChainRepository) UploadRouting(info *RoutingInfo, privKey bmcrypto.PrivKey) error

UploadRouting uploads routing information

type ConfigRepository

type ConfigRepository interface {
	GetConfig() (*ProofOfWorkConfig, error)
}

ConfigRepository is the interface to fetch resolver configurations

type OrganisationDownload

type OrganisationDownload struct {
	Hash        string                        `json:"hash"`
	PublicKey   bmcrypto.PubKey               `json:"public_key"`
	Validations []organisation.ValidationType `json:"validations"`
	Serial      uint64                        `json:"serial_number"`
}

OrganisationDownload is a JSON structure we download from a resolver server

type OrganisationInfo

type OrganisationInfo struct {
	Hash        string                        `json:"hash"`        // Hash of the organisation
	PublicKey   bmcrypto.PubKey               `json:"public_key"`  // PublicKey of the organisation
	Pow         string                        `json:"pow"`         // Proof of work
	Validations []organisation.ValidationType `json:"validations"` // Validations for this organisation
}

OrganisationInfo is a structure returned by the external resolver system

type OrganisationRepository

type OrganisationRepository interface {
	ResolveOrganisation(hash hash.Hash) (*OrganisationInfo, error)
	UploadOrganisation(info *OrganisationInfo, privKey bmcrypto.PrivKey, pow proofofwork.ProofOfWork) error
	DeleteOrganisation(info *OrganisationInfo, privKey bmcrypto.PrivKey) error
}

OrganisationRepository is the interface to manage organisation resolving

type ProofOfWorkConfig

type ProofOfWorkConfig struct {
	ProofOfWork struct {
		Address      int `json:"address"`
		Organisation int `json:"organisation"`
	} `json:"proof_of_work"`
}

ProofOfWorkConfig is a struct that holds the resolver configuration as fetched from a resolver

type Repository

Repository is a complete key resolver repository with the different parts

func NewMockRepository

func NewMockRepository() (Repository, error)

NewMockRepository creates a simple mock repository for testing purposes

func NewRemoteRepository

func NewRemoteRepository(baseURL string, debug, allowInsecure bool) Repository

NewRemoteRepository creates new remote resolve repository

func NewSqliteRepository

func NewSqliteRepository(dsn string) (Repository, error)

NewSqliteRepository creates new local repository where keys are stored in an SQLite database

type RoutingDownload

type RoutingDownload struct {
	Hash      string          `json:"hash"`
	PublicKey bmcrypto.PubKey `json:"public_key"`
	Routing   string          `json:"routing"`
	Serial    uint64          `json:"serial_number"`
}

RoutingDownload is a JSON structure we download from a resolver server

type RoutingInfo

type RoutingInfo struct {
	Hash      string          `json:"hash"`       // Hash / routingID
	PublicKey bmcrypto.PubKey `json:"public_key"` // PublicKey of the user
	Routing   string          `json:"routing"`    // Server where this email address resides
}

RoutingInfo is a structure returned by the external resolver system

type RoutingRepository

type RoutingRepository interface {
	ResolveRouting(routingID string) (*RoutingInfo, error)
	UploadRouting(info *RoutingInfo, privKey bmcrypto.PrivKey) error
	DeleteRouting(info *RoutingInfo, privKey bmcrypto.PrivKey) error
}

RoutingRepository is the interface to manage route resolving

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service represents a resolver service tied to a specific repository

func KeyRetrievalService

func KeyRetrievalService(repo Repository) *Service

KeyRetrievalService initialises a key retrieval service.

func (*Service) ClearRoutingCacheEntry

func (s *Service) ClearRoutingCacheEntry(routingID string)

ClearRoutingCacheEntry will disable using the routing cache.

func (*Service) GetConfig

func (s *Service) GetConfig() ProofOfWorkConfig

GetConfig returns the configuration from the given repo, or a default configuration on error

func (*Service) ResolveAddress

func (s *Service) ResolveAddress(addr hash.Hash) (*AddressInfo, error)

ResolveAddress resolves an address.

func (*Service) ResolveOrganisation

func (s *Service) ResolveOrganisation(orgHash hash.Hash) (*OrganisationInfo, error)

ResolveOrganisation resolves a route.

func (*Service) ResolveRouting

func (s *Service) ResolveRouting(routingID string) (*RoutingInfo, error)

ResolveRouting resolves a route.

func (*Service) UploadAddressInfo

func (s *Service) UploadAddressInfo(info vault.AccountInfo, orgToken string) error

UploadAddressInfo uploads resolve information to one (or more) resolvers

func (*Service) UploadOrganisationInfo

func (s *Service) UploadOrganisationInfo(info vault.OrganisationInfo) error

UploadOrganisationInfo uploads resolve information to one (or more) resolvers

func (*Service) UploadRoutingInfo

func (s *Service) UploadRoutingInfo(info RoutingInfo, privKey *bmcrypto.PrivKey) error

UploadRoutingInfo uploads resolve information to one (or more) resolvers

Jump to

Keyboard shortcuts

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