This commit is contained in:
Elizabeth Hunt 2024-04-02 09:23:21 -06:00
commit 79b2264ff5
Signed by: simponic
GPG Key ID: 2909B9A7FF6213EE
3 changed files with 118 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.secret

79
records.json Normal file
View File

@ -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"
}
]

38
script.py Normal file
View File

@ -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)