-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change DynDNS Provider to Cloudflare (#7)
* Changed DynDNS registrar to Cloudflare Updated some functions Rewrite to better add multiple domains New Logo * Updated deps * Updated Readme.md * Update README.md Added section on how to obtain Cloudflare credentials and IDs
- Loading branch information
Showing
8 changed files
with
150 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
environment | ||
venv | ||
__pycache__ | ||
.idea | ||
.gitignore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
config.json | ||
docker-compose.yml | ||
environment | ||
venv | ||
__pycache__ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
![GitHub release (with filter)](https://img.shields.io/github/v/release/simonl169/dns-owl) ![GitHub all releases](https://img.shields.io/github/downloads/simonl169/dns-owl/total) | ||
![Static Badge](https://img.shields.io/badge/Python-3.11-blue) | ||
|
||
|
||
|
||
|
||
|
||
# dns-owl | ||
This is a little Python script that updates your IP to the DynDNS servers of Strato | ||
This is a little Python script that updates your IP to the DynDNS servers of Cloudflare | ||
|
||
# Use | ||
You can deploy this container on your server and update your public IP to the Strato DynDNS Servers. You can specify the update intervall in the environment variables using standard cron notation. | ||
|
||
In the config.json you can enter the domains you want to update by a comma-separated list | ||
You can deploy this container on your server and update your public IP to the Cloudflare DynDNS Servers. You can specify the update intervall in the environment variables using standard cron notation. | ||
|
||
In the config.json you can enter the domains you want to update by a comma-separated list. | ||
New for Cloudflare: you have to add your Zone ID, Record IDs and API Key, as well as the Mail to access the Cloudflare API and Update your records. | ||
|
||
# Record ID and Zone ID, API Key | ||
You can get your Zone ID and API Key form your Cloudflare Profile. If you are unsure, refer to the Cloudflare docs. | ||
With Zone ID, Key and Mail, you can run | ||
~~~ | ||
curl --request GET \ | ||
--url https://api.cloudflare.com/client/v4/zones/{YOUR_ZONE_ID}/dns_records \ | ||
--header 'Content-Type: application/json' \ | ||
--header 'X-Auth-Email: [email protected]' \ | ||
--header 'X-Auth-Key: {YOUR_API_KEY}' | ||
~~~ | ||
The result contains a list of your subdomains for this record and their corresponding RECORD_ID. | ||
|
||
# Careful | ||
The script waits the specified interval before doing its first update. If you chose a long one (eg. 1 day) it takes as much time for the first update. During this, nothing is written to the log, so it can seems as the container is hung up, which is not the case. | ||
I try to remove this and have it run an update right at the start of the container. | ||
I will try to make the logs more verbose in future versions. | ||
|
||
# Strato | ||
Support for Strato is deprecated, since I no longer host my domains there and cannot test any changes. | ||
With the next update I will tr to make the script supporting both. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
{ | ||
|
||
"ZONE_ID": "your_zone_id", | ||
"USER_EMAIL": "[email protected]", | ||
"API_KEY": "your_CF_API_key", | ||
"domains": [ | ||
"domain1.example.com", | ||
"domain2.example.com", | ||
"domain3.example.com" | ||
{ | ||
"RECORD_ID": "record_key_1", | ||
"RECORD_NAME": "sub1.domain.com" | ||
}, | ||
{ | ||
"RECORD_ID": "record_key_2", | ||
"RECORD_NAME": "sub2.domain.com" | ||
} | ||
] | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,9 @@ | ||
# This is a sample Python script. | ||
import dns_functions as dns | ||
|
||
# Press Shift+F10 to execute it or replace it with your code. | ||
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. | ||
if __name__ == "__main__": | ||
|
||
import requests | ||
import json | ||
import os | ||
import datetime | ||
from subprocess import call | ||
|
||
|
||
from dns_functions import * | ||
|
||
def dns_main(): | ||
print('###############-------------------------------------') | ||
print(f'Current Time: {datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S")}') | ||
print('Getting current public IP address...') | ||
public_server_ip = get_current_public_ip() | ||
print('###############-------------------------------------') | ||
print('Reading config.json...') | ||
with open('config.json', 'r') as f: | ||
data = json.load(f) | ||
|
||
print('###############-------------------------------------') | ||
for url in data['domains']: | ||
print(f'\tChecking IP address for domain {url}') | ||
local_dns_ip, public_dns_ip = resolve_current_server_ip(url) | ||
print('\tCompare to current public IP address...') | ||
|
||
decide = compare_ip(public_server_ip, public_dns_ip) | ||
|
||
if not decide: | ||
print('\tDetecting different DNS IP, update needed') | ||
password = os.environ.get('STRATO_DYNDNS_PASSWORD', 'default') | ||
update_dns_ip(url, password) | ||
else: | ||
print('\tIP has not changed, no further action') | ||
|
||
print('###############-------------------------------------') | ||
|
||
|
||
# Press the green button in the gutter to run the script. | ||
if __name__ == '__main__': | ||
|
||
print('Running DNS Owl\n') | ||
print(' {o,o} ') | ||
print('./)_)') | ||
print(' ""\n') | ||
print('by Simon169\n') | ||
|
||
dns_main() | ||
|
||
print('done! Next repetition set by crontab variables!') | ||
dns.print_owl() | ||
print(f"{'':#<40}") | ||
ip = dns.get_current_public_ip() | ||
|
||
dns.update_all_ip(ip) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
certifi==2023.5.7 | ||
charset-normalizer==3.1.0 | ||
idna==3.4 | ||
certifi==2024.2.2 | ||
charset-normalizer==3.3.2 | ||
idna==3.6 | ||
pydig==0.4.0 | ||
requests==2.31.0 | ||
urllib3==2.0.3 | ||
urllib3==2.2.1 |