MCPcopy Index your code
hub / github.com/yann-shi/dht

github.com/yann-shi/dht @v0.1 sqlite

repository ↗ · DeepWiki ↗ · release v0.1 ↗
211 symbols 647 edges 16 files 180 documented · 85%
README

DHT

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

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 spide as more medata info as possiple. It doesn't follow the standard BEPs protocol. With the crawling mode, you can build another Pirate Bay.

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

Install

go get github.com/shiyanhui/dht

Example

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

import (
    "fmt"
    "github.com/shiyanhui/dht"
)

func main() {
    downloader := dht.NewWire()
    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()
}

License

MIT.

Core symbols most depended-on inside this repo

String
called by 35
bitmap.go
RawString
called by 23
bitmap.go
KBucket
called by 19
routingtable.go
send
called by 18
krpc.go
Set
called by 16
bitmap.go
Get
called by 16
container.go
Bit
called by 14
bitmap.go
Iter
called by 12
container.go

Shape

Method 104
Function 79
Struct 27
TypeAlias 1

Languages

Go100%

Modules by API surface

routingtable.go50 symbols
krpc.go40 symbols
container.go31 symbols
peerwire.go17 symbols
dht.go13 symbols
bitmap.go13 symbols
bencode.go13 symbols
util.go8 symbols
blacklist.go8 symbols
util_test.go4 symbols
bencode_test.go4 symbols
sample/spider/spider.go3 symbols

For agents

$ claude mcp add dht \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact