From 363e272d3fc3e825ff0aa3f410941daea8cd2012 Mon Sep 17 00:00:00 2001 From: Nyo Date: Tue, 17 May 2016 17:23:34 +0200 Subject: [PATCH] .BANCHO. Add timeout in location api requests --- locationHelper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/locationHelper.py b/locationHelper.py index 5038e37..ab1f73a 100644 --- a/locationHelper.py +++ b/locationHelper.py @@ -21,7 +21,7 @@ def getCountry(ip): try: # 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: consoleHelper.printColored("[!] Error in get country", bcolors.RED) @@ -41,7 +41,7 @@ def getLocation(ip): try: # 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: consoleHelper.printColored("[!] Error in get position", bcolors.RED)