1
0
Fork 0
mirror of https://github.com/ethauvin/fail2ban-digest.git synced 2025-04-27 11:18:12 -07:00

UTF-8 encode the db_creation_date_key globally.

This commit is contained in:
Erik C. Thauvin 2019-03-13 09:47:24 -07:00
parent 6dd8a04a40
commit adcb3bd917

View file

@ -34,7 +34,7 @@ import re
import sys import sys
db_location = '/var/lib/fail2ban/digest' db_location = '/var/lib/fail2ban/digest'
db_creation_date_key = 'db_creation_date' db_creation_date_key = u'db_creation_date'
db_date_format = '%Y-%m-%d %H:%M:%S' db_date_format = '%Y-%m-%d %H:%M:%S'
default_mail_template = Template('''Hi,\n default_mail_template = Template('''Hi,\n
This is a digest email of the ${count} banned IPs between ${creation_date} and ${date_now}: This is a digest email of the ${count} banned IPs between ${creation_date} and ${date_now}:
@ -176,7 +176,7 @@ def db_busy_open(filename, flags, timeout):
def add(db, ip): def add(db, ip):
db = db_busy_open(db_location + '/' + db + '.dbm', 'c', 30) db = db_busy_open(db_location + '/' + db + '.dbm', 'c', 30)
if db_creation_date_key.encode('UTF-8') not in db.keys(): if db_creation_date_key not in db.keys():
db[db_creation_date_key] = datetime.utcnow().strftime(db_date_format).encode('UTF-8') db[db_creation_date_key] = datetime.utcnow().strftime(db_date_format).encode('UTF-8')
event_date = ('%s, ' % datetime.utcnow().strftime(db_date_format)).encode('UTF-8') event_date = ('%s, ' % datetime.utcnow().strftime(db_date_format)).encode('UTF-8')
try: try: