- Rust 99.6%
- Shell 0.4%
| .cargo | ||
| build | ||
| config | ||
| examples | ||
| scripts | ||
| src | ||
| .gitattributes | ||
| .gitignore | ||
| .rusty-hook.toml | ||
| ARGS.md | ||
| BEPs.md | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
torrentz2
Torrent file creator and editor with v1/v2/hybrid support.
Description
torrentz2 (tz2) is an advanced, experimental utility for working with .torrent metadata files. It supports a wide array of BEPs and v1/v2/hybrid formats.
See here for details on BEP support.
Features
- Create, Edit, or Verify torrent files
- Convenient config file to define default options and trackers
- Multithreaded hashing
- Include/exclude files based on globs and if they are symlinks
- Create a single torrent file from disparate input paths, provided they share a common root
- Intelligent automatic piece size selection with support for up to 64 MiB
- Digitally sign/verify embedded signatures with standard X.509 certificates utilizing RSA or EC signatures
- Includes utility command to generate an appropriate root CA and leaf cert
- Optionally include md5 or sha1 sums per-file with v1 torrents
Optional Features
- CPU hardware accelerated hashing (on by default)
- GPU accelerated hashing (coming soon, maybe hopefully)
- Compile to a static binary
Pre-Built Binaries
If you do not want to build tz2 yourself, there are precompiled binaries available:
./build/tz2_x64_openssl_gnu: recommended and fastest, requires openssl installed./build/tz2_x64_musl: slower static build, no openssl
Building
Prerequisites
- You will want rustup installed, and to add
~/.cargo/binto your path. Depending on your installation method, you may need to initialize it as well. tz2 is currently tracking stable. - Add targets:
rustup target add x86_64-unknown-linux-gnu x86_64-unknown-linux-musl. - Either openssl (for default build) or a C compiler.
Compiling
- Clone this repo:
git clone https://codeberg.org/liliumstar/torrentz2.git && cd torrentz2 - Build and install with default configuration:
cargo install --release
This will compile a executable linked to glibc and openssl, which has proven fasted in testing.
If you would prefer a static binary, you can use something like this: cargo build --release --target x86_64-unknown-linux-musl --features static.
Alternately, you can choose to not include openssl with: cargo build --release --target x86_64-unknown-linux-musl --no-default-features.
Feature Flags
default: ext
ext: Enable openssl for hashing instead of pure rust implementation, faster
static: If ext is enabled, compile and embed the openssl library into the binary, a bit slower versus dynamic linking in testing
gpu: Not currently implemented
Windows
It is possible to cross-compile for Windows with cargo build --release --target x86_64-pc-windows-gnu --features static. This requires the MinGW64 toolchain. This configuration works (in limited testing).
Configuration
The configuration file is in yaml format. There is an example file to work off of in ./config/example_config.yaml. Alternately you can use tz2 gen-config to create a default configuration in a suitable location.
The config file is loaded from locations in this order, where BINDIR is the location of the tz2 executable:
- $BINDIR/config/config.yaml
- $XDG_CONFIG_HOME/tz2/config.yaml
- $HOME/.config/tz2/config.yaml
All fields in the config are required, and correspond to associated CLI flags. The only nullable field is a certificate key, which indicates you are not in possession of the associated private key.
The comment and created_by default values of "default" are special, they will be replaced by tz2 specific values.
Usage
The binary is called tz2 by default, and should be on your path if you used cargo install. You can get help with tz2 --help.
Arguments
Arguments specified on the CLI will override their corresponding config file counterparts.
Example Output
[*] torrentz2 0.1.0
[*] Found 1 groups of torrents to hash
[*] Beginning torrent hashing for /media/cache/temp...
| Num Files : 6
| Total Size: 6.0 GiB
| Piece Size: 4.0 MiB
| Num Pieces: 1535
| Version: Hybrid
[*] Finished hashing torrent and processing pieces in 00:00:02
[*] Operation complete!
| Output Directory: /media/some/place
Included in the ./examples directory are signed sample torrent files in each format.
Status
tz2 currently supports all of the intended features aside from GPU hashing. However, this project should be considered unstable. More features may be added, and the API/CLI may evolve over time.
ToDo
- Add output to another serialization format
- Test more signing/verifying types
- Add check to ensure provided private key and cert match
- Reimplement certificate date check
- Investigate P521 implementation
- Implement GPU hashing
- Clean up CLI args and config file
- Further testing
Supported Signature Methods
- SHA256/512 with RSA Encryption
- SHA-512 with ed25519
- ECDSA with NIST P-256/P-384/P-521, secp256k1
More can be added upon request. Ideally they would have trusted pure rust implementations available.
I'm not entirely sure P-521 is implemented correctly. Please raise an issue if you find that is the case.
Contributions
Contributions are welcome. Open a PR with one, or raise an issue if you'd like to discuss a potential change.
License
This project is licensed under the GPL-3, you can find the full text here or in the license file.