server

package
v0.5.1 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: 26 Imported by: 0

Documentation

Index

Constants

View Source
const IdleTimeout = 20

Timeout (in seconds) for detecting idle connections (which are not closed but are hanging)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddKeyRequest added in v0.5.0

type AddKeyRequest struct {
	Passphrase string `json:"passphrase" form:"passphrase"`
	GPGKeyId   string `json:"gpg" form:"gpg"`
}

func (*AddKeyRequest) FromBody added in v0.5.0

func (p *AddKeyRequest) FromBody(c *gin.Context) (ok bool)

FromBody adds data to the object from a request

type ErrorResponse added in v0.5.0

type ErrorResponse struct {
	Error string `json:"error"`
}

type InfoResponse added in v0.5.1

type InfoResponse struct {
	Name       string `json:"name"`
	AppVersion string `json:"version,omitempty"`
	BuildID    string `json:"buildId,omitempty"`
	BuildTime  string `json:"buildTime,omitempty"`
	CommitHash string `json:"commitHash,omitempty"`
	Runtime    string `json:"runtime,omitempty"`
	Info       string `json:"info,omitempty"`
	ReadOnly   bool   `json:"readOnly,omitempty"`
}

type MetadataResponse added in v0.5.0

type MetadataResponse struct {
	FileId   string     `json:"fileId"`
	Folder   string     `json:"folder"`
	Name     string     `json:"name"`
	Date     *time.Time `json:"date,omitempty"`
	MimeType string     `json:"mimeType,omitempty"`
	Size     int64      `json:"size,omitempty"`
}

type RepoInfoResponse added in v0.5.1

type RepoInfoResponse struct {
	Version   uint16 `json:"version"`
	FileCount int    `json:"files"`
}

type RepoKeyListItem added in v0.5.0

type RepoKeyListItem struct {
	KeyId string `json:"keyId"`
	Type  string `json:"type"`
	UID   string `json:"uid,omitempty"`
}

type RepoKeyListResponse added in v0.5.0

type RepoKeyListResponse struct {
	Keys []RepoKeyListItem `json:"keys"`
}

type Server

type Server struct {
	Store     fs.Fs
	Verbose   bool
	Repo      *repository.Repository
	Infofile  *infofile.InfoFile
	LogWriter io.Writer
	ReadOnly  bool
}

func (*Server) DeleteRepoKeyHandler added in v0.5.0

func (s *Server) DeleteRepoKeyHandler(c *gin.Context)

DeleteRepoKeyHandler is the handler for DELETE /api/repo/key/:keyId, which removes a key key

func (*Server) DeleteTreeHandler added in v0.3.0

func (s *Server) DeleteTreeHandler(c *gin.Context)

DeleteTreeHandler is the handler for DELETE /api/tree/:path, which removes an object The :path value must be an exact object, or must end with "/*" to remove a folder

func (*Server) FileHandler

func (s *Server) FileHandler(c *gin.Context)

FileHandler is the handler for GET /file/:fileId, which returns a (decrypted) file

func (*Server) GetInfoHandler added in v0.5.0

func (s *Server) GetInfoHandler(c *gin.Context)

GetInfoHandler is the handler for GET /api/info, which returns the info for the app

func (*Server) GetMetadataHandler added in v0.5.0

func (s *Server) GetMetadataHandler(c *gin.Context)

GetMetadataHandler is the handler for GET /api/metadata/:file, which returns the metadata for a file

func (*Server) GetRepoInfoHandler added in v0.5.1

func (s *Server) GetRepoInfoHandler(c *gin.Context)

GetInfoHandler is the handler for GET /api/repo/info, which returns info about the repository

func (*Server) GetRepoKeyHandler added in v0.5.0

func (s *Server) GetRepoKeyHandler(c *gin.Context)

GetRepoKeyHandler is the handler for GET /api/repo/key, which returns the list of keys allowed to unlock this repository

func (*Server) GetTreeHandler added in v0.3.0

func (s *Server) GetTreeHandler(c *gin.Context)

GetTreeHandler is the handler for GET /api/tree/:path, which returns the contents of a path

func (*Server) MiddlewareRequireInfoFileVersion added in v0.4.0

func (s *Server) MiddlewareRequireInfoFileVersion(version uint16) func(c *gin.Context)

MiddlewareRequireInfoFileVersion requires a minimum version of the info file to continue

func (*Server) MiddlewareRequireReadWrite added in v0.5.1

func (s *Server) MiddlewareRequireReadWrite(c *gin.Context)

MiddlewareRequireReadWrite disables a route that would edit the repository if we're operating in read-only mode

func (*Server) MiddlewareRequireRepo added in v0.5.0

func (s *Server) MiddlewareRequireRepo(c *gin.Context)

MiddlewareRequireRepo requires a repository to be selected (even if not unlocked)

func (*Server) MiddlewareRequireUnlock added in v0.5.0

func (s *Server) MiddlewareRequireUnlock(c *gin.Context)

MiddlewareRequireUnlock requires the repository to be unlocked before processing

func (*Server) PostRepoKeyHandler added in v0.5.0

func (s *Server) PostRepoKeyHandler(c *gin.Context)

PostRepoKeyHandler is the handler for POST /api/repo/key, which adds a new key

func (*Server) PostRepoSelectHandler added in v0.5.0

func (s *Server) PostRepoSelectHandler(c *gin.Context)

PostRepoSelectHandler is the handler for POST /api/repo/select, which selects a repository

func (*Server) PostRepoUnlockHandler added in v0.5.0

func (s *Server) PostRepoUnlockHandler(dryRun bool) func(c *gin.Context)

PostRepoUnlockHandler is the handler for POST /api/repo/unlock, which unlocks a repository The same handler is also used by POST /api/repo/keytest, which tests a key and returns its ID (essentially performing a "dry run" for the unlock operation)

func (*Server) PostTreeHandler added in v0.3.0

func (s *Server) PostTreeHandler(c *gin.Context)

PostTreeHandler is the handler for POST /api/tree/:path, which adds documents to the repository The path argument is the destination folder (just like the "-d" argument in the "prvt add" command) The post body can contain either one of: - One or more files transmitted in the request body, in the "file" field(s) - The path to a file or folder in the local filesystem, in the "localpath" field(s)

func (*Server) Start

func (s *Server) Start(ctx context.Context, address, port string) error

type TreeOperationResponse added in v0.5.0

type TreeOperationResponse struct {
	Path   string `json:"path"`
	Status string `json:"status"`
	FileId string `json:"fileId"`
	Error  string `json:"error,omitempty"`
}

type UnlockKeyRequest added in v0.5.0

type UnlockKeyRequest struct {
	Type       string `json:"type" form:"type"`
	Passphrase string `json:"passphrase" form:"passphrase"`
}

func (*UnlockKeyRequest) FromBody added in v0.5.0

func (p *UnlockKeyRequest) FromBody(c *gin.Context) (ok bool)

FromBody adds data to the object from a request

Jump to

Keyboard shortcuts

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