Documentation ¶
Index ¶
- Constants
- Variables
- func BitsInByte(b byte) int
- func ConvertNodeToBytes(nodes []Node) []byte
- func ConvertPeerToBytes(peers []*Peer) []string
- func Distance(src, dst NodeID) int
- func GNUAddHistory(line string)
- func GNUReadLine(prompt string) (string, bool)
- func GoReadLine(prompt string) (string, bool)
- func KRPCEncode(m *Message) (string, error)
- func KRPCEncodeAnnouncePeer(tid string, local string, infoHash string, port int, token string, ...) (string, error)
- func KRPCEncodeAnnouncePeerResponse(tid string, local string) (string, error)
- func KRPCEncodeError(tid string, code int, desc string) (string, error)
- func KRPCEncodeFindNode(tid string, local string, target string) (string, error)
- func KRPCEncodeFindNodeResponse(tid string, local string, nodes []Node) (string, error)
- func KRPCEncodeGetPeers(tid string, local string, infoHash string) (string, error)
- func KRPCEncodeGetPeersResponse(tid string, local string, token string, nodes []Node, values []*Peer) (string, error)
- func KRPCEncodePing(tid string, local string) (string, error)
- func KRPCEncodePingResponse(tid string, local string) (string, error)
- func KRPCValidate(data []byte) bool
- func RunClient(ctx context.Context, master chan string, logger *logrus.Logger)
- type AnnouncePeerQuery
- type AnnouncePeerResponse
- type DecodeError
- type EncodeError
- type Err
- type FindNodeQuery
- type FindNodeResponse
- type GetPeersQuery
- type GetPeersResponse
- type Kademila
- type Message
- func KRPCDecode(raw *RawData) (*Message, error)
- func KRPCNewAnnouncePeer(local NodeID, infoHash string, port int, token string, impliedPort bool, ...) *Message
- func KRPCNewAnnouncePeerResponse(tid string, local NodeID) *Message
- func KRPCNewError(tid string, q string, code int) *Message
- func KRPCNewFindNode(local NodeID, target NodeID, worker int) *Message
- func KRPCNewFindNodeResponse(tid string, local NodeID, nodes []Node) *Message
- func KRPCNewGetPeers(local NodeID, infoHash NodeID, worker int) *Message
- func KRPCNewGetPeersResponse(tid string, local NodeID, token string, nodes []Node, values []*Peer) *Message
- func KRPCNewPing(local NodeID, worker int) *Message
- func KRPCNewPingResponse(tid string, local NodeID) *Message
- type Node
- type NodeContext
- type NodeID
- type ParseError
- type Peer
- type PingQuery
- type PingResponse
- type RawData
- type TokenBuilder
Constants ¶
View Source
const ( INIT = iota GOOD = iota QUESTIONABLE = iota BAD = iota )
View Source
const ( Running = iota Suspend = iota Finished = iota )
View Source
const APPNAME = "DHTRobot"
View Source
const BucketLastChangedTimeLimit = 15 // minutes
View Source
const FindNodeTimeLimit = 120 // seconds
View Source
const FinderNum = 2
View Source
const K int = 8
Bucket size
View Source
const MAXSIZE = 2048
View Source
const MaxBitsLength = 160
View Source
const MaxUnchangedCount = 5000
View Source
const NodeRefreshnessTimeLimit = 60 // seconds
View Source
const PingNodeTimeLimit = 30 // seconds
View Source
const RequestTimeout = 10 // seconds
View Source
const TokenTimeLimit = 300 // seconds
View Source
const UndefinedWorker = -1
View Source
const VERSION = "0.1.0"
Variables ¶
View Source
var BOOTSTRAP = []string{
"router.bittorrent.com:6881",
"dht.transmissionbt.com:6881",
"service.ygrek.org.ua:6881",
"router.utorrent.com:6881",
"router.transmission.com:6881",
}
Bootstrap nodes
View Source
var ErrorDefinitions = map[int]string{ GenericError: "Generic Error", ServerError: "Server Error", ProtocolError: "Protocol Error", MethodUnknown: "Method Unknown", }
View Source
var FilteredClients = map[string]bool{ "LT(0.17)": true, }
View Source
var GenericError = 201
View Source
var MethodUnknown = 204
View Source
var ProtocolError = 203
View Source
var ServerError = 202
Functions ¶
func BitsInByte ¶
func ConvertNodeToBytes ¶
func ConvertPeerToBytes ¶
func GNUAddHistory ¶
func GNUAddHistory(line string)
func GNUReadLine ¶
func GoReadLine ¶
func KRPCEncode ¶
func KRPCEncodeAnnouncePeer ¶
func KRPCEncodeFindNode ¶
func KRPCEncodeGetPeers ¶
func KRPCValidate ¶
Types ¶
type AnnouncePeerQuery ¶
func (*AnnouncePeerQuery) String ¶
func (q *AnnouncePeerQuery) String() string
type AnnouncePeerResponse ¶
type AnnouncePeerResponse struct {
ID string
}
func (*AnnouncePeerResponse) String ¶
func (r *AnnouncePeerResponse) String() string
type DecodeError ¶
type DecodeError struct {
What string
}
func (DecodeError) Error ¶
func (e DecodeError) Error() string
type EncodeError ¶
type EncodeError struct {
What string
}
func (EncodeError) Error ¶
func (e EncodeError) Error() string
type FindNodeQuery ¶
func (*FindNodeQuery) String ¶
func (q *FindNodeQuery) String() string
type FindNodeResponse ¶
func (*FindNodeResponse) String ¶
func (r *FindNodeResponse) String() string
type GetPeersQuery ¶
func (*GetPeersQuery) String ¶
func (q *GetPeersQuery) String() string
type GetPeersResponse ¶
func (*GetPeersResponse) String ¶
func (r *GetPeersResponse) String() string
type Kademila ¶
type Kademila struct { Chan chan string // contains filtered or unexported fields }
func (*Kademila) AnnouncePeers ¶
type Message ¶
type Message struct { N Node //The transaction ID should be encoded as a short string of binary numbers, //typically 2 characters are enough as they cover 2^16 outstanding queries. T string //Every message also has a key "y" with a single character value describing the type of message. [q|r|e] Y string //The string should be a two character client identifier registered in BEP 20 [3] followed by a two character version identifier. //Not all implementations include a "v" key so clients should not assume its presence. V string Q string W int A interface{} }
func KRPCDecode ¶
func KRPCNewAnnouncePeer ¶
func KRPCNewFindNodeResponse ¶
func KRPCNewGetPeersResponse ¶
func KRPCNewPing ¶
func KRPCNewPingResponse ¶
type Node ¶
func ParseNodes ¶
type NodeContext ¶
type NodeContext struct { Local Node Log *logrus.Logger Conn net.PacketConn Master chan string Outgoing chan *Message Incoming chan RawData Writer io.Writer // contains filtered or unexported fields }
func FromContext ¶
func FromContext(ctx context.Context) (*NodeContext, bool)
type ParseError ¶
type ParseError struct {
What string
}
func (ParseError) Error ¶
func (e ParseError) Error() string
type Peer ¶
func ParsePeers ¶
type PingResponse ¶
type PingResponse struct {
ID string
}
func (*PingResponse) String ¶
func (r *PingResponse) String() string
type TokenBuilder ¶
type TokenBuilder struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.