diff options
author | Lizzy Hunt <elizabeth.hunt@simponic.xyz> | 2024-04-02 09:23:21 -0600 |
---|---|---|
committer | Lizzy Hunt <elizabeth.hunt@simponic.xyz> | 2024-04-02 09:23:21 -0600 |
commit | 79b2264ff586c40d3b49de321543e320326bd1fe (patch) | |
tree | 72cacb4e22843b62c5eb1bb24fae3fa222bab584 | |
download | dns-updater-79b2264ff586c40d3b49de321543e320326bd1fe.tar.gz dns-updater-79b2264ff586c40d3b49de321543e320326bd1fe.zip |
init
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | records.json | 79 | ||||
-rw-r--r-- | script.py | 38 |
3 files changed, 118 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bceb371 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.secret diff --git a/records.json b/records.json new file mode 100644 index 0000000..0eaf4e1 --- /dev/null +++ b/records.json @@ -0,0 +1,79 @@ +[ + { + "type": "A", + "name": "johan.internal.simponic.xyz", + "content": "100.64.0.5", + "ttl": "43200", + "internal": "on" + }, + { + "type": "A", + "name": "europa.internal.simponic.xyz", + "content": "100.64.0.8", + "ttl": "43200", + "internal": "on" + }, + { + "type": "CNAME", + "name": "vaultwarden.internal.simponic.xyz", + "content": "johan.internal.simponic.xyz", + "ttl": "43200", + "internal": "on" + }, + { + "type": "CNAME", + "name": "lldap.internal.simponic.xyz", + "content": "johan.internal.simponic.xyz", + "ttl": "43200", + "internal": "on" + }, + { + "type": "CNAME", + "name": "ca.internal.simponic.xyz", + "content": "johan.internal.simponic.xyz", + "ttl": "43200", + "internal": "on" + }, + { + "type": "CNAME", + "name": "pihole.internal.simponic.xyz", + "content": "johan.internal.simponic.xyz", + "ttl": "43200", + "internal": "on" + }, + { + "type": "CNAME", + "name": "owncloud.internal.simponic.xyz", + "content": "europa.internal.simponic.xyz", + "ttl": "43200", + "internal": "on" + }, + { + "type": "CNAME", + "name": "jellyfin.internal.simponic.xyz", + "content": "europa.internal.simponic.xyz", + "ttl": "43200", + "internal": "on" + }, + { + "type": "CNAME", + "name": "drone.internal.simponic.xyz", + "content": "europa.internal.simponic.xyz", + "ttl": "43200", + "internal": "on" + }, + { + "type": "CNAME", + "name": "scurvy.internal.simponic.xyz", + "content": "europa.internal.simponic.xyz", + "ttl": "43200", + "internal": "on" + }, + { + "type": "CNAME", + "name": "roundcube.internal.simponic.xyz", + "content": "europa.internal.simponic.xyz", + "ttl": "43200", + "internal": "on" + } +] diff --git a/script.py b/script.py new file mode 100644 index 0000000..ed97e8e --- /dev/null +++ b/script.py @@ -0,0 +1,38 @@ +import json +import requests +import time +import logging + +RECORDS_FILE = "records.json" +ENDPOINT = "https://hatecomputers.club" +API_KEY = open('apikey.secret', 'r').read().strip() + +class HatecomputersDNSAdapter: + def __init__(self, endpoint, api_key): + self.endpoint = endpoint + self.session = requests.Session() + self.headers = {'Authorization': 'Bearer ' + api_key} + self.session = requests.Session() + + def post_record(self, record): + endpoint = self.endpoint + "/dns" + logging.info("adding", record, "at", endpoint) + + self.session.post(endpoint, headers=self.headers, data=record) + + def post_records(self, dns_entries, sleep_time=300): + for record in dns_entries: + self.post_record(record) + + logging.info("sleeping", sleep_time) + time.sleep(sleep_time) + +if __name__ == "__main__": + logging.basicConfig() + logging.root.setLevel(logging.NOTSET) + + records_file = open(RECORDS_FILE, 'r') + dns_records = json.load(records_file) + + adapter = HatecomputersDNSAdapter(ENDPOINT, API_KEY) + adapter.post_records(dns_records) |