Versions in this module Expand all Collapse all v0 v0.0.22 Jun 30, 2015 Changes in this version + const FileMaximumSize + const HashSize + var ContentTypes = map[FileType]string + var ErrClientFailedConnectionTest = errors.New("Client failed connection test") + var ErrClientKeyExpired = errors.New("Client key is expired") + var ErrClientOtherConnected = errors.New("Other client is connected") + var ErrClientStartupFlood = errors.New("API flood protection enabled") + var ErrClientUnexpectedResponse = errors.New("Unexpected error") + var ErrClientVersionOld = errors.New("Client version is too old") + var ErrFileBadLength = errors.New("Bad lenght in file") + var ErrFileInconsistent = errors.New("File has bad hash") + var ErrFileNotFound = errors.New("File not found in cache") + var ErrFileTypeUnknown = errors.New("hath => file type unknown") + var ErrHashBadLength = errors.New("hath => hash of image has bad length") + var ErrNoFilesToRemove = errors.New("No more unused files") + var ErrTimeDesync = errors.New("Time on server and on client differ too much") + var FileTypes = []string + var FileTypesN = len(FileTypes) + var LocalNetworks []net.IPNet + func FileFromBytesTo(result []byte, f *File) error + func FromRequest(req *http.Request) (net.IP, error) + func GetRoughCacheSize(count int64) uint64 + func IsUnexpected(err error) bool + func UnmarshalFileTo(data []byte, f *File) error + type APIResponse struct + Data []string + Message string + Success bool + func (r APIResponse) ParseVars() Vars + type Args map[string]string + func ParseArgs(s string) (a Args) + func (a Args) Get(k string) string + func (a Args) GetInt(k string) int + func (a Args) GetInt64(k string) int64 + func (a Args) String() string + type BoltDB struct + func NewDB(dbPath string) (d *BoltDB, err error) + func (d BoltDB) Add(f File) error + func (d BoltDB) AddBatch(files []File) error + func (d BoltDB) Close() error + func (d BoltDB) Count() (count int) + func (d BoltDB) Exists(f File) (exists bool) + func (d BoltDB) Get(id []byte) (f File, err error) + func (d BoltDB) GetBatch(files chan File, max int64) (err error) + func (d BoltDB) GetOldFiles(maxCount int, deadline time.Time) (files []File, err error) + func (d BoltDB) GetOldFilesCount(deadline time.Time) (count int64, err error) + func (d BoltDB) Remove(f File) error + func (d BoltDB) RemoveBatch(files []File) error + func (d BoltDB) Size() (sum int64, err error) + func (d BoltDB) Use(f File) error + func (d BoltDB) UseBatch(files []File) error + type Client struct + func NewClient(cfg ClientConfig) *Client + func (c Client) ActionURL(args ...string) *url.URL + func (c Client) AddFiles(files []File) error + func (c Client) CheckStats() error + func (c Client) Close() error + func (c Client) GetFile(u *url.URL) (rc io.ReadCloser, err error) + func (c Client) Login() error + func (c Client) More() error + func (c Client) RemoveFiles(files []File) error + func (c Client) RequestFile(f File, u *url.URL) (rc io.ReadCloser, err error) + func (c Client) Resume() error + func (c Client) Settings() (cfg Settings, err error) + func (c Client) Start() error + func (c Client) StillAlive() error + func (c Client) Suspend() error + func (c Client) Tokens(files []File) (result map[string]string, err error) + type ClientConfig struct + Debug bool + Host string + type Credentials struct + ClientID int64 + Key string + type DataBase interface + Add func(f File) error + AddBatch func(f []File) error + Close func() error + Count func() int + Exists func(f File) bool + Get func(id []byte) (File, error) + GetBatch func(files chan File, max int64) (err error) + GetOldFiles func(maxCount int, deadline time.Time) (files []File, err error) + GetOldFilesCount func(deadline time.Time) (count int64, err error) + Remove func(f File) error + RemoveBatch func(f []File) error + Size func() (int64, error) + Use func(f File) error + UseBatch func(files []File) error + type DefaultServer struct + func NewServer(cfg ServerConfig) *DefaultServer + func (s *DefaultServer) Close() error + func (s *DefaultServer) Listen() error + func (s *DefaultServer) ServeHTTP(w http.ResponseWriter, r *http.Request) + func (s *DefaultServer) Start() error + func (s DefaultServer) PopulateFromFrontend() error + type DirectCache interface + Add func(file File, r io.Reader) error + Check func(file File) error + Get func(file File) (io.ReadCloser, error) + Remove func(f File) error + RemoveBatch func(f []File) error + Scan func(chan File, chan Progress) error + type DirectFrontend struct + func (d *DirectFrontend) Add(file File, r io.Reader) error + func (d *DirectFrontend) Check(file File) error + func (d *DirectFrontend) Get(file File) (io.ReadCloser, error) + func (d *DirectFrontend) Handle(file File, w http.ResponseWriter) error + func (d *DirectFrontend) Remove(file File) error + func (d *DirectFrontend) RemoveBatch(files []File) error + func (d *DirectFrontend) Scan(files chan File, progress chan Progress) error + type ErrUnexpected struct + Err error + Response APIResponse + func (e ErrUnexpected) Error() string + type Event struct + File File + Type EventType + type EventType byte + const EventAdded + const EventDownloaded + const EventRemoved + const EventSent + func (t EventType) String() string + type File struct + Hash [HashSize]byte + Height int + LastUsage int64 + Size int64 + Static bool + Type FileType + Width int + func FileFromBytes(result []byte) (f File, err error) + func FileFromID(fileid string) (f File, err error) + func UnmarshalFile(data []byte) (f File, err error) + func (f *File) Buffer() *bytes.Buffer + func (f *File) SetHash(s string) error + func (f *File) Use() + func (f File) Basex() string + func (f File) ByteID() []byte + func (f File) Bytes() []byte + func (f File) ContentType() string + func (f File) Dir() string + func (f File) HexID() string + func (f File) InRange(r StaticRange) bool + func (f File) KeyStamp(key string, timestamp int64) string + func (f File) LastUsageBefore(t time.Time) bool + func (f File) Marshal() ([]byte, error) + func (f File) Path() string + func (f File) Range() (r StaticRange) + func (f File) String() string + type FileCache struct + func (c *FileCache) Add(file File, r io.Reader) error + func (c *FileCache) Check(file File) error + func (c *FileCache) Get(file File) (io.ReadCloser, error) + func (c *FileCache) Remove(file File) error + func (c *FileCache) RemoveBatch(files []File) error + func (c *FileCache) Scan(results chan File, progress chan Progress) error + type FileGenerator struct + Dir string + ResolutionMax int + ResolutionMin int + SizeMax int64 + SizeMin int64 + TimeDelta int64 + func (g FileGenerator) New() (f File, err error) + func (g FileGenerator) NewFake() (f File) + type FileType byte + const GIF + const JPG + const PNG + const UnknownImage + func ParseFileType(filetype string) FileType + func (f FileType) String() string + type Frontend interface + Handle func(file File, w http.ResponseWriter) error + func NewDirectFrontend(cache DirectCache) Frontend + func NewFrontend(dir string) Frontend + type HTTPClient interface + Do func(req *http.Request) (*http.Response, error) + Get func(url string) (*http.Response, error) + type Progress struct + Current int + Percent float32 + Total int + func (p Progress) String() string + type ProxyMode byte + const ProxyAllNetworksOpen + const ProxyAllNetworksProtected + const ProxyDisabled + const ProxyLocalNetworksOpen + const ProxyLocalNetworksProtected + func (p ProxyMode) String() string + type Server interface + type ServerConfig struct + Client *Client + DataBase DataBase + Debug bool + DontCheckSHA1 bool + DontCheckTimestamps bool + Frontend Frontend + MaxDownloadAttemps int + RemoveRate time.Duration + RemoveTimeout time.Duration + Settings Settings + UpdateRate time.Duration + func (cfg *ServerConfig) PopulateDefaults() + type Settings struct + DiskReamainingBytes int64 + Host net.IP + ImageServer string + LowMemory bool + MaximumBytesPerSecond int64 + MaximumCacheSize int64 + Name string + Port int + ProxyMode ProxyMode + RPCServers []net.IP + RequestServer string + StaticRanges StaticRanges + func (s Settings) IsRPCServer(r *http.Request) bool + type StaticRange [staticRangeBytes]byte + func ParseStaticRange(s string) (r StaticRange, err error) + func (s StaticRange) String() string + type StaticRanges map[StaticRange]bool + func (s StaticRanges) Add(r StaticRange) + func (s StaticRanges) Contains(f File) bool + func (s StaticRanges) Count() int + func (s StaticRanges) Remove(r StaticRange) + func (s StaticRanges) String() string + type Stats struct + FilesDownloaded int + FilesDownloadedBytes int64 + FilesSent int + FilesSentBytes int64 + FilesTotal int + Started time.Time + Uptime time.Duration + func (s *Stats) Process(e Event) + type Vars map[string]string + func (v Vars) Get(k string) string + func (v Vars) GetInt(k string) (int, error) + func (v Vars) GetInt64(k string) (int64, error) + func (v Vars) GetProxyMode(k string) (p ProxyMode, err error) + func (v Vars) GetStaticRange(k string) (s StaticRanges, err error) + func (v Vars) GetUint64(k string) (uint64, error)