repo

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2018 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LockPathSuffix = ".locked"
	LockDirSuffix  = ".tgz" + LockPathSuffix
)
View Source
const (
	PermNone = 0
	PermRead = 1 << iota
	PermWrite
)

Variables

View Source
var Defaults = []struct {
	Name  string
	Value interface{}
}{
	{"daemon.port", 6666},
	{"sync.ignore_removed", false},
	{"sync.conflict_strategy", "marker"},
	{"data.ipfs.path", ""},
	{"data.compress.algo", "snappy"},
}
View Source
var (
	ErrBadPassword = errors.New("Failed to open repository. Probably wrong password")
)
View Source
var (
	ErrNoSuchRemote = errors.New("No such remote with this name")
)

Functions

func CheckPassword

func CheckPassword(baseFolder, password string) error

func Init

func Init(baseFolder, owner, password, backendName string) error

func LockRepo

func LockRepo(root, user, password string, lockExcludes, unlockExcludes []string) error

func UnlockRepo

func UnlockRepo(root, user, password string, lockExcludes, unlockExcludes []string) error

Types

type Backend

type Backend interface {
	// ForwardLog writes all logs of the backend to `w`.
	// The log level is chosen by the backend itself.
	ForwardLog(w io.Writer)

	GC() ([]h.Hash, error)
}

Backend defines the method needed from the underlying storage backend to create & manage a repository.

type Folder

type Folder struct {
	Folder string
	Perms  RemotePerms
}

type Keyring

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

Keyring manages our own keypair and stores the last known pubkeys of other remotes.

func (*Keyring) Decrypt

func (kp *Keyring) Decrypt(data []byte) ([]byte, error)

Decrypt decrypts a message encrypted with our public key. This is not an efficient method and is not supposed to be used for large amounts of data.

func (*Keyring) Encrypt

func (kp *Keyring) Encrypt(data, pubKey []byte) ([]byte, error)

Encrypt `data` with `pubKey`. If it's desired to encrypt a message with our own pubkey, then use the PubKeyBytes() method to load one. This is not an efficient method and is not supposed to be used for large amounts of data.

func (*Keyring) OwnPubKey

func (kp *Keyring) OwnPubKey() ([]byte, error)

OwnPubKey returns an exported version of our own public key.

func (*Keyring) PubKeyFor

func (kp *Keyring) PubKeyFor(name string) ([]byte, error)

PubKeyFor returns the stored public key for a partner named `name`

func (*Keyring) SavePubKey

func (kp *Keyring) SavePubKey(name string, pubKey []byte) error

SavePubKey stores a public key from a partner with the name `name`

type Perms

type Perms uint32

type Remote

type Remote struct {
	Name        string
	Folders     []Folder
	Fingerprint peer.Fingerprint
}

type RemoteList

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

RemoteList is a helper that parses the remote access yml file and makes it easily accessible from the Go side.

func NewRemotes

func NewRemotes(path string) (*RemoteList, error)

func (*RemoteList) AddRemote

func (rl *RemoteList) AddRemote(remote Remote) error

func (*RemoteList) Clear

func (rl *RemoteList) Clear() error

func (*RemoteList) Export

func (rl *RemoteList) Export(w io.Writer) error

func (*RemoteList) ListRemotes

func (rl *RemoteList) ListRemotes() ([]Remote, error)

func (*RemoteList) Remote

func (rl *RemoteList) Remote(name string) (Remote, error)

func (*RemoteList) RmRemote

func (rl *RemoteList) RmRemote(name string) error

func (*RemoteList) SaveList

func (rl *RemoteList) SaveList(remotes []Remote) error

type RemotePerms

type RemotePerms int

func (RemotePerms) FromStrings

func (rp RemotePerms) FromStrings(perms []string) RemotePerms

func (RemotePerms) String

func (rp RemotePerms) String() string

func (RemotePerms) ToStrings

func (rp RemotePerms) ToStrings() []string

type Repository

type Repository struct {

	// Absolute path to the repository root
	BaseFolder string

	// Name of the owner of this repository
	Owner string

	// Config interface
	Config *viper.Viper

	// Remotes gives access to all known remotes
	Remotes *RemoteList
	// contains filtered or unexported fields
}

Repository provides access to the file structure of a single repository.

Informal: This file structure currently looks like this: config.yml meta.yml remotes.yml data/

<backend_name>
    (data-backend specific)

metadata/

<name_1>
    (fs-backend specific)
<name_2>
    (fs-backend specific)

func Open

func Open(baseFolder, password string) (*Repository, error)

func (*Repository) BackendName

func (rp *Repository) BackendName() string

func (*Repository) BackendPath

func (rp *Repository) BackendPath(name string) string

func (*Repository) Close

func (rp *Repository) Close(password string) error

func (*Repository) CurrentUser

func (rp *Repository) CurrentUser() string

func (*Repository) FS

func (rp *Repository) FS(owner string, bk catfs.FsBackend) (*catfs.FS, error)

FS returns a filesystem for `owner`. If there is none yet, it will create own associated to the respective owner.

func (*Repository) GC

func (rp *Repository) GC(backend Backend, aggressive bool) (map[string]map[string]h.Hash, error)

func (*Repository) HaveFS

func (rp *Repository) HaveFS(owner string) bool

HaveFS will return true if we have data for a certain owner.

func (*Repository) Keyring

func (rp *Repository) Keyring() *Keyring

func (*Repository) SetCurrentUser

func (rp *Repository) SetCurrentUser(user string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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