app

package
v0.0.0-...-3dd0999 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(pw, salt, hash []byte) bool

CheckPassword - Check provided password against previously computed hash.

func WrapOut

func WrapOut(w io.Writer, s fmt.Stringer) io.Writer

WrapOut - instantiate an output wrapper

Types

type FakeFile

type FakeFile struct {
	bytes.Buffer
}

FakeFile - this is for testing, and it takes the place of an actual file.

func (*FakeFile) Close

func (ff *FakeFile) Close() error

Close - just present to complete the interface for io.ReadWriteCloser

type LogSet

type LogSet struct {
	Info     *log.Logger
	Error    *log.Logger // Error still just sends to Stdout
	TeeError *log.Logger // TeeError sends to both Stdout and Stderr
	Debug    *log.Logger
	Warn     *log.Logger
}

LogSet - the control structure for the log server.

func NewLogSet

func NewLogSet() *LogSet

NewLogSet - Allocate a new LogSet

func (*LogSet) Defaults

func (ls *LogSet) Defaults(out io.Writer)

Defaults - establish the standard defaults for this logset, which means establishing both stdout and stderr connections

type MemVolumeRecorder

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

MemVolumeRecorder - this structure is the controller for the set of active volumes In this case I'm doing it all in-memory, but for a production system this would actually talk to a database of some kind.

func (*MemVolumeRecorder) AddFile

func (vr *MemVolumeRecorder) AddFile(vf *VFile, volume *Volume) error

AddFile - add the file to the record of files.

func (*MemVolumeRecorder) AddVolume

func (vr *MemVolumeRecorder) AddVolume(v *Volume) error

AddVolume -

func (*MemVolumeRecorder) DeleteFile

func (vr *MemVolumeRecorder) DeleteFile(id, volumeID string) error

DeleteFile - Remove any record of the file.

func (*MemVolumeRecorder) GetFile

func (vr *MemVolumeRecorder) GetFile(id string, vol *Volume) (*VFile, error)

GetFile - return a file path.

func (*MemVolumeRecorder) GetVolume

func (vr *MemVolumeRecorder) GetVolume(name, password, id string) (*Volume, error)

GetVolume - Find a volume based on a given name. This is needed by the engine so it can specify where the file goes. If the ID is provided, then the password check is overridden.

type MyFilestoreServer

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

MyFilestoreServer - this is the actual implementation of the filestore server. It may make sense later to have different types of these, if we start working with vastly different file storage technologies.

func NewMyFilestoreServer

func NewMyFilestoreServer(logs *LogSet, config *viper.Viper, vm *VolumeManager) *MyFilestoreServer

NewMyFilestoreServer - allocate a new FilestoreServer object

func (*MyFilestoreServer) CreateVolume

func (mfs *MyFilestoreServer) CreateVolume(ctx context.Context, vd *pb.VolumeDef) (*pb.VolumeDef, error)

CreateVolume - open a volume for reading or writing.

func (*MyFilestoreServer) Delete

func (mfs *MyFilestoreServer) Delete(ctx context.Context, fb *pb.FileBlob) (*pb.FileBlob, error)

Delete - implement the DeleteFile command

func (*MyFilestoreServer) Get

Get - implement the GetFile command

func (*MyFilestoreServer) GetVolume

func (mfs *MyFilestoreServer) GetVolume(ctx context.Context, vd *pb.VolumeDef) (*pb.VolumeDef, error)

GetVolume - Return a pre-existing volume

func (*MyFilestoreServer) Put

func (mfs *MyFilestoreServer) Put(stream pb.FileStore_PutServer) error

Put - Transfer file to server This must be used whenever the file is more than 4mb, as that is the maximum default grpc message size.

func (*MyFilestoreServer) RunServer

func (mfs *MyFilestoreServer) RunServer() error

RunServer - this is the entrypoint of the GRPC file storage service

type Out

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

Out - Output wrapper

func (Out) String

func (o Out) String() string

func (*Out) Write

func (o *Out) Write(input []byte) (int, error)

type PostgresVolumeRecorder

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

PostgresVolumeRecorder - This is the volume recorder which uses Postgres as the persistant store

func (*PostgresVolumeRecorder) AddFile

func (pvr *PostgresVolumeRecorder) AddFile(vf *VFile, v *Volume) error

AddFile - Add a file record

func (*PostgresVolumeRecorder) AddVolume

func (pvr *PostgresVolumeRecorder) AddVolume(v *Volume) error

AddVolume - Add volume to records

func (*PostgresVolumeRecorder) DeleteFile

func (pvr *PostgresVolumeRecorder) DeleteFile(id, volume_id string) error

DeleteFile - Remove file from records

func (*PostgresVolumeRecorder) GetFile

func (pvr *PostgresVolumeRecorder) GetFile(id string, vol *Volume) (*VFile, error)

GetFile - Return file data, specifically the path

func (*PostgresVolumeRecorder) GetVolume

func (pvr *PostgresVolumeRecorder) GetVolume(name, password, id string) (*Volume, error)

GetVolume - return a volume from the records. The third argument "id" is there as an override. If this volume is being used as part of a 'put' or 'get' operation, then the password won't be provided, as it's not part of the token. The ID of the volume is however, and you can only get the volume ID if you open the volume with the password, so we have that level of security.

type TimeStruct

type TimeStruct struct{}

TimeStruct - so we can override the time format

func (TimeStruct) String

func (ts TimeStruct) String() string

type VFile

type VFile struct {
	ID       string
	Filename string // Original filename
	Path     string // Path includes filename
	Type     string // MIME file type
	Size     int    // Filesize
	// contains filtered or unexported fields
}

VFile - control structure for a volume-backed file

func (*VFile) Close

func (vf *VFile) Close() error

Close - close the file for writing. Also calls the volume recorder's AddFile()

func (*VFile) Read

func (vf *VFile) Read(buf []byte) (int, error)

func (*VFile) Write

func (vf *VFile) Write(buf []byte) (int, error)

type Volume

type Volume struct {
	ID       string    `db:"id"`
	Created  time.Time `db:"created"`
	Name     string    `db:"name"`
	Salt     []byte    `db:"salt"`
	PWHash   []byte    `db:"pwhash"`
	Path     string    `db:"path"`
	TestMode bool      `db:"testmode"`
	Tags     []string
	Attrs    map[string]string
	// contains filtered or unexported fields
}

Volume - represents a collection of file objects

func (*Volume) CheckPassword

func (v *Volume) CheckPassword(pw []byte) bool

CheckPassword - compare a user provided password with the one stored with the volume.

func (*Volume) Create

func (v *Volume) Create(fb *filestore.FileBlob, tags []string, attrs map[string]string) (*VFile, error)

Create - create a new file object within the volume

func (*Volume) DeleteFile

func (v *Volume) DeleteFile(id string) error

DeleteFile - remove a file both from disk and from the database.

func (*Volume) GetPath

func (v *Volume) GetPath() string

GetPath - return the path up to the filename for the volume.

func (*Volume) Open

func (v *Volume) Open(id string) (*VFile, error)

Open - return a VFile object, retrieved by the ID

func (*Volume) SignedToken

func (v *Volume) SignedToken(skey []byte) (string, error)

SignedToken - return a properly signed JWT token representing this OpenVolume session

type VolumeClaims

type VolumeClaims struct {
	jwt.StandardClaims
}

VolumeClaims - this is where we store private volume specific data in the token.

func GetTokenClaims

func GetTokenClaims(tokenstr string, skey []byte) (*VolumeClaims, error)

GetTokenClaims - parse the claims structure from thetoken

type VolumeManager

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

VolumeManager - this structure is the controller for the set of active volumes In this case I'm doing it all in-memory, but for a production system this would actually talk to a database of some kind.

func NewVolumeManager

func NewVolumeManager(vr VolumeRecorder, paths map[string]string) *VolumeManager

NewVolumeManager - allocate a new VolumeManager

func (*VolumeManager) AddFile

func (vm *VolumeManager) AddFile(vf *VFile, v *Volume) error

AddFile - Add a file record

func (*VolumeManager) CreateVolume

func (vm *VolumeManager) CreateVolume(name, password string, tags []string, attrs map[string]string) (*Volume, error)

CreateVolume - Create a new volume.

func (*VolumeManager) DeleteFile

func (vm *VolumeManager) DeleteFile(id, volume_id string) error

DeleteFile - Remove file from record

func (*VolumeManager) GetPath

func (vm *VolumeManager) GetPath(pathname string) (string, error)

GetPath - Return the path indicated as specified in the config file. Example config is as so: [vmgr]

 [vmgr.paths]
	  default = "/mnt/nasdrive/filestore"
   fast = "/mnt/nasdrive/filestore"

func (*VolumeManager) GetVolume

func (vm *VolumeManager) GetVolume(name, password, id string) (*Volume, error)

GetVolume - Find a volume based on a given name. This is needed by the engine so it can specify where the file goes

type VolumeRecorder

type VolumeRecorder interface {
	AddFile(vf *VFile, volume *Volume) error
	DeleteFile(id, volumeID string) error
	GetFile(id string, volume *Volume) (*VFile, error)
	AddVolume(v *Volume) error
	GetVolume(name, password, id string) (*Volume, error)
}

VolumeRecorder - interface for the data backing store.

func NewMemVolumeRecorder

func NewMemVolumeRecorder() VolumeRecorder

NewMemVolumeRecorder - allocate a new VolumeRecorder

func NewPostgresVolumeRecorder

func NewPostgresVolumeRecorder(cfg map[string]interface{}) (VolumeRecorder, error)

NewPostgresVolumeRecorder - Allocate a new PG recorder

func NewRedisVolumeRecorder

func NewRedisVolumeRecorder(host string, db int) (VolumeRecorder, error)

NewRedisVolumeRecorder - Allocate a new redis backend handler

Jump to

Keyboard shortcuts

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