mirror of
https://github.com/jung-geun/DynamicDNS-SSL.git
synced 2025-12-19 20:44:40 +09:00
Refactor file paths in Makefile, run_script.sh, and start.sh
Update default_env.json to include CLOUDFLARE_CNAME configuration Update update_dns.py to handle CNAME records for multiple A records Add .gitignore for env.json in init directory
This commit is contained in:
1
init/.gitignore
vendored
Normal file
1
init/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
env.json
|
||||
@@ -6,7 +6,9 @@
|
||||
"@": true
|
||||
},
|
||||
"CLOUDFLARE_CNAME": {
|
||||
"*": true
|
||||
"*": {
|
||||
"@": true
|
||||
}
|
||||
},
|
||||
"CLOUDFLARE_MX": {}
|
||||
}
|
||||
@@ -80,6 +80,8 @@ class DDNS:
|
||||
required_keys,
|
||||
)
|
||||
|
||||
self.domain = config["CLOUDFLARE_DOMAIN"]
|
||||
|
||||
return config
|
||||
|
||||
def get_config(self):
|
||||
@@ -258,9 +260,16 @@ class DDNS:
|
||||
def update_cname_list(self, cname_list, domain):
|
||||
try:
|
||||
records_list = self.read_record(type="CNAME", content=domain)
|
||||
tmp_cname_list = []
|
||||
for cname in cname_list.keys():
|
||||
a_record = list(cname_list[cname].keys())[0]
|
||||
a_record = a_record if a_record != "@" else self.domain.split(".")[0]
|
||||
proxy = list(cname_list[cname].values())[0]
|
||||
if a_record == domain.split(".")[0]:
|
||||
tmp_cname_list.append([cname, proxy])
|
||||
|
||||
if not records_list:
|
||||
for cname, proxy in cname_list.items():
|
||||
for [cname, proxy] in tmp_cname_list:
|
||||
self.create_record(
|
||||
type="CNAME", name=cname, content=domain, proxy=proxy
|
||||
)
|
||||
@@ -270,7 +279,7 @@ class DDNS:
|
||||
for r in records_list:
|
||||
pre_list[r["name"].split(".")[0]] = [r["proxied"], r["id"]]
|
||||
|
||||
for cname, proxy in cname_list.items():
|
||||
for [cname, proxy] in tmp_cname_list:
|
||||
if cname in pre_list.keys():
|
||||
if proxy != pre_list[cname][0]:
|
||||
self.update_record(
|
||||
@@ -316,9 +325,13 @@ if __name__ == "__main__":
|
||||
API.update_ip(API.current_ip)
|
||||
|
||||
# Update CNAME records
|
||||
result = API.update_cname_list(
|
||||
config["CLOUDFLARE_CNAME"], config["CLOUDFLARE_DOMAIN"]
|
||||
)
|
||||
for a in config["CLOUDFLARE_A"]:
|
||||
domain = (
|
||||
a + "." + config["CLOUDFLARE_DOMAIN"]
|
||||
if a != "@"
|
||||
else config["CLOUDFLARE_DOMAIN"]
|
||||
)
|
||||
result = API.update_cname_list(config["CLOUDFLARE_CNAME"], domain)
|
||||
if not result:
|
||||
logger.error("Failed to update CNAME records")
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user