From 4c1e72709cc901c4db71a2a37a35c23ccb50be3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Thu, 26 Jan 2017 22:31:06 +0000 Subject: [PATCH] Use local time for connected_since --- certidude/api/lease.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/certidude/api/lease.py b/certidude/api/lease.py index d7e7161..2a8b815 100644 --- a/certidude/api/lease.py +++ b/certidude/api/lease.py @@ -1,10 +1,13 @@ from datetime import datetime +from dateutil import tz from pyasn1.codec.der import decoder from certidude import config from certidude.auth import login_required, authorize_admin from certidude.decorators import serialize +localtime = tz.tzlocal() + OIDS = { (2, 5, 4, 3) : 'CN', # common name (2, 5, 4, 6) : 'C', # country @@ -39,10 +42,12 @@ class StatusFileLeaseResource(object): from openvpn_status import parse_status from urllib import urlopen fh = urlopen(self.uri) + # openvpn-status.log has no information about timezone + # and dates marked there use local time instead of UTC status = parse_status(fh.read()) for cn, e in status.routing_table.items(): yield { - "acquired": status.client_list[cn].connected_since, + "acquired": status.client_list[cn].connected_since.replace(tzinfo=localtime) "released": None, "address": e.virtual_address, "identity": "CN=%s" % cn, # BUGBUG