Skip to content

Commit 58b1913

Browse files
committed
Version 0.6.0
1 parent 2494bd8 commit 58b1913

5 files changed

Lines changed: 68 additions & 52 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
steps:
3636
- uses: actions/checkout@v3
3737

38+
- if: contains(matrix.target, 'x86')
39+
uses: ilammy/setup-nasm@v1
40+
3841
- name: Install Rust
3942
uses: actions-rs/toolchain@v1
4043
with:
@@ -48,6 +51,18 @@ jobs:
4851

4952
- uses: Swatinem/rust-cache@v1
5053

54+
- name: Install dependencies for aws-lc-rs
55+
shell: bash
56+
run: |
57+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
58+
echo 'LIBCLANG_PATH="C:\Program Files\LLVM\bin"' >> $GITHUB_ENV
59+
echo 'AWS_LC_SYS_PREBUILT_NASM=1' >> $GITHUB_ENV
60+
cargo install --force --locked bindgen-cli
61+
elif [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
62+
sudo apt-get install -y build-essential cmake golang libclang1 libclang-dev
63+
cargo install --force --locked bindgen-cli
64+
fi
65+
5166
- name: Build
5267
if: matrix.target != 'aarch64-apple-darwin'
5368
run: cargo build --verbose

.github/workflows/release.yml

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,46 +61,54 @@ jobs:
6161
fail-fast: false
6262
matrix:
6363
include:
64-
- build: linux
64+
- build: linux-x86_64-musl
6565
os: ubuntu-latest
66-
rust: nightly
66+
rust: stable
6767
target: x86_64-unknown-linux-musl
6868
strip: x86_64-linux-musl-strip
69-
- build: stable-aarch64
69+
70+
- build: linux-x86_64-gnu
7071
os: ubuntu-latest
7172
rust: stable
72-
target: aarch64-unknown-linux-gnu
73-
strip: aarch64-linux-gnu-strip
74-
qemu: qemu-aarch64
75-
- build: stable-powerpc64
73+
target: x86_64-unknown-linux-gnu
74+
strip: strip
75+
76+
- build: stable-aarch64-musl
7677
os: ubuntu-latest
7778
rust: stable
78-
target: powerpc64-unknown-linux-gnu
79-
strip: powerpc64-linux-gnu-strip
80-
qemu: qemu-ppc64
81-
- build: stable-s390x
79+
target: aarch64-unknown-linux-musl
80+
strip: aarch64-linux-musl-strip
81+
qemu: qemu-aarch64
82+
83+
- build: stable-aarch64-gnu
8284
os: ubuntu-latest
8385
rust: stable
84-
target: s390x-unknown-linux-gnu
85-
strip: s390x-linux-gnu-strip
86-
qemu: qemu-s390x
86+
target: aarch64-unknown-linux-gnu
87+
strip: aarch64-linux-gnu-strip
88+
qemu: qemu-aarch64
89+
8790
- build: macos
8891
os: macos-latest
89-
rust: nightly
92+
rust: stable
9093
target: x86_64-apple-darwin
94+
9195
- build: win-msvc
9296
os: windows-latest
93-
rust: nightly
97+
rust: stable
9498
target: x86_64-pc-windows-msvc
99+
95100
- build: win-gnu
96101
os: windows-latest
97-
rust: nightly-x86_64-gnu
102+
rust: stable-x86_64-gnu
98103
target: x86_64-pc-windows-gnu
99104

100105
steps:
101106
- name: Checkout repository
102107
uses: actions/checkout@v4
103108

109+
- if: contains(matrix.target, 'x86')
110+
uses: ilammy/setup-nasm@v1
111+
104112
- name: Install packages (Ubuntu)
105113
if: matrix.os == 'ubuntu-latest'
106114
shell: bash
@@ -141,6 +149,18 @@ jobs:
141149
echo "target flag is: ${{ env.TARGET_FLAGS }}"
142150
echo "target dir is: ${{ env.TARGET_DIR }}"
143151
152+
- name: Install dependencies for aws-lc-rs
153+
shell: bash
154+
run: |
155+
if [ "${{ matrix.os }}" = "windows-latest" ]; then
156+
echo 'LIBCLANG_PATH="C:\Program Files\LLVM\bin"' >> $GITHUB_ENV
157+
echo 'AWS_LC_SYS_PREBUILT_NASM=1' >> $GITHUB_ENV
158+
cargo install --force --locked bindgen-cli
159+
elif [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
160+
sudo apt-get install -y build-essential cmake golang libclang1 libclang-dev
161+
cargo install --force --locked bindgen-cli
162+
fi
163+
144164
- name: Build release binary
145165
shell: bash
146166
run: |
@@ -181,17 +201,17 @@ jobs:
181201
cp {README.md,LICENSE-APACHE,LICENSE-MIT} "$ARCHIVE"/
182202
183203
- name: Build archive (Windows)
184-
shell: bash
185204
if: matrix.os == 'windows-latest'
205+
shell: bash
186206
run: |
187207
7z a "$ARCHIVE.zip" "$ARCHIVE"
188208
certutil -hashfile "$ARCHIVE.zip" SHA256 > "$ARCHIVE.zip.sha256"
189209
echo "ASSET=$ARCHIVE.zip" >> $GITHUB_ENV
190210
echo "ASSET_SUM=$ARCHIVE.zip.sha256" >> $GITHUB_ENV
191211
192212
- name: Build archive (Unix)
193-
shell: bash
194213
if: matrix.os != 'windows-latest'
214+
shell: bash
195215
run: |
196216
tar czf "$ARCHIVE.tar.gz" "$ARCHIVE"
197217
shasum -a 256 "$ARCHIVE.tar.gz" > "$ARCHIVE.tar.gz.sha256"

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aget-rs"
3-
version = "0.5.1"
3+
version = "0.6.0"
44
authors = ["PeterDing <dfhayst@gmail.com>"]
55
homepage = "https://github.com/PeterDing/aget-rs"
66
description="Aget-rs - Fast Asynchronous Downloader with Rust 🦀"
@@ -41,7 +41,6 @@ thiserror = "1.0"
4141
# for crypto
4242
aes = "0.8"
4343
cbc = { version = "0.1", features = ["alloc", "block-padding"] }
44-
md-5 = "0.10"
4544

4645
# utilities
4746
term_size = "0.3"
@@ -57,7 +56,7 @@ dirs = "5.0"
5756
m3u8-rs = "6"
5857

5958
# for torrent
60-
librqbit = { git = "https://github.com/ikatson/rqbit.git", branch = "main" }
59+
librqbit = { git = "https://github.com/ikatson/rqbit.git", branch = "main", features = ["rust-tls"], default-features = false }
6160

6261
# for tracing
6362
tracing = "0.1"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ Following is the results of using `curl` and `aget-rs`. (For more details, you c
118118

119119
- Download a torrent or magnet link
120120

121+
Warning: The `/path/to/outdir` directory below command must NOT exist. It will be created automatically.
122+
121123
```shell
122124
ag "magnet:..." -o /path/to/outdir
123125
ag "/path/to/torrent" -o /path/to/outdir

src/app/core/bt.rs

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use std::{path::PathBuf, sync::Arc, time::Duration};
22

33
use librqbit::{
4-
api::TorrentIdOrHash, AddTorrent, AddTorrentOptions, AddTorrentResponse, Api, PeerConnectionOptions, Session,
5-
SessionOptions, SessionPersistenceConfig,
4+
api::TorrentIdOrHash, dht::PersistentDhtConfig, AddTorrent, AddTorrentOptions, AddTorrentResponse, Api,
5+
PeerConnectionOptions, Session, SessionOptions, SessionPersistenceConfig,
66
};
7-
use md5::Digest;
87
use url::Url;
98

109
use crate::{
@@ -34,37 +33,14 @@ impl BtHandler {
3433
}
3534
}
3635

37-
fn task_key(&self) -> Result<String> {
38-
let torrent_or_magnet = &self.torrent_or_magnet;
39-
if torrent_or_magnet.scheme() == "magnet" {
40-
for (key, value) in torrent_or_magnet.query_pairs() {
41-
match key.as_ref() {
42-
"xt" => {
43-
if let Some(ih) = value.as_ref().strip_prefix("urn:btih:") {
44-
return Ok(ih.to_lowercase().to_string());
45-
} else if let Some(ih) = value.as_ref().strip_prefix("urn:btmh:1220") {
46-
return Ok(ih.to_lowercase().to_string());
47-
} else {
48-
}
49-
}
50-
_ => {}
51-
}
52-
}
53-
return Err(Error::BitTorrentError("magnet link missing no info hash".to_string()));
54-
} else {
55-
let mut hasher = md5::Md5::new();
56-
hasher.update(torrent_or_magnet.as_str());
57-
let hash = hasher.finalize();
58-
Ok(format!("{:x}", hash).to_lowercase())
59-
}
60-
}
61-
6236
async fn start(self) -> Result<()> {
6337
tracing::debug!("BtHandler::start");
6438

6539
let output_dir = &self.output;
66-
let task_key = self.task_key()?;
67-
let persistence_dir = output_dir.join(task_key + ".bt.aget");
40+
let persistence_dir = output_dir
41+
.join("..")
42+
.join(output_dir.file_name().unwrap().to_string_lossy().to_string() + ".bt.aget");
43+
let dht_config_filename = persistence_dir.join("dht.json");
6844

6945
// 0. Check whether task is completed
7046
tracing::debug!("BtHandler: check whether task is completed");
@@ -77,6 +53,10 @@ impl BtHandler {
7753
let sopts = SessionOptions {
7854
disable_dht: false,
7955
disable_dht_persistence: false,
56+
dht_config: Some(PersistentDhtConfig {
57+
config_filename: Some(dht_config_filename),
58+
..Default::default()
59+
}),
8060
peer_id: None,
8161
peer_opts: Some(PeerConnectionOptions {
8262
connect_timeout: Some(Duration::from_secs(10)),

0 commit comments

Comments
 (0)