Documentation ¶
Index ¶
- Constants
- Variables
- func NewOwnerTypes(r *http.Request) (owners map[OwnerType]net.IP, err error)
- func ParseBytesize(s string) (size int64, err error)
- func ParseDuration(s string) (d time.Duration, err error)
- func PrettyBytesize(bs int64) string
- func PrettyDuration(d time.Duration) string
- func WebProtocol(r *http.Request) string
- type HardeningOpts
- type Item
- type MimeMap
- type OwnerType
- type Server
- type Store
- func (s *Store) BadgerHold() *badgerhold.Store
- func (s *Store) Close() error
- func (s *Store) Delete(i Item) (err error)
- func (s *Store) DeleteExpired() error
- func (s *Store) Get(id string, delExpired bool) (i Item, err error)
- func (s *Store) GetFile(i Item) (io.ReadCloser, error)
- func (s *Store) Put(i Item, file io.ReadCloser) (id string, err error)
Constants ¶
const ( DirDatabase = "db" DirStorage = "data" )
const MimeDrop = "DROP"
Variables ¶
var ( ErrLifetimeTooLong = errors.New("Lifetime is greater than maximum lifetime") ErrFileTooBig = errors.New("File size is greater than maxium filesize") )
var ErrMimeDrop = errors.New("MIME must be dropped")
var (
ErrNoMatch = errors.New("Input does not match pattern")
)
var ErrNotFound = errors.New("No Item found for this ID")
ErrNotFound is returned by the `Store.Get` method if there is no Item for the requested ID.
Functions ¶
func NewOwnerTypes ¶
NewOwnerTypes creates a map of OwnerTypes to IP addresses based on a Request.
func ParseBytesize ¶
ParseBytesize parses a positive, human readable and whole byte amount in the binary prefix notation. Legit values might be "1B", "23KiB"/"23KB" etc.
func ParseDuration ¶
ParseDuration parses a (positive) duration string, similar to the `time.ParseDuration` method. A duration string is sequence of decimal numbers and a unit suffix. Valid time units are "s", "m", "h", "d", "w", "mo", "y".
func PrettyBytesize ¶
PrettyBytesize returns a human readable representation of a byte size.
func PrettyDuration ¶
PrettyDuration returns a human readable representation of a time.Duration.
func WebProtocol ¶
WebProtocol returns "http" or "https", based either on the X-Forwarded-Proto header or FastCGI's SERVER_PORT variable.
Types ¶
type HardeningOpts ¶ added in v0.6.0
type HardeningOpts struct { // StoreDir is the path to the store; MUST be set. StoreDir *string // ListenTcpAddr is a listen address for a TCP socket; MIGHT be set. ListenTcpAddr *string // ListenUnixAddr is the path for a Unix domain socket; MIGHT be set. ListenUnixAddr *string // MimeMapFile is the path to an existing MimeMap file; MIGHT be set. MimeMapFile *string // ChangeUser is a system user which identity should be used; MIGHT be set. ChangeUser *string // ListenSocket is a file descriptor to a socket if either ListenTcpAddr or // ListenUnixAddr is set. ListenSocket *os.File }
HardeningOpts are being altered by platform specific functions to allow establishing a state of least privilege.
The topper variables are treated as inputs and might get altered, e.g., after entering a chroot. The bottom variables are output variables, being populated by platform specific code.
Use the Apply method on a *HardeningOpts.
func (*HardeningOpts) Apply ¶ added in v0.6.0
func (opts *HardeningOpts) Apply()
Apply both Unix and Linux specific hardening.
type Item ¶
type Item struct { ID string `badgerhold:"key"` DeletionKey string BurnAfterReading bool Filename string ContentType string Created time.Time Expires time.Time `badgerholdIndex:"Expires"` Owner map[OwnerType]net.IP }
Item describes an uploaded file.
func NewItem ¶
func NewItem(r *http.Request, maxSize int64, maxLifetime time.Duration) (item Item, file io.ReadCloser, err error)
NewItem creates a new Item based on a Request. The ID will be left empty. Furthermore, if no error has occurred, a file is returned from which the file content should be read. This file must be closed afterwards.
func (Item) DeleteFile ¶
DeleteFile removes the file of an Item from the given directory.
type MimeMap ¶
MimeMap replaces predefined MIME types with others or requires them to be dropped.
# An example MimeMap could look like this, comment included: text/html text/plain text/javascript text/plain text/mp4 DROP
func NewMimeMap ¶
NewMimeMap creates a new MimeMap based on the Reader's data.
type OwnerType ¶
type OwnerType string
OwnerType describes a possible type of an owner, as an IP address. This can be the remote address as well as some header field.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements an http.Handler for up- and download.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store stores an index of all Items as well as the pure files.
func NewStore ¶
NewStore opens or initializes a Store in the given directory. A background task for continuous cleaning can be activated.
func (*Store) BadgerHold ¶
func (s *Store) BadgerHold() *badgerhold.Store
BadgerHold returns a reference to the underlying BadgerHold instance.
func (*Store) DeleteExpired ¶
DeleteExpired checks the Store for expired Items and deletes them.