FlareTunnel Documentation

repository·main·Indexed 20 days ago

https://github.com/mordavid/flaretunnel

A unified proxy system that routes traffic through Cloudflare Workers to provide IP rotation, anonymity, and high-performance proxying via Cloudflare's global edge network. It includes a local proxy server with round-robin or random rotation modes, a blacklist system to optimize request quotas, and CLI tools for managing worker deployment across multiple Cloudflare accounts.

Tokens
4.2K
Snippets
17
Records
21
Agent score
21%

What's inside FlareTunnel

  1. Optimize worker usage with the Blacklist System

    main

    FlareTunnel includes a blacklist system to block unwanted traffic (like analytics, images, or ads), which saves Cloudflare Worker request quotas.

    Blacklist TypeDescriptionImpact on Website
    blacklist-minimal.txt (Default)Blocks analytics, images, fonts, and source maps. Saves ~30-40% quota.Works perfectly in browser.
    blacklist.txt (Full)Blocks everything in minimal plus advertising, social tracking, CSS/JS, and CDNs. Saves ~60-70% quota.Website may look broken.
    blacklist-aggressive.txtBlocks almost everything except HTML/API. Saves ~80-90% quota.Website will break (use for automation only).
  2. Configure Cloudflare credentials

    main

    Before deploying proxies, you must configure your Cloudflare credentials. You will need your Account ID and an API Token with "Edit Cloudflare Workers" permissions. FlareTunnel supports managing multiple accounts to maximize request quotas.

    ./FlareTunnel config
  3. Install FlareTunnel from source

    main

    To install FlareTunnel, clone the repository and build the binary using Go. Ensure you have Go 1.19 or higher installed.

    git clone https://github.com/MorDavid/FlareTunnel.git
    cd FlareTunnel
    go build -o FlareTunnel FlareTunnel.go
  4. How FlareTunnel workers proxy requests

    main

    FlareTunnel deploys a specific JavaScript WorkerScript to Cloudflare. This script intercepts incoming requests and proxies them to a target URL.

    Target URL Selection Priority:

    1. Query Parameter: ?url=https://example.com
    2. HTTP Header: X-Target-URL: https://example.com
    3. URL Path: /https://example.com (if the path starts with http)

    Proxy Behavior:

    • Headers: It copies allowed headers (accept, authorization, content-type, etc.) and sets the Host header to the target's hostname.
    • IP Spoofing: It sets the X-Forwarded-For header. If the header X-My-X-Forwarded-For is provided in the request, it uses that; otherwise, it generates a random IP.
    • CORS: It automatically adds Access-Control-Allow-Origin: * and other CORS headers to responses to allow browser-based proxying.
  5. Configure Cloudflare API credentials

    main

    Run the config command to interactively set up your Cloudflare accounts. This process saves your credentials to a flaretunnel.json file. You can add multiple accounts to increase your total daily request quota (each account provides approximately 100,000 requests per day).

    To configure, you will need:

    1. A Cloudflare API Token with 'Edit Cloudflare Workers' permissions.
    2. Your Cloudflare Account ID.

    Follow the interactive prompts to name your accounts and provide the required tokens.

    go run FlareTunnel.go config
  6. Use FlareTunnel with Python requests

    main

    To route Python HTTP requests through the FlareTunnel, configure the proxies dictionary in the requests library. Note that verify=False may be required if using SSL interception.

    import requests
    import urllib3
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    
    proxies = {
        'http': 'http://127.0.0.1:8080',
        'https': 'http://127.0.0.1:8080'
    }
    
    r = requests.get("https://httpbin.org/ip", 
                     proxies=proxies, 
                     verify=False)
    
    print(r.json()['origin'])  # Should show Cloudflare Worker IP
  7. Configure FlareTunnel via JSON

    main

    FlareTunnel uses a JSON configuration file (defaulting to flaretunnel.json) to manage multiple Cloudflare accounts. Each account entry must include a name, an API token, and an account ID.

    Account Schema:

    • name: A unique identifier for the account.
    • api_token: Your Cloudflare API token.
    • account_id: Your Cloudflare Account ID.
    • zone_id (optional): Your Cloudflare Zone ID.
    {
      "accounts": [
        {
          "name": "my-account",
          "api_token": "YOUR_API_TOKEN",
          "account_id": "YOUR_ACCOUNT_ID"
        }
      ]
    }
  8. Reference: FlareTunnel CLI Commands

    main

    Complete list of available CLI commands for FlareTunnel.

    config    : Configure Cloudflare API credentials (supports multiple accounts)
    create     : Deploy new Worker proxies
    list       : List all active proxies and show usage stats
    tunnel     : Start the local proxy server
    test       : Test connectivity of your proxies
    cleanup    : Delete all workers from your account
    export     : Export config (accounts + credentials)
    import     : Import config (replace or merge)
  9. Deploy Cloudflare Worker proxies

    main

    Use the create command to deploy new Cloudflare Workers as proxy endpoints. You can specify the number of workers to create and distribute them across accounts or target a specific account.

    # Create 5 new proxy workers
    ./FlareTunnel create --count 5
    
    # Multi-Account: Auto-distribute based on quota
    ./FlareTunnel create --count 10 --distribute
    
    # Create on a specific account
    ./FlareTunnel create --count 5 --account main
  10. Manage and clean up proxy workers

    main

    You can list active proxies, check their status, or delete them from your Cloudflare accounts.

    # List all active proxies and usage stats
    ./FlareTunnel list
    
    # Detailed view (created, age, live status)
    ./FlareTunnel list --verbose
    
    # Check worker response times
    ./FlareTunnel list --status
    
    # Delete all workers from ALL accounts
    ./FlareTunnel cleanup
    
    # Delete workers from a specific account only
    ./FlareTunnel cleanup --account main
  11. Start the FlareTunnel local proxy server

    main

    The tunnel command starts the local proxy server that routes traffic through your deployed Cloudflare Workers. By default, it listens on localhost:8080.

    ./FlareTunnel tunnel
    
    # Start with specific workers (e.g., index 0 to 2)
    ./FlareTunnel tunnel --workers 0-2
    
    # Use random rotation mode
    ./FlareTunnel tunnel --mode random
    
    # Use a custom blacklist file
    ./FlareTunnel tunnel --blacklist blacklist.txt --verbose
    
    # Configure as an upstream proxy for Burp Suite
    ./FlareTunnel tunnel --port 9090 --upstream-proxy http://127.0.0.1:8080 --verbose