From 64ce9667c4b55e22886191784db49260a40b417d Mon Sep 17 00:00:00 2001 From: Wojciech Kosior Date: Tue, 16 Jun 2020 13:59:34 +0200 Subject: fix to not write records for vpns we don't handle --- src/hourly.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hourly.py b/src/hourly.py index 0401bc1..f830bb7 100755 --- a/src/hourly.py +++ b/src/hourly.py @@ -69,6 +69,9 @@ def do_hourly_work(hour, logfile): if handled_vpns: logfile.write("Only handling vpns of ids {}\n".format(handled_vpns)) vpns = [vpn for vpn in vpns if vpn[0] in handled_vpns] + else: + # if not specfied in the config, all vpns are handled + hadled_vpns = [vpn[0] for vpn in vpns] for vpn_id, config_hash in vpns: config_path = "/var/lib/0tdns/{}.ovpn".format(config_hash) @@ -124,8 +127,8 @@ def do_hourly_work(hour, logfile): q.dns_id = r.dns_id AND q.vpn_id = r.vpn_id AND date = %s - WHERE r.id IS NULL); - ''', (hour, hour)) + WHERE r.id IS NULL AND q.vpn_id = ANY(%s)); + ''', (hour, hour, handled_vpns)) cursor.close() connection.close() -- cgit v1.2.3