This project automatically updates Cloudflare DNS records with the fastest proxy IP addresses found. It's designed to be run as a scheduled GitHub Actions workflow on a Ubuntu free runner.
-
Getting IPs (
scripts/getIPs.py
): Downloads a ZIP file containing IP lists, extracts it, combines the IPs. Then saving the results toresult/ip.txt
. -
IP Testing (
scripts/cfSpeedTest.py
): From theresult/ip.txt
, check the regions, ping, download, and upload speed. Then save the result toresult/tested-ips.csv
. -
Domain IP Mapping (
scripts/mapDomain.py
): From theresult/tested-ips.csv
. Map the IPs to the corresponding domains, then sort it by download speed. Then save the result toresult/domains-ips.csv
. -
Cloudflare Record Update (
scripts/cfRecUpdate.py
): Fromresult/domains-ips.csv
. Updates specified Cloudflare DNS records with the IP addresses. It intelligently updates existing records, creates new ones if needed, and deletes any extra records. -
Workflow Automation: A GitHub Actions workflow (
daily_update.yml
) schedules the entire process to run daily, every three hours.
-
Repository: Clone/Fork this repository to your GitHub account.
-
Edit Configurations: Edit the
config.ini
to your desired configs. -
Workflow Configuration:
- In your repository's settings (Settings > Secrets and variables > Actions > Secrets), add a secret named
CLOUDFLARE_API_TOKEN
with your Cloudflare API token.
- In your repository's settings (Settings > Secrets and variables > Actions > Secrets), add a secret named
-
Workflow Dispatch (Optional): You can manually trigger the workflow from the "Actions" tab of your repository if needed.
-
Repository: Clone this repository with git.
-
Edit Configurations: Edit the
config.ini
to your desired configs. -
Set Environment Variables:
- Set environment variable named
CLOUDFLARE_API_TOKEN
with your Cloudflare API token.
- Set environment variable named
-
Running:
- To get the Proxy IPs, run
python "scripts/getIPs.py"
- Test the Proxy IPs, run
python "scripts/cfSpeedTest.py"
- Map the IPs to Domains, run
python "scripts/mapDomain.py"
- Finally, Update Cloudflare records, run
python "scripts/cfRecUpdate.py"
- To get the Proxy IPs, run
- Purpose: Fetch IP addresses matching a specific pattern from a URL.
- Settings:
url
: The source URL for IP files (e.g.,https://zip.baipiao.eu.org
).file_pattern
: Pattern to match files (e.g.,*-1-443.txt
).output_file
: Path to save the collected IPs (e.g.,result/ips.txt
).
- Purpose: Test the speed and quality of IPs for download/upload performance.
- Settings:
file_ips
: Input file with collected IPs (e.g.,result/ips.txt
).max_ips
: Maximum number of IPs to test (e.g., 48).max_ping
: Maximum acceptable ping (e.g., 320 ms).test_size
: Data size for testing download/upload speeds (e.g., 5120 KB).min_download_speed
: Minimum acceptable download speed (e.g., 20 Mbps).min_upload_speed
: Minimum acceptable upload speed (e.g., 20 Mbps).force_ping_fallback
: Force to use ping fallback method (http method) regardlessping3
availability (e.g., True).output_file
: File to save the test results (e.g.,result/tested-ips.csv
).
- Purpose: Assign tested IPs to specific regions and domains.
- Settings:
input_csv
: Input file with tested IPs (e.g.,result/tested-ips.csv
).output_csv
: Output file with mapped domains (e.g.,result/domains-ips.csv
).
- Mapping Rules:
- Each line represent region with domain and max ips.
{REGION}
:{DOMAIN}
,{MAX_IPS}
. e.g.:Europe: eu.proxy.farelra.my.id,5
Asia_Pacific: ap.proxy.farelra.my.id,10
- Purpose: Update Cloudflare DNS records based on the mapped domains and IPs.
- Settings:
input_csv
: File with domains and their corresponding IPs (e.g.,result/domains-ips.csv
).zone_id
: Cloudflare Zone ID for updates.
Each section aligns with a specific step in the process, allowing for modular usage and configuration. Adjust paths and settings as needed to suit your environment.
This project is provided as-is. Use it at your own risk. Ensure you understand how it works and configure it correctly for your specific needs. The author is not responsible for any issues or damages caused by using this project.
Contributions are welcome! Feel free to open issues or submit pull requests.