.BANCHO. Add timeout in location api requests
This commit is contained in:
parent
f0c984ad47
commit
363e272d3f
|
@ -21,7 +21,7 @@ def getCountry(ip):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Try to get country from Pikolo Aul's Go-Sanic ip API
|
# Try to get country from Pikolo Aul's Go-Sanic ip API
|
||||||
country = json.loads(urllib.request.urlopen("{}/{}".format(URL, ip)).read().decode())["country"]
|
country = json.loads(urllib.request.urlopen("{}/{}".format(URL, ip), timeout=3).read().decode())["country"]
|
||||||
except:
|
except:
|
||||||
consoleHelper.printColored("[!] Error in get country", bcolors.RED)
|
consoleHelper.printColored("[!] Error in get country", bcolors.RED)
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ def getLocation(ip):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Try to get position from Pikolo Aul's Go-Sanic ip API
|
# Try to get position from Pikolo Aul's Go-Sanic ip API
|
||||||
data = json.loads(urllib.request.urlopen("{}/{}".format(URL, ip)).read().decode())["loc"].split(",")
|
data = json.loads(urllib.request.urlopen("{}/{}".format(URL, ip), timeout=3).read().decode())["loc"].split(",")
|
||||||
except:
|
except:
|
||||||
consoleHelper.printColored("[!] Error in get position", bcolors.RED)
|
consoleHelper.printColored("[!] Error in get position", bcolors.RED)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user