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

+ 15
- 5
certbot_pdns/authenticator.py View File

49
         pass
49
         pass
50
 
50
 
51
     def perform(self, achalls):  # pylint: disable=missing-docstring
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
         self.backend.wait_for_propagation(achalls)
67
         self.backend.wait_for_propagation(achalls)
54
         return responses
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
     def cleanup(self, achalls):  # pylint: disable=missing-docstring
70
     def cleanup(self, achalls):  # pylint: disable=missing-docstring
61
         for achall in achalls:
71
         for achall in achalls:
62
             self.backend.cleanup(achall)
72
             self.backend.cleanup(achall)

Loading…
Cancel
Save