The script is designed to scan Cloudflare's edge IPs and locate ones that are viable for use with v2ray/xray. It aims to identify edge IPs that are accessible and not blocked.
- Linux
- Python (>=3.6)
- Libraries
- requests
- pysocks
- Install prerequisites
sudo apt update && sudo apt install python3-pip git -y
- Clone the project
git clone https://github.com/MortezaBashsiz/CFScanner.git
- Change directory
cd CFScanner/python/
- Install required packages
pip install -r ./requirements.txt
- create a config json file (e.g., myconfig.json) with the following content. replace the values with your own!
{
"id": "248ecb72-89cf-5be7-923f-b790fca681c5",
"host": "scherehtzhel01.sudoer.net",
"port": "443",
"path": "api01",
"serverName": "248ecb72-89cf-5be7-923f-b790fca681c5.sudoer.net"
}
- To run without providing a subnets (CIDRs) file and using 8 threads:
python3 cfFindIP.py --threads 8 --config ./myconfig.json
- To run on a list of subnets (recommended). Each line
python3 cfFindIP.py --threads 8 --config ./myconfig.json --subnets ./mysubnets.selection
- To run with a minimum acceptable download speed (in KBps)
python3 cfFindIP.py --threads 8 --config ./myconfig.json --subnets ./mysubnets.selection --download-speed 100
- To run with a minimum acceptable download and upload speed (in KBps)
python3 cfFindIP.py --upload-test --threads 8 --config ./myconfig.json --subnets ./mysubnets.selection --download-speed 100 --upload-speed 25
- To run and try each IP multiple (3 in this case) times. An IP is marked ok if it passes all the tests.
python3 cfFindIP.py --upload-test --threads 8 --config ./myconfig.json --subnets ./mysubnets.selection --download-speed 100 --upload-speed 25 --tries 3
Each line of the subnets file must be a Cloudflare subnets in CIDR notation or a single IP:
1.0.0.0/24
108.162.218.0/24
108.162.236.0/22
162.158.8.0/21
162.158.60.0/24
162.158.82.12
...
--threads|-thr: Number of threads to use for parallel computing
--config|-c: The path to the config file. For confg file example, see ClientConfig.json
--subnets|-sn: The path to the custom subnets file. each line
should be in the form of ip.ip.ip.ip/subnet_mask. If not provided, the program will read the cidrs from asn lookup
--tries: Number of times to try each IP. An IP is marked as OK if all tries are successful.
--download-speed: Minimum acceptable download speed in kilobytes per second
--upload-test: If True, upload test will be conducted as well
--upload-speed: Mimimum Maximum acceptable upload speed in kilobytes per second
--download-time: Maximum (effective, excluding latency) time to spend for each download.
--upload-time: Maximum (effective, excluding latency) time to spend for each upload
--download-latency: Maximum allowed latency (seconds) for download
--upload-latency: Maximum allowed latency (seconds) for upload
- In the current version, an IP is marked "OK", only if it passes all tries of the experiment
- The size of the file for download is determined based on the arguments
download-speed
anddownload-time
(similar for upload as well). Therefore, it is recommended to choose these parameters carefully based on your expectations, internet speed and the number of threads being used
The results will be stored in the results
directory. Each line of the generated csv file includes a Cloudflare edge ip together with the following values:
avg_download_speed
: Average download speed in mbpsavg_upload_speed
: Average upload speed in mbpsavg_download_latency
: Average download latency in msavg_upload_latency
: Average upload latency in msavg_download_jitter
: Average jitter during downloads in msavg_upload_jitter
: Average jitter during uploads in msdownload_speed_1,...,n_tries
: Values of download speeds in mbps for each downloadupload_speed_1,...,n_ties
: Values of download speeds in mbps for each uploaddownload_latency_1,...,n_tries
: Values of download latencies in msdownload_latency_1,..._n_tries
: Values of upload latencies in ms
For each time running the code, a result file is generated in the result folder with the datetime string to avoid overwriting (e.g, 20230226_180502_result.csv
)
Contributors names and contact info
- 0.1
- Initial Release