更新:使用下面的代码可以自动判断哪些ip可以作为hosts
import requests
import re
import urllib3
import time
import threading
from urllib3.exceptions import InsecureRequestWarning
urllib3.disable_warnings(InsecureRequestWarning)
def ip_check(ip):
t1 = time.time_ns()
try:
# r = requests.get("https://{}/webgl-globe/data/data.json".format(ip), headers={
r = requests.get("https://{}/moozik".format(ip), headers={
'Host': 'github.com'
},verify = False, timeout=3)
except Exception as err:
return
if r.status_code == 200:
print("{} github.com #{}ms".format(ip, (time.time_ns() - t1)/1000000))
def ips():
metaUrl = 'https://api.github.com/meta'
metaData = requests.get(metaUrl).json()
for item in metaData['web']:
if item[-3:] != "/32":
continue
if ":" in item:
continue
yield item[:-3]
ret = []
for ip in ips():
t = threading.Thread(target=ip_check, args=(ip, ))
t.start()
执行结果如下:
20.27.177.113 github.com #275.9601ms
20.205.243.166 github.com #285.5741ms
20.207.73.82 github.com #432.8775ms
20.200.245.247 github.com #440.7051ms
20.233.83.145 github.com #492.8759ms
20.175.192.147 github.com #722.7297ms
20.248.137.48 github.com #754.3413ms
20.87.225.212 github.com #1224.6045ms
20.201.28.151 github.com #1226.61ms
2023-08-21
第一步
https://api.github.com/meta
打开上面的地址
第二步
根据你要使用的服务,找对应的ip,并尝试ping
这里只截取一部分
{
"verifiable_password_authentication": false,
"ssh_key_fingerprints": {
"SHA256_RSA": "nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8",
"SHA256_DSA": "br9IjFspm1vxR3iA35FWE+4VTyz1hYVLIE2t1/CeyWQ",
"SHA256_ECDSA": "p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM",
"SHA256_ED25519": "+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU"
},
"hooks": [
"192.30.252.0/22",
"185.199.108.0/22",
"140.82.112.0/20",
"143.55.64.0/20",
"2a0a:a440::/29",
"2606:50c0::/32"
],
"web": [
"192.30.252.0/22",
"185.199.108.0/22",
"13.250.177.223/32",
"52.74.223.119/32",
"13.236.229.21/32",
"13.237.44.5/32",
"52.64.108.95/32",
"18.228.52.138/32",
"18.228.67.229/32",
"18.231.5.6/32",
"20.201.28.151/32",
"20.205.243.166/32",
"102.133.202.242/32"
],
"api": [
"192.30.252.0/22",
"185.199.108.0/22",
"140.82.112.0/20",
"13.236.14.80/32",
"13.238.54.232/32",
"52.63.231.178/32",
"18.229.199.252/32",
"54.207.47.76/32",
"20.201.28.148/32",
"20.205.243.168/32",
"102.133.202.248/32"
],
"git": [
"192.30.252.0/22",
"185.199.108.0/22",
"140.82.112.0/20",
"143.55.64.0/20",
"2a0a:a440::/29",
"2606:50c0::/32",
"13.114.40.48/32",
"18.140.96.234/32",
"18.141.90.153/32",
"18.138.202.180/32",
"52.63.152.235/32",
"3.105.147.174/32",
"3.106.158.203/32",
"54.233.131.104/32",
"18.231.104.233/32",
"18.228.167.86/32",
"20.201.28.152/32",
"20.205.243.160/32",
"102.133.202.246/32"
],
第三步
如果ping通了,并且访问速度还可以,修改hosts
如果ping不通,继续 第二步
windows系统的hosts地址为C:\Windows\System32\drivers\etc\hosts
linux系统的hosts地址为/etc/hosts