Documentation
¶
Index ¶
Constants ¶
View Source
const ( FlagNone BitmapFlags = 0 FlagRequested = 1 FlagCompleted = 2 )
TODO
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByStatus ¶
type ByStatus []*Peer
ByStatus implements sort.Interface for []*Peer based on the PeerStatus field.
type HTTPTrackerResponse ¶
type HTTPTrackerResponse struct {
Interval int64 `bencode:"interval"`
Peers string `bencode:"peers"`
}
HTTPTrackerResponse TODO
type Handshake ¶
type Handshake struct {
Pstrlen byte
Pstr string
Reserved [8]byte
InfoHash [20]byte
PeerID [20]byte
}
Handshake TODO
type Peer ¶
type Peer struct {
IP net.IP
Port uint16
Choked bool
Interested bool
PeerStatus PeerStatus
ErrorReason string
PeerID [20]byte
// contains filtered or unexported fields
}
Peer TODO
func (*Peer) SetTorrent ¶
SetTorrent Funcion que setea el torrent en el tracker. Esta funcion existe para no crear una recursividad en gob
type PeerStatus ¶
type PeerStatus int
PeerStatus TODO
const ( PeerDisconnected PeerStatus = iota PeerConnected PeerError )
TODO
type Session ¶
type Session struct {
AllTorrents []*Torrent
// contains filtered or unexported fields
}
Session TODO
func NewSessionFromFile ¶
NewSessionFromFile TODO
func (*Session) AddTorrent ¶
func (s *Session) AddTorrent(tor *TorrentFile) (*Torrent, error)
AddTorrent TODO
type StatusEnum ¶
type StatusEnum int
StatusEnum TODO
const ( // Stopped Must be sent to the tracker if the client is shutting down gracefully Stopped StatusEnum = iota // Started The first request to the tracker must include the event key with this value. Started // Completed Must be sent to the tracker when the download completes. // However, must not be sent if the download was already 100% complete when the client started. Completed )
type Torrent ¶
type Torrent struct {
File *TorrentFile
Location string
Downloaded int64
Uploaded int64
Left int64
Status StatusEnum
Trackers []*Tracker
Peers []*Peer
Bitmap []PieceMap
BitmapChan chan int64
// contains filtered or unexported fields
}
Torrent TODO
type TorrentFile ¶
type TorrentFile struct {
// cadena que representa la URL del rastreador
Announce string
// (lista de cadenas opcional). Se usa para representar listas de rastreadores alternativos.
// Es una extensión a la especificación original.
RawAnnounceList [][]string `bencode:"announce-list"`
AnnounceList []string
// (entero opcional) La fecha de creación del torrent en formato de época UNIX.
RawCreationDate int64 `bencode:"creation date"`
CreationDate time.Time
// (cadena opcional) Campo libre para el creador del torrent.
Comment string
// (cadena opcional) Nombre y versión del programa usado para crear el archivo torrent.
CreatedBy string `bencode:"created-by"`
InfoHash []byte
Info struct {
// (cadena) El nombre del archivo o directorio donde se almacenarán los archivos.
Name string
// Como dijimos en la introducción, el archivo que queremos compartir es dividido en piezas.
// Este parámetro es un entero que representa el número de bytes de cada pieza.
// Piezas demasiado grandes causan ineficiencia y piezas demasiado pequeñas forman un archivo .torrent más pesado.
// Actualmente se aconseja fijar el tamaño de cada pieza en 512 KB o menos para archivos de varios GBs.
PieceLength int `bencode:"piece length"`
// Cadena que representa la concatenación de la lista de claves hash de cada parte del fichero compartido.
// Las claves hash son generadas utilizando SHA-1 con un resumen de 160 bits y un tamaño máximo por parte de 2^64 bits.
// Este conjunto de claves se utiliza como mecanismo para asegurar la integridad y consistencia de una parte, una vez ha sido completada la descarga de dicha parte.
AllPieces string `bencode:"pieces"`
Pieces [][]byte
// (opcional). Es un entero que puede tener valores 0 ó 1 y que indica si se pueden buscar pares fuera de los rastreadores explícitamente descritos en la metainformación o no.
Private bool
// (entero) Longitud del archivo en bytes.
Length int64
// (cadena opcional). Es una cadena hexadecimal de 32 caracteres correspondiente a la suma MD5 del archivo.
Md5sum string
// Sólo aparecerá en el caso de que sea un torrent multi archivo. Es una lista de diccionarios (uno para cada archivo, pero con una estructura diferente a info).
// Cada uno de estos diccionarios contendrá a su vez información sobre la longitud del archivo, la suma MD5 y una ruta (path) en donde debe ubicarse el archivo en la jerarquía de directorios.
Files []File
}
}
TorrentFile TODO
type Tracker ¶
type Tracker struct {
Protocol Protocol
URL string
LastError string
Status TrackerStatus
// contains filtered or unexported fields
}
Tracker TODO
func (*Tracker) SetTorrent ¶
SetTorrent Funcion que setea el torrent en el tracker. Esta funcion existe para no crear una recursividad en gob
type TrackerStatus ¶
type TrackerStatus int
TrackerStatus TODO
const ( NotConnected TrackerStatus = iota Connected Error )
TODO
Click to show internal directories.
Click to hide internal directories.