Documentation
¶
Index ¶
- Constants
- func Address(ip int32, port uint16) string
- func Init(meta *MetaData.MetaInfo)
- type BitArray
- type BlobStorage
- type FileStorage
- type HandshakeData
- type Manager
- type PeerClient
- func (this *PeerClient) BitField(size int)
- func (this *PeerClient) Close()
- func (this *PeerClient) Connect(peer tracker.Peer)
- func (this *PeerClient) HandleResponse()
- func (this *PeerClient) Have()
- func (this *PeerClient) Init()
- func (this *PeerClient) Piece(size int)
- func (this *PeerClient) Request()
- func (this *PeerClient) SendChoked()
- func (this *PeerClient) SendInterested()
- func (this *PeerClient) SendPiece(index, offset, size int)
- func (this *PeerClient) SendPieceRquest()
- func (this *PeerClient) SendUnchoked()
- func (this *PeerClient) SendUninterested()
- type Piece
- type PieceRequest
- type PiecesInfo
- type TorrentStats
Constants ¶
View Source
const ( DOWNLOADEDPIECE = iota UPLOADEDPIECE FAILEDPIECE AVAILABLE_PIECES ADD_ACTIVE_PEER DELETE_ACTIVE_PEER ADD_PEER DELETE_PEER )
View Source
const ( RETRYCOUNT = 1 BLOCKSIZE = 65536 MAXMEMORY = 1024 * 1024 * 10 )
View Source
const ( CHOKED = iota UNCHOKED INTERESTED UNINTERESTED HAVE BITFIELD REQUEST PIECE )
View Source
const ( KB = 1024 MB = 1024 * 1024 MIN = 60 HOUR = 3600 )
View Source
const (
TIMEOUT = 20
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BitArray ¶
type BitArray struct {
// contains filtered or unexported fields
}
func (*BitArray) UnlockPiece ¶
type BlobStorage ¶
type BlobStorage struct {
// contains filtered or unexported fields
}
func (*BlobStorage) GetBlock ¶
func (this *BlobStorage) GetBlock(index, offset, size int) []byte
func (*BlobStorage) Init ¶
func (this *BlobStorage) Init(meta *MetaData.MetaInfo) bool
Returns status if file created
func (*BlobStorage) PutBlock ¶
func (this *BlobStorage) PutBlock(data *[]byte, index int)
type FileStorage ¶
type FileStorage struct {
MultipleFiles bool
// contains filtered or unexported fields
}
func (*FileStorage) GetBlock ¶
func (this *FileStorage) GetBlock(index, offset, size int) []byte
func (*FileStorage) PutBlock ¶
func (this *FileStorage) PutBlock(data *[]byte, index int)
type HandshakeData ¶
type Manager ¶
type Manager struct {
MetaData *MetaData.MetaInfo
Blocks PiecesInfo
InfoHash [20]byte
PeerId [20]byte
PeerMap map[[20]byte]*PeerClient
MapLock sync.Mutex
Storage storage
Stats TorrentStats
}
func (*Manager) StorePiece ¶
type PeerClient ¶
func (*PeerClient) BitField ¶
func (this *PeerClient) BitField(size int)
func (*PeerClient) Close ¶
func (this *PeerClient) Close()
func (*PeerClient) Connect ¶
func (this *PeerClient) Connect(peer tracker.Peer)
func (*PeerClient) HandleResponse ¶
func (this *PeerClient) HandleResponse()
Handles all the Peer Wire protocol messages
func (*PeerClient) Have ¶
func (this *PeerClient) Have()
func (*PeerClient) Init ¶
func (this *PeerClient) Init()
func (*PeerClient) Piece ¶
func (this *PeerClient) Piece(size int)
func (*PeerClient) Request ¶
func (this *PeerClient) Request()
Incomplete function Receives 12 byte piece info
func (*PeerClient) SendChoked ¶
func (this *PeerClient) SendChoked()
func (*PeerClient) SendInterested ¶
func (this *PeerClient) SendInterested()
func (*PeerClient) SendPiece ¶
func (this *PeerClient) SendPiece(index, offset, size int)
func (*PeerClient) SendPieceRquest ¶
func (this *PeerClient) SendPieceRquest()
func (*PeerClient) SendUnchoked ¶
func (this *PeerClient) SendUnchoked()
func (*PeerClient) SendUninterested ¶
func (this *PeerClient) SendUninterested()
type PieceRequest ¶
type PiecesInfo ¶
type TorrentStats ¶
type TorrentStats struct {
DownloadedPieces int
UploadedPieces int
FailedPieces int
AvailablePieces int
TotalBytesDownloaded int
TotalBytesUploaded int
ActivePeers int
TotalPeers int
TimeStart time.Time
TimeElapsed int
PieceChan chan int
DownloadChan chan int
UploadChan chan int
}
func (*TorrentStats) Init ¶
func (this *TorrentStats) Init()
Source Files
¶
Click to show internal directories.
Click to hide internal directories.