Documentation ¶
Overview ¶
Package data provides the data structures and database backends used by the goat BitTorrent tracker.
Index ¶
- Variables
- func DBConnect() (dbModel, error)
- func DBName() string
- func DBPing() bool
- func RedisConnect() (c redis.Conn, err error)
- func RedisDo(command string, args ...interface{}) (interface{}, error)
- func RedisPing() bool
- type APIKey
- type AnnounceLog
- type FileRecord
- func (f FileRecord) Completed() (completed int)
- func (f FileRecord) Delete() bool
- func (f FileRecord) Leechers() (leechers int)
- func (f FileRecord) Load(id interface{}, col string) FileRecord
- func (f FileRecord) PeerList(exclude string, numwant int) (peers []byte)
- func (f FileRecord) PeerReaper() bool
- func (f FileRecord) Save() bool
- func (f FileRecord) Seeders() (seeders int)
- func (f FileRecord) ToJSON() []byte
- func (f FileRecord) Users() []FileUserRecord
- type FileRecordRepository
- type FileUserRecord
- type FileUserRecordRepository
- type ScrapeLog
- type UserRecord
- func (u UserRecord) Create(username string, torrentLimit int) UserRecord
- func (u UserRecord) Delete() bool
- func (u UserRecord) Downloaded() int64
- func (u UserRecord) Leeching() int
- func (u UserRecord) Load(id interface{}, col string) UserRecord
- func (u UserRecord) Save() bool
- func (u UserRecord) Seeding() int
- func (u UserRecord) Uploaded() int64
- type WhitelistRecord
Constants ¶
This section is empty.
Variables ¶
var ( // DBConnectFunc connects to a database backend DBConnectFunc func() (dbModel, error) // DBCloseFunc closes connection to a database backend DBCloseFunc = func() {} // DBNameFunc returns the name of a database backend DBNameFunc = func() string { return "" } // DBPingFunc checks connectivity to a database backend DBPingFunc = func() bool { return true } )
var MySQLDSN *string
MySQLDSN is set via command-line, and can be used to override all MySQL configuration
var QLDBPath *string
QLDBPath is set via command-line, and can be used to override ql database location
Functions ¶
func DBName ¶
func DBName() string
DBName will retrieve the name of the database backend currently in use
func RedisConnect ¶
RedisConnect initiates a connection to Redis server
Types ¶
type AnnounceLog ¶
type AnnounceLog struct { ID int InfoHash string `db:"info_hash"` Passkey string Key string IP string Port int UDP bool Uploaded int64 Downloaded int64 Left int64 Event string Client string Time int64 }
AnnounceLog represents an announce, to be logged to storage
func (AnnounceLog) FromValues ¶
func (a AnnounceLog) FromValues(query url.Values) AnnounceLog
FromValues generates an AnnounceLog struct from a url.Values map
func (AnnounceLog) Load ¶
func (a AnnounceLog) Load(ID interface{}, col string) AnnounceLog
Load AnnounceLog from storage
type FileRecord ¶
type FileRecord struct { ID int `json:"id"` InfoHash string `db:"info_hash" json:"infoHash"` Verified bool `json:"verified"` CreateTime int64 `db:"create_time" json:"createTime"` UpdateTime int64 `db:"update_time" json:"updateTime"` }
FileRecord represents a file tracked by tracker
func (FileRecord) Completed ¶
func (f FileRecord) Completed() (completed int)
Completed returns the number of completions, active or not, on this file
func (FileRecord) Leechers ¶
func (f FileRecord) Leechers() (leechers int)
Leechers returns the number of leechers on this file
func (FileRecord) Load ¶
func (f FileRecord) Load(id interface{}, col string) FileRecord
Load FileRecord from storage
func (FileRecord) PeerList ¶
func (f FileRecord) PeerList(exclude string, numwant int) (peers []byte)
PeerList returns the compact peer buffer for tracker announce, excluding self
func (FileRecord) PeerReaper ¶
func (f FileRecord) PeerReaper() bool
PeerReaper reaps peers who have not recently announced on this torrent, and mark them inactive
func (FileRecord) Seeders ¶
func (f FileRecord) Seeders() (seeders int)
Seeders returns the number of seeders on this file
func (FileRecord) ToJSON ¶
func (f FileRecord) ToJSON() []byte
ToJSON converts a FileRecord to a jsonFileRecord struct
func (FileRecord) Users ¶
func (f FileRecord) Users() []FileUserRecord
Users loads all FileUserRecord structs associated with this FileRecord struct
type FileRecordRepository ¶
type FileRecordRepository struct { }
FileRecordRepository is used to contain methods to load multiple FileRecord structs
func (FileRecordRepository) All ¶
func (f FileRecordRepository) All() (files []FileRecord)
All loads all FileRecord structs from storage
type FileUserRecord ¶
type FileUserRecord struct { FileID int `db:"file_id" json:"fileId"` UserID int `db:"user_id" json:"userId"` IP string `json:"ip"` Active bool `json:"active"` Completed bool `json:"completed"` Announced int `json:"announced"` Uploaded int64 `json:"uploaded"` Downloaded int64 `json:"downloaded"` Left int64 `json:"left"` Time int64 `json:"time"` }
FileUserRecord represents a file tracked by tracker
func (FileUserRecord) Delete ¶
func (f FileUserRecord) Delete() bool
Delete FileUserRecord from storage
func (FileUserRecord) Load ¶
func (f FileUserRecord) Load(fileID int, userID int, ip string) FileUserRecord
Load FileUserRecord from storage
type FileUserRecordRepository ¶
type FileUserRecordRepository struct { }
FileUserRecordRepository is used to contain methods to load multiple FileRecord structs
func (FileUserRecordRepository) Select ¶
func (f FileUserRecordRepository) Select(id interface{}, col string) (files []FileUserRecord)
Select loads selected FileUserRecord structs from storage
type ScrapeLog ¶
type ScrapeLog struct { ID int InfoHash string `db:"info_hash"` Passkey string IP string Time int64 UDP bool }
ScrapeLog represents a scrapelog, to be logged to storage
func (ScrapeLog) FromValues ¶
FromValues generates a ScrapeLog struct from a url.Values map
type UserRecord ¶
type UserRecord struct { ID int Username string Passkey string TorrentLimit int `db:"torrent_limit"` }
UserRecord represents a user on the tracker
func (UserRecord) Create ¶
func (u UserRecord) Create(username string, torrentLimit int) UserRecord
Create a UserRecord, using defined parameters
func (UserRecord) Downloaded ¶
func (u UserRecord) Downloaded() int64
Downloaded loads this user's total download
func (UserRecord) Leeching ¶
func (u UserRecord) Leeching() int
Leeching counts the number of torrents this user is leeching
func (UserRecord) Load ¶
func (u UserRecord) Load(id interface{}, col string) UserRecord
Load UserRecord from storage
func (UserRecord) Seeding ¶
func (u UserRecord) Seeding() int
Seeding counts the number of torrents this user is seeding
func (UserRecord) Uploaded ¶
func (u UserRecord) Uploaded() int64
Uploaded loads this user's total upload
type WhitelistRecord ¶
WhitelistRecord represents a whitelist entry
func (WhitelistRecord) Load ¶
func (w WhitelistRecord) Load(id interface{}, col string) WhitelistRecord
Load WhitelistRecord from storage