Compare commits
2 commits
39c5196349
...
0ebd1abdd7
Author | SHA1 | Date | |
---|---|---|---|
0ebd1abdd7 | |||
512f94d7f6 |
1 changed files with 47 additions and 23 deletions
26
log.py
26
log.py
|
@ -108,6 +108,31 @@ class logsManager:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
conn = pyodbc.connect(self.conn_str)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
timeThreshold = datetime.now() - timedelta(days=1)
|
||||||
|
|
||||||
|
cursor.execute("SELECT blockedipaddress, monutil_geoip.hostname, city, region, country, loc, org, postal, timezone FROM monutil_geoip INNER JOIN monutil_ipblock ON monutil_geoip.logID = monutil_ipblock.logID WHERE logtime >= ? AND blockedipaddress = ?", timeThreshold, ip)
|
||||||
|
|
||||||
|
rows = cursor.fetchall()
|
||||||
|
|
||||||
|
geoinfo = []
|
||||||
|
|
||||||
|
for row in rows:
|
||||||
|
geoinfo = {
|
||||||
|
"ip": row.blockedipaddress,
|
||||||
|
"hostname": row.hostname,
|
||||||
|
"city": row.city,
|
||||||
|
"region": row.region,
|
||||||
|
"country": row.country,
|
||||||
|
"loc": row.loc,
|
||||||
|
"org": row.org,
|
||||||
|
"postal": row.postal,
|
||||||
|
"timezone": row.timezone,
|
||||||
|
}
|
||||||
|
|
||||||
|
if not geoinfo:
|
||||||
|
|
||||||
if 'delayUntil' in locals() and datetime.now() < delayUntil:
|
if 'delayUntil' in locals() and datetime.now() < delayUntil:
|
||||||
|
|
||||||
print("Rate limit exceeded. Please wait before trying again.")
|
print("Rate limit exceeded. Please wait before trying again.")
|
||||||
|
@ -146,7 +171,6 @@ class logsManager:
|
||||||
"timezone": data.get("timezone"),
|
"timezone": data.get("timezone"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return geoinfo
|
return geoinfo
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in a new issue