def checkhost(host):
try:
idkey = requests.get(f"https://check-host.net/check-tcp?host={host}", headers={"Accept": "application/json"}).json()
time.sleep(4)
rescheck = requests.get(f"https://check-host.net/check-result/{idkey['request_id']}").json()
abroad_result = ""
iran_result = ""
iran = ["Tehran", "Shiraz", "Esfahan", "Karaj"]
abroad = ["Netherlands","Turkey"]
for location in rescheck:
country = idkey["nodes"][location][1]
city = idkey["nodes"][location][2]
if abroad_result == "":
if country in abroad and rescheck[location] and len(rescheck[location]) == 1:
result = rescheck[location][0]
if "error" not in rescheck[location][0]:
abroad_result = (result['address'],result['time'])
else:
error = result['error'].lower()
abroad_result = error
if iran_result == "":
if country == "Iran" and city in iran and rescheck[location] and len(rescheck[location]) == 1:
result = rescheck[location][0]
if "error" not in rescheck[location][0]:
iran_result = (result['address'],result['time'])
else:
error = result['error'].lower()
iran_result = error
if "unknown host" in (iran_result,abroad_result):
return "abuse"
elif len(iran_result) == 2:
return "ok",iran_result[0],iran_result[1]
elif "connection refused" == iran_result and "connection refused" == abroad_result:
return "down"
elif "connection refused" in iran_result and len(abroad_result) == 2:
return "filter"
elif "timeout" in (iran_result,abroad_result):
return "down"
else:
return "unknown",iran_result,abroad_result
except Exception as e:
print(e)
return False
اینم یه کد پیشرفته متصل به چک هاست برای چک کردن فیلتری و ابیوز
چون دیدم ارسام و خیلیا نتونستن درست بزنن گذاشتم
try:
idkey = requests.get(f"https://check-host.net/check-tcp?host={host}", headers={"Accept": "application/json"}).json()
time.sleep(4)
rescheck = requests.get(f"https://check-host.net/check-result/{idkey['request_id']}").json()
abroad_result = ""
iran_result = ""
iran = ["Tehran", "Shiraz", "Esfahan", "Karaj"]
abroad = ["Netherlands","Turkey"]
for location in rescheck:
country = idkey["nodes"][location][1]
city = idkey["nodes"][location][2]
if abroad_result == "":
if country in abroad and rescheck[location] and len(rescheck[location]) == 1:
result = rescheck[location][0]
if "error" not in rescheck[location][0]:
abroad_result = (result['address'],result['time'])
else:
error = result['error'].lower()
abroad_result = error
if iran_result == "":
if country == "Iran" and city in iran and rescheck[location] and len(rescheck[location]) == 1:
result = rescheck[location][0]
if "error" not in rescheck[location][0]:
iran_result = (result['address'],result['time'])
else:
error = result['error'].lower()
iran_result = error
if "unknown host" in (iran_result,abroad_result):
return "abuse"
elif len(iran_result) == 2:
return "ok",iran_result[0],iran_result[1]
elif "connection refused" == iran_result and "connection refused" == abroad_result:
return "down"
elif "connection refused" in iran_result and len(abroad_result) == 2:
return "filter"
elif "timeout" in (iran_result,abroad_result):
return "down"
else:
return "unknown",iran_result,abroad_result
except Exception as e:
print(e)
return False
اینم یه کد پیشرفته متصل به چک هاست برای چک کردن فیلتری و ابیوز
چون دیدم ارسام و خیلیا نتونستن درست بزنن گذاشتم