Skip to content

OpenSource-Syndicate/UTracker

Repository files navigation

UTracker - BitTorrent Tracker Aggregator

UTracker is a high-performance, multi-protocol BitTorrent tracker aggregator built with FastAPI (backend) and React (frontend). It provides a unified platform for aggregating peers across HTTP, UDP, and WebSocket protocols with real-time monitoring capabilities.

Features

  • Multi-Protocol Support: HTTP (BEP-3), UDP (BEP-15), and WebSocket tracking
  • Real-time Dashboard: React-based UI for monitoring swarm activity and tracker statistics
  • Cross-Protocol Peer Aggregation: Aggregates peers across all supported protocols
  • Public Tracker Integration: Automatically discovers and validates public trackers
  • Performance Metrics: Comprehensive metrics and monitoring capabilities
  • Ultra-low Latency: Optimized for high-performance tracker operations

Architecture

The application consists of:

  • Backend: FastAPI server with MongoDB integration supporting HTTP/UDP/WebSocket announce protocols
  • Frontend: React dashboard with real-time updates via WebSocket
  • Database: MongoDB for persistent storage of statistics and temporary data

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • MongoDB
  • Docker (optional, for containerization)

Quick Start

Option 1: Local Installation

  1. Clone the repository:
git clone https://github.com/your-username/UTracker.git
cd UTracker
  1. Set up the backend:
cd backend
pip install -r requirements.txt
  1. Create a .env file in the backend directory:
MONGO_URL=mongodb://localhost:27017
DB_NAME=tracker_db
CORS_ORIGINS=http://localhost:3000
  1. Start the backend server:
cd backend
uvicorn server:app --host 0.0.0.0 --port 8001
  1. Set up the frontend:
cd frontend
npm install
  1. Create a .env file in the frontend directory:
REACT_APP_BACKEND_URL=http://localhost:8001
  1. Start the frontend:
cd frontend
npm start

The frontend will be available at http://localhost:3000, and the backend API will run on http://localhost:8001.

Option 2: Docker (Recommended)

  1. Build and run with Docker Compose:
docker-compose up --build

The application will be accessible at http://localhost (port 80).

Docker Configuration Details

The application uses a multi-stage Docker build process:

  • Frontend-builder: Builds the React application using Node.js 18
  • Backend-builder: Installs Python dependencies and builds the backend
  • Backend: Production backend image with FastAPI running on port 8001
  • Frontend: Production frontend served by Nginx on port 80

Key ports:

  • HTTP tracker: 8001
  • UDP tracker: 8002
  • Frontend dashboard: 80 (exposed as port 80)
  • MongoDB: 27017 (internal only)

Docker Environment Variables

The docker-compose.yml defines the following environment variables:

Backend:

  • MONGO_URL: MongoDB connection URL (mongodb://mongodb:27017)
  • DB_NAME: Database name (tracker_db)
  • CORS_ORIGINS: Comma-separated allowed origins

Frontend:

  • REACT_APP_BACKEND_URL: Backend API URL (http://localhost:8001)
  • REACT_APP_DOCKER_ENV: Indicates Docker environment (true)

Docker Network and API Proxy

The Docker setup uses nginx to proxy API requests from the frontend to the backend:

  • Frontend runs on port 80
  • API requests to /api are proxied to the backend service
  • WebSocket connections to /api/announce_ws are also proxied
  • This allows the React app to make relative API calls that are handled by nginx

API Endpoints

Tracker Endpoints

  • GET /api/announce - HTTP BitTorrent announce (BEP-3)
  • UDP Port 8002 - UDP BitTorrent announce (BEP-15)
  • WS /api/announce_ws - WebSocket announce

Application Endpoints

  • GET /api/stats - Tracker statistics
  • GET /api/swarms - Active swarms
  • GET /api/trackers - Public tracker list
  • POST /api/scrape_trackers - Refresh tracker list
  • GET /api/metrics - Prometheus metrics

Environment Variables

Backend

  • MONGO_URL - MongoDB connection URL (default: mongodb://localhost:27017)
  • DB_NAME - MongoDB database name (default: tracker_db)
  • CORS_ORIGINS - Comma-separated list of allowed CORS origins

Frontend

Testing

Run backend tests:

cd backend
python backend_test.py
python additional_tests.py

Docker Configuration

A multi-stage Docker configuration is provided:

  • Backend: Python 3.11 with FastAPI
  • Frontend: Node.js 18 with Nginx
  • MongoDB: For data persistence

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Commit your changes (git commit -m 'Add some amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Based on BEP-3 (BitTorrent Protocol Specification) and BEP-15 (UDP Tracker Protocol)
  • Inspired by public tracker lists from ngosang and XIU2

About

BitTorrent Tracker Aggregator

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published