Automated Windscribe ephemeral port forwarding sync for qBittorrent on Debian
Find a file
2026-10-25 00:58:36 -07:00
openvpn Initial implementation of windscribe-portforward sync 2026-10-25 00:29:32 -07:00
systemd Initial implementation of windscribe-portforward sync 2026-10-25 00:29:32 -07:00
.gitignore Initial implementation of windscribe-portforward sync 2026-10-25 00:29:32 -07:00
config.example.env Initial implementation of windscribe-portforward sync 2026-10-25 00:29:32 -07:00
README.md Initial implementation of windscribe-portforward sync 2026-10-25 00:29:32 -07:00
requirements.txt Initial implementation of windscribe-portforward sync 2026-10-25 00:29:32 -07:00
windscribe_port_sync.py Fix qBittorrent setPreferences payload format (form-urlencoded with json string) 2026-10-25 00:58:36 -07:00

Windscribe Port Forward Sync

A lightweight, standalone Python utility that automates Windscribe ephemeral port forwarding and syncs the assigned listening port to qbittorrent-nox on Debian.

Background & Architecture

Windscribe Pro provides ephemeral port forwarding, but allocations expire every 7 days. Existing community projects wrap heavy Docker containers with full headless Chromium instances just to handle web logins.

This project uses a clean, zero-container approach:

  • VPN Connection (OpenVPN): Uses Debian's native openvpn systemd service (openvpn-client@windscribe). It creates a dedicated tun0 interface, runs without proprietary daemons, and lets you bind qBittorrent directly to tun0 for leak protection.
  • Port Synchronization (Python): Communicates directly with Windscribe's native API endpoints (api.windscribe.com) using session credentials or account login, requests matching port forwards, and updates qbittorrent-nox via its local Web API.
  • Automation: Runs as a standard cron job or a lightweight systemd timer every 6 days, well ahead of the 7-day expiration.

Requirements

  • Python 3.9+
  • requests
  • pyotp (optional, only required if using 2FA on username/password login)

Install dependencies on Debian:

sudo apt update
sudo apt install python3-requests python3-pyotp

Setup & Configuration

  1. Copy config.example.env to a secure location:

    sudo mkdir -p /etc/windscribe-portforward
    sudo cp config.example.env /etc/windscribe-portforward/config.env
    sudo chmod 600 /etc/windscribe-portforward/config.env
    
  2. Edit /etc/windscribe-portforward/config.env with your preferred authentication method:

    • Option A (authHash): If windscribe-cli is logged in on the system, the script automatically reads authHash from ~/.config/Windscribe/Windscribe2.conf. You can also paste it explicitly as WINDSCRIBE_AUTH_HASH=....
    • Option B (Credentials): Set WINDSCRIBE_USERNAME and WINDSCRIBE_PASSWORD (and WINDSCRIBE_TOTP if 2FA is active). The script will perform the two-step login and cache the session token locally.
  3. Configure qBittorrent Web UI connection details:

    QBIT_HOST=127.0.0.1
    QBIT_PORT=8080
    QBIT_USERNAME=admin
    QBIT_PASSWORD=your_password
    

CLI Usage

Inspect the active ephemeral port on Windscribe:

python3 windscribe_port_sync.py -c /etc/windscribe-portforward/config.env --status

Run in dry-run mode:

python3 windscribe_port_sync.py -c /etc/windscribe-portforward/config.env --dry-run

Sync or renew port and update qBittorrent:

python3 windscribe_port_sync.py -c /etc/windscribe-portforward/config.env --force-renew

Automation

  1. Copy the script to /usr/local/bin:

    sudo cp windscribe_port_sync.py /usr/local/bin/windscribe_port_sync.py
    sudo chmod +x /usr/local/bin/windscribe_port_sync.py
    
  2. Copy systemd units:

    sudo cp systemd/windscribe-port-sync.service /etc/systemd/system/
    sudo cp systemd/windscribe-port-sync.timer /etc/systemd/system/
    
  3. Enable and start the timer:

    sudo systemctl daemon-reload
    sudo systemctl enable --now windscribe-port-sync.timer
    

Check timer status:

systemctl list-timers | grep windscribe

Option 2: Cron Job

If you prefer standard cron, add an entry to /etc/cron.d/windscribe-portforward or root's crontab (crontab -e):

# Run every 6 days at 04:00 AM
0 4 */6 * * /usr/bin/python3 /usr/local/bin/windscribe_port_sync.py -c /etc/windscribe-portforward/config.env --force-renew >> /var/log/windscribe-port-sync.log 2>&1

Tunnel Setup & Leak Protection

See openvpn/README.md for step-by-step instructions on setting up OpenVPN with systemd on Debian and binding qBittorrent to tun0.