python-socks 2.5.0__py3-none-any.whl → 2.5.2__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.
@@ -3,7 +3,6 @@ import socket
3
3
  from .._abc import AsyncSocketStream, AsyncResolver
4
4
  from .abc import AsyncConnector
5
5
 
6
- from .._protocols.errors import ReplyError
7
6
  from .._protocols import socks5
8
7
  from .._helpers import is_ip_address
9
8
 
@@ -66,15 +65,28 @@ class Socks5AsyncConnector(AsyncConnector):
66
65
  data = conn.send(request)
67
66
  await stream.write_all(data)
68
67
 
68
+ data = await self._read_reply(stream)
69
+ reply: socks5.ConnectReply = conn.receive(data)
70
+ return reply
71
+
72
+ # noinspection PyMethodMayBeStatic
73
+ async def _read_reply(self, stream: AsyncSocketStream) -> bytes:
69
74
  data = await stream.read_exact(4)
70
- if data[3] == socks5.AddressType.IPV4:
75
+ if data[0] != socks5.SOCKS_VER:
76
+ return data
77
+ if data[1] != socks5.ReplyCode.SUCCEEDED:
78
+ return data
79
+ if data[2] != socks5.RSV:
80
+ return data
81
+
82
+ addr_type = data[3]
83
+
84
+ if addr_type == socks5.AddressType.IPV4:
71
85
  data += await stream.read_exact(6)
72
- elif data[3] == socks5.AddressType.IPV6:
86
+ elif addr_type == socks5.AddressType.IPV6:
73
87
  data += await stream.read_exact(18)
74
- elif data[3] == socks5.AddressType.DOMAIN:
75
- data += await stream.read_exact(int.from_bytes(await stream.read_exact(1)) + 2)
76
- else: # pragma: no cover
77
- raise ReplyError(f'Invalid address type: {data[3]:#02X}')
88
+ elif addr_type == socks5.AddressType.DOMAIN:
89
+ host_len, *_ = await stream.read_exact(1)
90
+ data += await stream.read_exact(host_len + 2)
78
91
 
79
- reply: socks5.ConnectReply = conn.receive(data)
80
- return reply
92
+ return data
@@ -3,7 +3,6 @@ import socket
3
3
  from .._abc import SyncSocketStream, SyncResolver
4
4
  from .abc import SyncConnector
5
5
 
6
- from .._protocols.errors import ReplyError
7
6
  from .._protocols import socks5
8
7
  from .._helpers import is_ip_address
9
8
 
@@ -57,15 +56,28 @@ class Socks5SyncConnector(SyncConnector):
57
56
  data = conn.send(request)
58
57
  stream.write_all(data)
59
58
 
59
+ data = self._read_reply(stream)
60
+ reply: socks5.ConnectReply = conn.receive(data)
61
+ return reply
62
+
63
+ # noinspection PyMethodMayBeStatic
64
+ def _read_reply(self, stream: SyncSocketStream) -> bytes:
60
65
  data = stream.read_exact(4)
61
- if data[3] == socks5.AddressType.IPV4:
66
+ if data[0] != socks5.SOCKS_VER:
67
+ return data
68
+ if data[1] != socks5.ReplyCode.SUCCEEDED:
69
+ return data
70
+ if data[2] != socks5.RSV:
71
+ return data
72
+
73
+ addr_type = data[3]
74
+
75
+ if addr_type == socks5.AddressType.IPV4:
62
76
  data += stream.read_exact(6)
63
- elif data[3] == socks5.AddressType.IPV6:
77
+ elif addr_type == socks5.AddressType.IPV6:
64
78
  data += stream.read_exact(18)
65
- elif data[3] == socks5.AddressType.DOMAIN:
66
- data += stream.read_exact(int.from_bytes(stream.read_exact(1)) + 2)
67
- else: # pragma: no cover
68
- raise ReplyError(f'Invalid address type: {data[3]:#02X}')
79
+ elif addr_type == socks5.AddressType.DOMAIN:
80
+ host_len, *_ = stream.read_exact(1)
81
+ data += stream.read_exact(host_len + 2)
69
82
 
70
- reply: socks5.ConnectReply = conn.receive(data)
71
- return reply
83
+ return data
python_socks/_version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  __title__ = 'python-socks'
2
- __version__ = '2.5.0'
2
+ __version__ = '2.5.2'
@@ -2,7 +2,10 @@ import asyncio
2
2
  import socket
3
3
  import sys
4
4
 
5
- import async_timeout
5
+ if sys.version_info >= (3, 11):
6
+ import asyncio as async_timeout
7
+ else:
8
+ import async_timeout
6
9
 
7
10
  from ..._types import ProxyType
8
11
  from ..._helpers import parse_proxy_url
@@ -1,8 +1,13 @@
1
1
  import asyncio
2
2
  import ssl
3
3
  import warnings
4
+ import sys
4
5
 
5
- import async_timeout
6
+
7
+ if sys.version_info >= (3, 11):
8
+ import asyncio as async_timeout
9
+ else:
10
+ import async_timeout
6
11
 
7
12
  from ...._types import ProxyType
8
13
  from ...._helpers import parse_proxy_url
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-socks
3
- Version: 2.5.0
3
+ Version: 2.5.2
4
4
  Summary: Core proxy (SOCKS4, SOCKS5, HTTP tunneling) functionality for Python
5
5
  Home-page: https://github.com/romis2012/python-socks
6
6
  Author: Roman Snegirev
@@ -10,13 +10,13 @@ Keywords: socks socks5 socks4 http proxy asyncio trio curio anyio
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE.txt
12
12
  Provides-Extra: anyio
13
- Requires-Dist: anyio <5.0.0,>=3.3.4 ; extra == 'anyio'
13
+ Requires-Dist: anyio<5.0.0,>=3.3.4; extra == "anyio"
14
14
  Provides-Extra: asyncio
15
- Requires-Dist: async-timeout >=3.0.1 ; extra == 'asyncio'
15
+ Requires-Dist: async-timeout>=3.0.1; python_version < "3.11" and extra == "asyncio"
16
16
  Provides-Extra: curio
17
- Requires-Dist: curio >=1.4 ; extra == 'curio'
17
+ Requires-Dist: curio>=1.4; extra == "curio"
18
18
  Provides-Extra: trio
19
- Requires-Dist: trio >=0.16.0 ; extra == 'trio'
19
+ Requires-Dist: trio>=0.16.0; extra == "trio"
20
20
 
21
21
  ## python-socks
22
22
 
@@ -3,7 +3,7 @@ python_socks/_abc.py,sha256=_kK5iWNYpHuWRxhK-e6GQdVgRYxcioKIGnSYy2QzAK8,1422
3
3
  python_socks/_errors.py,sha256=l2j03Zna_EJhNqF3yApTYuQ147BcY0k74pkT4HAlRp4,245
4
4
  python_socks/_helpers.py,sha256=WTqOACKhJ80bCLWqeoXHPKp6YWCg66vLtai5AM7HJNY,2517
5
5
  python_socks/_types.py,sha256=dgQifNf2mIwdKoX7YmI91H_lUsW9-Y0ZkZGlIV6_NNw,90
6
- python_socks/_version.py,sha256=3BvpvFG4zPWrLEEv8Ldtw2rIXRnWsseKynCtjZBLORw,49
6
+ python_socks/_version.py,sha256=JkzJVCbfeNU1o7WHtrsZv6U5tL5lzTbwZM3uruyhsSc,49
7
7
  python_socks/_connectors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  python_socks/_connectors/abc.py,sha256=1fgjPiv64UAMiJDsJXYr-GofPGhuHTwTzaodQfrzf7Q,397
9
9
  python_socks/_connectors/factory_async.py,sha256=y9JGVk-ub9FMuQlIp2s5y95F7JMvA2fEdWGRKLUpRXc,997
@@ -12,8 +12,8 @@ python_socks/_connectors/http_async.py,sha256=sCkEporEkm5yr5S08JjzX9VHtXjEsIqrfI
12
12
  python_socks/_connectors/http_sync.py,sha256=BecdB5J8fIAMkNCgTgJqrdF82uIwBVjzoZmefKear34,878
13
13
  python_socks/_connectors/socks4_async.py,sha256=dlQ-AwJ9gNBWMth-E4PxxfW17oWBF2Blxp71HeO80gM,1131
14
14
  python_socks/_connectors/socks4_sync.py,sha256=m0KixzO5jQ6qHHtA5Muq7HcPjTdYPLM4AlTmWZr3SmY,1100
15
- python_socks/_connectors/socks5_async.py,sha256=XufGdX5NRQridwOmUyMHwL0eNIygG8WHa583SMilFX4,2423
16
- python_socks/_connectors/socks5_sync.py,sha256=r3Q-u8VjEoxWj0QuW7wuNQjyQzRc0Rcungs-6JcRlM8,2215
15
+ python_socks/_connectors/socks5_async.py,sha256=A4ZXY-znAaVGpeKNyRdbiW0V3-EgHODNMneDJ-LlEKI,2703
16
+ python_socks/_connectors/socks5_sync.py,sha256=kxT4bQgbsY32BnlnAJFhHtqRz7LnC2ncG7W_Py1pfQo,2482
17
17
  python_socks/_protocols/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  python_socks/_protocols/errors.py,sha256=4XqU4AqgrWaedmUVGMjd6TvQKXv3mV0H76s5lf8aazY,150
19
19
  python_socks/_protocols/http.py,sha256=h6uLgiNbqrd8HUk-nX5lOnCoYRjrZWaQ2CjbOB6QDHI,4451
@@ -34,13 +34,13 @@ python_socks/async_/anyio/v2/_proxy.py,sha256=3qElDSprsJZOsFikn_i7clcKQe7XGg3EiK
34
34
  python_socks/async_/anyio/v2/_stream.py,sha256=40D3Pmb0rryk9gaQlmjpAMdiJi5H5O0xbBseblGG1FY,1616
35
35
  python_socks/async_/asyncio/__init__.py,sha256=0WAM07vy0YvI8IhKGmaUA0GaNLHaG3l-4mnJVbfoqHE,65
36
36
  python_socks/async_/asyncio/_connect.py,sha256=niNKiz2o1kfeIPVR3kXW7YHZ2sTK_Uehgq9tmFwbp7w,1014
37
- python_socks/async_/asyncio/_proxy.py,sha256=l_opVG1HA8ilQyRZ00lRXjTpGlKn4vGi6RQB4WaINcA,4283
37
+ python_socks/async_/asyncio/_proxy.py,sha256=sA3RqbjQU1HFAM6q42wBeQzgT3z8zOtpwz-U8MVMQrQ,4361
38
38
  python_socks/async_/asyncio/_resolver.py,sha256=ROqOncuIub87J9_nMdvRTG_5zYOh8uafk265z0s2ORQ,681
39
39
  python_socks/async_/asyncio/_stream.py,sha256=RP7BIP9iFFy5nLRf9kHH7s1h_zPfo0yoEVKNpExqFcI,1021
40
40
  python_socks/async_/asyncio/v2/__init__.py,sha256=v9eJQeZ2yGJHeBQ0FYqNmIMCRrB547QqoAANHVBitxY,108
41
41
  python_socks/async_/asyncio/v2/_chain.py,sha256=Yle3F3TKEpCo9Snd-T5hRnmfn9iWj2VNLb3UHz6yNiU,607
42
42
  python_socks/async_/asyncio/v2/_connect.py,sha256=b3kQBR7L6wp-yvWVwtcdb4JUdQV04JW-DXF1g1P3gxI,587
43
- python_socks/async_/asyncio/v2/_proxy.py,sha256=wUAiY502lCkFRdQ6cC0qAPEKufy4V6d_O93dSaeyn5g,4207
43
+ python_socks/async_/asyncio/v2/_proxy.py,sha256=wneFY5qU1sC7lknYu7Xhd506GLlVRMZHWTqp8dK2kSE,4297
44
44
  python_socks/async_/asyncio/v2/_stream.py,sha256=dOvZPMLd0lHeZwlJIL-bK-PQN9sjM6urA5AyFXxdaas,3834
45
45
  python_socks/async_/curio/__init__.py,sha256=1OyhLhvLJ23iDROgyxGqQACice66SrIYCMqmwjw_dqY,63
46
46
  python_socks/async_/curio/_connect.py,sha256=u1HRJ8n3OZbux-wETO9HuqZv9By2LGhhSsM78gnxr_0,328
@@ -69,8 +69,8 @@ python_socks/sync/v2/_connect.py,sha256=eqMKsH2wVnGZhV24_t9QfsNhjbnKtnipj7wzSNct
69
69
  python_socks/sync/v2/_proxy.py,sha256=-38o3QxE_FfJjQ88SK2YqBlWQgeNQQfYkGsFtYHWq94,3400
70
70
  python_socks/sync/v2/_ssl_transport.py,sha256=MURwzvKu-S2-MI7o8KaZTvvBFOiiKIu5R0ERVIMvERE,6088
71
71
  python_socks/sync/v2/_stream.py,sha256=Jq89x1xmIX3L_v-WyS1nRTItjTnYTcDcfDblsANxfJI,1544
72
- python_socks-2.5.0.dist-info/LICENSE.txt,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
73
- python_socks-2.5.0.dist-info/METADATA,sha256=mDM73fWuSRo_6HX2Cl0WLdUPOpOAI7gSJ_tyPW1WeCY,7018
74
- python_socks-2.5.0.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
75
- python_socks-2.5.0.dist-info/top_level.txt,sha256=7qyDAVwjTZ0sIYG1iatFbE-SLpWhONjaoMQ0Ib2DX0Q,13
76
- python_socks-2.5.0.dist-info/RECORD,,
72
+ python_socks-2.5.2.dist-info/LICENSE.txt,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
73
+ python_socks-2.5.2.dist-info/METADATA,sha256=Cy8SjUtrdBH1NX4ZibdLVnyePvLYUB4i0oXSSqzyQFM,7038
74
+ python_socks-2.5.2.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
75
+ python_socks-2.5.2.dist-info/top_level.txt,sha256=7qyDAVwjTZ0sIYG1iatFbE-SLpWhONjaoMQ0Ib2DX0Q,13
76
+ python_socks-2.5.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.1.1)
2
+ Generator: setuptools (75.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5