⚡ cfray
Cloudflare Proxy Toolkit
Scan configs + Find clean IPs + Deploy Xray servers + Pipeline test with DPI bypass + Worker proxy
English • فارسی
🇬🇧 English
📖 What is cfray?
cfray is a single-file Python proxy toolkit for VLESS/VMess configs behind Cloudflare. What started as an IP scanner is now a full suite:
- Config Scanner — test hundreds of IPs for latency + download speed, rank by score, export the best configs
- Clean IP Finder — scan all ~1.5M Cloudflare IPv4 addresses to find reachable edge IPs (Mega mode: ~3M probes on 2 ports)
- Xray Pipeline Test — 3-stage pipeline that scans IPs, swaps them into your config, and expands with fragment presets + SNI variations to bypass DPI/firewall blocks
- Deploy Xray Server — deploy a full xray-core server on any Linux VPS with systemd, TLS certs, REALITY keys, and multi-config support
- Worker Proxy — generate a Cloudflare Worker script for a fresh
workers.dev SNI on any VLESS WebSocket config
- Connection Manager — manage inbounds, users, URIs, and uninstall on deployed servers
- WARP WireGuard Gen — generate free anonymous Cloudflare WARP+ WireGuard VPN configs (
--warp)
- Local Sub Server — host scanned configs locally via built-in HTTP server (
--serve-sub)
- Sub Deduplicator — clean, validate, and deduplicate subscription links (
--clean-subs)
- Advanced Networking — DoH DNS resolution (
--doh), Geo-IP tagging (--geo), UDP & censorship probes (--udp, --check-censorship), Webhooks (--notify), Watchdog daemon (--watch), Sing-box/Clash Meta export (--export-client), Deep Config Inspector (--inspect), Jitter benchmark (--jitter), Telegram Exporter (--export-tg), and HTTP/2 ALPN probe (--alpn-h2)
Zero dependencies. Just Python 3.8+ and one file.
🚀 Quick Start
# Download
git clone https://github.com/SamNet-dev/cfray.git
cd cfray
# Run interactive TUI
python3 scanner.py
# That's it! Pick your input, choose a mode, and watch the results.
📥 Input Methods
cfray supports 5 ways to load your configs:
1️⃣ Config File [1-9]
A .txt file with one VLESS or VMess URI per line:
vless://uuid@domain1.ir:443?type=ws&host=sni.com&path=/dl&security=tls#config-1
vless://uuid@domain2.ir:443?type=ws&host=sni.com&path=/dl&security=tls#config-2
vmess://eyJ2IjoiMiIsImFkZCI6...
Drop your file in the same folder as scanner.py and it shows up automatically.
2️⃣ Subscription URL [S]
Paste a remote URL that serves VLESS/VMess configs:
# Interactive
python3 scanner.py
# Press S, paste URL
# CLI
python3 scanner.py --sub https://example.com/sub.txt
Supports both plain text (one URI per line) and base64-encoded subscriptions.
3️⃣ Template + Address List [T]
Have ONE working config but want to test it against many Cloudflare IPs? This is for you.
How it works:
- You give a VLESS/VMess config as a template
- You give a
.txt file with Cloudflare IPs or domains (one per line)
- cfray creates a config for each address by replacing the IP in your template
- Tests them all and finds the fastest
# Interactive
python3 scanner.py
# Press T, paste your config, enter path to address list
# CLI
python3 scanner.py --template 'vless://uuid@placeholder:443?type=ws&...' -i addresses.txt
Example address list (addresses.txt):
104.21.12.206
188.114.96.7
172.67.132.102
172.67.166.192
4️⃣ Domain JSON File
A JSON file with domain + IP data:
{"data": [
{"domain": "example.ir", "ipv4": "104.21.x.x"},
{"domain": "other.ir", "ipv4": "172.67.x.x"}
]}
5️⃣ Clean IP Finder [F]
Don't have any configs or IPs? cfray can scan all Cloudflare IP ranges to find clean, reachable edge IPs — then use them directly with a template for speed testing.
How it works:
- Generates IPs from all 14 Cloudflare IPv4 subnets (~1.5M IPs)
- Probes each IP with TLS handshake + Cloudflare header validation
- Returns all responding IPs sorted by latency
- Save the results or feed them into Template mode for a full speed test
Scan modes:
| Mode |
IPs Tested |
Ports |
Est. Time |
Description |
| Quick |
~4,000 |
443 |
~30 sec |
1 random IP per /24 block |
| Normal |
~12,000 |
443 |
~2 min |
3 IPs per /24 + CF verify (recommended) |
| Full |
~1,500,000 |
443 |
20+ min |
All IPs + CF verify |
| Mega |
~3,000,000 |
443 + 8443 |
30-60 min |
All IPs on 2 ports for maximum coverage |
Cloudflare publishes 14 IPv4 subnets totaling ~1,511,808 unique IPs. Full and Mega modes scan all of them. Mega mode tests every IP on both port 443 and 8443 (Cloudflare's alternate HTTPS port), doubling the probes to ~3M (1.5M IPs × 2 ports). This is useful when some IPs are blocked on one port but reachable on another. Results include the port (e.g., 104.16.5.20:8443).
# Interactive
python3 scanner.py
# Press F, choose scan mode
# CLI
python3 scanner.py --find-clean --no-tui --clean-mode mega
# With custom subnets
python3 scanner.py --find-clean --no-tui --subnets "104.16.0.0/13,172.64.0.0/13"
Found IPs are saved to results/clean_ips.txt (full absolute path shown). You can then use them with Template mode to speed test a config against all discovered IPs.
🔬 How the Scan Works
Step 1: 🔍 DNS Resolution
Resolve all domains to their Cloudflare edge IPs
Group configs by IP (many domains share the same CF edge)
Step 2: 📡 Latency Test
TCP connect + TLS handshake to each unique IP
Mark alive/dead, measure ping & connection time
Step 3: 📊 Speed Test (progressive rounds)
R1: Small file (1-5MB) → test all alive IPs
R2: Medium file (5-25MB) → test top candidates
R3: Large file (20-50MB) → test the best ones
(For <50 IPs, ALL are tested in every round)
Step 4: 🏆 Scoring & Export
Score = Latency (35%) + Speed (50%) + TTFB (15%)
Export top configs ranked by score
⚙️ Scan Modes
| Mode |
Rounds |
Est. Data |
Est. Time |
Best For |
| ⚡ Quick |
1MB → 5MB |
~200 MB |
~2-3 min |
Fast check |
| 🔄 Normal |
1MB → 5MB → 20MB |
~850 MB |
~5-10 min |
Balanced (recommended) |
| 🔬 Thorough |
5MB → 25MB → 50MB |
~5-10 GB |
~20-45 min |
Maximum accuracy |
🖥️ Dashboard Controls
After the scan, you get an interactive dashboard:
| Key |
Action |
S |
🔄 Cycle sort: score → latency → speed |
C |
📋 View all VLESS/VMess URIs for an IP |
D |
🌐 View domains for an IP |
E |
💾 Export results (CSV + top N configs) |
A |
📦 Export ALL configs sorted best → worst |
J/K |
⬆️⬇️ Scroll up/down |
N/P |
📄 Page up/down |
B |
◀️ Back to main menu (new scan) |
H |
❓ Help |
Q |
🚪 Quit |
🔧 CLI Options
python3 scanner.py [options]
| Option |
Description |
Default |
-i, --input |
Input file (VLESS URIs or .json) |
— |
--sub |
Subscription URL |
— |
--template |
VLESS/VMess template URI (use with -i) |
— |
-m, --mode |
quick / normal / thorough |
normal |
--rounds |
Custom rounds, e.g. "1MB:200,5MB:50" |
auto |
-w, --workers |
Latency test workers |
300 |
--speed-workers |
Download test workers |
10 |
--timeout |
Latency timeout (seconds) |
5 |
--speed-timeout |
Download timeout (seconds) |
30 |
--skip-download |
Latency only, no speed test |
off |
--top |
Export top N configs (0 = all) |
50 |
--no-tui |
Headless mode (plain text output) |
off |
-o, --output |
CSV output path |
auto |
--output-configs |
Config file output path |
auto |
--find-clean |
Find clean Cloudflare IPs |
off |
--clean-mode |
quick / normal / full / mega |
normal |
--subnets |
Custom subnets (file or comma-separated) |
all CF |
--warp |
Generate free WARP+ WireGuard config |
off |
--serve-sub |
Start local HTTP subscription server |
off |
--clean-subs |
Clean & deduplicate subscription links |
— |
--watch |
Daemon watchdog mode (rescan interval) |
off |
--notify |
Webhook alert URL (Discord/Telegram) |
— |
--geo |
Fetch Geo-IP country & colocation tag |
off |
--doh |
Resolve DNS via Cloudflare DoH |
off |
--udp |
Test UDP probe over Xray tunnel |
off |
--check-censorship |
Test HTTP censorship probe over tunnel |
off |
--export-client |
Auto-export singbox or clash profile |
— |
--inspect |
Deep diagnostic check & syntax validator |
— |
--jitter |
Multi-probe jitter & loss benchmark |
off |
--export-tg |
Export clickable Telegram proxy links |
off |
--alpn-h2 |
Probe HTTP/2 ALPN multiplexing |
off |
💡 Examples
# Interactive TUI — easiest way
python3 scanner.py
# Quick scan with subscription
python3 scanner.py --sub https://example.com/sub.txt --mode quick
# Template: test one config against 500 IPs
python3 scanner.py --template 'vless://uuid@x:443?type=ws&host=sni.com&security=tls#test' -i ips.txt
# Headless mode for scripts/cron
python3 scanner.py -i configs.txt --no-tui --mode normal -o results.csv
# Latency only (no download test)
python3 scanner.py -i configs.txt --skip-download
# Custom rounds
python3 scanner.py -i configs.txt --rounds "2MB:100,10MB:30,50MB:10"
# Find clean Cloudflare IPs (interactive)
python3 scanner.py # Press F
# Find clean IPs (headless, mega mode — ~3M probes)
python3 scanner.py --find-clean --no-tui --clean-mode mega
📁 Output Files
Results are saved to the results/ folder:
| File |
Contents |
*_results.csv |
Full CSV with all metrics |
*_top50.txt |
Top 50 VLESS/VMess URIs (ready to use) |
*_full_sorted.txt |
ALL configs sorted best → worst |
clean_ips.txt |
Clean Cloudflare IPs from IP finder |
🛡️ Rate Limiting & CDN Fallback
cfray is smart about Cloudflare's speed test limits:
- Tracks request budget (550 requests per 10-minute window)
- When rate-limited (429), automatically switches to CDN mirror (
cloudflaremirrors.com)
- When CF blocks large downloads (403), retries through CDN
- Shows countdown timer when waiting for rate limit reset
🌟 What's New in v1.2 (Step-by-Step Guide)
v1.2 transforms cfray into an all-in-one Cloudflare proxy toolkit. Here is how to use each new feature step by step:
1️⃣ Deep Config Inspector [I]
Paste any VLESS or VMess link to run an automated diagnostic check.
2️⃣ Anonymous Cloudflare WARP WireGuard Generator [W]
Register a free, anonymous Cloudflare WARP+ account on the fly and save a working WireGuard VPN profile (warp.conf).
3️⃣ Local Subscription Web Server [G]
Host your fastest scanned configs locally over a built-in lightweight HTTP web server.
4️⃣ Subscription Deduplicator & Cleaner [L]
Clean messy remote subscription feeds or local files by stripping out duplicate links and validating URI syntax.