Skip to content

JoelVCrasta/clover

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

139 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Clover

Clover (πŸ€) is a lightweight, fast, leech-only torrent client written in Go. It implements the core BitTorrent protocol to download torrents directly from the terminal.

Features

  • Torrent parsing - Implements an encoder and decoder for parsing bencode encoded .torrent files.
  • Dual peer discovery - Finds peers via both UDP trackers and the DHT network, merging them into a single stream.
  • Concurrent downloads - Manages multiple peer connections to download pieces simultaneously.
  • Session management - Supports resuming and deleting stopped downloads.
  • Clean CLI stats - Real-time stats showing a progress bar, percentage completed, pieces downloaded, active peer count, and time elapsed.

Getting Started

Prerequisites

  • Go

Installation

1. Install Pre-compiled Binary

You can install the latest pre-compiled binary of Clover automatically.

Linux & macOS

Run the following command in your terminal to download and run the installer:

curl -fsSL https://raw.githubusercontent.com/JoelVCrasta/clover/main/scripts/install.sh | sh

Note: By default, this installs the binary to /usr/local/bin. If write permission is denied, it will prompt for sudo. To install to a different directory, download the script and specify BIN_DIR, for example:

curl -fsSL https://raw.githubusercontent.com/JoelVCrasta/clover/main/scripts/install.sh -o install.sh
chmod +x install.sh
BIN_DIR=$HOME/.local/bin ./install.sh
Windows

Run the following command in PowerShell:

irm https://raw.githubusercontent.com/JoelVCrasta/clover/main/scripts/install.ps1 | iex

Note: This downloads clover.exe to $HOME\.clover\bin and appends it to your User PATH environment variable. You will need to restart your terminal after installation.

2. Build from Source

If you have Go installed and want to build the executable from source:

git clone https://github.com/JoelVCrasta/clover.git
cd clover
go build ./cmd/clover

Usage & Commands

1. Download a Torrent

To download a torrent, use the download subcommand. The --input (-i) flag is required.

# Using go run:
go run ./cmd/clover/main.go download -i <path-to-torrent-file> -o <output-directory>

# Using the built binary:
clover download -i <path-to-torrent-file> -o <output-directory>

If the output flag is not provided, then it will download to the ~/Downloads directory.

Examples:

# Download to a specific directory
clover download -i ~/downloads/ubuntu.torrent -o ~/downloads/

# Download to the default ~/Downloads directory
clover download -i ~/downloads/ubuntu.torrent

2. List Paused Downloads

To see the list of paused downloads:

clover list

3. Resume a Download

To resume a paused download by its index (from the list command):

clover resume <index>

4. Delete a Download Session

To delete a download session by its index (from the list command):

clover delete <index>

Project Structure

.
β”œβ”€β”€ client
β”‚   β”œβ”€β”€ bitfield.go
β”‚   └── client.go
β”œβ”€β”€ cmd
β”‚   β”œβ”€β”€ clover
β”‚   β”‚   └── main.go
β”‚   └── example
β”‚       └── main.go
β”œβ”€β”€ config
β”‚   └── config.go
β”œβ”€β”€ dht
β”‚   └── dht.go
β”œβ”€β”€ download
β”‚   β”œβ”€β”€ download.go
β”‚   β”œβ”€β”€ state.go
β”‚   └── save.go
β”œβ”€β”€ handshake
β”‚   └── handshake.go
β”œβ”€β”€ message
β”‚   └── message.go
β”œβ”€β”€ metainfo
β”‚   β”œβ”€β”€ decode.go
β”‚   β”œβ”€β”€ encode.go
β”‚   β”œβ”€β”€ hash.go
β”‚   └── torrentfile.go
β”œβ”€β”€ peer
β”‚   β”œβ”€β”€ peer.go
β”‚   └── peer_id.go
β”œβ”€β”€β”€ tracker
β”‚   β”œβ”€β”€ scrape.go
β”‚   β”œβ”€β”€ tracker.go
β”‚   └── tracker_test.go
β”œβ”€β”€ torrent.go
β”œβ”€β”€ discover_peers.go
β”œβ”€β”€ go.mod
└── go.sum

About

πŸ€ A lightweight and fast torrent client written in Go.

Topics

Resources

License

Stars

Watchers

Forks

Contributors