Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """DNS plugin."""
  4. import collections
  5. import logging
  6. import zope.interface
  7. from acme import challenges
  8. from certbot import interfaces
  9. from certbot.plugins import common
  10. from certbot_pdns.PdnsApiAuthenticator import PdnsApiAuthenticator
  11. logger = logging.getLogger(__name__)
  12. @zope.interface.implementer(interfaces.IAuthenticator)
  13. @zope.interface.provider(interfaces.IPluginFactory)
  14. class Authenticator(common.Plugin):
  15. """PDNS Authenticator."""
  16. description = "Place challenges in DNS records"
  17. MORE_INFO = """\
  18. Authenticator plugin that performs dns-01 challenge by saving
  19. necessary validation resources to appropriate records in a PowerDNS server."""
  20. backend = None
  21. def more_info(self): # pylint: disable=missing-docstring,no-self-use
  22. return self.MORE_INFO
  23. @classmethod
  24. def add_parser_arguments(cls, add):
  25. add("certbot-pdns-config", default="/etc/letsencrypt/certbot-pdns.json",
  26. help="Path to certbot-pdns configuration file")
  27. def get_chall_pref(self, domain): # pragma: no cover
  28. # pylint: disable=missing-docstring,no-self-use,unused-argument
  29. return [challenges.DNS01]
  30. def __init__(self, *args, **kwargs):
  31. super(Authenticator, self).__init__(*args, **kwargs)
  32. self.full_roots = {}
  33. self.performed = collections.defaultdict(set)
  34. def prepare(self): # pylint: disable=missing-docstring
  35. self.backend = PdnsApiAuthenticator()
  36. conf_path = self.conf("certbot-pdns-config")
  37. self.backend.prepare(conf_path)
  38. pass
  39. def perform(self, achalls): # pylint: disable=missing-docstring
  40. responses = []
  41. zones = []
  42. for achall in achalls:
  43. response, validation = achall.response_and_validation()
  44. resp = self.backend.perform_single(achall, response, validation)
  45. responses.append(resp)
  46. domain = achall.domain
  47. zone = self.backend.find_best_matching_zone(domain)
  48. if zone not in zones:
  49. zones.append(zone)
  50. for zone in zones:
  51. self.backend.perform_notify(zone)
  52. self.backend.wait_for_propagation(achalls)
  53. return responses
  54. def cleanup(self, achalls): # pylint: disable=missing-docstring
  55. for achall in achalls:
  56. self.backend.cleanup(achall)