aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojciech Kosior <kwojtus@protonmail.com>2020-06-12 12:05:33 +0200
committerWojciech Kosior <kwojtus@protonmail.com>2020-06-12 12:05:33 +0200
commit6006e6a460ea0692df7d74936d388b479bf26ad9 (patch)
treea772230d3e0c8107bd88fac5e77f0875de108541
parent6b119f76190cb2f5d38f9fb52ec5b60e65d29cc4 (diff)
download0tdns-6006e6a460ea0692df7d74936d388b479bf26ad9.tar.gz
0tdns-6006e6a460ea0692df7d74936d388b479bf26ad9.zip
add option to only handle some of the vpns on a give back-end instance
-rw-r--r--db_connection_config.yml3
-rwxr-xr-xsrc/hourly.py4
2 files changed, 4 insertions, 3 deletions
diff --git a/db_connection_config.yml b/db_connection_config.yml
index abe2500..5e23380 100644
--- a/db_connection_config.yml
+++ b/db_connection_config.yml
@@ -3,4 +3,5 @@ password: postgres
host: "127.0.0.1"
port: "5432"
database: "ztdns"
-enabled: no \ No newline at end of file
+enabled: no
+handled_vpns: [1, 2] \ No newline at end of file
diff --git a/src/hourly.py b/src/hourly.py
index 2c87bee..7396bc2 100755
--- a/src/hourly.py
+++ b/src/hourly.py
@@ -50,7 +50,7 @@ hour = strftime('%Y-%m-%d %H:00', gmtime())
vpns = get_vpn_connections(cursor, hour)
-for vpn_id, config_hash in vpns:
+for vpn_id, config_hash in vpns if vpn_id in ztdns_config['handled_vpns']:
config_path = "/var/lib/0tdns/{}.ovpn".format(config_hash)
if not path.isfile(config_path):
sync_ovpn_config(cursor, vpn_id, config_path, config_hash)
@@ -58,7 +58,7 @@ for vpn_id, config_hash in vpns:
cursor.close()
connection.close()
-for vpn_id, config_hash in vpns:
+for vpn_id, config_hash in vpns if vpn_id in ztdns_config['handled_vpns']:
config_path = "/var/lib/0tdns/{}.ovpn".format(config_hash)
physical_ip = get_default_host_address(ztdns_config['database'])
route_through_veth = ztdns_config['database'] + "/32"