data

package
v0.0.0-...-25adc38 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2014 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package data provides the data structures and database backends used by the goat BitTorrent tracker.

Index

Constants

This section is empty.

Variables

View Source
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 }
)
View Source
var MySQLDSN *string

MySQLDSN is set via command-line, and can be used to override all MySQL configuration

View Source
var QLDBPath *string

QLDBPath is set via command-line, and can be used to override ql database location

Functions

func DBConnect

func DBConnect() (dbModel, error)

DBConnect connects to a database

func DBName

func DBName() string

DBName will retrieve the name of the database backend currently in use

func DBPing

func DBPing() bool

DBPing will attempt to "ping" the database to verify connectivity

func RedisConnect

func RedisConnect() (c redis.Conn, err error)

RedisConnect initiates a connection to Redis server

func RedisDo

func RedisDo(command string, args ...interface{}) (interface{}, error)

RedisDo runs a single Redis command and returns its reply

func RedisPing

func RedisPing() bool

RedisPing verifies that Redis server is available

Types

type APIKey

type APIKey struct {
	ID     int
	UserID int `db:"user_id"`
	Key    string
	Salt   string
}

APIKey represents a user's API key

func (APIKey) Delete

func (a APIKey) Delete() bool

Delete APIKey from storage

func (APIKey) Load

func (a APIKey) Load(id interface{}, col string) (key APIKey)

Load APIKey from storage

func (APIKey) Save

func (a APIKey) Save() bool

Save APIKey to storage

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) Delete

func (a AnnounceLog) Delete() bool

Delete AnnounceLog from 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

func (AnnounceLog) Save

func (a AnnounceLog) Save() bool

Save AnnounceLog to 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) Delete

func (f FileRecord) Delete() bool

Delete FileRecord from storage

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) Save

func (f FileRecord) Save() bool

Save FileRecord to storage

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

func (FileUserRecord) Save

func (f FileUserRecord) Save() bool

Save FileUserRecord to 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) Delete

func (s ScrapeLog) Delete() bool

Delete ScrapeLog from storage

func (ScrapeLog) FromValues

func (s ScrapeLog) FromValues(query url.Values) ScrapeLog

FromValues generates a ScrapeLog struct from a url.Values map

func (ScrapeLog) Load

func (s ScrapeLog) Load(id interface{}, col string) ScrapeLog

Load ScrapeLog from storage

func (ScrapeLog) Save

func (s ScrapeLog) Save() bool

Save ScrapeLog to storage

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) Delete

func (u UserRecord) Delete() bool

Delete UserRecord from storage

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) Save

func (u UserRecord) Save() bool

Save UserRecord to 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

type WhitelistRecord struct {
	ID       int
	Client   string
	Approved bool
}

WhitelistRecord represents a whitelist entry

func (WhitelistRecord) Load

func (w WhitelistRecord) Load(id interface{}, col string) WhitelistRecord

Load WhitelistRecord from storage

func (WhitelistRecord) Save

func (w WhitelistRecord) Save() bool

Save WhitelistRecord to storage

Directories

Path Synopsis
Package udp provides the UDP-related data structures and methods for the goat BitTorrent tracker.
Package udp provides the UDP-related data structures and methods for the goat BitTorrent tracker.

Jump to

Keyboard shortcuts

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