Documentation
¶
Index ¶
- Variables
- func Bod(t time.Time) time.Time
- func Copy(src, dst string, followSymlinks bool) (string, error)
- func CopyFile(src, dst string, followSymlinks bool) error
- func CopyMode(src, dst string, followSymlinks bool) error
- func CopyTree(src, dst string, options *CopyTreeOptions) error
- func DecodeFileURL(u string) (ret string)
- func DefaultPeerID() string
- func DefaultUserAgent() string
- func Difference(arrs ...interface{}) (reflect.Value, bool)
- func Distinct(arr interface{}) (reflect.Value, bool)
- func EncodeFileURL(u string) (ret string)
- func FreeMemory()
- func FreeMemoryGC()
- func GetContextHTTPHost(ctx *gin.Context) string
- func GetHTTPHost() string
- func GetListenAddr(confAutoIP bool, confAutoPort bool, confInterfaces string, confPortMin int, ...) (listenIP, listenIPv6 string, listenPort int, disableIPv6 bool, err error)
- func GetTorrentVersion() string
- func GetUserAndPeer() (peerID, userAgent string)
- func GetVersion() string
- func HasAudioExt(filename string) bool
- func HasSubtitlesExt(filename string) bool
- func InternalProxyURL() string
- func IsAudioExt(ext string) bool
- func IsSubtitlesExt(ext string) bool
- func IsSymlink(fi os.FileInfo) bool
- func LocalIP() (net.IP, error)
- func Max(a, b int) int
- func Min(a, b int) int
- func Move(src, dst string) (string, error)
- func NowInt() int
- func NowInt64() int64
- func NowPlusSecondsInt(seconds int) int
- func PeerIDRandom(peer string) string
- func StrInterfaceToInt(t interface{}) (i int)
- func StringSliceContains(ary []string, q string) bool
- func ToFileName(filename string) string
- func TrailerURL(u string) (ret string)
- func UTCBod() time.Time
- type AlreadyExistsError
- type CopyTreeOptions
- type Event
- type NotADirectoryError
- type RateLimiter
- type SameFileError
- type SpecialFileError
Constants ¶
This section is empty.
Variables ¶
var ( ErrExceeded = errors.New("Rate-Limit Exceeded") ErrNotFound = errors.New("Not Found") ErrHTTP = errors.New("HTTP error") )
ErrExceeded should be returned if we need to rerun the function
var (
// Version ...
Version = "v0.0.1"
)
Functions ¶
func Copy ¶
Copy data and mode bits ("cp src dst"). Return the file's destination.
The destination may be a directory.
If followSymlinks is false, symlinks won't be followed. This resembles GNU's "cp -P src dst".
If source and destination are the same file, a SameFileError will be raised.
func CopyFile ¶
CopyFile Copy data from src to dst
If followSymlinks is not set and src is a symbolic link, a new symlink will be created instead of copying the file it points to.
func CopyMode ¶
CopyMode bits from src to dst.
If followSymlinks is false, symlinks aren't followed if and only if both `src` and `dst` are symlinks. If `lchmod` isn't available and both are symlinks this does nothing. (I don't think lchmod is available in Go)
func DecodeFileURL ¶
DecodeFileURL decodes file path from url
func EncodeFileURL ¶
EncodeFileURL encode file path into proper url
func GetListenAddr ¶
func GetListenAddr(confAutoIP bool, confAutoPort bool, confInterfaces string, confPortMin int, confPortMax int) (listenIP, listenIPv6 string, listenPort int, disableIPv6 bool, err error)
GetListenAddr parsing configuration setted for interfaces and port range and returning IP, IPv6, and port
func GetTorrentVersion ¶
func GetTorrentVersion() string
GetTorrentVersion returns version of GoTorrent, provided to compiler
func GetUserAndPeer ¶
func GetUserAndPeer() (peerID, userAgent string)
GetUserAndPeer returns PeerID and UserAgent, according to Config settings. If not set - returns default values
func HasAudioExt ¶
HasAudioExt searches different audio extensions in file name
func HasSubtitlesExt ¶
HasSubtitlesExt searches different subtitles extensions in file name
func IsAudioExt ¶
IsAudioExt checks if extension belong to Audio type
func IsSubtitlesExt ¶
IsSubtitlesExt checks if extension belong to Subtitles type
func Move ¶
Move a file from src to dst
Simply tries os.Rename first in case the file is getting moved on the same disk, and uses Copy() otherwise.
Does not follow symlinks when copying.
func StringSliceContains ¶
StringSliceContains ...
func TrailerURL ¶
TrailerURL returns trailer url, constructed for Kodi
Types ¶
type CopyTreeOptions ¶
type CopyTreeOptions struct { Symlinks bool IgnoreDanglingSymlinks bool CopyFunction func(string, string, bool) (string, error) Ignore func(string, []os.FileInfo) []string }
CopyTreeOptions ...
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event ...
func (*Event) C ¶
func (me *Event) C() <-chan struct{}
C Returns a chan that is closed when the event is true.
func (*Event) LockedChan ¶
LockedChan ...
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
A RateLimiter limits the rate at which an action can be performed. It applies neither smoothing (like one could achieve in a token bucket system) nor does it offer any conception of warmup, wherein the rate of actions granted are steadily increased until a steady throughput equilibrium is reached.
func NewRateLimiter ¶
func NewRateLimiter(limit int, interval time.Duration, parallelCount int) *RateLimiter
NewRateLimiter creates a new rate limiter for the limit and interval.
func (*RateLimiter) CoolDown ¶
func (r *RateLimiter) CoolDown(headers http.Header)
CoolDown is checking HTTP headers if we need to wait
func (*RateLimiter) Enter ¶
func (r *RateLimiter) Enter()
Enter blocks parallen channel for simultaneous connections limitation
func (*RateLimiter) ForceWait ¶
func (r *RateLimiter) ForceWait()
ForceWait is forcing rate limit if we have an external cause (like Response from API).
func (*RateLimiter) Try ¶
func (r *RateLimiter) Try() (ok bool, remaining time.Duration)
Try returns true if under the rate limit, or false if over and the remaining time before the rate limit expires.
func (*RateLimiter) Wait ¶
func (r *RateLimiter) Wait()
Wait blocks if the rate limit has been reached. Wait offers no guarantees of fairness for multiple actors if the allowed rate has been temporarily exhausted.
type SameFileError ¶
SameFileError ...
type SpecialFileError ¶
SpecialFileError ...