Improve WOAcme ip check

This commit is contained in:
VirtuBox
2024-04-21 12:51:59 +02:00
parent e12cc063d6
commit 9a7c5e4ea1
2 changed files with 15 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ from wo.core.logging import Log
from wo.core.shellexec import WOShellExec, CommandExecutionError
from wo.core.variables import WOVar
from wo.core.template import WOTemplate
from wo.core.checkfqdn import WOFqdn
class WOAcme:
@@ -181,10 +182,10 @@ class WOAcme:
def check_dns(self, acme_domains):
"""Check if a list of domains point to the server IP"""
server_ip = requests.get('https://v4.wordops.eu/').text
server_ip = WOFqdn.get_server_ip(self)
for domain in acme_domains:
domain_ip = requests.get('http://v4.wordops.eu/dns/{0}/'
.format(domain)).text
domain_ip = WOFqdn.get_domain_ip(self, domain)
if (not domain_ip == server_ip):
Log.warn(
self, "{0}".format(domain) +

View File

@@ -51,3 +51,14 @@ class WOFqdn:
except requests.exceptions.RequestException as e:
print("Error occurred during request:", e)
return None
def get_domain_ip(self, wo_domain):
"""Get the server externet IP"""
try:
y = requests.get('http://v4.wordops.eu/dns/{0}/'.format(wo_domain))
domain_ip = (y.text).strip()
return domain_ip
except requests.exceptions.RequestException as e:
print("Error occurred during request:", e)
return None