mirror of
https://github.com/aaPanel/aaPanel.git
synced 2026-09-22 09:24:53 +02:00
Fixed known bugs Panel Feature Modification Points to note after updating the panel: 1. The default port of the panel is changed to 7800 (Port 8888 has been flooded) 2. Panel entry error will prompt 404 3. After the panel is bound to the domain name, if the domain access is not used,it will return 401 4. After the panel is set to authorize IP access, other IP access panels will return 401 5. The website welcome page is changed to the nginx welcome page 6. Change the stop page to Nginx 404 page
78 lines
3.3 KiB
Python
78 lines
3.3 KiB
Python
import logging
|
|
|
|
|
|
class BaseDns(object):
|
|
"""
|
|
"""
|
|
|
|
def __init__(self, LOG_LEVEL="INFO"):
|
|
self.LOG_LEVEL = LOG_LEVEL
|
|
self.dns_provider_name = self.__class__.__name__
|
|
|
|
self.logger = logging.getLogger("sewer")
|
|
handler = logging.StreamHandler()
|
|
formatter = logging.Formatter("%(message)s")
|
|
handler.setFormatter(formatter)
|
|
if not self.logger.handlers:
|
|
self.logger.addHandler(handler)
|
|
self.logger.setLevel(self.LOG_LEVEL)
|
|
|
|
def log_response(self, response):
|
|
"""
|
|
renders a python-requests response as json or as a string
|
|
"""
|
|
try:
|
|
log_body = response.json()
|
|
except ValueError:
|
|
log_body = response.content
|
|
return log_body
|
|
|
|
def create_dns_record(self, domain_name, domain_dns_value):
|
|
"""
|
|
Method that creates/adds a model TXT record for a domain/subdomain name on
|
|
a chosen DNS provider.
|
|
|
|
:param domain_name: :string: The domain/subdomain name whose model record ought to be
|
|
created/added on a chosen DNS provider.
|
|
:param domain_dns_value: :string: The value/content of the TXT record that will be
|
|
created/added for the given domain/subdomain
|
|
|
|
This method should return None
|
|
|
|
Basic Usage:
|
|
If the value of the `domain_name` variable is example.com and the value of
|
|
`domain_dns_value` is HAJA_4MkowIFByHhFaP8u035skaM91lTKplKld
|
|
Then, your implementation of this method ought to create a DNS TXT record
|
|
whose name is '_acme-challenge' + '.' + domain_name + '.' (ie: _acme-challenge.example.com. )
|
|
and whose value/content is HAJA_4MkowIFByHhFaP8u035skaM91lTKplKld
|
|
|
|
Using a model client like dig(https://linux.die.net/man/1/dig) to do a model lookup should result
|
|
in something like:
|
|
dig TXT _acme-challenge.example.com
|
|
...
|
|
;; ANSWER SECTION:
|
|
_acme-challenge.example.com. 120 IN TXT "HAJA_4MkowIFByHhFaP8u035skaM91lTKplKld"
|
|
_acme-challenge.singularity.brandur.org. 120 IN TXT "9C0DqKC_4MkowIFByHhFaP8u0Zv4z7Wz2IHM91lTKec"
|
|
Optionally, you may also use an online model client like: https://toolbox.googleapps.com/apps/dig/#TXT/
|
|
|
|
Please consult your model provider on how/format of their DNS TXT records.
|
|
You may also want to consult the cloudflare DNS implementation that is found in this repository.
|
|
"""
|
|
self.logger.info("create_dns_record")
|
|
raise NotImplementedError("create_dns_record method must be implemented.")
|
|
|
|
def delete_dns_record(self, domain_name, domain_dns_value):
|
|
"""
|
|
Method that deletes/removes a model TXT record for a domain/subdomain name on
|
|
a chosen DNS provider.
|
|
|
|
:param domain_name: :string: The domain/subdomain name whose model record ought to be
|
|
deleted/removed on a chosen DNS provider.
|
|
:param domain_dns_value: :string: The value/content of the TXT record that will be
|
|
deleted/removed for the given domain/subdomain
|
|
|
|
This method should return None
|
|
"""
|
|
self.logger.info("delete_dns_record")
|
|
raise NotImplementedError("delete_dns_record method must be implemented.")
|