A very simple and fast DHT crawler in Golang.
go get github.com/fanpei91/godht
package main
import (
"fmt"
"github.com/fanpei91/godht"
)
func main() {
laddr, maxFriendsPerSec := "0.0.0.0:6331", 500
dht, err := godht.New(laddr, godht.MaxFriendsPerSec(maxFriendsPerSec))
if err != nil {
panic(err)
}
for announce := range dht.Announce {
fmt.Println(fmt.Sprintf("link: magnet:?xt=urn:btih:%v\nnode: %s\npeer: %s\n",
announce.InfohashHex,
announce.From.String(),
announce.Peer.String(),
))
}
}
func Bootstraps(addr []string) option
func LocalID(id []byte) option
func MaxFriendsPerSec(n int) option
func Secret(s string) option
type Announce struct {
Raw map[string]interface{}
From *net.UDPAddr
Peer *net.TCPAddr
Infohash []byte
InfohashHex string
}
type GoDHT struct {
Announce chan *Announce
}
func New(laddr string, options ...option) (*GoDHT, error)