mirror of
https://github.com/laurivosandi/certidude
synced 2024-12-23 00:25:18 +00:00
Use local time for connected_since
This commit is contained in:
parent
108c2bc017
commit
4c1e72709c
@ -1,10 +1,13 @@
|
|||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from dateutil import tz
|
||||||
from pyasn1.codec.der import decoder
|
from pyasn1.codec.der import decoder
|
||||||
from certidude import config
|
from certidude import config
|
||||||
from certidude.auth import login_required, authorize_admin
|
from certidude.auth import login_required, authorize_admin
|
||||||
from certidude.decorators import serialize
|
from certidude.decorators import serialize
|
||||||
|
|
||||||
|
localtime = tz.tzlocal()
|
||||||
|
|
||||||
OIDS = {
|
OIDS = {
|
||||||
(2, 5, 4, 3) : 'CN', # common name
|
(2, 5, 4, 3) : 'CN', # common name
|
||||||
(2, 5, 4, 6) : 'C', # country
|
(2, 5, 4, 6) : 'C', # country
|
||||||
@ -39,10 +42,12 @@ class StatusFileLeaseResource(object):
|
|||||||
from openvpn_status import parse_status
|
from openvpn_status import parse_status
|
||||||
from urllib import urlopen
|
from urllib import urlopen
|
||||||
fh = urlopen(self.uri)
|
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())
|
status = parse_status(fh.read())
|
||||||
for cn, e in status.routing_table.items():
|
for cn, e in status.routing_table.items():
|
||||||
yield {
|
yield {
|
||||||
"acquired": status.client_list[cn].connected_since,
|
"acquired": status.client_list[cn].connected_since.replace(tzinfo=localtime)
|
||||||
"released": None,
|
"released": None,
|
||||||
"address": e.virtual_address,
|
"address": e.virtual_address,
|
||||||
"identity": "CN=%s" % cn, # BUGBUG
|
"identity": "CN=%s" % cn, # BUGBUG
|
||||||
|
Loading…
Reference in New Issue
Block a user