aboutsummaryrefslogtreecommitdiff
path: root/script.py
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-04-10 16:13:16 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2024-04-10 16:13:16 -0600
commit0c7ac77127e47f0130ab4961303eedd245c0ca6f (patch)
tree27fa0ea407703606c54d09303eab07afb6ae5328 /script.py
parent7c62833cb3dfc28d279bc72c6a68a7a907488759 (diff)
downloadhatecomputers-dns-updater-0c7ac77127e47f0130ab4961303eedd245c0ca6f.tar.gz
hatecomputers-dns-updater-0c7ac77127e47f0130ab4961303eedd245c0ca6f.zip
initial setup
Diffstat (limited to 'script.py')
-rw-r--r--script.py37
1 files changed, 0 insertions, 37 deletions
diff --git a/script.py b/script.py
deleted file mode 100644
index 4315de9..0000000
--- a/script.py
+++ /dev/null
@@ -1,37 +0,0 @@
-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}
-
- def post_record(self, record):
- endpoint = self.endpoint + "/dns"
- logging.info(f"adding {record} to {endpoint}")
-
- self.session.post(endpoint, headers=self.headers, data=record)
-
- def post_records(self, dns_entries, eepy_time=0.25):
- for record in dns_entries:
- self.post_record(record)
-
- logging.info(f"sleeping for {eepy_time}")
- time.sleep(eepy_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)