godht

package module
v0.0.0-...-4c9bd28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2017 License: MIT Imports: 10 Imported by: 0

README

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)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BootstrapNodes = []string{
	"router.bittorrent.com:6881",
	"dht.transmissionbt.com:6881",
	"router.utorrent.com:6881",
}

Functions

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

Types

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
	// contains filtered or unexported fields
}

func New

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL