Socket
Book a DemoInstallSign in
Socket

github.com/hktalent/dht

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/hktalent/dht

v1.3.5
Source
Go
Version published
Created
Source

image

what's the new

  • :white_check_mark: update all depend mod to new
  • :white_check_mark: update to go 1.18
  • :white_check_mark: and config.LocalNodeId
  • :white_check_mark: 45396 DHT tracker server ips,now,fly in at high speed to DHT network
  • :white_check_mark: Rich annotations
  • :white_check_mark: Friendly UML diagram rendering
  • :white_check_mark: china,please use VPN over GWF
  • :white_check_mark: fix Stuttering problem at startup
  • :white_check_mark: fix do one time bug,now to tick 30 Second to do it
  • :white_check_mark: fix public ip changed, cleanAll blackIp to do join

Introduction

DHT implements the bittorrent DHT protocol in Go. Now it includes:

  • BEP-3 (part)
  • BEP-5
  • BEP-9
  • BEP-10

It contains two modes, the standard mode and the crawling mode. The standard mode follows the BEPs, and you can use it as a standard dht server. The crawling mode aims to crawl as more metadata info as possiple. It doesn't follow the standard BEPs protocol. With the crawling mode, you can build another BTDigg.

bthub.io is a BT search engine based on the crawling mode.

Installation


go get -u github.com/hktalent/dht@latest

Example

Below is a simple spider. You can move here to see more samples.

cd sample/spider
go build spider.go
# your Elasticsearch is http://127.0.0.1:9200/dht_index
./spider -resUrl="http://127.0.0.1:9200/dht_index/_doc/" -address=":0"
open http://127.0.0.1:9200/dht_index/_search?q=GB%20and%20mp4&pretty=true
open http://127.0.0.1:9200/dht_index/_search?q=1080P%20GB%20and%20mp4&pretty=true
open http://127.0.0.1:9200/dht_index/_search?q=pentest%20pdf&pretty=true
import (
    "fmt"
    "github.com/hktalent/dht"
)

func main() {
    downloader := dht.NewWire(65535)
    go func() {
        // once we got the request result
        for resp := range downloader.Response() {
            fmt.Println(resp.InfoHash, resp.MetadataInfo)
        }
    }()
    go downloader.Run()

    config := dht.NewCrawlConfig()
    config.OnAnnouncePeer = func(infoHash, ip string, port int) {
        // request to download the metadata info
        downloader.Request([]byte(infoHash), ip, port)
    }
    d := dht.New(config)

    d.Run()
}

Download

You can download the demo compiled binary file here.

Note

  • The default crawl mode configure costs about 300M RAM. Set MaxNodes and BlackListMaxSize to fit yourself.
  • Now it cant't run in LAN because of NAT.

TODO

  • :white_check_mark: NAT Traversal.
  • :white_check_mark: Implements the full BEP-3.
  • :white_check_mark: Optimization.

FAQ

Why it is slow compared to other spiders ?

Well, maybe there are several reasons.

  • DHT aims to implements the standard BitTorrent DHT protocol, not born for crawling the DHT network.
  • NAT Traversal issue. You run the crawler in a local network.
  • It will block ip which looks like bad and a good ip may be mis-judged.

License

MIT, read more here

FAQs

Package last updated on 10 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.