Skip to content
forked from forging2012/godht

A very simple and fast DHT crawler in Golang.

License

Notifications You must be signed in to change notification settings

dimitriss/godht

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

godht

A very simple and fast DHT crawler in Golang.

Install

go get github.com/fanpei91/godht

Usage

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(),
		))
	}
}

API

func Bootstraps

func Bootstraps(addr []string) option

func LocalID

func LocalID(id []byte) option

func MaxFriendsPerSec

func MaxFriendsPerSec(n int) option

func Secret

func Secret(s string) option

type Announce

type Announce struct {
	Raw         map[string]interface{}
	From        *net.UDPAddr
	Peer        *net.TCPAddr
	Infohash    []byte
	InfohashHex string
}

type GoDHT

type GoDHT struct {
	Announce chan *Announce
}

func New

func New(laddr string, options ...option) (*GoDHT, error)

About

A very simple and fast DHT crawler in Golang.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%