Commit 229a55c4 by Dudás Ádám

firewall: use timezone instead of datetime

Using datetime causes a RuntimeWarning because DateTimeField receives a naive
datetime while time zone support is active.
parent 57d260d5
......@@ -2,7 +2,7 @@ import re
import logging
from collections import OrderedDict
from netaddr import IPAddress, AddrFormatError
from datetime import datetime, timedelta
from datetime import timedelta
from itertools import product
from .models import (Host, Rule, Vlan, Domain, Record, BlacklistItem,
......@@ -11,6 +11,7 @@ from .iptables import IptRule, IptChain
import django.conf
from django.db.models import Q
from django.template import loader, Context
from django.utils import timezone
settings = django.conf.settings.FIREWALL_SETTINGS
......@@ -134,7 +135,7 @@ class BuildFirewall:
def ipset():
week = datetime.now() - timedelta(days=2)
week = timezone.now() - timedelta(days=2)
filter_ban = (Q(type='tempban', modified_at__gte=week) |
Q(type='permban'))
return BlacklistItem.objects.filter(filter_ban).values('ipv4', 'reason')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment