aiomisc 17.6.1__py3-none-any.whl → 17.7.1__py3-none-any.whl

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.
aiomisc/process_pool.py CHANGED
@@ -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)
aiomisc/service/tls.py CHANGED
@@ -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:
aiomisc/version.py CHANGED
@@ -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, 1)
6
- __version__ = "17.6.1"
5
+ version_info = (17, 7, 1)
6
+ __version__ = "17.7.1"
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: aiomisc
3
- Version: 17.6.1
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
@@ -15,7 +15,7 @@ aiomisc/periodic.py,sha256=OFYZbPkcGgeMjBk8zwsLr2TqPRTS6MNewaL3q9qK5js,2252
15
15
  aiomisc/plugins/__init__.py,sha256=eHKGec_217rBjXGf8u-Joyf7dzpO1O0QAuFan1IEyYE,1057
16
16
  aiomisc/plugins/__main__.py,sha256=y3mykRQmimDRHb_PvY4n08vegjWTjd9CONFbCecAxxw,1365
17
17
  aiomisc/pool.py,sha256=kmTEziX7U1kXxmNsTEain9Jkzn8ZbFubuCYWaozZoRk,5764
18
- aiomisc/process_pool.py,sha256=EwzB_HqxoKX7h3A7DVeRy1AIg-rN0nSpCl9KfGW54Ss,1596
18
+ aiomisc/process_pool.py,sha256=tYSWEXxCP-QXum2TFhyQzyvg86JUSo7EUcrCI7si2-c,1614
19
19
  aiomisc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  aiomisc/recurring.py,sha256=LJ13P_OhZM6mVOed8iUrS-M9PXY12516XBZcFtO7XtI,4923
21
21
  aiomisc/service/__init__.py,sha256=_JSkI4Q78UljG4CvhK6He2UGLxJaQS6cVwZ9QT0cSWo,607
@@ -37,7 +37,7 @@ aiomisc/service/profiler.py,sha256=6KiJsU7tD5eO4YKZXYujV2E8P-G8GUqLAGIl0AuPNG4,1
37
37
  aiomisc/service/raven.py,sha256=VHqnXWx-_r71_pjFniIB_E4CgT2reuRD1EB4yEC0hzE,12214
38
38
  aiomisc/service/sdwatchdog.py,sha256=6AMI0MP5deZKEmxguE3w68dapW4xFLRYgx9rgBk5mRw,4473
39
39
  aiomisc/service/tcp.py,sha256=gIdm4wXT191TMpL3Yzm_I7y--1kVxBLioN5lBP8mlhs,5507
40
- aiomisc/service/tls.py,sha256=oFTYVe2zf1Ow_Gniem9WyNj_SkD3q95bcsz8LWAYqdI,7325
40
+ aiomisc/service/tls.py,sha256=EyWADLNV4P0BSXE8sALXwZUTHo6zjstMS7ecka-bBmU,9337
41
41
  aiomisc/service/tracer.py,sha256=_dxk5y2JEteki9J1OXnOkI-EowD9vakSfsLaRDB4uMQ,2826
42
42
  aiomisc/service/udp.py,sha256=_uHzMAkpd7y-yt3tE9jN2llEETG7r47g2DF1SO7xyig,3616
43
43
  aiomisc/service/uvicorn.py,sha256=I2KYQL9ysFFqQHPYK00G4EoceA7J9p9Or6v1ATpLGw8,4324
@@ -45,7 +45,7 @@ aiomisc/signal.py,sha256=_iiC2jukXg7-LLirIl1YATlKIIsKLbmTNFr1Ezheu7g,1728
45
45
  aiomisc/thread_pool.py,sha256=591u5HV1aBmBRcaVm4kAtMLPZOb6veqhT9wkts_knqE,14017
46
46
  aiomisc/timeout.py,sha256=5jNDooLW4MAe6ZUIKhkiX29CoyI0zlXd-dZoZwQPxak,920
47
47
  aiomisc/utils.py,sha256=6yTfTpeRCVzfZp-MJCmB1oayOHUBVwQwzC3U5PBAjn8,11919
48
- aiomisc/version.py,sha256=B1TWv5iW-jCEjR-oBMiuzklqcstWO0YKJhja1ibBplg,154
48
+ aiomisc/version.py,sha256=ilCS52JKzZl7hvZBGb2kc1YcDTr33fTbVWDUYneN5D4,154
49
49
  aiomisc/worker_pool.py,sha256=GA91KdOrBlqHthbVSTxu_d6BsBIbl-uKqW2NxqSafG0,11107
50
50
  aiomisc_log/__init__.py,sha256=N3g8Ea1YE2dWPDd-MwohuAn3Y0pBxSyL4l4Jsxqkv0Q,4854
51
51
  aiomisc_log/enum.py,sha256=_zfCZPYCGyI9KL6TqHiYVlOfA5U5MCbsuCuDKxDHdxg,1549
@@ -63,8 +63,8 @@ aiomisc_worker/process_inner.py,sha256=8ZtjCSLrgySW57OIbuGrpEWxfysRLYKx1or1YaAqx
63
63
  aiomisc_worker/protocol.py,sha256=1smmlBbdreSmnrxuhHaUMUC10FO9xMIEcedhweQJX_A,2705
64
64
  aiomisc_worker/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
65
  aiomisc_worker/worker.py,sha256=f8nCFhlKh84UUBUaEgCllwMRvVZiD8_UUXaeit6g3T8,3236
66
- aiomisc-17.6.1.dist-info/COPYING,sha256=Ky_8CQMaIixfyOreUBsl0hKN6A5fLnPF8KPQ9molMYA,1125
67
- aiomisc-17.6.1.dist-info/METADATA,sha256=lv79HXU0kcTEBHkLhwfCsd19zqzJ4E7V9tKh1Dgu0VI,15735
68
- aiomisc-17.6.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
69
- aiomisc-17.6.1.dist-info/entry_points.txt,sha256=KRsSPCwKJyGTWrvzpwbS0yIDwzsgDA2X6f0CBWYmNao,55
70
- aiomisc-17.6.1.dist-info/RECORD,,
66
+ aiomisc-17.7.1.dist-info/COPYING,sha256=Ky_8CQMaIixfyOreUBsl0hKN6A5fLnPF8KPQ9molMYA,1125
67
+ aiomisc-17.7.1.dist-info/METADATA,sha256=LO9OgOb81BQZvB91ZWZp_T-p3piEI4ASpJOgSJu0baQ,15685
68
+ aiomisc-17.7.1.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
69
+ aiomisc-17.7.1.dist-info/entry_points.txt,sha256=KRsSPCwKJyGTWrvzpwbS0yIDwzsgDA2X6f0CBWYmNao,55
70
+ aiomisc-17.7.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.0.1
2
+ Generator: poetry-core 2.1.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any