Permalink
Browse files

Indicates the time of the query in JSON and XML. Closes #14.

  • Loading branch information...
bortzmeyer committed Mar 5, 2013
1 parent a5e8acd commit e7511a0224bd93b38969a712620c9b198c1958c5
Showing with 9 additions and 4 deletions.
  1. +5 −1 DNSLG/Formatter.py
  2. +3 −2 JSON.txt
  3. +1 −1 setup.py
View
@@ -364,6 +364,8 @@ def format(self, answer, qtype, qclass, flags, querier):
duration = (delay.days*86400) + delay.seconds + \
(float(delay.microseconds)/1000000.0)
self.object['Query'] = {'Server': answer.nameserver,
+ 'Time': time.strftime("%Y-%m-%d %H:%M:%SZ",
+ time.gmtime(time.time())),
'Duration': duration}
if querier.description:
self.object['Query']['Description'] = querier.description
@@ -384,7 +386,7 @@ def result(self, querier):
<result>
<query>
<question><qname tal:content="qname"/><qtype tal:content="qtype"/></question>
- <server><resolver tal:content="resolver"/><duration tal:content="duration"/><description tal:condition="description" tal:content="description"/><versions tal:condition="version" tal:content="version"/></server>
+ <server><resolver tal:content="resolver"/><duration tal:content="duration"/><time tal:content="time"/><description tal:condition="description" tal:content="description"/><versions tal:condition="version" tal:content="version"/></server>
</query>
<response>
<!-- TODO: query ID -->
@@ -494,6 +496,8 @@ def format(self, answer, qtype, qclass, flags, querier):
duration = (delay.days*86400) + delay.seconds + \
(float(delay.microseconds)/1000000.0)
self.context.addGlobal ("duration", duration)
+ self.context.addGlobal ("time", time.strftime("%Y-%m-%d %H:%M:%SZ",
+ time.gmtime(time.time())))
self.context.addGlobal ("description", querier.description)
self.context.addGlobal ("version",
"DNS Looking Glass %s, DNSpython version %s, Python version %s %s on %s\n" % \
View
@@ -119,8 +119,9 @@ SPF:
Note there is no concept of resource record sets.
-The Query object has fields about the query: Time is the time taken
-to process the request, Server the resolver used.
+The Query object has fields about the query: Time is the time of the
+test, Duration is the number of seconds it took to process the
+request, Server is the resolver used.
Examples:
View
@@ -6,7 +6,7 @@
from setuptools import setup
setup(name='DNS-LG',
- version='2013030101',
+ version='2013030501',
description='DNS Looking Glass',
license='BSD',
author='Stephane Bortzmeyer',

0 comments on commit e7511a0

Please sign in to comment.