aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cgi/framework.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/cgi/framework.py b/cgi/framework.py
index e2af143..86683dd 100644
--- a/cgi/framework.py
+++ b/cgi/framework.py
@@ -77,7 +77,10 @@ def addressIsTor(ip):
res = True
else:
with open('tor.txt') as f:
- nodes = [line.rstrip() for line in f]
+ for line in f:
+ if ip == line.rstrip():
+ res = True
+ break
if ip in nodes:
res = True
Settings._.IS_TOR = res
@@ -116,9 +119,13 @@ def getCountry(ip):
return "v6"
else:
import geoip2.database
- with geoip2.database.Reader('GeoLite2-Country.mmdb') as reader:
- response = reader.country(ip)
- return response.country.iso_code
+ import geoip2.errors
+ try:
+ with geoip2.database.Reader('GeoLite2-Country.mmdb') as reader:
+ response = reader.country(ip)
+ return response.country.iso_code
+ except geoip2.errors.AddressNotFoundError:
+ return "??"
def getHost(ip):
@@ -258,7 +265,10 @@ def getFormData(self):
formdata = {}
for key in dict(fs):
- formdata.update({key: fs[key].value})
+ if type(fs[key]) is list:
+ formdata.update({key: fs[key]})
+ else:
+ formdata.update({key: fs[key].value})
return formdata