You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1.7 KiB

  1. # Copyright 2014-2016 OpenMarket Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import logging
  15. import sys
  16. from synapse import python_dependencies # noqa: E402
  17. logger = logging.getLogger(__name__)
  18. try:
  19. python_dependencies.check_requirements()
  20. except python_dependencies.DependencyException as e:
  21. sys.stderr.writelines(
  22. e.message # noqa: B306, DependencyException.message is a property
  23. )
  24. sys.exit(1)
  25. def check_bind_error(e, address, bind_addresses):
  26. """
  27. This method checks an exception occurred while binding on 0.0.0.0.
  28. If :: is specified in the bind addresses a warning is shown.
  29. The exception is still raised otherwise.
  30. Binding on both 0.0.0.0 and :: causes an exception on Linux and macOS
  31. because :: binds on both IPv4 and IPv6 (as per RFC 3493).
  32. When binding on 0.0.0.0 after :: this can safely be ignored.
  33. Args:
  34. e (Exception): Exception that was caught.
  35. address (str): Address on which binding was attempted.
  36. bind_addresses (list): Addresses on which the service listens.
  37. """
  38. if address == "0.0.0.0" and "::" in bind_addresses:
  39. logger.warning(
  40. "Failed to listen on 0.0.0.0, continuing because listening on [::]"
  41. )
  42. else:
  43. raise e