proxynt 2.0.44__tar.gz → 2.0.46__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.44/proxynt.egg-info → proxynt-2.0.46}/PKG-INFO +1 -1
- {proxynt-2.0.44 → proxynt-2.0.46}/common/nat_serialization_v2.py +22 -3
- {proxynt-2.0.44 → proxynt-2.0.46}/constant/system_constant.py +1 -1
- {proxynt-2.0.44 → proxynt-2.0.46/proxynt.egg-info}/PKG-INFO +1 -1
- {proxynt-2.0.44 → proxynt-2.0.46}/proxynt.egg-info/SOURCES.txt +0 -1
- {proxynt-2.0.44 → proxynt-2.0.46}/proxynt.egg-info/requires.txt +1 -1
- {proxynt-2.0.44 → proxynt-2.0.46}/run_client.py +3 -1
- {proxynt-2.0.44 → proxynt-2.0.46}/setup.py +1 -1
- proxynt-2.0.44/entity/rule_entity.py +0 -28
- {proxynt-2.0.44 → proxynt-2.0.46}/LICENSE +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/MANIFEST.in +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/client/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/client/abstract_tunnel.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/client/clear_nonce_task.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/client/heart_beat_task.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/client/kcp_tunnel_impl.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/client/n4_tunnel_manager.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/client/quic_tunnel_impl.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/client/tcp_forward_client.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/client/tunnel_protocol.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/client/udp_forward_client.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/cert_utils.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/crypto/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/crypto/table.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/encrypt_utils.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/kcp.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/logger_factory.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/n4_protocol.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/n4_punch.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/nat_serialization.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/nat_serialization_v1.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/pool.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/register_append_data.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/speed_limit.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_abnf.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_app.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_cookiejar.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_core.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_exceptions.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_handshake.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_http.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_logging.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_socket.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_ssl_compat.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_url.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_utils.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/_wsdump.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/tests/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/tests/echo-server.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/tests/test_abnf.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/tests/test_app.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/tests/test_cookiejar.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/tests/test_http.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/tests/test_url.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/common/websocket/tests/test_websocket.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/constant/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/constant/message_type_constnat.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/context/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/context/context_utils.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/entity/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/entity/client_config_entity.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/entity/message/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/entity/message/message_entity.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/entity/message/push_config_entity.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/entity/message/tcp_over_websocket_message.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/entity/server_config_entity.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/exceptions/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/exceptions/duplicated_name.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/exceptions/invalid_password.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/exceptions/replay_error.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/exceptions/signature_error.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/p2ptest/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/p2ptest/client.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/p2ptest/n4.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/proxynt.egg-info/dependency_links.txt +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/proxynt.egg-info/entry_points.txt +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/proxynt.egg-info/top_level.txt +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/run_server.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/admin_http_handler.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/n4.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/n4_signal_service.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/task/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/task/check_cookie_task.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/task/clear_nonce_task.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/task/heart_beat_task.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/tcp_forward_client.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/template/__init__.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/template/base.html +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/template/css/fonts/element-icons.woff +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/template/css/index.css +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/template/ele_index.html +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/template/js/axios.min.js +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/template/js/index.js +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/template/js/vue.min.js +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/template/login.html +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/udp_forward_client.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/server/websocket_handler.py +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/setup.cfg +0 -0
- {proxynt-2.0.44 → proxynt-2.0.46}/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:
|
|
@@ -16,6 +16,8 @@ from urllib.parse import urlparse
|
|
|
16
16
|
import tornado
|
|
17
17
|
from tornado import ioloop
|
|
18
18
|
|
|
19
|
+
PROTOCOL_VERSION = 2
|
|
20
|
+
|
|
19
21
|
# Try to enable high-performance event loop (20-30% boost)
|
|
20
22
|
# Use winloop on Windows, uvloop on Linux/macOS
|
|
21
23
|
_UVLOOP_ENABLED = False
|
|
@@ -146,7 +148,7 @@ class WebsocketClient:
|
|
|
146
148
|
self.heart_beat_task: HeatBeatTask = heart_beat_task
|
|
147
149
|
self.config_data: ClientConfigEntity = config_data
|
|
148
150
|
self.compress_support: bool = config_data['server']['compress']
|
|
149
|
-
self.protocol_version: int =
|
|
151
|
+
self.protocol_version: int = PROTOCOL_VERSION
|
|
150
152
|
|
|
151
153
|
# P2P support
|
|
152
154
|
self.public_ip: str = None
|
|
@@ -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
|