-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(WIP) A custom implementation of torrent in rust as a library and a client.
- Loading branch information
Showing
28 changed files
with
3,922 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,5 +24,6 @@ Cargo.lock | |
|
||
/target | ||
|
||
.DS_Store | ||
|
||
lol* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# ZUNG TODOs | ||
|
||
## ZUNG_PARSERS | ||
|
||
- Value enum should have better methonds. | ||
- from_value deserializer to the implemented. | ||
|
||
## ZUNG_TORRENT | ||
|
||
- FileTree should be indexable. | ||
- Infohash should be calculated by the MetaInfo type and not the client. I think. | ||
- Implement Trackers. | ||
- Write tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "utilities" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Ishaan Goel <[email protected]>"] | ||
|
||
[dependencies] | ||
|
||
zung_torrent = { version = "0.1.0", path = "../zung_torrent" } |
93 changes: 93 additions & 0 deletions
93
utilities/sample_torrents/MC_GRID-7f06f8280a3b496f2af0f78131ced619df14a0c3.torrent
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file added
BIN
+306 KB
utilities/sample_torrents/kali-linux-2024.1-installer-amd64.iso.torrent
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod torrent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use std::{path::PathBuf, sync::LazyLock}; | ||
use zung_torrent::*; | ||
|
||
pub struct TestClient { | ||
pub arch: Client, | ||
pub mit: Client, | ||
pub kali: Client, | ||
pub mc: Client, | ||
} | ||
|
||
impl TestClient { | ||
pub fn new() -> Self { | ||
// Contains only url-list and no announce field | ||
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
path.push("sample_torrents/archlinux-2024.04.01-x86_64.iso.torrent"); | ||
let arch = Client::new(path).expect("Unable to open the arch torrrent"); | ||
|
||
// Contains both url-list and announce field | ||
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
path.push("sample_torrents/MIT6.00SCS11_archive.torrent"); | ||
let mit = Client::new(path).expect("Unable to read mit torrent"); | ||
|
||
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
path.push("sample_torrents/kali-linux-2024.1-installer-amd64.iso.torrent"); | ||
let kali = Client::new(path).expect("Unable to read kali torrent"); | ||
|
||
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
path.push("sample_torrents/MC_GRID-7f06f8280a3b496f2af0f78131ced619df14a0c3.torrent"); | ||
let mc = Client::new(path).expect("Unable to read kali torrent"); | ||
|
||
TestClient { | ||
arch, | ||
mit, | ||
kali, | ||
mc, | ||
} | ||
} | ||
} | ||
|
||
impl Default for TestClient { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
pub static CLIENT: LazyLock<TestClient> = LazyLock::new(TestClient::new); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[package] | ||
name = "zung_torrent" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Ishaan Goel <[email protected]>"] | ||
description = "A BitTorrent Client Library" | ||
license = "MIT" | ||
repository = "https://github.com/ishaan26/zung" | ||
readme = "README.md" | ||
keywords = ["projects", "learning", "torrent", "protocol"] | ||
|
||
[features] | ||
default = ["client"] | ||
client = ["dep:colored", "dep:human_bytes"] | ||
|
||
[dependencies] | ||
anyhow = "1.0.89" | ||
bytes = { version = "1.7.2", features = ["serde"] } | ||
clap = { version = "4.5.18", features = ["derive"] } | ||
hex = "0.4.3" | ||
chrono = { version = "0.4.38", features = ["serde"] } | ||
sha1_smol = "1.0.1" | ||
rayon = "1.10.0" | ||
indexmap = "2.6.0" | ||
rand = "0.8.5" | ||
tokio = { version = "1.41.1", features = ["full"] } | ||
|
||
colored = { version = "2.1.0", optional = true } | ||
human_bytes = { version = "0.4.3", optional = true } | ||
|
||
|
||
serde = { version = "1.0.210", features = ["derive"] } | ||
serde_bytes = "0.11.15" | ||
serde_urlencoded = "0.7.1" | ||
|
||
zung_parsers = { version = "0.1.1", path = "../zung_parsers" } | ||
futures = "0.3.31" | ||
|
||
[dev-dependencies] | ||
utilities = { path = "../utilities" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Zung Torrent - A BitTorrent Client Library | ||
|
||
This Library is an implementation of the [The BitTorrent Protocol Specification](https://www.bittorrent.org/beps/bep_0003.html) | ||
|
||
## Zung Family | ||
|
||
This library is part of the [zung](https://github.com/ishaan26/zung) family. | ||
Install the zung binary with `cargo install zung` to try out some of the features of this | ||
library. | ||
|
||
## Disclaimer | ||
|
||
_This library is intended for **learning purposes only**. While I will do my best to write the most professional code I can (with my limited coding knowledge), it is not my intention for this library to be used in any production environment._ | ||
|
||
Ateast not yet... | ||
|
||
## Table of Contents | ||
|
||
- [Introduction](#introduction) | ||
|
||
# Introduction | ||
|
||
BitTorrent is a peer-to-peer file sharing protocol designed by Bram Cohen. BitTorrent is designed to facilitate file transfers among multiple peers across unreliable networks. | ||
|
||
BitTorrent is a protocol for distributing files. It identifies content by URL and is designed to integrate seamlessly with the web. Its advantage over plain HTTP is that when multiple downloads of the same file happen concurrently, the downloaders upload to each other, making it possible for the file source to support very large numbers of downloaders with only a modest increase in its load. | ||
|
||
# Usage | ||
|
||
TODO: Update |
Oops, something went wrong.