proxynt 2.0.45__tar.gz → 2.0.48__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.
- {proxynt-2.0.45/proxynt.egg-info → proxynt-2.0.48}/PKG-INFO +1 -1
- {proxynt-2.0.45 → proxynt-2.0.48}/common/nat_serialization_v2.py +22 -3
- {proxynt-2.0.45 → proxynt-2.0.48}/constant/system_constant.py +1 -1
- {proxynt-2.0.45 → proxynt-2.0.48/proxynt.egg-info}/PKG-INFO +1 -1
- {proxynt-2.0.45 → proxynt-2.0.48}/proxynt.egg-info/SOURCES.txt +0 -1
- {proxynt-2.0.45 → proxynt-2.0.48}/proxynt.egg-info/requires.txt +1 -1
- {proxynt-2.0.45 → proxynt-2.0.48}/server/websocket_handler.py +6 -3
- {proxynt-2.0.45 → proxynt-2.0.48}/setup.py +1 -1
- proxynt-2.0.45/entity/rule_entity.py +0 -28
- {proxynt-2.0.45 → proxynt-2.0.48}/LICENSE +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/MANIFEST.in +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/client/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/client/abstract_tunnel.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/client/clear_nonce_task.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/client/heart_beat_task.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/client/kcp_tunnel_impl.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/client/n4_tunnel_manager.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/client/quic_tunnel_impl.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/client/tcp_forward_client.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/client/tunnel_protocol.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/client/udp_forward_client.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/cert_utils.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/crypto/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/crypto/table.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/encrypt_utils.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/kcp.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/logger_factory.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/n4_protocol.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/n4_punch.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/nat_serialization.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/nat_serialization_v1.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/pool.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/register_append_data.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/speed_limit.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_abnf.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_app.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_cookiejar.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_core.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_exceptions.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_handshake.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_http.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_logging.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_socket.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_ssl_compat.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_url.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_utils.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/_wsdump.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/tests/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/tests/echo-server.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/tests/test_abnf.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/tests/test_app.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/tests/test_cookiejar.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/tests/test_http.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/tests/test_url.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/common/websocket/tests/test_websocket.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/constant/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/constant/message_type_constnat.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/context/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/context/context_utils.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/entity/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/entity/client_config_entity.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/entity/message/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/entity/message/message_entity.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/entity/message/push_config_entity.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/entity/message/tcp_over_websocket_message.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/entity/server_config_entity.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/exceptions/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/exceptions/duplicated_name.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/exceptions/invalid_password.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/exceptions/replay_error.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/exceptions/signature_error.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/p2ptest/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/p2ptest/client.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/p2ptest/n4.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/proxynt.egg-info/dependency_links.txt +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/proxynt.egg-info/entry_points.txt +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/proxynt.egg-info/top_level.txt +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/run_client.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/run_server.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/admin_http_handler.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/n4.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/n4_signal_service.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/task/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/task/check_cookie_task.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/task/clear_nonce_task.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/task/heart_beat_task.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/tcp_forward_client.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/template/__init__.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/template/base.html +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/template/css/fonts/element-icons.woff +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/template/css/index.css +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/template/ele_index.html +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/template/js/axios.min.js +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/template/js/index.js +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/template/js/vue.min.js +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/template/login.html +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/server/udp_forward_client.py +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/setup.cfg +0 -0
- {proxynt-2.0.45 → proxynt-2.0.48}/test_exchange.py +0 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"""
|
|
2
2
|
NatSerialization V2 - msgpack format (flexible, supports arbitrary fields)
|
|
3
3
|
"""
|
|
4
|
+
import logging
|
|
4
5
|
import os
|
|
5
6
|
import struct
|
|
6
7
|
import time
|
|
7
8
|
|
|
8
9
|
import msgpack
|
|
9
10
|
|
|
11
|
+
from common.logger_factory import LoggerFactory
|
|
12
|
+
|
|
10
13
|
try:
|
|
11
14
|
import snappy
|
|
12
15
|
has_snappy = True
|
|
@@ -40,14 +43,30 @@ class NatSerializationV2:
|
|
|
40
43
|
# 处理 data_content,确保可以被 msgpack 序列化
|
|
41
44
|
if data_content is not None:
|
|
42
45
|
# 复制一份避免修改原数据
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
if compress:
|
|
47
|
+
serializable_content = dict(data_content) if isinstance(data_content, dict) else data_content
|
|
48
|
+
else:
|
|
49
|
+
serializable_content = data_content
|
|
46
50
|
# 如果有 'data' 字段且需要压缩
|
|
47
51
|
if isinstance(serializable_content, dict) and 'data' in serializable_content:
|
|
48
52
|
if compress and has_snappy and serializable_content['data']:
|
|
53
|
+
original_size = len(serializable_content['data'])
|
|
54
|
+
|
|
49
55
|
serializable_content['data'] = snappy.snappy.compress(serializable_content['data'])
|
|
50
56
|
serializable_content['_compressed'] = True
|
|
57
|
+
compressed_size = len(serializable_content['data'])
|
|
58
|
+
|
|
59
|
+
if LoggerFactory.get_logger().isEnabledFor(logging.DEBUG):
|
|
60
|
+
if original_size > 0:
|
|
61
|
+
ratio = compressed_size / original_size
|
|
62
|
+
LoggerFactory.get_logger().debug(
|
|
63
|
+
"NatSerializationV2 compress | type=%s | original=%d bytes | "
|
|
64
|
+
"compressed=%d bytes | ratio=%.2f",
|
|
65
|
+
type_,
|
|
66
|
+
original_size,
|
|
67
|
+
compressed_size,
|
|
68
|
+
ratio
|
|
69
|
+
)
|
|
51
70
|
|
|
52
71
|
body = msgpack.packb(serializable_content, use_bin_type=True)
|
|
53
72
|
else:
|
|
@@ -105,6 +105,9 @@ class MyWebSocketaHandler(WebSocketHandler):
|
|
|
105
105
|
await (super(MyWebSocketaHandler, self).write_message(byte_message, binary))
|
|
106
106
|
if LoggerFactory.get_logger().isEnabledFor(logging.DEBUG):
|
|
107
107
|
LoggerFactory.get_logger().debug(f'Write message cost {time.time() - start_time}s, length: {len(message)}')
|
|
108
|
+
heart_beat_task = ContextUtils.get_heart_beat_task()
|
|
109
|
+
if heart_beat_task:
|
|
110
|
+
heart_beat_task.update_business_activity(self.client_name)
|
|
108
111
|
return
|
|
109
112
|
except Exception:
|
|
110
113
|
LoggerFactory.get_logger().info(f'Send error: {message[:10]}')
|
|
@@ -132,9 +135,9 @@ class MyWebSocketaHandler(WebSocketHandler):
|
|
|
132
135
|
# 智能心跳:记录业务活动(非 PING 消息)
|
|
133
136
|
if self.client_name and message_dict['type_'] != MessageTypeConstant.PING:
|
|
134
137
|
from server.task.heart_beat_task import HeartBeatTask
|
|
135
|
-
heart_beat_task = ContextUtils.get_heart_beat_task()
|
|
136
|
-
if heart_beat_task:
|
|
137
|
-
|
|
138
|
+
# heart_beat_task = ContextUtils.get_heart_beat_task()
|
|
139
|
+
# if heart_beat_task:
|
|
140
|
+
# heart_beat_task.update_business_activity(self.client_name)
|
|
138
141
|
|
|
139
142
|
if message_dict['type_'] == MessageTypeConstant.WEBSOCKET_OVER_TCP:
|
|
140
143
|
data: TcpOverWebsocketMessage = message_dict['data']
|
|
@@ -32,7 +32,7 @@ setuptools.setup(
|
|
|
32
32
|
install_requires=['tornado',
|
|
33
33
|
'typing_extensions',
|
|
34
34
|
'winloop>=0.1.0; sys_platform == "win32"',
|
|
35
|
-
'uvloop
|
|
35
|
+
'uvloop>0.22.0; sys_platform != "win32" and python_version >= "3.7"',
|
|
36
36
|
'uvloop<0.15; sys_platform != "win32" and python_version < "3.7"',
|
|
37
37
|
'xxhash>=3.0.0',
|
|
38
38
|
'msgpack',
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
from typing_extensions import TypedDict
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class RuleEntity(TypedDict):
|
|
5
|
-
# {
|
|
6
|
-
# "name": "xjy_test",
|
|
7
|
-
# "source_client": "家里小主机",
|
|
8
|
-
# "target_client": "xinjiaya_server_test",
|
|
9
|
-
# "local_port": 33333,
|
|
10
|
-
# "local_ip": "127.0.0.1",
|
|
11
|
-
# "protocol": "tcp",
|
|
12
|
-
# "speed_limit": 0.0,
|
|
13
|
-
# "enabled": true,
|
|
14
|
-
# "p2p_enabled": false,
|
|
15
|
-
# "target_ip": "127.0.0.1",
|
|
16
|
-
# "target_port": 22
|
|
17
|
-
# }
|
|
18
|
-
name: str
|
|
19
|
-
source_client: str
|
|
20
|
-
target_client: str
|
|
21
|
-
local_port: int
|
|
22
|
-
local_ip: str
|
|
23
|
-
protocol: str
|
|
24
|
-
speed_limit: float
|
|
25
|
-
enabled: bool
|
|
26
|
-
p2p_enabled: bool
|
|
27
|
-
target_ip: str
|
|
28
|
-
target_port: int
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|