Skip to content

Commit 342af13

Browse files
authored
Merge pull request #315 from clausing/main
[20251103-000] fix 3.12 deprecation warning for datetime.utcnow()
2 parents ddb089a + e12a904 commit 342af13

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

srv/dshield/fwlogparser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from time import strptime
1212
from time import mktime
1313
from time import time
14-
from datetime import datetime
14+
from datetime import datetime, timezone
1515
from DShield import DshieldSubmit
1616

1717
maxlines=100000;
@@ -105,7 +105,10 @@ def checklock(lockfile):
105105
lastdir="/var/tmp/dshield/"
106106
config = "/etc/dshield.ini"
107107
startdate = 0
108-
now = datetime.utcnow()
108+
if sys.version_info < (3, 12):
109+
now = datetime.utcnow()
110+
else:
111+
now = datetime.now(timezone.utc)
109112
fieldmap = {'SRC': 'sip', 'DST': 'dip', 'PROTO': 'proto', 'TYPE': 'sport',
110113
'CODE': 'dport', 'SPT': 'sport', 'DPT': 'dport'}
111114
protomap = {'ICMP': 1, 'IGMP': 2, 'TCP': 6, 'UDP': 17, 'ESP': 50, 'AH': 51, 'ICMPv6': 58}

0 commit comments

Comments
 (0)