simple-proxy 0.0.4__tar.gz → 0.0.6__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.
- {simple-proxy-0.0.4/simple_proxy.egg-info → simple-proxy-0.0.6}/PKG-INFO +1 -1
- {simple-proxy-0.0.4 → simple-proxy-0.0.6}/setup.py +1 -1
- {simple-proxy-0.0.4 → simple-proxy-0.0.6}/simple_proxy/__init__.py +19 -14
- {simple-proxy-0.0.4 → simple-proxy-0.0.6}/simple_proxy/utils.py +9 -9
- simple-proxy-0.0.6/simple_proxy/version.py +1 -0
- {simple-proxy-0.0.4 → simple-proxy-0.0.6/simple_proxy.egg-info}/PKG-INFO +1 -1
- simple-proxy-0.0.6/simple_proxy.egg-info/requires.txt +4 -0
- simple-proxy-0.0.4/simple_proxy/version.py +0 -1
- simple-proxy-0.0.4/simple_proxy.egg-info/requires.txt +0 -3
- {simple-proxy-0.0.4 → simple-proxy-0.0.6}/LICENSE +0 -0
- {simple-proxy-0.0.4 → simple-proxy-0.0.6}/README.md +0 -0
- {simple-proxy-0.0.4 → simple-proxy-0.0.6}/setup.cfg +0 -0
- {simple-proxy-0.0.4 → simple-proxy-0.0.6}/simple_proxy.egg-info/SOURCES.txt +0 -0
- {simple-proxy-0.0.4 → simple-proxy-0.0.6}/simple_proxy.egg-info/dependency_links.txt +0 -0
- {simple-proxy-0.0.4 → simple-proxy-0.0.6}/simple_proxy.egg-info/entry_points.txt +0 -0
- {simple-proxy-0.0.4 → simple-proxy-0.0.6}/simple_proxy.egg-info/top_level.txt +0 -0
|
@@ -22,7 +22,7 @@ config = {
|
|
|
22
22
|
'keywords': ['network', 'tcp', 'non-blocking', 'proxy'],
|
|
23
23
|
'version': __version__,
|
|
24
24
|
'packages': find_packages(),
|
|
25
|
-
'install_requires': ['click', 'py-netty
|
|
25
|
+
'install_requires': ['click', 'py-netty', 'cryptography', 'attrs'],
|
|
26
26
|
'python_requires': ">=3.7, <4",
|
|
27
27
|
'setup_requires': ['wheel'],
|
|
28
28
|
'package_data': {'simple_proxy': ['*']},
|
|
@@ -4,6 +4,7 @@ import ssl
|
|
|
4
4
|
from functools import wraps
|
|
5
5
|
from py_netty.handler import LoggingChannelHandler
|
|
6
6
|
from py_netty import Bootstrap, ServerBootstrap, EventLoopGroup
|
|
7
|
+
from py_netty.channel import NioSocketChannel
|
|
7
8
|
import traceback
|
|
8
9
|
import sys
|
|
9
10
|
import os
|
|
@@ -188,22 +189,26 @@ def sneaky():
|
|
|
188
189
|
|
|
189
190
|
|
|
190
191
|
@sneaky()
|
|
191
|
-
def _handle(buffer, direction, src, dst, print_content, to_file):
|
|
192
|
-
try:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
except OSError:
|
|
196
|
-
|
|
192
|
+
def _handle(buffer: bytes, direction: bool, src: NioSocketChannel, dst: NioSocketChannel, print_content: bool, to_file: bool):
|
|
193
|
+
# try:
|
|
194
|
+
# src_ip, src_port = src.getpeername()[:2]
|
|
195
|
+
# dst_ip, dst_port = dst.getpeername()[:2]
|
|
196
|
+
# except OSError:
|
|
197
|
+
# return buffer
|
|
198
|
+
|
|
199
|
+
src_ip, src_port = src.channelinfo().peername
|
|
200
|
+
dst_ip, dst_port = dst.channelinfo().peername
|
|
197
201
|
|
|
198
202
|
raddr = (src_ip, src_port) if direction else (dst_ip, dst_port)
|
|
199
|
-
|
|
203
|
+
|
|
200
204
|
if buffer:
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
client = _clients.get(raddr)
|
|
206
|
+
if client:
|
|
207
|
+
if direction:
|
|
208
|
+
client.read(len(buffer))
|
|
209
|
+
else:
|
|
210
|
+
client.write(len(buffer))
|
|
205
211
|
else: # EOF
|
|
206
|
-
del _clients[raddr]
|
|
207
212
|
return buffer
|
|
208
213
|
|
|
209
214
|
if not print_content and not to_file:
|
|
@@ -296,7 +301,7 @@ class ProxyChannelHandler(LoggingChannelHandler):
|
|
|
296
301
|
class _ChannelHandler(LoggingChannelHandler):
|
|
297
302
|
|
|
298
303
|
def channel_read(this, ctx, bytebuf):
|
|
299
|
-
_handle(bytebuf, False, ctx.channel()
|
|
304
|
+
_handle(bytebuf, False, ctx.channel(), ctx0.channel(), self._content, self._to_file)
|
|
300
305
|
ctx0.write(bytebuf)
|
|
301
306
|
|
|
302
307
|
def channel_inactive(this, ctx):
|
|
@@ -338,7 +343,7 @@ class ProxyChannelHandler(LoggingChannelHandler):
|
|
|
338
343
|
self._client_channel(ctx, self._remote_host, self._remote_port)
|
|
339
344
|
_clients[self.raddr].proxy_socket = self._client.socket()
|
|
340
345
|
|
|
341
|
-
_handle(bytebuf, True, ctx.channel()
|
|
346
|
+
_handle(bytebuf, True, ctx.channel(), self._client, self._content, self._to_file)
|
|
342
347
|
self._client.write(bytebuf)
|
|
343
348
|
|
|
344
349
|
def channel_inactive(self, ctx):
|
|
@@ -105,22 +105,22 @@ def from_module(filename=None):
|
|
|
105
105
|
return os.path.join(module_path(mod), filename)
|
|
106
106
|
|
|
107
107
|
|
|
108
|
-
def
|
|
108
|
+
def _get_address_str(sock: socket.socket, peer: bool = False) -> str:
|
|
109
109
|
if not sock:
|
|
110
110
|
return '?'
|
|
111
111
|
try:
|
|
112
|
-
|
|
112
|
+
addr_tuple = sock.getpeername() if peer else sock.getsockname()
|
|
113
|
+
return ':'.join(map(str, addr_tuple[:2]))
|
|
113
114
|
except OSError:
|
|
114
|
-
return '
|
|
115
|
+
return '!'
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def getpeername(sock: socket.socket) -> str:
|
|
119
|
+
return _get_address_str(sock, peer=True)
|
|
115
120
|
|
|
116
121
|
|
|
117
122
|
def getsockname(sock: socket.socket) -> str:
|
|
118
|
-
|
|
119
|
-
return '?'
|
|
120
|
-
try:
|
|
121
|
-
return ':'.join(map(str, sock.getsockname()))
|
|
122
|
-
except OSError:
|
|
123
|
-
return '?'
|
|
123
|
+
return _get_address_str(sock, peer=False)
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
def generate_private_key():
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.6"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.4"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|