Documentation ¶
Index ¶
- Constants
- Variables
- func ResolveNodes(nodes []byte) (peers map[ID][]byte)
- func ResolvePeer(peer []byte) (ip string, port int)
- type Bucket
- func (b *Bucket) Capacity() int
- func (b *Bucket) Count() int
- func (b *Bucket) Find(id *ID) (node *Node)
- func (b *Bucket) Insert(id *ID, addr *net.UDPAddr) (n *Node)
- func (b *Bucket) Map(f func(n *Node) bool)
- func (b *Bucket) Random() *Node
- func (b *Bucket) Remove(id *ID)
- func (b *Bucket) String() string
- func (b *Bucket) Time() time.Time
- func (b *Bucket) Update()
- type CallBack
- type DHT
- func (d *DHT) Addr() *net.UDPAddr
- func (d *DHT) Conn() *net.UDPConn
- func (d *DHT) DoTimer(secret, node, peer, search time.Duration)
- func (d *DHT) FindNode(id *ID) (err error)
- func (d *DHT) FindNodeFromAddr(id *ID, addr *net.UDPAddr) error
- func (d *DHT) FindNodeFromAddrs(id *ID, addrs []*net.UDPAddr) (int, error)
- func (d *DHT) GetPeers(tor *ID) [][]byte
- func (d *DHT) HandleMessage(addr *net.UDPAddr, data []byte, t *Tracker) (err error)
- func (d *DHT) ID() *ID
- func (d *DHT) Ping(addr *net.UDPAddr) error
- func (d *DHT) Route() *Table
- func (d *DHT) Search(tor *ID, cb CallBack) (tid int16, err error)
- type ErrorTracker
- type ID
- type Node
- type QueryTracker
- type ReplyTracker
- type Table
- type Tracker
Constants ¶
View Source
const IDLen = 20
IDLen []byte len
Variables ¶
View Source
var ZeroID = new(ID)
ZeroID "0000000000000000000000000000000000000000"
Functions ¶
func ResolveNodes ¶
ResolveNodes returns peers
func ResolvePeer ¶
ResolvePeer returns ip and port
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket manage node
type DHT ¶
type DHT struct {
// contains filtered or unexported fields
}
DHT server
func (*DHT) FindNodeFromAddr ¶
FindNodeFromAddr find node from address
func (*DHT) FindNodeFromAddrs ¶
FindNodeFromAddrs find node from some address
func (*DHT) HandleMessage ¶
HandleMessage handle udp packet
type ErrorTracker ¶
ErrorTracker interface
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represent a dht node
type QueryTracker ¶
type QueryTracker interface { Ping(id *ID) FindNode(id *ID, target *ID) GetPeers(id *ID, tor *ID) AnnouncePeer(id *ID, tor *ID, peer []byte) }
QueryTracker interface
type ReplyTracker ¶
type ReplyTracker interface { Ping(id *ID) FindNode(id *ID, nodes []byte) GetPeers(id *ID, peers [][]byte, nodes []byte) AnnouncePeer(id *ID) }
ReplyTracker interface
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table store all nodes
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker struct
func NewTracker ¶
func NewTracker(q QueryTracker, r ReplyTracker, e ErrorTracker) *Tracker
NewTracker returns tracker
Source Files ¶
Click to show internal directories.
Click to hide internal directories.