aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-06-15 22:54:52 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-06-15 22:54:52 +0200
commit90a01f573bfc6e31d1ad1d71cdaa8135ca7193f7 (patch)
tree94d035bdaad7a70b7ad3b9c3b21935b907fd124e /src
parenta1d391c923fae02a85a598f32c5788fbcfd57f25 (diff)
download0tdns-90a01f573bfc6e31d1ad1d71cdaa8135ca7193f7.tar.gz
0tdns-90a01f573bfc6e31d1ad1d71cdaa8135ca7193f7.zip
put vpn connection failure info in responses table
Diffstat (limited to 'src')
-rwxr-xr-xsrc/hourly.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/hourly.py b/src/hourly.py
index 60d9cab..8fe68a4 100755
--- a/src/hourly.py
+++ b/src/hourly.py
@@ -67,9 +67,6 @@ with open("/var/log/0tdns.log", "a") as logfile:
.format(vpn_id, config_hash))
sync_ovpn_config(cursor, vpn_id, config_path, config_hash)
- cursor.close()
- connection.close()
-
parallel_vpns = ztdns_config['parallel_vpns']
pids_vpns = {} # map each wrapper pid to id of the vpn it connects to
@@ -106,3 +103,19 @@ with open("/var/log/0tdns.log", "a") as logfile:
while len(pids_vpns) > 0:
wait_for_wrapper_process()
+
+ cursor.execute('''
+ INSERT INTO user_side_responses(date, result, dns_id, service_id, vpn_id)
+ (SELECT TIMESTAMP WITH TIME ZONE %s,
+ 'internal failure: vpn_connection_failure',
+ q.dns_id, q.service_id, q.vpn_id
+ FROM user_side_responses AS r RIGHT JOIN user_side_queries AS q
+ ON q.service_id = r.service_id AND
+ q.dns_id = r.dns_id AND
+ q.vpn_id = r.vpn_id AND
+ date = %s
+ WHERE r.id IS NULL);
+ ''', (hour, hour))
+
+ cursor.close()
+ connection.close()