From 32ce8656071b0d4b9e18f82bac1d78217ee1e442 Mon Sep 17 00:00:00 2001 From: Julian Lobbes Date: Fri, 2 Sep 2022 22:55:34 +0200 Subject: [PATCH] feat: merge user vars into a single config file --- .gitignore | 3 --- README.md | 46 ++++++++++++++++++++-------------------------- apikey.yml | 7 ------- config.yml | 14 ++++++++++++++ domains.json | 8 -------- 5 files changed, 34 insertions(+), 44 deletions(-) delete mode 100644 apikey.yml create mode 100644 config.yml delete mode 100644 domains.json diff --git a/.gitignore b/.gitignore index 1646dc9..4ccfae7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,2 @@ .venv **/__pycache__ - -apikey.yml -domains.json diff --git a/README.md b/README.md index 2acd8d0..7961e57 100644 --- a/README.md +++ b/README.md @@ -8,41 +8,35 @@ Python libraries: - [requests](https://pypi.org/project/requests/) - [pyyaml](https://pypi.org/project/PyYAML/) -### Initial setup +### Configuration -Install the [dependencies](#dependencies), preferrably using your system's package manager. +Configuration is declared inside the file `config.yml`. +Once modified, this file **must be kept secret**, else anyone visiting your domains runs the risk of being DNS-poisoned. -Next, you will need your Ionos API keypair. -Clone the repo and edit the file `apikey.yml`. -Inside the file, paste the respective value of your Ionos API-keypair, following this format: +First, you will need to set your Ionos API keypair in the config file. +Paste the respective values of your Ionos API-keypair into the file ```yaml ---- - apikey: prefix: secret: - -... ``` -This file **must be kept secret**. +Next, add every domain you wish to send an update for to the `domains` list. +The script will set a global DNS record for each listed domain and have it point to the local host's public IP address. +The `domains` list should have the following format: -### Adding target domains - -Add every domain you want to send an update for to the file `domains.json`. -The file should list each domain whose global DNS record should point to the local host's public IP. -The file must have the following format: - -```json -{ - "domains": [ - "example.com", - "subdomain1.example.com", - "subdomain2.example.com", - ], - "description": "My dynamic DNS." -} +```yaml +domains: + - example.com + - subdomain1.example.com + - subdomain2.example.com ``` -The description can have any string as a value, but it must be present. +You may optionally set a descriptive string which is sent along with the update: +```yaml +description: "Dynamic DNS update." +``` + +As of right now, I am actually not sure what the description is needed for, but the API requires it. +The value displayed above is used by default, if you don't override it inside `config.yml`. diff --git a/apikey.yml b/apikey.yml deleted file mode 100644 index 05722ab..0000000 --- a/apikey.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -apikey: - prefix: - secret: - -... diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..c1ae455 --- /dev/null +++ b/config.yml @@ -0,0 +1,14 @@ +--- + +apikey: + prefix: + secret: + +domains: + - example.com + - subdomain1.example.com + - subdomain2.example.com + +description: "Dynamic DNS update." + +... diff --git a/domains.json b/domains.json deleted file mode 100644 index eafbd85..0000000 --- a/domains.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "domains": [ - "example.com", - "subdomain1.example.com", - "subdomain2.example.com", - ], - "description": "My dynamic DNS." -}