server

package
v0.0.0-...-7bf499b Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2017 License: MIT Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// characters used for short-urls
	SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

	// someone set us up the bomb !!
	BASE = int64(len(SYMBOLS))
)
View Source
const SERVER_INFO = "transfer.sh"

Variables

This section is empty.

Functions

func Decode

func Decode(input string) int64

Decodes a string given in our encoding and returns the decimal integer.

func Encode

func Encode(number int64) string

encodes a number into our *base* representation TODO can this be made better with some bitshifting?

func LoveHandler

func LoveHandler(h http.Handler) http.HandlerFunc

Create a log handler for every request it receives.

func RenderFloat

func RenderFloat(format string, n float64) string

func RenderInteger

func RenderInteger(format string, n int) string

Types

type LocalStorage

type LocalStorage struct {
	Storage
	// contains filtered or unexported fields
}

func NewLocalStorage

func NewLocalStorage(basedir string) (*LocalStorage, error)

func (*LocalStorage) Get

func (s *LocalStorage) Get(token string, filename string) (reader io.ReadCloser, contentType string, contentLength uint64, err error)

func (*LocalStorage) Head

func (s *LocalStorage) Head(token string, filename string) (contentType string, contentLength uint64, err error)

func (*LocalStorage) IsNotExist

func (s *LocalStorage) IsNotExist(err error) bool

func (*LocalStorage) Put

func (s *LocalStorage) Put(token string, filename string, reader io.Reader, contentType string, contentLength uint64) error

func (*LocalStorage) Type

func (s *LocalStorage) Type() string

type Metadata

type Metadata struct {
	// ContentType is the original uploading content type
	ContentType string
	// Secret as knowledge to delete file
	// Secret string
	// Downloads is the actual number of downloads
	Downloads int
	// MaxDownloads contains the maximum numbers of downloads
	MaxDownloads int
	// MaxDate contains the max age of the file
	MaxDate time.Time
}

func MetadataForRequest

func MetadataForRequest(contentType string, r *http.Request) Metadata

type OptionFn

type OptionFn func(*Server)

func ClamavHost

func ClamavHost(s string) OptionFn

func EnableProfiler

func EnableProfiler() OptionFn

func ForceHTTPs

func ForceHTTPs() OptionFn

func Listener

func Listener(s string) OptionFn

func LogFile

func LogFile(s string) OptionFn

func ProfileListener

func ProfileListener(s string) OptionFn

func RateLimit

func RateLimit(requests int) OptionFn

func TLSConfig

func TLSConfig(cert, pk string) OptionFn

func TLSListener

func TLSListener(s string) OptionFn

func TempPath

func TempPath(s string) OptionFn

func UseLetsEncrypt

func UseLetsEncrypt(hosts []string) OptionFn

func UseStorage

func UseStorage(s Storage) OptionFn

func VirustotalKey

func VirustotalKey(s string) OptionFn

func WebPath

func WebPath(s string) OptionFn

type S3Storage

type S3Storage struct {
	Storage
	// contains filtered or unexported fields
}

func NewS3Storage

func NewS3Storage(accessKey, secretKey, bucketName string) (*S3Storage, error)

func (*S3Storage) Get

func (s *S3Storage) Get(token string, filename string) (reader io.ReadCloser, contentType string, contentLength uint64, err error)

func (*S3Storage) Head

func (s *S3Storage) Head(token string, filename string) (contentType string, contentLength uint64, err error)

func (*S3Storage) IsNotExist

func (s *S3Storage) IsNotExist(err error) bool

func (*S3Storage) Put

func (s *S3Storage) Put(token string, filename string, reader io.Reader, contentType string, contentLength uint64) (err error)

func (*S3Storage) Type

func (s *S3Storage) Type() string

type Server

type Server struct {
	VirusTotalKey    string
	ClamAVDaemonHost string

	ListenerString        string
	TLSListenerString     string
	ProfileListenerString string

	Certificate string

	LetsEncryptCache string
	// contains filtered or unexported fields
}

func New

func New(options ...OptionFn) (*Server, error)

func (*Server) CheckMetadata

func (s *Server) CheckMetadata(token, filename string) error

func (*Server) Lock

func (s *Server) Lock(token, filename string) error

func (*Server) RedirectHandler

func (s *Server) RedirectHandler(h http.Handler) http.HandlerFunc

func (*Server) Run

func (s *Server) Run()

func (*Server) Unlock

func (s *Server) Unlock(token, filename string) error

type Storage

type Storage interface {
	Get(token string, filename string) (reader io.ReadCloser, contentType string, contentLength uint64, err error)
	Head(token string, filename string) (contentType string, contentLength uint64, err error)
	Put(token string, filename string, reader io.Reader, contentType string, contentLength uint64) error
	IsNotExist(err error) bool

	Type() string
}

Jump to

Keyboard shortcuts

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