Documentation ¶
Index ¶
- func Read(r io.Reader, data interface{}) error
- func Write(w io.Writer, data interface{}) error
- type Action
- type AnnounceEvent
- type AnnounceRequest
- type AnnounceResponseHeader
- type AnnounceResponsePeers
- type Client
- type ConnClient
- type ConnectionId
- type ConnectionRequest
- type ConnectionResponse
- type DispatchedResponse
- type Dispatcher
- type InfoHash
- type NewConnClientOpts
- type Options
- type RequestHeader
- type ResponseHeader
- type ScrapeInfohashResult
- type ScrapeRequest
- type ScrapeResponse
- type Transaction
- type TransactionId
- type TransactionResponseHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AnnounceEvent ¶
type AnnounceEvent int32
func (AnnounceEvent) String ¶
func (e AnnounceEvent) String() string
type AnnounceRequest ¶
type AnnounceRequest struct { InfoHash [20]byte PeerId [20]byte Downloaded int64 Left int64 // If less than 0, math.MaxInt64 will be used for HTTP trackers instead. Uploaded int64 // Apparently this is optional. None can be used for announces done at // regular intervals. Event AnnounceEvent IPAddress uint32 Key int32 NumWant int32 // How many peer addresses are desired. -1 for default. Port uint16 } // 82 bytes
Marshalled as binary by the UDP client, so be careful making changes.
type AnnounceResponseHeader ¶
type AnnounceResponsePeers ¶
type AnnounceResponsePeers interface { encoding.BinaryUnmarshaler NodeAddrs() []krpc.NodeAddr }
type Client ¶
type Client struct { Dispatcher *Dispatcher Writer io.Writer // contains filtered or unexported fields }
func (*Client) Announce ¶
func (cl *Client) Announce( ctx context.Context, req AnnounceRequest, peers AnnounceResponsePeers, opts Options, ) ( respHdr AnnounceResponseHeader, err error, )
type ConnClient ¶
type ConnClient struct { Client Client // contains filtered or unexported fields }
func NewConnClient ¶
func NewConnClient(opts NewConnClientOpts) (cc *ConnClient, err error)
func (*ConnClient) Announce ¶
func (c *ConnClient) Announce( ctx context.Context, req AnnounceRequest, opts Options, ) ( h AnnounceResponseHeader, nas AnnounceResponsePeers, err error, )
func (*ConnClient) Close ¶
func (c *ConnClient) Close() error
type ConnectionId ¶
type ConnectionId = int64
type ConnectionRequest ¶
type ConnectionRequest struct { ConnectionId ConnectionId Action Action TransactionId TransactionId }
type ConnectionResponse ¶
type ConnectionResponse struct {
ConnectionId ConnectionId
}
type DispatchedResponse ¶
type DispatchedResponse struct { Header ResponseHeader Body []byte }
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func (*Dispatcher) NewTransaction ¶
func (me *Dispatcher) NewTransaction(h TransactionResponseHandler) Transaction
type NewConnClientOpts ¶
type RequestHeader ¶
type RequestHeader struct { ConnectionId ConnectionId Action Action TransactionId TransactionId } // 16 bytes
type ResponseHeader ¶
type ResponseHeader struct { Action Action TransactionId TransactionId }
type ScrapeInfohashResult ¶
type ScrapeRequest ¶
type ScrapeRequest []InfoHash
type ScrapeResponse ¶
type ScrapeResponse []ScrapeInfohashResult
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func (*Transaction) End ¶
func (t *Transaction) End()
func (*Transaction) Id ¶
func (t *Transaction) Id() TransactionId
type TransactionId ¶
type TransactionId = int32
func RandomTransactionId ¶
func RandomTransactionId() TransactionId
type TransactionResponseHandler ¶
type TransactionResponseHandler func(dr DispatchedResponse)
Click to show internal directories.
Click to hide internal directories.