aiomisc 17.6.3__tar.gz → 17.7.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. {aiomisc-17.6.3 → aiomisc-17.7.1}/PKG-INFO +3 -4
  2. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/process_pool.py +3 -1
  3. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/tls.py +57 -8
  4. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/version.py +2 -2
  5. {aiomisc-17.6.3 → aiomisc-17.7.1}/pyproject.toml +6 -6
  6. {aiomisc-17.6.3 → aiomisc-17.7.1}/COPYING +0 -0
  7. {aiomisc-17.6.3 → aiomisc-17.7.1}/README.rst +0 -0
  8. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/__init__.py +0 -0
  9. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/_context_vars.py +0 -0
  10. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/aggregate.py +0 -0
  11. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/backoff.py +0 -0
  12. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/circuit_breaker.py +0 -0
  13. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/compat.py +0 -0
  14. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/context.py +0 -0
  15. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/counters.py +0 -0
  16. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/cron.py +0 -0
  17. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/entrypoint.py +0 -0
  18. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/io.py +0 -0
  19. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/iterator_wrapper.py +0 -0
  20. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/log.py +0 -0
  21. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/periodic.py +0 -0
  22. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/plugins/__init__.py +0 -0
  23. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/plugins/__main__.py +0 -0
  24. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/pool.py +0 -0
  25. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/py.typed +0 -0
  26. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/recurring.py +0 -0
  27. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/__init__.py +0 -0
  28. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/aiohttp.py +0 -0
  29. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/asgi.py +0 -0
  30. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/base.py +0 -0
  31. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/carbon.py +0 -0
  32. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/cron.py +0 -0
  33. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/dns/__init__.py +0 -0
  34. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/dns/records.py +0 -0
  35. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/dns/service.py +0 -0
  36. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/dns/store.py +0 -0
  37. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/dns/tree.py +0 -0
  38. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/dns/zone.py +0 -0
  39. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/grpc_server.py +0 -0
  40. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/periodic.py +0 -0
  41. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/process.py +0 -0
  42. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/profiler.py +0 -0
  43. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/raven.py +0 -0
  44. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/sdwatchdog.py +0 -0
  45. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/tcp.py +0 -0
  46. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/tracer.py +0 -0
  47. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/udp.py +0 -0
  48. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/service/uvicorn.py +0 -0
  49. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/signal.py +0 -0
  50. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/thread_pool.py +0 -0
  51. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/timeout.py +0 -0
  52. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/utils.py +0 -0
  53. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc/worker_pool.py +0 -0
  54. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_log/__init__.py +0 -0
  55. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_log/enum.py +0 -0
  56. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_log/formatter/__init__.py +0 -0
  57. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_log/formatter/color.py +0 -0
  58. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_log/formatter/journald.py +0 -0
  59. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_log/formatter/json.py +0 -0
  60. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_log/formatter/rich.py +0 -0
  61. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_log/py.typed +0 -0
  62. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_worker/__init__.py +0 -0
  63. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_worker/__main__.py +0 -0
  64. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_worker/forking.py +0 -0
  65. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_worker/process.py +0 -0
  66. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_worker/process_inner.py +0 -0
  67. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_worker/protocol.py +0 -0
  68. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_worker/py.typed +0 -0
  69. {aiomisc-17.6.3 → aiomisc-17.7.1}/aiomisc_worker/worker.py +0 -0
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aiomisc
3
- Version: 17.6.3
3
+ Version: 17.7.1
4
4
  Summary: aiomisc - miscellaneous utils for asyncio
5
5
  License: MIT
6
6
  Author: Dmitry Orlov
7
7
  Author-email: me@mosquito.su
8
- Requires-Python: >=3.8,<4.0
8
+ Requires-Python: >=3.9,<4.0
9
9
  Classifier: Development Status :: 5 - Production/Stable
10
10
  Classifier: Framework :: AsyncIO
11
11
  Classifier: Framework :: Pytest
@@ -23,7 +23,6 @@ Classifier: Operating System :: POSIX
23
23
  Classifier: Operating System :: POSIX :: Linux
24
24
  Classifier: Programming Language :: Python
25
25
  Classifier: Programming Language :: Python :: 3
26
- Classifier: Programming Language :: Python :: 3.8
27
26
  Classifier: Programming Language :: Python :: 3.9
28
27
  Classifier: Programming Language :: Python :: 3.10
29
28
  Classifier: Programming Language :: Python :: 3.11
@@ -66,7 +65,7 @@ Requires-Dist: rich ; extra == "rich"
66
65
  Requires-Dist: setuptools ; python_version < "3.8"
67
66
  Requires-Dist: typing_extensions ; python_version < "3.10"
68
67
  Requires-Dist: uvicorn (>=0.27,<0.28) ; extra == "uvicorn"
69
- Requires-Dist: uvloop (>=0.19,<1) ; extra == "uvloop"
68
+ Requires-Dist: uvloop (>=0.21,<1) ; extra == "uvloop"
70
69
  Project-URL: Changelog, https://github.com/aiokitchen/aiomisc/blob/master/CHANGELOG.md
71
70
  Project-URL: Documentation, https://docs.aiomisc.com/
72
71
  Project-URL: Homepage, https://github.com/aiokitchen/aiomisc
@@ -39,7 +39,9 @@ class ProcessPoolExecutor(ProcessPoolExecutorBase, EventLoopMixin):
39
39
  self._statistic.sum_time += loop.time() - start_time
40
40
 
41
41
  def submit(self, *args: Any, **kwargs: Any) -> Future:
42
- """Submit blocking function to the pool"""
42
+ """
43
+ Submit blocking function to the pool
44
+ """
43
45
  loop = asyncio.get_running_loop()
44
46
  start_time = loop.time()
45
47
  future = super().submit(*args, **kwargs)
@@ -17,6 +17,19 @@ PathOrStr = Union[Path, str]
17
17
  log = logging.getLogger(__name__)
18
18
 
19
19
 
20
+ DEFAULT_SSL_CIPHERS = (
21
+ "ECDHE-RSA-AES256-GCM-SHA384",
22
+ "ECDHE-ECDSA-AES256-GCM-SHA384",
23
+ "ECDHE-RSA-CHACHA20-POLY1305",
24
+ "ECDHE-ECDSA-CHACHA20-POLY1305",
25
+ "ECDHE-RSA-AES128-GCM-SHA256",
26
+ "ECDHE-ECDSA-AES128-GCM-SHA256",
27
+ )
28
+
29
+ DEFAULT_SSL_MIN_VERSION = ssl.TLSVersion.TLSv1_3
30
+ DEFAULT_SSL_MAX_VERSION = ssl.TLSVersion.TLSv1_3
31
+
32
+
20
33
  @dataclass(frozen=True)
21
34
  class SSLOptionsBase:
22
35
  cert: Optional[Path]
@@ -25,6 +38,9 @@ class SSLOptionsBase:
25
38
  verify: bool
26
39
  require_client_cert: bool
27
40
  purpose: ssl.Purpose
41
+ minimum_version: ssl.TLSVersion = DEFAULT_SSL_MIN_VERSION
42
+ maximum_version: ssl.TLSVersion = DEFAULT_SSL_MAX_VERSION
43
+ ciphers: Tuple[str, ...] = DEFAULT_SSL_CIPHERS
28
44
 
29
45
 
30
46
  class SSLOptions(SSLOptionsBase):
@@ -32,6 +48,9 @@ class SSLOptions(SSLOptionsBase):
32
48
  self, cert: Optional[PathOrStr], key: Optional[PathOrStr],
33
49
  ca: Optional[PathOrStr], verify: bool, require_client_cert: bool,
34
50
  purpose: ssl.Purpose,
51
+ minimum_version: ssl.TLSVersion = DEFAULT_SSL_MIN_VERSION,
52
+ maximum_version: ssl.TLSVersion = DEFAULT_SSL_MAX_VERSION,
53
+ ciphers: Tuple[str, ...] = DEFAULT_SSL_CIPHERS,
35
54
  ) -> None:
36
55
  super().__init__(
37
56
  cert=Path(cert) if cert else None,
@@ -40,25 +59,48 @@ class SSLOptions(SSLOptionsBase):
40
59
  verify=verify,
41
60
  require_client_cert=require_client_cert,
42
61
  purpose=purpose,
62
+ minimum_version=minimum_version,
63
+ maximum_version=maximum_version,
64
+ ciphers=ciphers,
43
65
  )
44
66
 
45
67
  def create_context(self) -> ssl.SSLContext:
46
68
  context = ssl.create_default_context(
47
- purpose=self.purpose, cafile=self.ca,
69
+ purpose=self.purpose,
48
70
  )
49
71
 
50
- if self.ca and not self.ca.exists():
51
- raise FileNotFoundError("CA file doesn't exists")
72
+ # Disable compression to prevent CRIME attacks
73
+ context.options |= ssl.OP_NO_COMPRESSION
74
+
75
+ context.maximum_version = self.maximum_version
76
+ context.minimum_version = self.minimum_version
77
+ context.set_ciphers(":".join(self.ciphers))
78
+
79
+ if not self.verify:
80
+ context.check_hostname = False
81
+
82
+ if self.ca:
83
+ log.debug("Loading CA from %s", self.ca)
84
+ if not self.ca.exists():
85
+ raise FileNotFoundError(
86
+ "CA file doesn't exists", str(self.ca.resolve()),
87
+ )
88
+ context.load_verify_locations(cafile=str(self.ca))
52
89
 
53
90
  if self.require_client_cert:
91
+ log.debug("Set server-side cert verification")
54
92
  context.verify_mode = ssl.VerifyMode.CERT_REQUIRED
93
+ # Post-handshake authentication is required
94
+ context.post_handshake_auth = True
95
+ else:
96
+ # Disable server-side cert verification
97
+ context.check_hostname = False
98
+ context.verify_mode = ssl.VerifyMode.CERT_NONE
55
99
 
100
+ # Load server-side cert and key
56
101
  if self.key and self.cert:
57
102
  context.load_cert_chain(self.cert, self.key)
58
103
 
59
- if not self.verify:
60
- context.check_hostname = False
61
-
62
104
  return context
63
105
 
64
106
 
@@ -69,13 +111,20 @@ class TLSServer(SimpleServer):
69
111
  self, *, address: Optional[str] = None, port: Optional[int] = None,
70
112
  cert: PathOrStr, key: PathOrStr, ca: Optional[PathOrStr] = None,
71
113
  require_client_cert: bool = False, verify: bool = True,
114
+ minimum_version: ssl.TLSVersion = DEFAULT_SSL_MIN_VERSION,
115
+ maximum_version: ssl.TLSVersion = DEFAULT_SSL_MAX_VERSION,
116
+ ciphers: Tuple[str, ...] = DEFAULT_SSL_CIPHERS,
72
117
  options: OptionsType = (), sock: Optional[socket.socket] = None,
73
118
  **kwargs: Any,
74
119
  ):
75
120
 
76
121
  self.__ssl_options = SSLOptions(
77
- cert, key, ca, verify, require_client_cert,
78
- ssl.Purpose.CLIENT_AUTH,
122
+ cert=cert, key=key, ca=ca, verify=verify,
123
+ require_client_cert=require_client_cert,
124
+ purpose=ssl.Purpose.CLIENT_AUTH,
125
+ minimum_version=minimum_version,
126
+ maximum_version=maximum_version,
127
+ ciphers=ciphers,
79
128
  )
80
129
 
81
130
  if not sock:
@@ -2,5 +2,5 @@
2
2
  # BY: poem-plugins "git" plugin
3
3
  # NEVER EDIT THIS FILE MANUALLY
4
4
 
5
- version_info = (17, 6, 3)
6
- __version__ = "17.6.3"
5
+ version_info = (17, 7, 1)
6
+ __version__ = "17.7.1"
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "aiomisc"
3
3
  # This is a dummy version which will be rewritten with poem-plugins
4
- version = "17.6.3"
4
+ version = "17.7.1"
5
5
  description = "aiomisc - miscellaneous utils for asyncio"
6
6
  authors = ["Dmitry Orlov <me@mosquito.su>"]
7
7
  readme = "README.rst"
@@ -24,11 +24,11 @@ classifiers = [
24
24
  "Operating System :: POSIX :: Linux",
25
25
  "Operating System :: POSIX",
26
26
  "Programming Language :: Python :: 3",
27
- "Programming Language :: Python :: 3.8",
28
27
  "Programming Language :: Python :: 3.9",
29
28
  "Programming Language :: Python :: 3.10",
30
29
  "Programming Language :: Python :: 3.11",
31
30
  "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
32
32
  "Programming Language :: Python :: Implementation :: CPython",
33
33
  "Programming Language :: Python",
34
34
  "Topic :: Internet :: WWW/HTTP",
@@ -55,7 +55,7 @@ packages = [
55
55
  "Documentation" = "https://docs.aiomisc.com/"
56
56
 
57
57
  [tool.poetry.dependencies]
58
- python = "^3.8"
58
+ python = "^3.9"
59
59
  aiocarbon = { version = "^0.15", optional = true }
60
60
  aiohttp = { version = ">3", optional = true }
61
61
  aiohttp-asgi = { version = "^0.5.2", optional = true }
@@ -69,14 +69,14 @@ raven = { version = "*", optional = true }
69
69
  rich = { version = "*", optional = true }
70
70
  setuptools = [{ version = '*', python = "< 3.8" }]
71
71
  typing_extensions = [{ version = '*', python = "< 3.10" }]
72
- uvloop = { version = ">=0.19, <1", optional = true }
72
+ uvloop = { version = ">=0.21, <1", optional = true }
73
73
  uvicorn = { version = "^0.27", optional = true }
74
74
  asgiref = { version = "^3.7", optional = true }
75
75
  dnslib = { version = "^0.9", optional = true }
76
76
 
77
77
  [tool.poetry.group.dev.dependencies]
78
78
  aiocarbon = "^0.15.3"
79
- aiohttp = "^3.9"
79
+ aiohttp = "^3.11"
80
80
  aiohttp-asgi = "~0.5.2"
81
81
  aiomisc-pytest = "^1.0.8"
82
82
  asgiref = "^3.7"
@@ -116,7 +116,7 @@ pytest-rerunfailures = "^14.0"
116
116
  sphinxcontrib-googleanalytics = "^0.4"
117
117
 
118
118
  [tool.poetry.group.uvloop.dependencies]
119
- uvloop = "^0.19.0"
119
+ uvloop = "^0.21"
120
120
 
121
121
  [tool.poetry.extras]
122
122
  aiohttp = ["aiohttp"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes