Documentation ¶
Index ¶
- type CompactNodeInfo
- type CompactNodeInfos
- type CompactPeer
- type CompactPeers
- type Error
- type Message
- func NewAnnouncePeerQuery(id []byte, implied_port bool, info_hash []byte, port uint16, token []byte) *Message
- func NewAnnouncePeerResponse(t []byte, id []byte) *Message
- func NewFindNodeQuery(id []byte, target []byte) *Message
- func NewFindNodeResponse(t []byte, id []byte, nodes []CompactNodeInfo) *Message
- func NewGetPeersQuery(id []byte, info_hash []byte) *Message
- func NewGetPeersResponseWithNodes(t []byte, id []byte, token []byte, nodes []CompactNodeInfo) *Message
- func NewGetPeersResponseWithValues(t []byte, id []byte, token []byte, values []CompactPeer) *Message
- func NewPingQuery(id []byte) *Message
- func NewPingResponse(t []byte, id []byte) *Message
- type Protocol
- type ProtocolEventHandlers
- type QueryArguments
- type ResponseValues
- type Transport
- type TrawlingResult
- type TrawlingService
- type TrawlingServiceEventHandlers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompactNodeInfo ¶
func UnmarshalCompactNodeInfos ¶
func UnmarshalCompactNodeInfos(b []byte) (ret []CompactNodeInfo, err error)
func (CompactNodeInfo) MarshalBinary ¶
func (cni CompactNodeInfo) MarshalBinary() []byte
func (*CompactNodeInfo) UnmarshalBinary ¶
func (cni *CompactNodeInfo) UnmarshalBinary(b []byte) error
type CompactNodeInfos ¶
type CompactNodeInfos []CompactNodeInfo
func (CompactNodeInfos) MarshalBencode ¶
func (cnis CompactNodeInfos) MarshalBencode() ([]byte, error)
func (*CompactNodeInfos) UnmarshalBencode ¶
func (cnis *CompactNodeInfos) UnmarshalBencode(b []byte) (err error)
This allows bencode.Unmarshal to do better than a string or []byte.
type CompactPeer ¶
Represents peer address in either IPv6 or IPv4 form.
func UnmarshalCompactPeers ¶
func UnmarshalCompactPeers(b []byte) (ret []CompactPeer, err error)
func (CompactPeer) MarshalBencode ¶
func (cp CompactPeer) MarshalBencode() (ret []byte, err error)
func (*CompactPeer) UnmarshalBencode ¶
func (cp *CompactPeer) UnmarshalBencode(b []byte) (err error)
func (*CompactPeer) UnmarshalBinary ¶
func (cp *CompactPeer) UnmarshalBinary(b []byte) error
type CompactPeers ¶
type CompactPeers []CompactPeer
func (CompactPeers) MarshalBinary ¶
func (cps CompactPeers) MarshalBinary() (ret []byte, err error)
func (*CompactPeers) UnmarshalBencode ¶
func (cps *CompactPeers) UnmarshalBencode(b []byte) (err error)
This allows bencode.Unmarshal to do better than a string or []byte.
type Message ¶
type Message struct { // Query method (one of 4: "ping", "find_node", "get_peers", "announce_peer") Q string `bencode:"q,omitempty"` // named QueryArguments sent with a query A QueryArguments `bencode:"a,omitempty"` // required: transaction ID T []byte `bencode:"t"` // required: type of the message: q for QUERY, r for RESPONSE, e for ERROR Y string `bencode:"y"` // RESPONSE type only R ResponseValues `bencode:"r,omitempty"` // ERROR type only E Error `bencode:"e,omitempty"` }
func NewAnnouncePeerQuery ¶
func NewAnnouncePeerResponse ¶
func NewFindNodeQuery ¶
func NewFindNodeResponse ¶
func NewFindNodeResponse(t []byte, id []byte, nodes []CompactNodeInfo) *Message
func NewGetPeersQuery ¶
func NewGetPeersResponseWithNodes ¶
func NewGetPeersResponseWithNodes(t []byte, id []byte, token []byte, nodes []CompactNodeInfo) *Message
func NewGetPeersResponseWithValues ¶
func NewGetPeersResponseWithValues(t []byte, id []byte, token []byte, values []CompactPeer) *Message
func NewPingQuery ¶
func NewPingResponse ¶
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
func NewProtocol ¶
func NewProtocol(laddr string, eventHandlers ProtocolEventHandlers) (p *Protocol)
type ProtocolEventHandlers ¶
type ProtocolEventHandlers struct { OnPingQuery func(*Message, *net.UDPAddr) OnFindNodeQuery func(*Message, *net.UDPAddr) OnGetPeersQuery func(*Message, *net.UDPAddr) OnAnnouncePeerQuery func(*Message, *net.UDPAddr) OnGetPeersResponse func(*Message, *net.UDPAddr) OnFindNodeResponse func(*Message, *net.UDPAddr) OnPingORAnnouncePeerResponse func(*Message, *net.UDPAddr) OnCongestion func() }
type QueryArguments ¶
type QueryArguments struct { // ID of the quirying Node ID []byte `bencode:"id"` // InfoHash of the torrent InfoHash []byte `bencode:"info_hash,omitempty"` // ID of the node sought Target []byte `bencode:"target,omitempty"` // Token received from an earlier get_peers query Token []byte `bencode:"token,omitempty"` // Senders torrent port Port int `bencode:"port,omitempty"` // Use senders apparent DHT port ImpliedPort int `bencode:"implied_port,omitempty"` // Indicates whether the querying node is seeding the torrent it announces. // Defined in BEP 33 "DHT Scrapes" for `announce_peer` queries. Seed int `bencode:"seed,omitempty"` // If 1, then the responding node should try to fill the `values` list with non-seed items on a // best-effort basis." // Defined in BEP 33 "DHT Scrapes" for `get_peers` queries. NoSeed int `bencode:"noseed,omitempty"` // If 1, then the responding node should add two fields to the "r" dictionary in the response: // - `BFsd`: Bloom Filter (256 bytes) representing all stored seeds for that infohash // - `BFpe`: Bloom Filter (256 bytes) representing all stored peers (leeches) for that // infohash // Defined in BEP 33 "DHT Scrapes" for `get_peers` queries. Scrape int `bencode:"noseed,omitempty"` }
type ResponseValues ¶
type ResponseValues struct { // ID of the querying node ID []byte `bencode:"id"` // K closest nodes to the requested target Nodes CompactNodeInfos `bencode:"nodes,omitempty"` // Token for future announce_peer Token []byte `bencode:"token,omitempty"` // Torrent peers Values []CompactPeer `bencode:"values,omitempty"` // If `scrape` is set to 1 in the `get_peers` query then the responding node should add the // below two fields to the "r" dictionary in the response: // Defined in BEP 33 "DHT Scrapes" for responses to `get_peers` queries. // Bloom Filter (256 bytes) representing all stored seeds for that infohash: BFsd *bloom.BloomFilter `bencode:"BFsd,omitempty"` // Bloom Filter (256 bytes) representing all stored peers (leeches) for that infohash: BFpe *bloom.BloomFilter `bencode:"BFpe,omitempty"` }
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
func NewTransport ¶
type TrawlingResult ¶
type TrawlingService ¶
type TrawlingService struct {
// contains filtered or unexported fields
}
func NewTrawlingService ¶
func NewTrawlingService(laddr string, initialMaxNeighbors uint, interval time.Duration, eventHandlers TrawlingServiceEventHandlers) *TrawlingService
func (*TrawlingService) Start ¶
func (s *TrawlingService) Start()
func (*TrawlingService) Terminate ¶
func (s *TrawlingService) Terminate()
type TrawlingServiceEventHandlers ¶
type TrawlingServiceEventHandlers struct {
OnResult func(TrawlingResult)
}
Click to show internal directories.
Click to hide internal directories.