address

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = errors.New("record not found")
	ErrCannotUpdate = errors.New("cannot update record")
)

Error codes

View Source
var TimeNow = time.Now

Functions

func GenerateToken

func GenerateToken(addrHash hash.Hash, routingID string, validUntil time.Time, pk bmcrypto.PrivKey) string

func SetDefaultRepository

func SetDefaultRepository(r Repository)

Sets the default repository for resolving. Can be used to override for mocking/testing purposes

func VerifyInviteToken

func VerifyInviteToken(token string, addrHash hash.Hash, routingID string, key bmcrypto.PubKey) bool

Types

type KeyStatus added in v0.2.0

type KeyStatus int
const (
	KSNormal      KeyStatus = iota + 1 // Regular key, just rotated
	KSCompromised                      // Key was compromised
)

func StringToKeyStatus added in v0.2.0

func StringToKeyStatus(s string) (KeyStatus, error)

func (KeyStatus) ToString added in v0.2.0

func (k KeyStatus) ToString() string

type Repository

type Repository interface {
	// Retrieve from hash
	Get(hash string) (*ResolveInfoType, error)
	// Create a new entry
	Create(hash, routing string, publicKey *bmcrypto.PubKey, proof string, redirHash string) (bool, error)
	// Update an existing entry
	Update(info *ResolveInfoType, routing string, publicKey *bmcrypto.PubKey, redirHash string) (bool, error)
	// Softdelete an entry
	SoftDelete(hash string) (bool, error)
	// Undelete a softdeleted entry
	SoftUndelete(hash string) (bool, error)
	// Remove the entry completely (destructive)
	Delete(hash string) (bool, error)

	// Get the status of this (old) key
	GetKeyStatus(hash string, fingerprint string) (KeyStatus, error)
	// Set the given key status
	SetKeyStatus(hash string, fingerprint string, status KeyStatus) error
}

Repository to resolve records

func GetResolveRepository

func GetResolveRepository() Repository

GetResolveRepository returns a new repository based on DynamoDB

func NewBoltResolver

func NewBoltResolver() Repository

NewBoltResolver returns a new resolver based on BoltDB

func NewDynamoDBResolver

func NewDynamoDBResolver(client dynamodbiface.DynamoDBAPI, tableName, historyTableName string) Repository

NewDynamoDBResolver returns a new resolver based on DynamoDB

func NewSqliteResolver

func NewSqliteResolver(dsn string) Repository

NewDynamoDBResolver returns a new resolver based on DynamoDB

type ResolveInfoType

type ResolveInfoType struct {
	Hash      string
	RedirHash string
	RoutingID string
	PubKey    string
	Proof     string
	Serial    uint64
	Deleted   bool
	DeletedAt time.Time
}

ResolveInfoType returns information found in the resolver repository

type SqliteDbResolver

type SqliteDbResolver struct {
	TableName string
	TimeNow   time.Time
	// contains filtered or unexported fields
}

func (*SqliteDbResolver) Create

func (r *SqliteDbResolver) Create(hash, routing string, publicKey *bmcrypto.PubKey, proof, redirHash string) (bool, error)

func (*SqliteDbResolver) Delete

func (r *SqliteDbResolver) Delete(hash string) (bool, error)

func (*SqliteDbResolver) Get

func (r *SqliteDbResolver) Get(hash string) (*ResolveInfoType, error)

func (*SqliteDbResolver) GetKeyStatus added in v0.2.0

func (r *SqliteDbResolver) GetKeyStatus(hash string, fingerprint string) (KeyStatus, error)

func (*SqliteDbResolver) SetKeyStatus added in v0.2.0

func (r *SqliteDbResolver) SetKeyStatus(hash string, fingerprint string, status KeyStatus) error

func (*SqliteDbResolver) SoftDelete added in v0.2.0

func (r *SqliteDbResolver) SoftDelete(hash string) (bool, error)

func (*SqliteDbResolver) SoftUndelete added in v0.2.0

func (r *SqliteDbResolver) SoftUndelete(hash string) (bool, error)

func (*SqliteDbResolver) Update

func (r *SqliteDbResolver) Update(info *ResolveInfoType, routing string, publicKey *bmcrypto.PubKey, redirHash string) (bool, error)

Jump to

Keyboard shortcuts

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