tctypes

package
v0.0.0-...-8f4bd53 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package tctypes contains the shared types for client implementations.

Index

Constants

This section is empty.

Variables

View Source
var DefaultAsIEC bool = true

DefaultAsIEC toggles whether the IEC format is used by default for byte counts/rates/limits' string conversion.

View Source
var DefaultTransport = http.DefaultTransport

DefaultTransport is the default transport used by the HTTP logger.

Functions

func Format

func Format(i int64, asIEC bool, precision int) string

Format formats size i using the supplied precision, as a human readable string (1 B, 2 kB, 3 MB, 5 GB, ...). When asIEC is true, will format the amount as a IEC size (1 B, 2 KiB, 4 MiB, 5 GiB, ...)

Types

type Bool

type Bool bool

Bool wraps int64.

func (Bool) MarshalJSON

func (b Bool) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the json.Marshaler interface.

func (Bool) MarshalYAML

func (b Bool) MarshalYAML() (interface{}, error)

MarshalYAML satisfies the yaml.Marshaler interface.

func (*Bool) UnmarshalJSON

func (b *Bool) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies the json.Unmarshaler interface.

type ByteCount

type ByteCount int64

ByteCount wraps a byte count as int64.

func (ByteCount) Add

func (bc ByteCount) Add(i interface{}) interface{}

Add adds i to the byte count.

func (ByteCount) Format

func (bc ByteCount) Format(asIEC bool, prec int) string

Format formats the byte count.

func (ByteCount) Int64

func (bc ByteCount) Int64() int64

Int64 returns the byte count as an int64.

func (ByteCount) String

func (bc ByteCount) String() string

String satisfies the fmt.Stringer interface.

type ByteFormatter

type ByteFormatter interface {
	// Int64 returns the actual value in a int64.
	Int64() int64

	// Format formats the value in a human readable string, with the passed
	// precision.
	Format(bool, int) string

	// String satisfies the fmt.Stringer interface, returning a human readable
	// string.
	String() string

	// Add adds the passed value to itself, returning the sum of the two values.
	Add(interface{}) interface{}
}

ByteFormatter is the shared interface for byte counts, rates, and limits.

type Duration

type Duration time.Duration

Duration wraps time.Duration.

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the json.Marshaler interface.

func (Duration) MarshalYAML

func (d Duration) MarshalYAML() (interface{}, error)

MarshalYAML satisfies the yaml.Marshaler interface.

func (Duration) String

func (d Duration) String() string

String satisfies the fmt.Stringer interface.

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies the json.Unmarshaler interface.

type ErrNo

type ErrNo int64

ErrNo wraps remote errors.

func (ErrNo) String

func (errNo ErrNo) String() string

String satisifies the fmt.Stringer interface.

type Error

type Error string

Error is an error.

const (
	// ErrInvalidTime is the invalid time error.
	ErrInvalidTime Error = "invalid time"

	// ErrInvalidDuration is the invalid duration error.
	ErrInvalidDuration Error = "invalid duration"

	// ErrInvalidBool is the invalid bool error.
	ErrInvalidBool Error = "invalid bool"

	// ErrInvalidPriority is the invalid priority error.
	ErrInvalidPriority Error = "invalid priority"

	// ErrInvalidStatus is the invalid status error.
	ErrInvalidStatus Error = "invalid status"

	// ErrInvalidMode is the invalid mode error.
	ErrInvalidMode Error = "invalid mode"

	// ErrInvalidState is the invalid state error.
	ErrInvalidState Error = "invalid state"

	// ErrInvalidEncryption is the invalid encryption error.
	ErrInvalidEncryption Error = "invalid encryption"
)

func (Error) Error

func (err Error) Error() string

Error satisfies the error interface.

type File

type File struct {
	BytesCompleted ByteCount `json:"bytesCompleted,omitempty" yaml:"bytesCompleted,omitempty"` // tr_torrent
	Length         ByteCount `json:"length,omitempty" yaml:"length,omitempty"`                 // tr_info
	Name           string    `json:"name,omitempty" yaml:"name,omitempty"`                     // tr_info
	Wanted         bool      `json:"wanted,omitempty" yaml:"wanted,omitempty"`                 // tr_info
	Priority       string    `json:"priority,omitempty" yaml:"priority,omitempty"`             // tr_info
	ID             int64     `json:"id" yaml:"id"`
	Torrent        string    `json:"-" yaml:"-" all:"torrent"`
	HashString     string    `json:"-" yaml:"-" all:"hashString"`
}

File is combined fields of files, fileStats from a torrent.

func (File) PercentDone

func (f File) PercentDone() Percent

DoPercentDone calculates the done percent for the file.

func (File) ShortHash

func (f File) ShortHash() string

ShortHash returns the short hash of the torrent.

type HTTPLogger

type HTTPLogger struct {
	// contains filtered or unexported fields
}

HTTPLogger provides a logging http.RoundTripper transport.

Handles logging of HTTP requests and responses to standard logging funcs.

func NewHTTPLogf

func NewHTTPLogf(transport http.RoundTripper, logf func(string, ...interface{})) *HTTPLogger

NewHTTPLogf creates a new HTTP transport that logs to the provided logging function for the provided transport.

Prefixes "-> " and "<- " to each line of the HTTP request, response, and an additional blank line ("\n\n") to the output.

func NewHTTPLogger

func NewHTTPLogger(transport http.RoundTripper, reqf, resf func([]byte)) *HTTPLogger

NewHTTPLogger creates a new HTTP transport.

func (*HTTPLogger) RoundTrip

func (hl *HTTPLogger) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip satisfies the http.RoundTripper interface.

type KiLimit

type KiLimit int64

KiLimit is a K bytes per second limit.

func (KiLimit) Add

func (l KiLimit) Add(i interface{}) interface{}

Add adds i to the byte count.

func (KiLimit) Format

func (l KiLimit) Format(asIEC bool, prec int) string

Format formats the rate.

func (KiLimit) Int64

func (l KiLimit) Int64() int64

Int64 returns the rate as an int64.

func (KiLimit) String

func (l KiLimit) String() string

String satisfies the fmt.Stringer interface.

type Limit

type Limit int64

Limit is a K bytes per second limit.

func (Limit) Add

func (l Limit) Add(i interface{}) interface{}

Add adds i to the byte count.

func (Limit) Format

func (l Limit) Format(asIEC bool, prec int) string

Format formats the rate.

func (Limit) Int64

func (l Limit) Int64() int64

Int64 returns the rate as an int64.

func (Limit) String

func (l Limit) String() string

String satisfies the fmt.Stringer interface.

type MilliDuration

type MilliDuration time.Duration

MilliDuration wraps time.Duration.

func (MilliDuration) MarshalJSON

func (d MilliDuration) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the json.Marshaler interface.

func (MilliDuration) MarshalYAML

func (d MilliDuration) MarshalYAML() (interface{}, error)

MarshalYAML satisfies the yaml.Marshaler interface.

func (MilliDuration) String

func (d MilliDuration) String() string

String satisfies the fmt.Stringer interface.

func (*MilliDuration) UnmarshalJSON

func (d *MilliDuration) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies the json.Unmarshaler interface.

type MilliTime

type MilliTime time.Time

MilliTime wraps time.Time.

func (MilliTime) MarshalJSON

func (t MilliTime) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the json.Marshaler interface.

func (MilliTime) MarshalYAML

func (t MilliTime) MarshalYAML() (interface{}, error)

MarshalYAML satisfies the yaml.Marshaler interface.

func (MilliTime) String

func (t MilliTime) String() string

String satisfies the fmt.Stringer interface.

func (*MilliTime) UnmarshalJSON

func (t *MilliTime) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies the json.Unmarshaler interface.

type Mode

type Mode int64

Mode are idle/ratio modes.

const (
	ModeGlobal Mode = iota
	ModeSingle
	ModeUnlimited
)

Modes.

func (Mode) String

func (i Mode) String() string

func (*Mode) UnmarshalJSON

func (m *Mode) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies the json.Unmarshaler interface.

type Peer

type Peer struct {
	Address            string  `json:"address,omitempty" yaml:"address,omitempty"`                       // tr_peer_stat
	ClientName         string  `json:"clientName,omitempty" yaml:"clientName,omitempty"`                 // tr_peer_stat
	ClientIsChoked     bool    `json:"clientIsChoked,omitempty" yaml:"clientIsChoked,omitempty"`         // tr_peer_stat
	ClientIsInterested bool    `json:"clientIsInterested,omitempty" yaml:"clientIsInterested,omitempty"` // tr_peer_stat
	FlagStr            string  `json:"flagStr,omitempty" yaml:"flagStr,omitempty"`                       // tr_peer_stat
	IsDownloadingFrom  bool    `json:"isDownloadingFrom,omitempty" yaml:"isDownloadingFrom,omitempty"`   // tr_peer_stat
	IsEncrypted        bool    `json:"isEncrypted,omitempty" yaml:"isEncrypted,omitempty"`               // tr_peer_stat
	IsIncoming         bool    `json:"isIncoming,omitempty" yaml:"isIncoming,omitempty"`                 // tr_peer_stat
	IsUploadingTo      bool    `json:"isUploadingTo,omitempty" yaml:"isUploadingTo,omitempty"`           // tr_peer_stat
	IsUTP              bool    `json:"isUTP,omitempty" yaml:"isUTP,omitempty"`                           // tr_peer_stat
	PeerIsChoked       bool    `json:"peerIsChoked,omitempty" yaml:"peerIsChoked,omitempty"`             // tr_peer_stat
	PeerIsInterested   bool    `json:"peerIsInterested,omitempty" yaml:"peerIsInterested,omitempty"`     // tr_peer_stat
	Port               int64   `json:"port,omitempty" yaml:"port,omitempty"`                             // tr_peer_stat
	Progress           Percent `json:"progress,omitempty" yaml:"progress,omitempty"`                     // tr_peer_stat
	RateToClient       Rate    `json:"rateToClient,omitempty" yaml:"rateToClient,omitempty"`             // tr_peer_stat
	RateToPeer         Rate    `json:"rateToPeer,omitempty" yaml:"rateToPeer,omitempty"`                 // tr_peer_stat
	ID                 int64   `json:"id" yaml:"id"`
	Torrent            string  `json:"-" yaml:"-" all:"torrent"`
	HashString         string  `json:"-" yaml:"-" all:"hashString"`
}

Peer is a peer.

func (Peer) ShortHash

func (p Peer) ShortHash() string

ShortHash returns the short hash of the torrent.

type Percent

type Percent float64

Percent wraps a float64.

func (Percent) String

func (p Percent) String() string

String satisfies the fmt.Stringer interface.

type Priority

type Priority int64

Priority are file priorities.

const (
	PriorityLow    Priority = -1
	PriorityNormal Priority = 0
	PriorityHigh   Priority = 1
)

Priorities.

func (Priority) String

func (i Priority) String() string

func (*Priority) UnmarshalJSON

func (p *Priority) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies the json.Unmarshaler interface.

type Rate

type Rate int64

Rate is a bytes per second rate.

func (Rate) Add

func (r Rate) Add(i interface{}) interface{}

Add adds i to the byte count.

func (Rate) Format

func (r Rate) Format(asIEC bool, prec int) string

Format formats the rate.

func (Rate) Int64

func (r Rate) Int64() int64

Int64 returns the rate as an int64.

func (Rate) String

func (r Rate) String() string

String satisfies the fmt.Stringer interface.

type State

type State int64

State are tracker states.

const (
	StateInactive State = iota
	StateWaiting
	StateQueued
	StateActive
)

States.

func (State) String

func (i State) String() string

func (*State) UnmarshalJSON

func (s *State) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies the json.Unmarshaler interface.

type Status

type Status int64

Status are torrent statuses.

const (
	StatusStopped Status = iota
	StatusCheckWait
	StatusChecking
	StatusDownloadWait
	StatusDownloading
	StatusSeedWait
	StatusSeeding
)

Statuses.

func (Status) String

func (i Status) String() string

func (*Status) UnmarshalJSON

func (s *Status) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies the json.Unmarshaler interface.

type Time

type Time time.Time

Time wraps time.Time.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the json.Marshaler interface.

func (Time) MarshalYAML

func (t Time) MarshalYAML() (interface{}, error)

MarshalYAML satisfies the yaml.Marshaler interface.

func (Time) String

func (t Time) String() string

String satisfies the fmt.Stringer interface.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies the json.Unmarshaler interface.

type Torrent

type Torrent struct {
	ActivityDate      Time      `json:"activityDate,omitempty" yaml:"activityDate,omitempty"`           // tr_stat
	AddedDate         Time      `json:"addedDate,omitempty" yaml:"addedDate,omitempty"`                 // tr_stat
	BandwidthPriority Priority  `json:"bandwidthPriority,omitempty" yaml:"bandwidthPriority,omitempty"` // tr_priority_t
	Comment           string    `json:"comment,omitempty" yaml:"comment,omitempty"`                     // tr_info
	CorruptEver       ByteCount `json:"corruptEver,omitempty" yaml:"corruptEver,omitempty"`             // tr_stat
	Creator           string    `json:"creator,omitempty" yaml:"creator,omitempty"`                     // tr_info
	DateCreated       Time      `json:"dateCreated,omitempty" yaml:"dateCreated,omitempty"`             // tr_info
	DesiredAvailable  ByteCount `json:"desiredAvailable,omitempty" yaml:"desiredAvailable,omitempty"`   // tr_stat
	DoneDate          Time      `json:"doneDate,omitempty" yaml:"doneDate,omitempty"`                   // tr_stat
	DownloadDir       string    `json:"downloadDir,omitempty" yaml:"downloadDir,omitempty"`             // tr_torrent
	DownloadedEver    ByteCount `json:"downloadedEver,omitempty" yaml:"downloadedEver,omitempty"`       // tr_stat
	DownloadLimit     Limit     `json:"downloadLimit,omitempty" yaml:"downloadLimit,omitempty"`         // tr_torrent
	DownloadLimited   bool      `json:"downloadLimited,omitempty" yaml:"downloadLimited,omitempty"`     // tr_torrent
	EditDate          Time      `json:"editDate,omitempty" yaml:"editDate,omitempty"`                   // tr_stat
	Error             ErrNo     `json:"error,omitempty" yaml:"error,omitempty"`                         // tr_stat
	ErrorString       string    `json:"errorString,omitempty" yaml:"errorString,omitempty"`             // tr_stat
	Eta               Duration  `json:"eta,omitempty" yaml:"eta,omitempty"`                             // tr_stat
	EtaIdle           Duration  `json:"etaIdle,omitempty" yaml:"etaIdle,omitempty"`                     // tr_stat
	Files             []struct {
		BytesCompleted ByteCount `json:"bytesCompleted,omitempty" yaml:"bytesCompleted,omitempty"` // tr_torrent
		Length         ByteCount `json:"length,omitempty" yaml:"length,omitempty"`                 // tr_info
		Name           string    `json:"name,omitempty" yaml:"name,omitempty"`                     // tr_info
	} `json:"files,omitempty" yaml:"files,omitempty"` // n/a
	FileStats []struct {
		BytesCompleted ByteCount `json:"bytesCompleted,omitempty" yaml:"bytesCompleted,omitempty"` // tr_torrent
		Wanted         bool      `json:"wanted,omitempty" yaml:"wanted,omitempty"`                 // tr_info
		Priority       Priority  `json:"priority,omitempty" yaml:"priority,omitempty"`             // tr_info
	} `json:"fileStats,omitempty" yaml:"fileStats,omitempty"` // n/a
	HashString              string    `json:"hashString,omitempty" yaml:"hashString,omitempty"`                           // tr_info
	HaveUnchecked           ByteCount `json:"haveUnchecked,omitempty" yaml:"haveUnchecked,omitempty"`                     // tr_stat
	HaveValid               ByteCount `json:"haveValid,omitempty" yaml:"haveValid,omitempty"`                             // tr_stat
	HonorsSessionLimits     bool      `json:"honorsSessionLimits,omitempty" yaml:"honorsSessionLimits,omitempty"`         // tr_torrent
	ID                      int64     `json:"id,omitempty" yaml:"id,omitempty"`                                           // tr_torrent
	IsFinished              bool      `json:"isFinished,omitempty" yaml:"isFinished,omitempty"`                           // tr_stat
	IsPrivate               bool      `json:"isPrivate,omitempty" yaml:"isPrivate,omitempty"`                             // tr_torrent
	IsStalled               bool      `json:"isStalled,omitempty" yaml:"isStalled,omitempty"`                             // tr_stat
	Labels                  []string  `json:"labels,omitempty" yaml:"labels,omitempty"`                                   // tr_torrent
	LeftUntilDone           ByteCount `json:"leftUntilDone,omitempty" yaml:"leftUntilDone,omitempty"`                     // tr_stat
	MagnetLink              string    `json:"magnetLink,omitempty" yaml:"magnetLink,omitempty"`                           // n/a
	ManualAnnounceTime      Time      `json:"manualAnnounceTime,omitempty" yaml:"manualAnnounceTime,omitempty"`           // tr_stat
	MaxConnectedPeers       int64     `json:"maxConnectedPeers,omitempty" yaml:"maxConnectedPeers,omitempty"`             // tr_torrent
	MetadataPercentComplete Percent   `json:"metadataPercentComplete,omitempty" yaml:"metadataPercentComplete,omitempty"` // tr_stat
	Name                    string    `json:"name,omitempty" yaml:"name,omitempty"`                                       // tr_info
	PeerLimit               int64     `json:"peer-limit,omitempty" yaml:"peer-limit,omitempty"`                           // tr_torrent
	Peers                   []struct {
		Address            string  `json:"address,omitempty" yaml:"address,omitempty"`                       // tr_peer_stat
		ClientName         string  `json:"clientName,omitempty" yaml:"clientName,omitempty"`                 // tr_peer_stat
		ClientIsChoked     bool    `json:"clientIsChoked,omitempty" yaml:"clientIsChoked,omitempty"`         // tr_peer_stat
		ClientIsInterested bool    `json:"clientIsInterested,omitempty" yaml:"clientIsInterested,omitempty"` // tr_peer_stat
		FlagStr            string  `json:"flagStr,omitempty" yaml:"flagStr,omitempty"`                       // tr_peer_stat
		IsDownloadingFrom  bool    `json:"isDownloadingFrom,omitempty" yaml:"isDownloadingFrom,omitempty"`   // tr_peer_stat
		IsEncrypted        bool    `json:"isEncrypted,omitempty" yaml:"isEncrypted,omitempty"`               // tr_peer_stat
		IsIncoming         bool    `json:"isIncoming,omitempty" yaml:"isIncoming,omitempty"`                 // tr_peer_stat
		IsUploadingTo      bool    `json:"isUploadingTo,omitempty" yaml:"isUploadingTo,omitempty"`           // tr_peer_stat
		IsUTP              bool    `json:"isUTP,omitempty" yaml:"isUTP,omitempty"`                           // tr_peer_stat
		PeerIsChoked       bool    `json:"peerIsChoked,omitempty" yaml:"peerIsChoked,omitempty"`             // tr_peer_stat
		PeerIsInterested   bool    `json:"peerIsInterested,omitempty" yaml:"peerIsInterested,omitempty"`     // tr_peer_stat
		Port               int64   `json:"port,omitempty" yaml:"port,omitempty"`                             // tr_peer_stat
		Progress           Percent `json:"progress,omitempty" yaml:"progress,omitempty"`                     // tr_peer_stat
		RateToClient       Rate    `json:"rateToClient,omitempty" yaml:"rateToClient,omitempty"`             // tr_peer_stat
		RateToPeer         Rate    `json:"rateToPeer,omitempty" yaml:"rateToPeer,omitempty"`                 // tr_peer_stat
	} `json:"peers,omitempty" yaml:"peers,omitempty"` // n/a
	PeersConnected int64 `json:"peersConnected,omitempty" yaml:"peersConnected,omitempty"` // tr_stat
	PeersFrom      struct {
		FromCache    int64 `json:"fromCache,omitempty" yaml:"fromCache,omitempty"`       // tr_stat
		FromDht      int64 `json:"fromDht,omitempty" yaml:"fromDht,omitempty"`           // tr_stat
		FromIncoming int64 `json:"fromIncoming,omitempty" yaml:"fromIncoming,omitempty"` // tr_stat
		FromLpd      int64 `json:"fromLpd,omitempty" yaml:"fromLpd,omitempty"`           // tr_stat
		FromLtep     int64 `json:"fromLtep,omitempty" yaml:"fromLtep,omitempty"`         // tr_stat
		FromPex      int64 `json:"fromPex,omitempty" yaml:"fromPex,omitempty"`           // tr_stat
		FromTracker  int64 `json:"fromTracker,omitempty" yaml:"fromTracker,omitempty"`   // tr_stat
	} `json:"peersFrom,omitempty" yaml:"peersFrom,omitempty"` // n/a
	PeersGettingFromUs int64      `json:"peersGettingFromUs,omitempty" yaml:"peersGettingFromUs,omitempty"` // tr_stat
	PeersSendingToUs   int64      `json:"peersSendingToUs,omitempty" yaml:"peersSendingToUs,omitempty"`     // tr_stat
	PercentDone        Percent    `json:"percentDone,omitempty" yaml:"percentDone,omitempty"`               // tr_stat
	Pieces             []byte     `json:"pieces,omitempty" yaml:"pieces,omitempty"`                         // tr_torrent
	PieceCount         int64      `json:"pieceCount,omitempty" yaml:"pieceCount,omitempty"`                 // tr_info
	PieceSize          ByteCount  `json:"pieceSize,omitempty" yaml:"pieceSize,omitempty"`                   // tr_info
	Priorities         []Priority `json:"priorities,omitempty" yaml:"priorities,omitempty"`                 // n/a
	QueuePosition      int64      `json:"queuePosition,omitempty" yaml:"queuePosition,omitempty"`           // tr_stat
	RateDownload       Rate       `json:"rateDownload,omitempty" yaml:"rateDownload,omitempty"`             // tr_stat
	RateUpload         Rate       `json:"rateUpload,omitempty" yaml:"rateUpload,omitempty"`                 // tr_stat
	RecheckProgress    Percent    `json:"recheckProgress,omitempty" yaml:"recheckProgress,omitempty"`       // tr_stat
	SecondsDownloading Duration   `json:"secondsDownloading,omitempty" yaml:"secondsDownloading,omitempty"` // tr_stat
	SecondsSeeding     Duration   `json:"secondsSeeding,omitempty" yaml:"secondsSeeding,omitempty"`         // tr_stat
	SeedIdleLimit      int64      `json:"seedIdleLimit,omitempty" yaml:"seedIdleLimit,omitempty"`           // tr_torrent
	SeedIdleMode       Mode       `json:"seedIdleMode,omitempty" yaml:"seedIdleMode,omitempty"`             // tr_inactvelimit
	SeedRatioLimit     float64    `json:"seedRatioLimit,omitempty" yaml:"seedRatioLimit,omitempty"`         // tr_torrent
	SeedRatioMode      Mode       `json:"seedRatioMode,omitempty" yaml:"seedRatioMode,omitempty"`           // tr_ratiolimit
	SizeWhenDone       ByteCount  `json:"sizeWhenDone,omitempty" yaml:"sizeWhenDone,omitempty"`             // tr_stat
	StartDate          Time       `json:"startDate,omitempty" yaml:"startDate,omitempty"`                   // tr_stat
	Status             Status     `json:"status,omitempty" yaml:"status,omitempty"`                         // tr_stat
	Trackers           []struct {
		Announce string `json:"announce,omitempty" yaml:"announce,omitempty"` // tr_tracker_info
		ID       int64  `json:"id,omitempty" yaml:"id,omitempty"`             // tr_tracker_info
		Scrape   string `json:"scrape,omitempty" yaml:"scrape,omitempty"`     // tr_tracker_info
		Tier     int64  `json:"tier,omitempty" yaml:"tier,omitempty"`         // tr_tracker_info
	} `json:"trackers,omitempty" yaml:"trackers,omitempty"` // n/a
	TrackerStats []struct {
		Announce              string `json:"announce,omitempty" yaml:"announce,omitempty"`                           // tr_tracker_stat
		AnnounceState         State  `json:"announceState,omitempty" yaml:"announceState,omitempty"`                 // tr_tracker_stat
		DownloadCount         int64  `json:"downloadCount,omitempty" yaml:"downloadCount,omitempty"`                 // tr_tracker_stat
		HasAnnounced          bool   `json:"hasAnnounced,omitempty" yaml:"hasAnnounced,omitempty"`                   // tr_tracker_stat
		HasScraped            bool   `json:"hasScraped,omitempty" yaml:"hasScraped,omitempty"`                       // tr_tracker_stat
		Host                  string `json:"host,omitempty" yaml:"host,omitempty"`                                   // tr_tracker_stat
		ID                    int64  `json:"id,omitempty" yaml:"id,omitempty"`                                       // tr_tracker_stat
		IsBackup              bool   `json:"isBackup,omitempty" yaml:"isBackup,omitempty"`                           // tr_tracker_stat
		LastAnnouncePeerCount int64  `json:"lastAnnouncePeerCount,omitempty" yaml:"lastAnnouncePeerCount,omitempty"` // tr_tracker_stat
		LastAnnounceResult    string `json:"lastAnnounceResult,omitempty" yaml:"lastAnnounceResult,omitempty"`       // tr_tracker_stat
		LastAnnounceStartTime Time   `json:"lastAnnounceStartTime,omitempty" yaml:"lastAnnounceStartTime,omitempty"` // tr_tracker_stat
		LastAnnounceSucceeded bool   `json:"lastAnnounceSucceeded,omitempty" yaml:"lastAnnounceSucceeded,omitempty"` // tr_tracker_stat
		LastAnnounceTime      Time   `json:"lastAnnounceTime,omitempty" yaml:"lastAnnounceTime,omitempty"`           // tr_tracker_stat
		LastAnnounceTimedOut  bool   `json:"lastAnnounceTimedOut,omitempty" yaml:"lastAnnounceTimedOut,omitempty"`   // tr_tracker_stat
		LastScrapeResult      string `json:"lastScrapeResult,omitempty" yaml:"lastScrapeResult,omitempty"`           // tr_tracker_stat
		LastScrapeStartTime   Time   `json:"lastScrapeStartTime,omitempty" yaml:"lastScrapeStartTime,omitempty"`     // tr_tracker_stat
		LastScrapeSucceeded   bool   `json:"lastScrapeSucceeded,omitempty" yaml:"lastScrapeSucceeded,omitempty"`     // tr_tracker_stat
		LastScrapeTime        Time   `json:"lastScrapeTime,omitempty" yaml:"lastScrapeTime,omitempty"`               // tr_tracker_stat
		LastScrapeTimedOut    int64  `json:"lastScrapeTimedOut,omitempty" yaml:"lastScrapeTimedOut,omitempty"`       // tr_tracker_stat
		LeecherCount          int64  `json:"leecherCount,omitempty" yaml:"leecherCount,omitempty"`                   // tr_tracker_stat
		NextAnnounceTime      Time   `json:"nextAnnounceTime,omitempty" yaml:"nextAnnounceTime,omitempty"`           // tr_tracker_stat
		NextScrapeTime        Time   `json:"nextScrapeTime,omitempty" yaml:"nextScrapeTime,omitempty"`               // tr_tracker_stat
		Scrape                string `json:"scrape,omitempty" yaml:"scrape,omitempty"`                               // tr_tracker_stat
		ScrapeState           State  `json:"scrapeState,omitempty" yaml:"scrapeState,omitempty"`                     // tr_tracker_stat
		SeederCount           int64  `json:"seederCount,omitempty" yaml:"seederCount,omitempty"`                     // tr_tracker_stat
		Tier                  int64  `json:"tier,omitempty" yaml:"tier,omitempty"`                                   // tr_tracker_stat
	} `json:"trackerStats,omitempty" yaml:"trackerStats,omitempty"` // n/a
	TotalSize           ByteCount `json:"totalSize,omitempty" yaml:"totalSize,omitempty"`                     // tr_info
	TorrentFile         string    `json:"torrentFile,omitempty" yaml:"torrentFile,omitempty"`                 // tr_info
	UploadedEver        ByteCount `json:"uploadedEver,omitempty" yaml:"uploadedEver,omitempty"`               // tr_stat
	UploadLimit         Limit     `json:"uploadLimit,omitempty" yaml:"uploadLimit,omitempty"`                 // tr_torrent
	UploadLimited       bool      `json:"uploadLimited,omitempty" yaml:"uploadLimited,omitempty"`             // tr_torrent
	UploadRatio         float64   `json:"uploadRatio,omitempty" yaml:"uploadRatio,omitempty"`                 // tr_stat
	Wanted              []Bool    `json:"wanted,omitempty" yaml:"wanted,omitempty"`                           // n/a
	Webseeds            []string  `json:"webseeds,omitempty" yaml:"webseeds,omitempty"`                       // n/a
	WebseedsSendingToUs int64     `json:"webseedsSendingToUs,omitempty" yaml:"webseedsSendingToUs,omitempty"` // tr_stat
}

Torrent holds information about a torrent.

func (Torrent) ShortHash

func (t Torrent) ShortHash() string

ShortHash returns the short hash of the torrent.

type Tracker

type Tracker struct {
	Announce              string `json:"announce,omitempty" yaml:"announce,omitempty"`                           // tr_tracker_info
	ID                    int64  `json:"id" yaml:"id"`                                                           // tr_tracker_info
	Scrape                string `json:"scrape,omitempty" yaml:"scrape,omitempty"`                               // tr_tracker_info
	Tier                  int64  `json:"tier,omitempty" yaml:"tier,omitempty"`                                   // tr_tracker_info
	AnnounceState         State  `json:"announceState,omitempty" yaml:"announceState,omitempty"`                 // tr_tracker_stat
	DownloadCount         int64  `json:"downloadCount,omitempty" yaml:"downloadCount,omitempty"`                 // tr_tracker_stat
	HasAnnounced          bool   `json:"hasAnnounced,omitempty" yaml:"hasAnnounced,omitempty"`                   // tr_tracker_stat
	HasScraped            bool   `json:"hasScraped,omitempty" yaml:"hasScraped,omitempty"`                       // tr_tracker_stat
	Host                  string `json:"host,omitempty" yaml:"host,omitempty"`                                   // tr_tracker_stat
	IsBackup              bool   `json:"isBackup,omitempty" yaml:"isBackup,omitempty"`                           // tr_tracker_stat
	LastAnnouncePeerCount int64  `json:"lastAnnouncePeerCount,omitempty" yaml:"lastAnnouncePeerCount,omitempty"` // tr_tracker_stat
	LastAnnounceResult    string `json:"lastAnnounceResult,omitempty" yaml:"lastAnnounceResult,omitempty"`       // tr_tracker_stat
	LastAnnounceStartTime Time   `json:"lastAnnounceStartTime,omitempty" yaml:"lastAnnounceStartTime,omitempty"` // tr_tracker_stat
	LastAnnounceSucceeded bool   `json:"lastAnnounceSucceeded,omitempty" yaml:"lastAnnounceSucceeded,omitempty"` // tr_tracker_stat
	LastAnnounceTime      Time   `json:"lastAnnounceTime,omitempty" yaml:"lastAnnounceTime,omitempty"`           // tr_tracker_stat
	LastAnnounceTimedOut  bool   `json:"lastAnnounceTimedOut,omitempty" yaml:"lastAnnounceTimedOut,omitempty"`   // tr_tracker_stat
	LastScrapeResult      string `json:"lastScrapeResult,omitempty" yaml:"lastScrapeResult,omitempty"`           // tr_tracker_stat
	LastScrapeStartTime   Time   `json:"lastScrapeStartTime,omitempty" yaml:"lastScrapeStartTime,omitempty"`     // tr_tracker_stat
	LastScrapeSucceeded   bool   `json:"lastScrapeSucceeded,omitempty" yaml:"lastScrapeSucceeded,omitempty"`     // tr_tracker_stat
	LastScrapeTime        Time   `json:"lastScrapeTime,omitempty" yaml:"lastScrapeTime,omitempty"`               // tr_tracker_stat
	LastScrapeTimedOut    int64  `json:"lastScrapeTimedOut,omitempty" yaml:"lastScrapeTimedOut,omitempty"`       // tr_tracker_stat
	LeecherCount          int64  `json:"leecherCount,omitempty" yaml:"leecherCount,omitempty"`                   // tr_tracker_stat
	NextAnnounceTime      Time   `json:"nextAnnounceTime,omitempty" yaml:"nextAnnounceTime,omitempty"`           // tr_tracker_stat
	NextScrapeTime        Time   `json:"nextScrapeTime,omitempty" yaml:"nextScrapeTime,omitempty"`               // tr_tracker_stat
	ScrapeState           State  `json:"scrapeState,omitempty" yaml:"scrapeState,omitempty"`                     // tr_tracker_stat
	SeederCount           int64  `json:"seederCount,omitempty" yaml:"seederCount,omitempty"`                     // tr_tracker_stat
	Torrent               string `json:"-" yaml:"-" all:"torrent"`
	HashString            string `json:"-" yaml:"-" all:"hashString"`
}

Tracker is combined fields of trackers, trackerStats from a torrent.

func (Tracker) ShortHash

func (t Tracker) ShortHash() string

ShortHash returns the short hash of the torrent.

Jump to

Keyboard shortcuts

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