-
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.
* 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 * Added new feature for push notifications Added start-up sequence Refactor code into more files * Change image to Python 3.12
- Loading branch information
Showing
8 changed files
with
115 additions
and
37 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 @@ | ||
FROM python:3.11-alpine | ||
FROM python:3.12-alpine | ||
|
||
RUN mkdir app | ||
RUN apk add bind-tools | ||
|
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,6 @@ | ||
{ | ||
|
||
"NOTIFY_SERVER": "https://<YOUR_NTFY_SERVER>/<TOPIC>", | ||
"ENABLE_NOTIFICATIONS": false, | ||
"ZONE_ID": "your_zone_id", | ||
"USER_EMAIL": "[email protected]", | ||
"API_KEY": "your_CF_API_key", | ||
|
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import json | ||
|
||
|
||
def load_config(filename: str): | ||
with open(filename, 'r') as f: | ||
data = json.load(f) | ||
return data | ||
|
||
|
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,3 +1,5 @@ | ||
python -c 'from owl import *; starting_message()' # Run starting message and logo | ||
python main.py # Run Update once directly at the start | ||
echo "$CRONVARS2" "cd /app && python main.py" >> mycron | ||
crontab mycron | ||
crond -f |
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,9 +1,12 @@ | ||
import dns_functions as dns | ||
import owl as owl | ||
|
||
if __name__ == "__main__": | ||
|
||
dns.print_owl() | ||
# owl.print_owl() | ||
print(f"{'':#<40}") | ||
ip = dns.get_current_public_ip() | ||
|
||
dns.update_all_ip(ip) | ||
dns.update_all_ip(ip) | ||
|
||
print(f"\tDone updating, sleep until next CRON schedule...") |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import requests | ||
from config import load_config | ||
|
||
|
||
class Notifier: | ||
def __init__(self): | ||
self.data = load_config('config.json') | ||
self.ntfy_server = self.data['NOTIFY_SERVER'] | ||
|
||
def send_success(self, message: str = "Generic success message"): | ||
message = "🟢 Success: " + message | ||
requests.post(self.ntfy_server, data=message.encode(encoding='utf-8')) | ||
|
||
def send_warning(self, message: str = "Generic warning message"): | ||
message = "⚠️ Warning: " + message | ||
requests.post(self.ntfy_server, data=message.encode(encoding='utf-8')) | ||
|
||
def send_error(self, message: str = "Generic error message"): | ||
message = "🚩 Error: " + message | ||
requests.post(self.ntfy_server, data=message.encode(encoding='utf-8')) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
test_notifier = Notifier() | ||
test_notifier.send_success() | ||
test_notifier.send_warning() | ||
test_notifier.send_error() | ||
|
||
# test_notifier = None | ||
# if test_notifier: | ||
# print('ladida') |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from datetime import datetime | ||
|
||
|
||
def print_owl(): | ||
print(r""" | ||
# _____ _ _ _____ ____ __ __ _ ___ ____ | ||
# | __ \ | \ | | / ____| / __ \\ \ / /| | / _ \ |___ \ | ||
# | | | || \| || (___ | | | |\ \ /\ / / | | __ __| | | | __) | | ||
# | | | || . ` | \___ \ | | | | \ \/ \/ / | | \ \ / /| | | | |__ < | ||
# | |__| || |\ | ____) | | |__| | \ /\ / | |____ \ V / | |_| |_ ___) | | ||
# |_____/ |_| \_||_____/ \____/ \/ \/ |______| \_/ \___/(_)|____/ | ||
__________-------____ ____-------__________ | ||
\------____-------___--__---------__--___-------____------/ | ||
\//////// / / / / / \ _-------_ / \ \ \ \ \ \\\\\\\\/ | ||
\////-/-/------/_/_| /___ ___\ |_\_\------\-\-\\\\/ | ||
--//// / / / //|| (O)\ /(O) ||\\ \ \ \ \\\\-- | ||
---__/ // /| \_ /V\ _/ |\ \\ \__--- | ||
-// / /\_ ------- _/\ \ \\- | ||
\_/_/ /\---------/\ \_\_/ | ||
----\ | /---- | ||
| -|- | | ||
/ | \ | ||
---- \___| | ||
# by Simon169 | ||
""") | ||
|
||
|
||
def starting_message(): | ||
now = datetime.now() | ||
current_time = now.strftime("%d/%m/%Y, %H:%M:%S") | ||
|
||
print(f""" | ||
\t Starting DNS-Owl... | ||
\t Time/Date: {current_time} | ||
""") | ||
print_owl() | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
starting_message() | ||
|
||
|
||
# ASCII Art vreated with https://patorjk.com/software/taag |