aboutsummaryrefslogtreecommitdiff
path: root/src/ztdns_db_connectivity.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/ztdns_db_connectivity.py')
-rw-r--r--src/ztdns_db_connectivity.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/ztdns_db_connectivity.py b/src/ztdns_db_connectivity.py
index b754daa..86f9a44 100644
--- a/src/ztdns_db_connectivity.py
+++ b/src/ztdns_db_connectivity.py
@@ -12,3 +12,14 @@ def start_db_connection():
# should set it themselves - but for now, set it here
connection.autocommit = True
return connection
+
+# we'll use it for setting SNAT
+# https://stackoverflow.com/questions/166506/finding-local-ip-addresses-using-pythons-stdlib
+def get_default_host_address(remote_address):
+ import socket
+ config = yaml.safe_load(open(db_config_path, 'r'))
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ s.connect((config['database'], 80))
+ hostaddr = s.getsockname()[0]
+ s.close()
+ return hostaddr