Skip to content

Repository files navigation

PeerGuard

Real-time P2P & torrent leak prevention guard for Windows. Audits open network sockets, detects background seeding processes, mitigates browser WebTorrent swarms, and prevents unauthorized copyright exposure.

Platform License: MIT Electron React Languages


Why I Built This

In jurisdictions with strict digital copyright monitoring (such as Germany, Austria, and Switzerland under § 97 UrhG), automated monitoring services continuously observe public BitTorrent swarms. The moment a machine uploads even a single data chunk (a few kilobytes), the public IP address is recorded, potentially triggering civil cease-and-desist claims (Abmahnungen) and statutory damage notices ranging from €500 to €1,500+ per file.

Similar automated strike frameworks exist in the United States, the United Kingdom, and across Europe, where unintentional background seeding can lead to ISP warnings, bandwidth throttling, or service termination.

The danger isn't just standalone torrent clients:

  1. In-Browser WebTorrent Leaks: Many unofficial streaming websites embed WebTorrent or HLS-P2P video players. While streaming, the browser opens WebRTC peer channels and actively uploads downloaded segments from your home IP address to other viewers without explicit notification.
  2. Zombie Background Processes: Applications like qBittorrent, AceStream, Popcorn Time, or Stremio frequently remain running in the background after closing their main window, quietly seeding files.

I wanted a lightweight, reliable desktop utility that sits quietly in the system tray, monitors active sockets, immediately flags unauthorized P2P traffic, and can kill offending processes on the spot.


Key Features

  • Continuous Socket & Port Auditing: Inspects local TCP/UDP connections in real time without third-party kernel drivers. Monitors standard BitTorrent listener ranges (6881–6889, 51413, 8621, 6878, 11470, etc.).
  • Process Heuristic Scanner: Identifies 20+ known P2P clients and streaming daemons (qBittorrent, Transmission, Deluge, uTorrent, AceStream, Popcorn Time, Soda Player, WebTorrent Desktop, etc.).
  • Auto-Kill Defense: Optional toggle to forcibly terminate any detected P2P process within the first second of discovery.
  • WebTorrent & WebRTC Mitigation: Tracks known public WebTorrent trackers (tracker.openwebtorrent.com, open.stealth.si, etc.) and provides actionable hardening steps for Chrome, Brave, Firefox, and Edge.
  • Windows Defender Firewall Integration: One-click creation of OS-level firewall rules to block inbound and outbound BitTorrent listener ports.
  • Discreet System Tray Operation: Runs silently near the clock with a crisp, dynamic tray icon (Green = Protected, Red = Threat Detected) and consumes less than 40 MB of memory.
  • Simulation / Test Mode: Built-in safe testing mode to verify desktop notifications and alert mechanisms without launching actual torrents.
  • Internationalization (7 Languages): Full native translations for:
    • English (en)
    • German (de)
    • Ukrainian (uk)
    • Spanish (es)
    • French (fr)
    • Polish (pl)
    • Italian (it)

How It Works

┌─────────────────────────────────────────────────────────┐
│                      PeerGuard                          │
│               (Electron + React 19 UI)                  │
└───────────────────────────┬─────────────────────────────┘
                            │ IPC Bridge
┌───────────────────────────▼─────────────────────────────┐
│                    Background Engine                    │
│  ┌──────────────────────┐    ┌───────────────────────┐  │
│  │  Socket Inspector    │    │  Process Watcher      │  │
│  │  Get-NetTCPConnection│    │  Task & Memory Audit  │  │
│  └──────────┬───────────┘    └──────────┬────────────┘  │
│             │                           │               │
│             ▼                           ▼               │
│  ┌───────────────────────────────────────────────────┐  │
│  │             Threat Detection Matrix               │  │
│  │  - Suspicious Port Matches (6881-6889, 51413...)  │  │
│  │  - Known P2P Binaries (qBit, AceStream, etc.)     │  │
│  │  - WebTorrent Tracker Host Analysis               │  │
│  └──────────────────────┬────────────────────────────┘  │
│                         │                               │
│                         ▼                               │
│  ┌───────────────────────────────────────────────────┐  │
│  │              Automated Countermeasures            │  │
│  │  - Auto-Kill / Taskkill by PID                    │  │
│  │  - Windows Defender Firewall Rules                │  │
│  │  - Tray Icon Flip & Native Windows Notification   │  │
│  └───────────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────┘
  1. Socket Inspection: Queries Get-NetTCPConnection via PowerShell with compressed JSON output every 2 seconds (configurable to 1s or 5s).
  2. Correlation: Maps owning Process IDs (PIDs) back to executable names and paths.
  3. Response: If a forbidden P2P signature is detected, PeerGuard updates the tray icon, triggers an alert, and (if enabled) terminates the process immediately.

Getting Started

Prerequisites

  • Windows 10 or 11 (64-bit)
  • Node.js v18 or newer
  • PowerShell (built into Windows)

Installation & Running Locally

# Clone the repository
git clone https://github.com/your-username/peerguard.git
cd peerguard

# Install dependencies
npm install

# Run in development mode (Vite + Electron)
npm run electron:dev

# Or run standard Electron production preview
npm start

Building a Standalone .exe

To package a standalone Windows executable:

npm run build:exe

The output will be placed in release/PeerGuard-win32-x64/PeerGuard.exe.


Project Structure

├── electron/
│   ├── main.cjs            # Main Electron process, tray menu, window lifecycle, IPC handlers
│   ├── preload.cjs         # Context bridge exposing safe IPC methods
│   ├── scanner.cjs         # Core process and socket inspection engine
│   ├── firewall.cjs        # Windows Defender Firewall rule automation
│   └── icon-generator.cjs  # Dynamic vector shield icon generator for the system tray
├── src/
│   ├── components/
│   │   ├── TitleBar.jsx    # Custom frameless titlebar with window controls & language selector
│   │   ├── Navigation.jsx  # Clean segmented tab navigation
│   │   ├── Toast.jsx       # Discreet in-app toast alerts
│   │   └── tabs/
│   │       ├── OverviewTab.jsx    # System health, hero card, metrics, regulatory context
│   │       ├── NetworkTab.jsx     # Live socket inspector, search, port filter
│   │       ├── WebTorrentTab.jsx  # Browser WebRTC leak defense & firewall manager
│   │       ├── LogsTab.jsx        # Timestamped audit log with copy/clear functions
│   │       └── SettingsTab.jsx    # Startup modes, auto-kill, audio, notifications
│   ├── hooks/
│   │   └── useScanner.js   # Custom hook managing state, scans, IPC, and event logs
│   ├── i18n/
│   │   ├── index.jsx       # Translation context and language provider
│   │   └── locales/        # Dictionaries (en, de, uk, es, fr, pl, it)
│   ├── styles/
│   │   └── index.css       # Clean, restrained dark design system (no neon glow)
│   ├── App.jsx             # Clean modular root component
│   └── main.jsx            # React 19 entry point
└── package.json

Contributing

Pull requests are welcome! If you want to:

  • Add detection rules for emerging P2P software or WebTorrent trackers.
  • Improve translations for your native language.
  • Enhance socket auditing performance.

Feel free to open an issue or submit a PR.


Disclaimer

PeerGuard is an informational monitoring and privacy tool designed to help users identify and prevent unintended background peer-to-peer data transfers. It does not constitute legal advice. Laws regarding file sharing and copyright vary by jurisdiction.


License

Released under the MIT License.

About

Real-time P2P & torrent leak shield for Windows. Audits open network sockets, terminates unauthorized background seeding, mitigates browser WebTorrent swarms, and prevents copyright exposure.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages