Run ACME server on specified ``port``. This method is idempotent, i.e. all calls with the same pair of ``(port, challenge_type)`` will reuse the same server. :param int port: Port to run the server on. :param challenge_type: Subclass of `acme.challenges.Challenge`,
(self, port: int, challenge_type: type[challenges.Challenge],
listenaddr: str = "")
| 34 | self.http_01_resources = http_01_resources |
| 35 | |
| 36 | def run(self, port: int, challenge_type: type[challenges.Challenge], |
| 37 | listenaddr: str = "") -> acme_standalone.HTTP01DualNetworkedServers: |
| 38 | """Run ACME server on specified ``port``. |
| 39 | |
| 40 | This method is idempotent, i.e. all calls with the same pair of |
| 41 | ``(port, challenge_type)`` will reuse the same server. |
| 42 | |
| 43 | :param int port: Port to run the server on. |
| 44 | :param challenge_type: Subclass of `acme.challenges.Challenge`, |
| 45 | currently only `acme.challenge.HTTP01`. |
| 46 | :param str listenaddr: (optional) The address to listen on. Defaults to all addrs. |
| 47 | |
| 48 | :returns: DualNetworkedServers instance. |
| 49 | :rtype: ACMEServerMixin |
| 50 | |
| 51 | """ |
| 52 | assert challenge_type == challenges.HTTP01 |
| 53 | if port in self._instances: |
| 54 | return self._instances[port] |
| 55 | |
| 56 | address = (listenaddr, port) |
| 57 | try: |
| 58 | servers = acme_standalone.HTTP01DualNetworkedServers( |
| 59 | address, self.http_01_resources) |
| 60 | except OSError as error: |
| 61 | raise errors.StandaloneBindError(error, port) |
| 62 | |
| 63 | servers.serve_forever() |
| 64 | |
| 65 | # if port == 0, then random free port on OS is taken |
| 66 | # both servers, if they exist, have the same port |
| 67 | real_port = servers.getsocknames()[0][1] |
| 68 | self._instances[real_port] = servers |
| 69 | return servers |
| 70 | |
| 71 | def stop(self, port: int) -> None: |
| 72 | """Stop ACME server running on the specified ``port``. |