mirror of
https://github.com/jung-geun/DynamicDNS-SSL.git
synced 2025-12-19 20:44:40 +09:00
Refactor file paths and update dependencies
This commit is contained in:
3
dynamicdns_ssl/__init__.py
Normal file
3
dynamicdns_ssl/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from .update_dns import DDNS
|
||||||
|
|
||||||
|
__all__ = ["DDNS"]
|
||||||
@@ -3,7 +3,7 @@ import logging
|
|||||||
import logging.handlers
|
import logging.handlers
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from typing import Literal, Optional
|
from typing import Literal
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
@@ -259,6 +259,7 @@ class DDNS:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"A RECORDS UPDATE Error: {e}")
|
logger.error(f"A RECORDS UPDATE Error: {e}")
|
||||||
|
logger.error("Failed to update A records")
|
||||||
sys.exit(5)
|
sys.exit(5)
|
||||||
|
|
||||||
def update_cname_list(self, cname_list):
|
def update_cname_list(self, cname_list):
|
||||||
@@ -316,26 +317,5 @@ class DDNS:
|
|||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"CNAME RECORDS UPDATE Error: {e}")
|
logger.error(f"CNAME RECORDS UPDATE Error: {e}")
|
||||||
|
logger.error("Failed to update CNAME records")
|
||||||
sys.exit(5)
|
sys.exit(5)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
API = DDNS()
|
|
||||||
config = API.get_config()
|
|
||||||
|
|
||||||
# Check if the IP has changed
|
|
||||||
results = API.update_a_list(config["CLOUDFLARE_A"], API.current_ip)
|
|
||||||
|
|
||||||
if not results:
|
|
||||||
logger.error("Failed to update DNS A records")
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
API.update_ip(API.current_ip)
|
|
||||||
|
|
||||||
# Update CNAME records
|
|
||||||
result = API.update_cname_list(config["CLOUDFLARE_CNAME"])
|
|
||||||
if not result:
|
|
||||||
logger.error("Failed to update CNAME records")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
sys.exit(0)
|
|
||||||
17
run.py
Normal file
17
run.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import sys
|
||||||
|
from dynamicdns_ssl import DDNS
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
API = DDNS()
|
||||||
|
config = API.get_config()
|
||||||
|
|
||||||
|
# Check if the IP has changed
|
||||||
|
results = API.update_a_list(config["CLOUDFLARE_A"], API.current_ip)
|
||||||
|
|
||||||
|
API.update_ip(API.current_ip)
|
||||||
|
|
||||||
|
# Update CNAME records
|
||||||
|
result = API.update_cname_list(config["CLOUDFLARE_CNAME"])
|
||||||
|
|
||||||
|
sys.exit(0)
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
# Run the script
|
# Run the script
|
||||||
python3 $DIR/../src/update_dns.py $@
|
python3 $DIR/../run.py $@
|
||||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
1
tmp/.gitignore
vendored
Normal file
1
tmp/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
external_ip
|
||||||
Reference in New Issue
Block a user