Documentation ¶
Index ¶
- Constants
- func LogDebug(fmt string, args ...interface{})
- func LogError(fmt string, args ...interface{})
- func LogFatal(fmt string, args ...interface{})
- func LogInfo(fmt string, args ...interface{})
- func LogWarning(fmt string, args ...interface{})
- func SetLoggingVerbosity(level Verbosity)
- type Distributor
- type File
- type Metadata
- type MetadataInfo
- type Peer
- type PeerResponse
- type Tracker
- type Verbosity
- type Watcher
Constants ¶
View Source
const ( VerbNormal = Verbosity(0) VerbVerbose = Verbosity(1) VerbDebug = Verbosity(2) )
View Source
const PIECE_LENGTH = int64(256 * 1024)
256kb is now the pseudo-standard for BT pieces and is reasonable (metadata file is ~1MB for an 8GB file being served).
Variables ¶
This section is empty.
Functions ¶
func LogWarning ¶
func LogWarning(fmt string, args ...interface{})
func SetLoggingVerbosity ¶
func SetLoggingVerbosity(level Verbosity)
Types ¶
type Distributor ¶
type Distributor struct {
// contains filtered or unexported fields
}
func NewDistributor ¶
func (*Distributor) Close ¶
func (dist *Distributor) Close()
func (*Distributor) Run ¶
func (dist *Distributor) Run()
func (*Distributor) Start ¶
func (dist *Distributor) Start()
func (*Distributor) Wait ¶
func (dist *Distributor) Wait()
type File ¶
type File struct { Name string // Base filename. FQFN string // Path + filename. Size int64 // File size. ModTime time.Time // Modification time. MetadataInfo *MetadataInfo // Reference to our metadata. SeedCommand *exec.Cmd // Owned by the Tracker methods. Lock sync.Mutex }
File represents a single file that we are serving. These are read by other parts of the system but only written by this module.
type Metadata ¶
type Metadata struct { Announce string `announce` // URL of our tracker. Info MetadataInfo `info` }
type MetadataInfo ¶
type MetadataInfo struct { Name string `name` // Filename. PieceLength int `piece length` // Size of pieces. Pieces string `pieces` // The actual pieces data. Length int64 `length` }
func GenerateMetadataInfo ¶
func GenerateMetadataInfo(fqfn string) (*MetadataInfo, error)
GenerateMetadata takes a file and generates the metadata required to serve that file.
type PeerResponse ¶
type Tracker ¶
type Tracker struct { // We keep a separate set of peers for each info_hash. We don't actually verify that these // hashes are valid; so there's a pretty easy DoS here. This system is designed to be used // in a production environment with good actors. TODO: harden. // TODO: We need a way of droppign peers that have not reported in a while. PeerSeen map[string]map[string]time.Time PeerList map[string]map[string]Peer // contains filtered or unexported fields }
type Watcher ¶
type Watcher struct { Watcher *fsnotify.Watcher Directory string Files map[string]*File // FQFN as key. FilesLock sync.Mutex QuitChannel chan bool }
Watcher is instantiated for each directory we're serving files for.
func StartWatcher ¶
startWatcher creates a watcher for a given directory and starts watching it.
Click to show internal directories.
Click to hide internal directories.