I suspect that any method that tries to test a large firewall directly will be unreliable, possibly in the short term and definitely in the long term. However, since your goal is to choose servers both within China and outside the country, I suggest using the deviceβs time zone as quick and dirty "where am I?" check. If the time zone name is Asia/Chungking , for example, use a Chinese server. If he is Europe/Amsterdam , for example, does not use a Chinese server. Check every time zone in mainland China and you will probably be fine.
You can get the time zone name as TimeZone.current.identifier .
source share