Browse Source

fixed authenticator to notify each zone only once

issue #1
tags/v1.1.0
Robin Thoni 7 years ago
parent
commit
607e6f5ffc
2 changed files with 21 additions and 7 deletions
  1. 6
    2
      certbot_pdns/PdnsApiAuthenticator.py
  2. 15
    5
      certbot_pdns/authenticator.py

+ 6
- 2
certbot_pdns/PdnsApiAuthenticator.py View File

@@ -77,12 +77,16 @@ class PdnsApiAuthenticator:
77 77
         res = self.api.replace_record(zone["name"], "_acme-challenge." + domain + ".", "TXT", 1, "\"" + token + "\"", False, False)
78 78
         if res is not None:
79 79
             raise errors.PluginError("Bad return from PDNS API when adding record: %s" % res)
80
+
81
+        return response
82
+
83
+    def perform_notify(self, zone):
84
+        logger.info("Notifying zone %s..." % zone["name"])
85
+
80 86
         self.update_soa(zone["name"])
81 87
         self.flush_zone(zone["name"])
82 88
         self.notify_zone(zone["name"])
83 89
 
84
-        return response
85
-
86 90
     def wait_for_propagation(self, achalls):
87 91
         # TODO search zones authoritative servers and check for TXT record on each of them
88 92
         # raw_input('Press <ENTER> to continue')

+ 15
- 5
certbot_pdns/authenticator.py View File

@@ -49,14 +49,24 @@ necessary validation resources to appropriate records in a PowerDNS server."""
49 49
         pass
50 50
 
51 51
     def perform(self, achalls):  # pylint: disable=missing-docstring
52
-        responses = [self._perform_single(achall) for achall in achalls]
52
+        responses = []
53
+        zones = []
54
+        for achall in achalls:
55
+            response, validation = achall.response_and_validation()
56
+            resp = self.backend.perform_single(achall, response, validation)
57
+            responses.append(resp)
58
+
59
+            domain = achall.domain
60
+            zone = self.backend.find_best_matching_zone(domain)
61
+            if zone not in zones:
62
+                zones.append(zone)
63
+
64
+        for zone in zones:
65
+            self.backend.perform_notify(zone)
66
+
53 67
         self.backend.wait_for_propagation(achalls)
54 68
         return responses
55 69
 
56
-    def _perform_single(self, achall):
57
-        response, validation = achall.response_and_validation()
58
-        return self.backend.perform_single(achall, response, validation)
59
-
60 70
     def cleanup(self, achalls):  # pylint: disable=missing-docstring
61 71
         for achall in achalls:
62 72
             self.backend.cleanup(achall)

Loading…
Cancel
Save