https://github.com/cenkalti/rain
🌧 BitTorrent client and library in Go
https://github.com/cenkalti/rain
bittorrent golang p2p torrent
Last synced: 1 day ago
JSON representation
🌧 BitTorrent client and library in Go
- Host: GitHub
- URL: https://github.com/cenkalti/rain
- Owner: cenkalti
- License: mit
- Created: 2014-05-21T09:17:24.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2025-04-03T03:35:04.000Z (10 days ago)
- Last Synced: 2025-04-04T14:42:55.401Z (8 days ago)
- Topics: bittorrent, golang, p2p, torrent
- Language: Go
- Homepage:
- Size: 3.46 MB
- Stars: 1,036
- Watchers: 17
- Forks: 77
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - rain - BitTorrent client and library. (Distributed Systems / Search and Analytic Databases)
- awesome-repositories - cenkalti/rain - 🌧 BitTorrent client and library in Go (Go)
- go-awesome - rain - Bittorrent client and library (Open source library / The Internet)
- awesome-go-extra - rain - 05-21T09:17:24Z|2022-08-21T22:17:27Z| (Distributed Systems / Advanced Console UIs)
- awesome-go - rain - BitTorrent client and library. Stars:`1.0K`. (Distributed Systems / Search and Analytic Databases)
README
rain
====
---
BitTorrent client and library in Go. Running in production at [put.io](putio-link) since 2019. Processing thousands of torrents every day.
[](https://pkg.go.dev/github.com/cenkalti/rain/torrent?tab=doc)
[](https://github.com/cenkalti/rain/releases)
[](https://coveralls.io/github/cenkalti/rain)
[](https://goreportcard.com/report/github.com/cenkalti/rain)Features
--------
- [Core protocol](http://bittorrent.org/beps/bep_0003.html)
- [Fast extension](http://bittorrent.org/beps/bep_0006.html)
- [Magnet links](http://bittorrent.org/beps/bep_0009.html)
- [Multiple trackers](http://bittorrent.org/beps/bep_0012.html)
- [UDP trackers](http://bittorrent.org/beps/bep_0015.html)
- [DHT](http://bittorrent.org/beps/bep_0005.html)
- [PEX](http://bittorrent.org/beps/bep_0011.html)
- [Message stream encryption](http://wiki.vuze.com/w/Message_Stream_Encryption)
- [WebSeed](http://bittorrent.org/beps/bep_0019.html)
- Fast resuming
- IP blocklist
- RPC server & client
- Console UI
- Tool for creating & reading .torrent filesScreenshot
----------
Installing
----------If you are on MacOS you can install from [brew](https://brew.sh/):
```sh
brew install cenkalti/rain/rain
```Otherwise, get the latest binary from [releases page](https://github.com/cenkalti/rain/releases).
Usage as torrent client
-----------------------Rain is distributed as single binary file.
The main use case is running `rain server` command and operating the server with `rain client ` commands.
Server consists of a BitTorrent client and a RPC server.
`rain client` is used to give commands to the server.
There is also `rain client console` command which opens up a text based UI that you can view and manage the torrents on the server.
Run `rain help` to see other commands.Usage as library
----------------```go
import "github.com/cenkalti/rain/torrent"// Create a session
ses, _ := torrent.NewSession(torrent.DefaultConfig)// Add magnet link
tor, _ := ses.AddURI(magnetLink, nil)// Watch the progress
for range time.Tick(time.Second) {
s := tor.Stats()
log.Printf("Status: %s, Downloaded: %d, Peers: %d", s.Status.String(), s.Bytes.Completed, s.Peers.Total)
}
```More complete example can be found under `handleDownload` function at [main.go](https://github.com/cenkalti/rain/blob/master/main.go) file.
See [package documentation](https://pkg.go.dev/github.com/cenkalti/rain/torrent?tab=doc) for complete API.
Configuration
-------------All values have sensible defaults, so you can run Rain with an empty config but if you want to customize it's behavior,
you can pass a YAML config with `-config` flag. Config keys must be in lowercase.
See the description of values in here: [config.go](https://github.com/cenkalti/rain/blob/master/torrent/config.go)Difference from other clients
-----------------------------Rain is the main BitTorrent client used at [put.io](putio-link).
It is designed to handle hundreds of torrents while using low system resources.
One notable difference from other clients is that Rain uses a separate peer port for each torrent.
This allows Rain to download same torrent for multiple accounts in same private tracker and keep reporting their ratio correctly.Missing features
----------------The following features are not implemented in Rain, and this list should not be considered as a roadmap. These features are intentionally omitted either because they don't provide sufficient value for our use case at [put.io](putio-link), or because implementing them would add unnecessary complexity to the codebase. We prefer to maintain a focused and efficient implementation that serves our specific needs.
- [IPv6 tracker extension](http://bittorrent.org/beps/bep_0007.html)
- [IPv6 extension for DHT](http://bittorrent.org/beps/bep_0032.html)
- [uTorrent transport protocol](http://bittorrent.org/beps/bep_0029.html)
- [Superseeding](http://bittorrent.org/beps/bep_0016.html)
- [HTTP seeding](http://bittorrent.org/beps/bep_0017.html)
- [Merkle tree torrent extension](http://bittorrent.org/beps/bep_0030.html)
- uPnP port forwarding
- Selective downloading
- Sequential downloadingContributing
------------Rain is primarily developed to serve the specific requirements of [put.io](putio-link). Due to this focused purpose, feature requests that do not align with put.io's needs are likely to be rejected. Additionally, we maintain a strong preference for simplicity in implementation - complex solutions, even if technically superior, will generally not be accepted. Please keep these guidelines in mind when submitting issues or pull requests.
Star History
------------[](https://star-history.com/#cenkalti/rain&Date)
[putio-link]: https://put.io