pool

package
v0.0.0-...-ee25e63 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ID_CREATE       = 0x0
	ID_FORCE_CREATE = 0x1
)
View Source
const SafeConfigFile = ".safepool-pool.json"

Variables

View Source
var Connections = map[string]transport.Exchanger{}
View Source
var ConnectionsMutex = &sync.Mutex{}
View Source
var ErrAlreadyExist = errors.New("pool already exists")
View Source
var ErrInvalidConfig = errors.New("provided config is invalid: missing name or configs")
View Source
var ErrInvalidSignature = errors.New("signature is invalid")
View Source
var ErrInvalidToken = errors.New("provided token is invalid: missing name or configs")
View Source
var ErrNoExchange = errors.New("no Exchange available")
View Source
var ErrNotAuthorized = errors.New("no authorization for this file")
View Source
var ErrNotTrusted = errors.New("the author is not a trusted user")
View Source
var ForceCreation = false
View Source
var ReplicaPeriod = time.Hour

Functions

func Define

func Define(c Config) error

func EncodeToken

func EncodeToken(t Token, guest *security.Identity) (string, error)

func List

func List() []string

func Load

func Load(name string) ([]transport.Config, error)

func Save

func Save(name string, configs []transport.Config) error

Types

type AccessFile

type AccessFile struct {
	Version     float32
	Grants      []Grant
	Nonce       []byte
	MasterKeyId uint64
	Keystore    []byte
}

type Config

type Config struct {
	Name    string
	Configs []transport.Config
}

func GetConfig

func GetConfig(name string) (Config, error)

type Consumer

type Consumer interface {
	TimeOffset(s *Pool) time.Time
	Accept(s *Pool, h Head) bool
}

type Grant

type Grant struct {
	Identity    security.Identity
	Since       uint64
	KeystoreKey []byte
}
type Head struct {
	Id        uint64
	Name      string
	Size      int64
	Hash      []byte
	ModTime   time.Time
	Author    security.Identity
	Signature []byte
	TimeStamp time.Time `json:"-"`
	Meta      []byte
}
type Header struct {
	Version float32 `json:"v"`
	Thread  uint64  `json:"t"`
	Key     uint64  `json:"k"`
	Hash    []byte  `json:"h"`
	Name    string  `json:"s"`
}

type Identity

type Identity struct {
	security.Identity
	//Since is the keyId used when the identity was added to the Pool access
	Since uint64
	//AddedOn is the timestamp when the identity is stored on the local DB
	AddedOn time.Time
}

type Keystore

type Keystore map[uint64][]byte

type Pool

type Pool struct {
	Name      string
	Self      security.Identity
	Consumers []Consumer
	// contains filtered or unexported fields
}

func Create

func Create(self security.Identity, name string) (*Pool, error)

func Open

func Open(self security.Identity, name string) (*Pool, error)

Init initialized a domain on the specified exchangers

func (*Pool) Close

func (p *Pool) Close()

func (*Pool) Delete

func (p *Pool) Delete() error

func (*Pool) ExportAccessFile

func (p *Pool) ExportAccessFile(e transport.Exchanger) error

func (*Pool) Get

func (p *Pool) Get(id uint64, rang *transport.Range, w io.Writer) error

func (*Pool) Identities

func (p *Pool) Identities() ([]Identity, error)

func (*Pool) ImportAccess

func (p *Pool) ImportAccess(e transport.Exchanger) (hash.Hash, error)

func (*Pool) List

func (p *Pool) List(afterId uint64, afterTs time.Time) []Head

func (*Pool) Post

func (p *Pool) Post(name string, r io.Reader, meta []byte) (Head, error)

func (*Pool) Sync

func (p *Pool) Sync()

type Token

type Token struct {
	Config Config
	Host   security.Identity
}

func DecodeToken

func DecodeToken(guest *security.Identity, token string) (Token, error)

Jump to

Keyboard shortcuts

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