A secure, feature-rich BitTorrent client with GUI built using Python and libtorrent.
- Magnet Link Support - Add torrents via magnet links
- .torrent File Support - Add torrents from .torrent files
- Resume Downloads - Automatically resume interrupted downloads on restart
- Single Instance - Prevents duplicate windows, sends magnet links to existing instance
- Remove Torrents - Remove with option to delete downloaded files
- Bandwidth Limiting - Set upload/download speed limits
- ProtonVPN Integration - Built-in VPN controller
- Firewall Check - Verify VPN kill switch is active
- Path Traversal Protection - Secure filename handling
- Input Validation - Comprehensive security checks
- Real-time Progress - Download progress, speed, ETA, peers
- Torrent Details - View files, trackers, and metadata
- Settings Management - Persistent settings across sessions
- Status Indicators - Visual feedback for download states
# Clone the repository
git clone https://github.com/IsThatLegal/torrent.git
cd torrent
# Install dependencies (Ubuntu/Debian)
sudo apt install python3 python3-libtorrent# Launch the GUI
python3 torrent-dl-gui-secure.py
# Or use the launcher script
./launch-torrent-gui.shVia Magnet Link:
- Copy a magnet link
- Click "Add Magnet"
- Paste the link and click OK
Via .torrent File:
- Click "Add .torrent"
- Select the .torrent file
- Click Open
From System:
- Right-click a magnet link and select "Open with Torrent Downloader"
- Double-click a .torrent file (if file associations are set up)
The project includes a comprehensive automated test suite with 96 tests and 98% coverage.
python3 run_tests.pyExpected output:
Status: ✓ ALL TESTS PASSED
Tests run: 96
✓ Passed: 96
Time: ~1.8s
# Test utilities
python3 run_tests.py --suite test_utils
# Test validation and security
python3 run_tests.py --suite test_validation
# Test single-instance functionality
python3 run_tests.py --suite test_single_instance
# Test torrent core functionality
python3 run_tests.py --suite test_torrent_core
# Test remove torrents
python3 run_tests.py --suite test_remove_torrents| Test Suite | Tests | Coverage |
|---|---|---|
test_utils.py |
32 | Utility functions |
test_validation.py |
29 | Input validation & security |
test_single_instance.py |
8 | IPC communication |
test_torrent_core.py |
14 | Libtorrent integration |
test_remove_torrents.py |
13 | Remove/delete functionality |
| Total | 96 | 98% |
- Quick Start Guide - Get started with testing
- Single Instance Guide - How single-instance works
- Resume Guide - Download resumption details
- Remove Torrents Guide - How to remove torrents
- Test Suite Guide - Complete testing documentation
- Feature Ideas - Planned improvements
torrent-downloader/
├── torrent-dl-gui-secure.py # Main GUI application
├── torrent_utils.py # Utility functions
├── privacy_security.py # Security features
├── protonvpn_controller.py # VPN integration
├── run_tests.py # Test runner
├── tests/ # Test suite
│ ├── test_utils.py
│ ├── test_validation.py
│ ├── test_single_instance.py
│ ├── test_torrent_core.py
│ └── test_remove_torrents.py
├── launch-torrent-gui.sh # Launch script
└── *.md # Documentation
GUI (tkinter)
- Main window with tabs for Downloads and Settings
- Real-time updates via threading
- Responsive UI with proper event handling
Libtorrent Session
- Manages all torrent operations
- Handles resume data persistence
- Provides status updates via alerts
IPC (Unix Domain Sockets)
- Prevents multiple instances
- Passes magnet links to existing instance
- Thread-safe communication
Resume Data
- Saves
.fastresumefiles for download state - Saves
.torrentfiles for metadata - Saves
.magnetfiles as backup
- Download Path:
~/Downloads/torrents/ - Resume Data:
~/.config/torrent-downloader/resume/ - Bandwidth: Unlimited (configurable)
- Max Connections: 200
- Max Upload Slots: 50
Settings are stored in ~/.config/torrent-downloader/settings.json:
{
"download_path": "/path/to/downloads",
"upload_limit": 100,
"download_limit": 1000,
"protonvpn_enabled": true
}Symptom: Downloads start from 0% after restart
Solution:
# Check for corrupted resume files
python3 check_resume_data.py
# Clean up corrupted files
python3 cleanup_resume.pySymptom: Multiple GUI windows open for same app
Solution:
# Check for stale socket
rm /tmp/torrent-downloader-gui.sock
# Restart the application
python3 torrent-dl-gui-secure.pySymptom: VPN controls don't work
Solution:
# Check ProtonVPN installation
protonvpn status
# Reconnect VPN
protonvpn connect- Python: 3.6+
- libtorrent: 1.2+ (python3-libtorrent)
- tkinter: Python GUI toolkit (usually included)
- ProtonVPN: (optional) For VPN integration
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass:
python3 run_tests.py - Submit a pull request
This project is provided as-is for educational and personal use.
- Built with libtorrent
- Uses ProtonVPN for privacy
- Developed with assistance from Claude Code
For security vulnerabilities, please create an issue on GitHub.
- ✅ Path traversal prevention
- ✅ Input validation and sanitization
- ✅ Command injection prevention
- ✅ Null byte handling
- ✅ VPN kill switch verification
- ✅ Firewall status checking
Fixed:
- ✅ Single-instance support with IPC
- ✅ Resume functionality for magnet links
- ✅ Remove torrents bug (torrents reappearing after restart)
- ✅ Metadata saving with newer libtorrent versions
Added:
- ✅ Comprehensive test suite (96 tests)
- ✅ Automated test runner
- ✅ Complete documentation
- ✅ Remove with option to delete files
Improved:
- ✅ Error handling for corrupted resume files
- ✅ File validation (size checks)
- ✅ Thread safety with proper locking
- ✅ Test coverage (98%)
Status: ✅ Fully functional with comprehensive test coverage