Documentation ¶
Index ¶
- Constants
- func CloseCheck(f func() error)
- func LoveHandler(h http.Handler) http.HandlerFunc
- func WrapIPFilter(next http.Handler, opts IPFilterOptions) http.Handler
- type GDrive
- func (s *GDrive) Delete(ctx context.Context, token string, filename string) (err error)
- func (s *GDrive) Get(ctx context.Context, token string, filename string) (reader io.ReadCloser, contentLength uint64, err error)
- func (s *GDrive) Head(ctx context.Context, token string, filename string) (contentLength uint64, err error)
- func (s *GDrive) IsNotExist(err error) bool
- func (s *GDrive) Purge(ctx context.Context, days time.Duration) (err error)
- func (s *GDrive) Put(ctx context.Context, token string, filename string, reader io.Reader, ...) error
- func (s *GDrive) Type() string
- type IPFilterOptions
- type LocalStorage
- func (s *LocalStorage) Delete(ctx context.Context, token string, filename string) (err error)
- func (s *LocalStorage) Get(ctx context.Context, token string, filename string) (reader io.ReadCloser, contentLength uint64, err error)
- func (s *LocalStorage) Head(ctx context.Context, token string, filename string) (contentLength uint64, err error)
- func (s *LocalStorage) IsNotExist(err error) bool
- func (s *LocalStorage) Purge(ctx context.Context, days time.Duration) (err error)
- func (s *LocalStorage) Put(ctx context.Context, token string, filename string, reader io.Reader, ...) error
- func (s *LocalStorage) Type() string
- type OptionFn
- func ClamavHost(s string) OptionFn
- func CorsDomains(s string) OptionFn
- func EmailContact(emailContact string) OptionFn
- func EnableProfiler() OptionFn
- func FilterOptions(options IPFilterOptions) OptionFn
- func ForceHTTPS() OptionFn
- func GoogleAnalytics(gaKey string) OptionFn
- func HTTPAuthCredentials(user string, pass string) OptionFn
- func Listener(s string) OptionFn
- func LogFile(logger *log.Logger, s string) OptionFn
- func Logger(logger *log.Logger) OptionFn
- func MaxUploadSize(kbytes int64) OptionFn
- func PerformClamavPrescan(b bool) OptionFn
- func ProfileListener(s string) OptionFn
- func ProxyPath(s string) OptionFn
- func ProxyPort(s string) OptionFn
- func Purge(days, interval int) OptionFn
- func RandomTokenLength(length int) OptionFn
- func RateLimit(requests int) OptionFn
- func TLSConfig(cert, pk string) OptionFn
- func TLSListener(s string, t bool) OptionFn
- func TempPath(s string) OptionFn
- func UseLetsEncrypt(hosts []string) OptionFn
- func UseStorage(s Storage) OptionFn
- func UserVoice(userVoiceKey string) OptionFn
- func VirustotalKey(s string) OptionFn
- func WebPath(s string) OptionFn
- type S3Storage
- func (s *S3Storage) Delete(ctx context.Context, token string, filename string) (err error)
- func (s *S3Storage) Get(ctx context.Context, token string, filename string) (reader io.ReadCloser, contentLength uint64, err error)
- func (s *S3Storage) Head(ctx context.Context, token string, filename string) (contentLength uint64, err error)
- func (s *S3Storage) IsNotExist(err error) bool
- func (s *S3Storage) Purge(ctx context.Context, days time.Duration) (err error)
- func (s *S3Storage) Put(ctx context.Context, token string, filename string, reader io.Reader, ...) (err error)
- func (s *S3Storage) Type() string
- type Server
- type Storage
- type StorjStorage
- func (s *StorjStorage) Delete(ctx context.Context, token string, filename string) (err error)
- func (s *StorjStorage) Get(ctx context.Context, token string, filename string) (reader io.ReadCloser, contentLength uint64, err error)
- func (s *StorjStorage) Head(ctx context.Context, token string, filename string) (contentLength uint64, err error)
- func (s *StorjStorage) IsNotExist(err error) bool
- func (s *StorjStorage) Purge(ctx context.Context, days time.Duration) (err error)
- func (s *StorjStorage) Put(ctx context.Context, token string, filename string, reader io.Reader, ...) (err error)
- func (s *StorjStorage) Type() string
Constants ¶
const (
// SYMBOLS characters used for short-urls
SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
Variables ¶
This section is empty.
Functions ¶
func CloseCheck ¶
func CloseCheck(f func() error)
func LoveHandler ¶
func LoveHandler(h http.Handler) http.HandlerFunc
LoveHandler Create a log handler for every request it receives.
func WrapIPFilter ¶
func WrapIPFilter(next http.Handler, opts IPFilterOptions) http.Handler
WrapIPFilter is equivalent to newIPFilter(opts) then Wrap(next)
Types ¶
type GDrive ¶
type GDrive struct {
// contains filtered or unexported fields
}
GDrive is a storage backed by GDrive
func NewGDriveStorage ¶
func NewGDriveStorage(clientJSONFilepath string, localConfigPath string, basedir string, chunkSize int, logger *log.Logger) (*GDrive, error)
NewGDriveStorage is the factory for GDrive
func (*GDrive) Get ¶
func (s *GDrive) Get(ctx context.Context, token string, filename string) (reader io.ReadCloser, contentLength uint64, err error)
Get retrieves a file from storage
func (*GDrive) Head ¶
func (s *GDrive) Head(ctx context.Context, token string, filename string) (contentLength uint64, err error)
Head retrieves content length of a file from storage
func (*GDrive) IsNotExist ¶
IsNotExist indicates if a file doesn't exist on storage
type IPFilterOptions ¶
type IPFilterOptions struct { //explicity allowed IPs AllowedIPs []string //explicity blocked IPs BlockedIPs []string //block by default (defaults to allow) BlockByDefault bool // TrustProxy enable check request IP from proxy TrustProxy bool Logger interface { Printf(format string, v ...interface{}) } }
IPFilterOptions for ipFilter. Allowed takes precedence over Blocked. IPs can be IPv4 or IPv6 and can optionally contain subnet masks (/24). Note however, determining if a given IP is included in a subnet requires a linear scan so is less performant than looking up single IPs.
This could be improved with some algorithmic magic.
type LocalStorage ¶
type LocalStorage struct { Storage // contains filtered or unexported fields }
LocalStorage is a local storage
func NewLocalStorage ¶
func NewLocalStorage(basedir string, logger *log.Logger) (*LocalStorage, error)
NewLocalStorage is the factory for LocalStorage
func (*LocalStorage) Get ¶
func (s *LocalStorage) Get(ctx context.Context, token string, filename string) (reader io.ReadCloser, contentLength uint64, err error)
Get retrieves a file from storage
func (*LocalStorage) Head ¶
func (s *LocalStorage) Head(ctx context.Context, token string, filename string) (contentLength uint64, err error)
Head retrieves content length of a file from storage
func (*LocalStorage) IsNotExist ¶
func (s *LocalStorage) IsNotExist(err error) bool
IsNotExist indicates if a file doesn't exist on storage
type OptionFn ¶
type OptionFn func(*Server)
OptionFn is the option function type
func FilterOptions ¶
func FilterOptions(options IPFilterOptions) OptionFn
FilterOptions sets ip filtering
func HTTPAuthCredentials ¶
HTTPAuthCredentials sets basic http auth credentials
func PerformClamavPrescan ¶
PerformClamavPrescan enables clamav prescan on upload
func ProfileListener ¶
ProfileListener sets profile listener
func RandomTokenLength ¶
RandomTokenLength sets random token length
func TLSListener ¶
TLSListener sets TLS listener and option
func UseLetsEncrypt ¶
UseLetsEncrypt set letsencrypt usage
type S3Storage ¶
type S3Storage struct { Storage // contains filtered or unexported fields }
S3Storage is a storage backed by AWS S3
func NewS3Storage ¶
func NewS3Storage(accessKey, secretKey, bucketName string, purgeDays int, region, endpoint string, disableMultipart bool, forcePathStyle bool, logger *log.Logger) (*S3Storage, error)
NewS3Storage is the factory for S3Storage
func (*S3Storage) Get ¶
func (s *S3Storage) Get(ctx context.Context, token string, filename string) (reader io.ReadCloser, contentLength uint64, err error)
Get retrieves a file from storage
func (*S3Storage) Head ¶
func (s *S3Storage) Head(ctx context.Context, token string, filename string) (contentLength uint64, err error)
Head retrieves content length of a file from storage
func (*S3Storage) IsNotExist ¶
IsNotExist indicates if a file doesn't exist on storage
type Server ¶
type Server struct { AuthUser string AuthPass string VirusTotalKey string ClamAVDaemonHost string TLSListenerOnly bool CorsDomains string ListenerString string TLSListenerString string ProfileListenerString string Certificate string LetsEncryptCache string // contains filtered or unexported fields }
Server is the main application
func (*Server) RedirectHandler ¶
func (s *Server) RedirectHandler(h http.Handler) http.HandlerFunc
RedirectHandler handles redirect
type Storage ¶
type Storage interface { // Get retrieves a file from storage Get(ctx context.Context, token string, filename string) (reader io.ReadCloser, contentLength uint64, err error) // Head retrieves content length of a file from storage Head(ctx context.Context, token string, filename string) (contentLength uint64, err error) // Put saves a file on storage Put(ctx context.Context, token string, filename string, reader io.Reader, contentType string, contentLength uint64) error // Delete removes a file from storage Delete(ctx context.Context, token string, filename string) error // IsNotExist indicates if a file doesn't exist on storage IsNotExist(err error) bool // Purge cleans up the storage Purge(ctx context.Context, days time.Duration) error // Type returns the storage type Type() string }
Storage is the interface for storage operation
type StorjStorage ¶
type StorjStorage struct { Storage // contains filtered or unexported fields }
StorjStorage is a storage backed by Storj
func NewStorjStorage ¶
func NewStorjStorage(access, bucket string, purgeDays int, logger *log.Logger) (*StorjStorage, error)
NewStorjStorage is the factory for StorjStorage
func (*StorjStorage) Get ¶
func (s *StorjStorage) Get(ctx context.Context, token string, filename string) (reader io.ReadCloser, contentLength uint64, err error)
Get retrieves a file from storage
func (*StorjStorage) Head ¶
func (s *StorjStorage) Head(ctx context.Context, token string, filename string) (contentLength uint64, err error)
Head retrieves content length of a file from storage
func (*StorjStorage) IsNotExist ¶
func (s *StorjStorage) IsNotExist(err error) bool
IsNotExist indicates if a file doesn't exist on storage