{"id":13464537,"url":"https://github.com/shiyanhui/dht","last_synced_at":"2025-05-15T02:06:56.654Z","repository":{"id":37735571,"uuid":"65117543","full_name":"shiyanhui/dht","owner":"shiyanhui","description":"BitTorrent DHT Protocol \u0026\u0026 DHT Spider.","archived":false,"fork":false,"pushed_at":"2021-08-17T01:48:19.000Z","size":10820,"stargazers_count":2751,"open_issues_count":13,"forks_count":489,"subscribers_count":122,"default_branch":"master","last_synced_at":"2025-04-13T23:55:16.357Z","etag":null,"topics":["bittorrent-dht-protocol","dht","go","spider"],"latest_commit_sha":null,"homepage":"http://bthub.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shiyanhui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-07T05:35:02.000Z","updated_at":"2025-04-10T10:05:09.000Z","dependencies_parsed_at":"2022-07-12T15:18:25.370Z","dependency_job_id":null,"html_url":"https://github.com/shiyanhui/dht","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiyanhui%2Fdht","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiyanhui%2Fdht/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiyanhui%2Fdht/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shiyanhui%2Fdht/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shiyanhui","download_url":"https://codeload.github.com/shiyanhui/dht/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254259383,"owners_count":22040820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bittorrent-dht-protocol","dht","go","spider"],"created_at":"2024-07-31T14:00:45.708Z","updated_at":"2025-05-15T02:06:56.635Z","avatar_url":"https://github.com/shiyanhui.png","language":"Go","readme":"![](https://raw.githubusercontent.com/shiyanhui/dht/master/doc/screen-shot.png)\n\nSee the video on the [Youtube](https://www.youtube.com/watch?v=AIpeQtw22kc).\n\n[中文版README](https://github.com/shiyanhui/dht/blob/master/README_CN.md)\n\n## Introduction\n\nDHT implements the bittorrent DHT protocol in Go. Now it includes:\n\n- [BEP-3 (part)](http://www.bittorrent.org/beps/bep_0003.html)\n- [BEP-5](http://www.bittorrent.org/beps/bep_0005.html)\n- [BEP-9](http://www.bittorrent.org/beps/bep_0009.html)\n- [BEP-10](http://www.bittorrent.org/beps/bep_0010.html)\n\nIt contains two modes, the standard mode and the crawling mode. The standard\nmode follows the BEPs, and you can use it as a standard dht server. The crawling\nmode aims to crawl as more metadata info as possiple. It doesn't follow the\nstandard BEPs protocol. With the crawling mode, you can build another [BTDigg](http://btdigg.org/).\n\n[bthub.io](http://bthub.io) is a BT search engine based on the crawling mode.\n\n## Installation\n\n    go get github.com/shiyanhui/dht\n\n## Example\n\nBelow is a simple spider. You can move [here](https://github.com/shiyanhui/dht/blob/master/sample)\nto see more samples.\n\n```go\nimport (\n    \"fmt\"\n    \"github.com/shiyanhui/dht\"\n)\n\nfunc main() {\n    downloader := dht.NewWire(65535)\n    go func() {\n        // once we got the request result\n        for resp := range downloader.Response() {\n            fmt.Println(resp.InfoHash, resp.MetadataInfo)\n        }\n    }()\n    go downloader.Run()\n\n    config := dht.NewCrawlConfig()\n    config.OnAnnouncePeer = func(infoHash, ip string, port int) {\n        // request to download the metadata info\n        downloader.Request([]byte(infoHash), ip, port)\n    }\n    d := dht.New(config)\n\n    d.Run()\n}\n```\n\n## Download\n\nYou can download the demo compiled binary file [here](https://github.com/shiyanhui/dht/files/407021/spider.zip).\n\n## Note\n\n- The default crawl mode configure costs about 300M RAM. Set **MaxNodes**\n  and **BlackListMaxSize** to fit yourself.\n- Now it cant't run in LAN because of NAT.\n\n## TODO\n\n- [ ] NAT Traversal.\n- [ ] Implements the full BEP-3.\n- [ ] Optimization.\n\n## FAQ\n\n#### Why it is slow compared to other spiders ?\n\nWell, maybe there are several reasons.\n\n- DHT aims to implements the standard BitTorrent DHT protocol, not born for crawling the DHT network.\n- NAT Traversal issue. You run the crawler in a local network.\n- It will block ip which looks like bad and a good ip may be mis-judged.\n\n## License\n\nMIT, read more [here](https://github.com/shiyanhui/dht/blob/master/LICENSE)\n","funding_links":[],"categories":["All","Go","Go (531)","Repositories"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiyanhui%2Fdht","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshiyanhui%2Fdht","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiyanhui%2Fdht/lists"}