aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-06-15 21:19:02 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-06-15 21:19:02 +0200
commit41693328880905b719f458c37b6c8c7bdc9ab2ac (patch)
treeb38600f4ba8e24dbaaff1a00dce7ab8657a6b570
parent7b861f4398407d289ece997715f3ffa828850130 (diff)
download0tdns-41693328880905b719f458c37b6c8c7bdc9ab2ac.tar.gz
0tdns-41693328880905b719f458c37b6c8c7bdc9ab2ac.zip
round hour when inserting
-rwxr-xr-xsrc/perform_queries.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/perform_queries.py b/src/perform_queries.py
index 0d77355..688f4c5 100755
--- a/src/perform_queries.py
+++ b/src/perform_queries.py
@@ -15,7 +15,8 @@ class dns_queries:
self.services = services
class single_query:
- def __init__(self, cursor, vpn_id, dns_id, service_id):
+ def __init__(self, hour, cursor, vpn_id, dns_id, service_id):
+ self.hour = hour
self.cursor = cursor
self.vpn_id = vpn_id
self.dns_id = dns_id
@@ -67,9 +68,10 @@ def resolve_call_back(mydata, status, result):
# write to database
query.cursor.execute('''
INSERT INTO user_side_responses (date, result, dns_id, service_id, vpn_id)
- VALUES (current_timestamp, %s, %s, %s, %s)
+ VALUES (%s, %s, %s, %s, %s)
RETURNING id
- ''', (result_info, query.dns_id, query.service_id, query.vpn_id))
+ ''', (query.hour, result_info, query.dns_id,
+ query.service_id, query.vpn_id))
responses_id = query.cursor.fetchone()[0]
@@ -93,7 +95,8 @@ def query_dns(dns_queries):
for service_id, service_name in dns_queries.services:
print("starting resolution of {} through {}".format(service_name,
dns_queries.dns_IP))
- query = single_query(cursor, vpn_id, dns_queries.dns_id, service_id)
+ query = single_query(hour, cursor, vpn_id,
+ dns_queries.dns_id, service_id)
ctx.resolve_async(service_name, query, resolve_call_back,
unbound.RR_TYPE_A, unbound.RR_CLASS_IN)