Select the optimal IP from Gcore-CDN for the lowest latency and most stable connectionsš¶.
I use Github Actionsļ¼ļ¼to run the repo in LAN, which generates a result.txt in case of available results. If U R Chinese guys, I recommand you open the file to look results, instead of running the repo. If you found latancies are 0 in result.txt, you should not trust them.
Gcore's CDN delivers a seamless experience globally. However, network connections from China sometimes experience packet loss and high latency. To address this, some users prefer to bind Gcore's domain to low-latency IP addresses. This script helps select the IP addresses with the lowest latency for such situations.
-
set up node environment. In case people haven't set up node. I highly recommend nvm or nvm-windows to set up.
-
run this JS file.
npm install
node .
- wait for a few minutes to receive result.txt, which contains the optimal IP addresses saved in this folder.
For choosing the best one of result, you may need ē«éæping to make sure that the connection is almost stable on every China citis. Otherwise, you can use your HTTP service to test bandwidth.
At present, I use https://api.gcorelabs.com/cdn/public-net-list to query IPs. In case it expired, this script will be invalid. If you find this script is invalid, please put up an issue or find new URL to replace it.
click to expand
I know some countries, like China, have a strong internet censorship system called the Great Firewall (GFW). It's even stricter than China's version. You might have trouble downloading IP ranges during running this script. To fix this, I have a backup plan. I use Github actions to save IP ranges in this repository every week. You can turn off the code `fetchWithTimeout()`. If you don't do that, it will still work, but it might take more time to finish.I have written another IP-selector for Cloudfront: https://github.com/BruceWind/CloudFrontIPSelector, you can try it.