mirror of
https://github.com/fail0verflow/letterbomb.git
synced 2024-11-16 15:39:18 +01:00
Do not spam on geoip not found errors
This commit is contained in:
parent
eeb869e553
commit
0130c51c2c
4
app.py
4
app.py
@ -1,7 +1,7 @@
|
|||||||
import os, zipfile, hashlib, hmac, struct, logging, random, json
|
import os, zipfile, hashlib, hmac, struct, logging, random, json
|
||||||
import urllib
|
import urllib
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import geoip2.database
|
import geoip2.database, geoip2.errors
|
||||||
from logging.handlers import SMTPHandler
|
from logging.handlers import SMTPHandler
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from flask import Flask, request, g, render_template, make_response, redirect, url_for
|
from flask import Flask, request, g, render_template, make_response, redirect, url_for
|
||||||
@ -54,6 +54,8 @@ def region():
|
|||||||
country = gi.country(request.remote_addr).country.iso_code
|
country = gi.country(request.remote_addr).country.iso_code
|
||||||
app.logger.info("GI: %s -> %s", request.remote_addr, country)
|
app.logger.info("GI: %s -> %s", request.remote_addr, country)
|
||||||
return COUNTRY_REGIONS.get(country, 'E')
|
return COUNTRY_REGIONS.get(country, 'E')
|
||||||
|
except geoip2.errors.AddressNotFoundError:
|
||||||
|
return 'E'
|
||||||
except:
|
except:
|
||||||
app.logger.exception("GeoIP exception")
|
app.logger.exception("GeoIP exception")
|
||||||
return 'E'
|
return 'E'
|
||||||
|
Loading…
Reference in New Issue
Block a user