mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-19 08:20:44 +00:00
ykxmz 1.5.0锛氫慨澶嶆墜琛ㄧ TLS 璇佷功鏍¢獙 + MTU 淇缃戠粶绋冲畾鎬?
琚帶绔?- 淇 MTU 闂锛氬す MSS + 璺緞 MTU 鎺㈡祴锛堝叕缃戝彲鐢ㄧ巼 48% -> 100%锛?- 澶嶇敤 HTTP 杩炴帴锛堝厤鎺夋瘡娆℃柊寤?TLS 鐨?30% 鎻℃墜澶辫触锛?- 姣忓垎閽熷洖澶存壘灞€鍩熺綉锛岃嚜鍔ㄥ垏鍥炲揩 400 鍊嶇殑璺緞 - 鐢婚潰蹇冭烦甯э細闈欐鏃剁渷娴侀噺锛屽鎴风浠嶇煡閬撴祦鏄椿鐨?- 閿佸睆鏃剁粰鍑哄彲鎿嶄綔鐨勬彁绀? 鎵嬭〃绔?- 鍐呯疆 GTS Root R4 / GlobalSign Root CA锛屼慨 SSLHandshakeException - 杩炴帴閿欒缈昏瘧鎴愪汉璇濓紙璇佷功/鏃堕棿/瑙f瀽/瓒呮椂鍒嗗埆鎻愮ず锛?- 缁忎腑杞繛涓婂悗鐢ㄦ湇鍔″櫒鎶ョ殑鍦板潃鍒锋柊宸查厤瀵硅褰?- 鏂板灞€鍩熺綉杩炴帴椤甸潰銆佹湇鍔″櫒寤惰繜妫€娴? 鏈嶅姟鍣ㄧ - 鏀寔 chunked 璇锋眰浣擄紙淇瘡 16 绉掍竴娆$殑杩炴帴閿欎贡涓庡ぇ闈㈢Н 502锛?- 缃戠粶璋冧紭鑴氭湰 net-tune.sh锛堝紑鏈鸿嚜鍔ㄥ簲鐢級 - 绠$悊椤碉細鎵归噺鍒犻櫎銆佺綉缁滀綋妫€銆佷笅杞藉尯 - 闅ч亾鏀?HTTP/2 + 鍙岃繛鎺? 鏂囨。 - 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""让爆破测试从**另一个源 IP** 发起。
|
||||
|
||||
现在限速是按来源 IP 的(防止别人用错码把你锁在门外)。
|
||||
测试如果从 127.0.0.1 爆破,就会把同 IP 的合法配对也锁上。
|
||||
|
||||
Windows 整个 127.0.0.0/8 都是回环,所以从 127.0.0.2 发就能模拟"另一台机器",
|
||||
顺带真正验证了按 IP 隔离。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
E2E = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote\_tests"
|
||||
r"\test_e2e_features.py")
|
||||
|
||||
# Client 支持指定源地址
|
||||
CLIENT_OLD = '''class Client:
|
||||
def __init__(self, host, port, timeout=10.0):
|
||||
self.sock = socket.create_connection((host, port), timeout=timeout)'''
|
||||
|
||||
CLIENT_NEW = '''class Client:
|
||||
def __init__(self, host, port, timeout=10.0, source_ip=None):
|
||||
if source_ip:
|
||||
# 绑定一个具体的源地址,用来模拟"另一台机器"
|
||||
# (Windows 上整个 127.0.0.0/8 都是回环)
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.sock.settimeout(timeout)
|
||||
self.sock.bind((source_ip, 0))
|
||||
self.sock.connect((host, port))
|
||||
else:
|
||||
self.sock = socket.create_connection((host, port), timeout=timeout)'''
|
||||
|
||||
# 爆破客户端换源地址
|
||||
BREAKER_OLD = ' breaker = Client("127.0.0.1", PORT)'
|
||||
BREAKER_NEW = (' # 从 127.0.0.2 发起 —— 限速是按 IP 的,\n'
|
||||
' # 用同一个 IP 会把后面的合法配对一起锁掉\n'
|
||||
' breaker = Client("127.0.0.1", PORT, source_ip="127.0.0.2")')
|
||||
|
||||
# 顺带断言"另一个 IP 被锁不影响本机"
|
||||
EXTRA_CHECK = ''' check("连续错码会被限速", limited,
|
||||
f"12 次都没触发限速,最后一次: {r}")
|
||||
breaker.close()
|
||||
|
||||
# 反向验证:另一个 IP 被锁住了,本机不受影响
|
||||
probe = Client("127.0.0.1", PORT)
|
||||
reply_probe = probe.call({"cmd": "pair", "deviceId": "probe",
|
||||
"deviceName": "本机", "code": code},
|
||||
timeout=10)
|
||||
check("★ 别的 IP 被锁不影响本机配对",
|
||||
reply_probe.get("ok") is True, str(reply_probe)[:120])
|
||||
probe.close()
|
||||
|
||||
# 上面这台已经配上并自动关闭了配对窗口,所以后面的合法配对
|
||||
# 用已保存的令牌继续(重新起一个连接)
|
||||
paired_token = reply_probe.get("token", "")
|
||||
'''
|
||||
|
||||
|
||||
def main() -> int:
|
||||
text = E2E.read_text(encoding="utf-8")
|
||||
|
||||
if "source_ip" in text:
|
||||
print(" 已经改过")
|
||||
return 0
|
||||
|
||||
for old, new, tag in ((CLIENT_OLD, CLIENT_NEW, "Client 支持源地址"),
|
||||
(BREAKER_OLD, BREAKER_NEW, "爆破用 127.0.0.2")):
|
||||
if old not in text:
|
||||
print(f" [跳过] {tag} —— 锚点没找到")
|
||||
return 1
|
||||
text = text.replace(old, new, 1)
|
||||
print(f" {tag}: OK")
|
||||
|
||||
# 在爆破检查之后插入反向验证
|
||||
old_tail = ''' check("连续错码会被限速", limited,
|
||||
f"12 次都没触发限速,最后一次: {r}")
|
||||
breaker.close()
|
||||
'''
|
||||
if old_tail in text:
|
||||
text = text.replace(old_tail, EXTRA_CHECK, 1)
|
||||
print(" 反向验证: OK")
|
||||
|
||||
E2E.write_text(text, encoding="utf-8")
|
||||
|
||||
import ast
|
||||
try:
|
||||
ast.parse(E2E.read_text(encoding="utf-8"))
|
||||
print(" 语法 OK")
|
||||
except SyntaxError as exc:
|
||||
print(f" 语法错误: {exc}")
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user