.BANCHO. .FIX. More location api checks, this _should_ fix clients stuck at 'singing in'
This commit is contained in:
parent
363e272d3f
commit
afa6fa8563
|
@ -21,11 +21,11 @@ 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), timeout=3).read().decode())["country"]
|
result = json.loads(urllib.request.urlopen("{}/{}".format(URL, ip), timeout=3).read().decode())["country"]
|
||||||
|
return result.upper()
|
||||||
except:
|
except:
|
||||||
consoleHelper.printColored("[!] Error in get country", bcolors.RED)
|
consoleHelper.printColored("[!] Error in get country", bcolors.RED)
|
||||||
|
return "XX"
|
||||||
return country.upper()
|
|
||||||
|
|
||||||
|
|
||||||
def getLocation(ip):
|
def getLocation(ip):
|
||||||
|
@ -41,8 +41,8 @@ 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), timeout=3).read().decode())["loc"].split(",")
|
result = json.loads(urllib.request.urlopen("{}/{}".format(URL, ip), timeout=3).read().decode())["loc"].split(",")
|
||||||
|
return [float(result[0]), float(result[1])]
|
||||||
except:
|
except:
|
||||||
consoleHelper.printColored("[!] Error in get position", bcolors.RED)
|
consoleHelper.printColored("[!] Error in get position", bcolors.RED)
|
||||||
|
return [0,0]
|
||||||
return [float(data[0]), float(data[1])]
|
|
||||||
|
|
|
@ -123,14 +123,7 @@ def handle(flaskRequest):
|
||||||
responseToken.enqueue(serverPackets.onlineUsers())
|
responseToken.enqueue(serverPackets.onlineUsers())
|
||||||
|
|
||||||
# Get location and country from ip.zxq.co or database
|
# Get location and country from ip.zxq.co or database
|
||||||
if generalFunctions.stringToBool(glob.conf.config["server"]["localizeusers"]):
|
if generalFunctions.stringToBool(glob.conf.config["server"]["localizeusers"]):
|
||||||
# Make sure this user has not disabled his country flag
|
|
||||||
#if userHelper.getShowCountry(userID) == False:
|
|
||||||
# location = [0,0]
|
|
||||||
# countryLetters = "XX"
|
|
||||||
# country = 0
|
|
||||||
#else:
|
|
||||||
|
|
||||||
# Get location and country from IP
|
# Get location and country from IP
|
||||||
location = locationHelper.getLocation(requestIP)
|
location = locationHelper.getLocation(requestIP)
|
||||||
countryLetters = locationHelper.getCountry(requestIP)
|
countryLetters = locationHelper.getCountry(requestIP)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user