Introduce ProxyWarmupGate to manage MTProxy warmup state and throttle startup fanout; wire it into FileLoadOperation, FileLoader, FileLoaderPriorityQueue and ProxyRuntimeStateStore to classify requests and enforce limits/delays. Refactor ConnectionsManager DNS path: unified DoH loader, DNS resolver chain (cache/system/Google/Cloudflare), DoH query encoding, IPv6 support, renamed Mozilla->Cloudflare task and improved DNS logging. Add log atomicity guard and tighten several Tools checks; update runtime verifier with warmup fanout thresholds and DNS log validation. Miscellaneous logging/message wording fixes and throttling adjustments.
77 lines
2.6 KiB
Python
77 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
CONNECTION = ROOT / "TMessagesProj/jni/tgnet/Connection.cpp"
|
|
MTPROXY_ALL = ROOT / "Tools/check_mtproxy_all.py"
|
|
|
|
|
|
def read(path: Path) -> str:
|
|
return path.read_text(encoding="utf-8", errors="replace")
|
|
|
|
|
|
def require(condition: bool, message: str, failures: list[str]) -> None:
|
|
if not condition:
|
|
failures.append(message)
|
|
|
|
|
|
def main() -> int:
|
|
failures: list[str] = []
|
|
connection = read(CONNECTION)
|
|
mtproxy_all = read(MTPROXY_ALL)
|
|
|
|
require(
|
|
"received packet size less" not in connection
|
|
and "then message size" not in connection,
|
|
"partial MTProto packet assembly must not use failure-looking packet-size wording",
|
|
failures,
|
|
)
|
|
require(
|
|
"NetworkDebugCounters::partialPackets" in connection
|
|
and "NetworkDebugCounters::partialPacketBytes" in connection
|
|
and "NetworkDebugCounters::recordPartialPacket" in connection,
|
|
"partial MTProto packet assembly must update NetworkDebugCounters before logging",
|
|
failures,
|
|
)
|
|
require(
|
|
"NetworkDebugCounters::verboseNetworkDebugEnabled()" in connection,
|
|
"partial MTProto packet logs must be gated behind verbose network debug",
|
|
failures,
|
|
)
|
|
require(
|
|
"mtproto_partial_packet assembled=%u expected=%u connection=%p" in connection,
|
|
"partial MTProto packet assembly must log neutral assembled/expected counters",
|
|
failures,
|
|
)
|
|
partial_idx = connection.find("mtproto_partial_packet assembled=%u expected=%u connection=%p")
|
|
counter_idx = connection.find("NetworkDebugCounters::recordPartialPacket", partial_idx - 500)
|
|
store_idx = connection.find("restOfTheData = BuffersStorage::getInstance().getFreeBuffer(len)", partial_idx)
|
|
require(
|
|
counter_idx >= 0
|
|
and partial_idx >= 0
|
|
and store_idx >= 0
|
|
and counter_idx < partial_idx
|
|
and partial_idx < store_idx,
|
|
"partial MTProto packet path must count then optionally log before storing restOfTheData",
|
|
failures,
|
|
)
|
|
require(
|
|
'"check_mtproto_partial_packet_log.py"' in mtproxy_all,
|
|
"full MTProxy guard suite must include MTProto partial-packet log guard",
|
|
failures,
|
|
)
|
|
|
|
if failures:
|
|
print("MTProto partial-packet log guard failed:", file=sys.stderr)
|
|
for failure in failures:
|
|
print(f" - {failure}", file=sys.stderr)
|
|
return 1
|
|
|
|
print("MTProto partial-packet log guard passed.")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|