torus

package module
v0.0.0-...-04c6e67 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2016 License: MIT Imports: 8 Imported by: 0

README

torus

Simple shareable torrent server.

Not production ready. Not even alpha software.

Configuration

listen_addr = ":8000"
database_path = "/static/torrents.db"
data_path = "/static/data"
htpasswd_path = "/static/htpasswd"
download_token = 5
torrent_port = 50007

[mailgun]
domain = "example.com"
secret_key = "XXXXX"
public_key = "XXXXX"
email = "torus@example.com"

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version   string
	Build     string
	BuildTime string
)
View Source
var AnonUser = User{}

Functions

func Revision

func Revision() string

Types

type DatabaseService

type DatabaseService interface {
	AddUser(u User) error
	AddTransaction(t Transaction) error
	AddRequest(r Request) error
	AddTorrent(t Torrent) error
	AddRecord(r Record) error
}

type Mail

type Mail struct {
	Datetime time.Time
	To       string
	From     string
	Title    string
	Body     string
}

type MailService

type MailService interface {
	SendMail(m Mail) error
	ReceiveMail() <-chan Mail
}

type Record

type Record struct {
	ID       uint64    `json:"id"`
	Request  Request   `json:"request"`
	Torrents []Torrent `json:"torrents"`
}

type Request

type Request struct {
	UserId uint64       `json:"user_id"`
	URLs   []string     `json:"urls"`
	State  RequestState `json:"state"`

	RequestTime        time.Time     `json:"request_time"`
	DownloadDuration   time.Duration `json:"download_duration"`
	ProcessingDuration time.Duration `json:"processing_duration"`
}

type RequestService

type RequestService interface {
	NewRequest(userId uint64, URLs []string)
}

type RequestState

type RequestState int
const (
	Waiting RequestState = iota
	Downloading
	Completed
)

type Torrent

type Torrent struct {
	Name     string   `json:"name"`
	Size     uint64   `json:"size"`
	InfoHash string   `json:"info_hash"`
	Files    []string `json:"-"`

	Payload []byte `json:"-"`
}

func NewTorrent

func NewTorrent(payload []byte) (Torrent, error)

NewTorrent creates a new torrent from a payload. It returns an error if the payload is invalid.

type Transaction

type Transaction struct {
	Type   TransactionType
	Cost   uint
	Tags   []string
	UserId uint64

	Datetime time.Time
}

type TransactionService

type TransactionService interface {
	Add(t Transaction) error
	View(begin, end time.Time) ([]Transaction, error)
}

type TransactionType

type TransactionType int
const (
	AddTorrent TransactionType = iota
	DownloadTorrent
)

type User

type User struct {
	Id           uint64
	Email        string
	PasswordHash string

	CreationTime time.Time

	IsAdmin bool
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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