Update MTProxy checker documentation and logic to clarify probing modes and improve error handling. Modify README and Docker documentation to reflect changes in the -probe flag behavior, including detailed descriptions of exit codes and timeout handling. Refactor connection handling to enhance robustness and align with Telethon's approach.
Publish mtproxy_checker Docker image / test (push) Successful in 7s
Publish mtproxy_checker Docker image / build-and-push (push) Successful in 52s

This commit is contained in:
Denozordec
2026-04-11 14:16:11 +07:00
parent 935401b1f8
commit a846ef5373
9 changed files with 45 additions and 31 deletions
+10
View File
@@ -112,6 +112,7 @@ func isResPQ(mtInner []byte) bool {
// DrainPostInitEE reads inbound fake-TLS records after MTProxy init and before req_pq (Telethon TcpMTProxy waits for data ~2s).
// Consumes 0x17 payloads with dec so the CTR stream stays aligned with the server; discards MTProto frames until idle.
func DrainPostInitEE(ctx context.Context, br *bufio.Reader, conn net.Conn, dec cipher.Stream, maxWait time.Duration) error {
defer func() { _ = conn.SetReadDeadline(time.Time{}) }()
end := time.Now().Add(maxWait)
if d, ok := ctx.Deadline(); ok && d.Before(end) {
end = d
@@ -139,6 +140,9 @@ func DrainPostInitEE(ctx context.Context, br *bufio.Reader, conn net.Conn, dec c
}
_ = conn.SetReadDeadline(time.Now().Add(d))
if err := sniffCleartextHTTP(br); err != nil {
if ne, ok := err.(net.Error); ok && ne.Timeout() {
continue
}
return err
}
chunk, err := readNextTLS17Payload(br)
@@ -219,6 +223,12 @@ func VerifyResPQ(ctx context.Context, conn net.Conn, enc, dec cipher.Stream, tls
var rerr error
if tlsBR != nil {
if err := sniffCleartextHTTP(tlsBR); err != nil {
if ne, ok := err.(net.Error); ok && ne.Timeout() {
if time.Now().Before(deadline) {
continue
}
break
}
return err
}
chunk, rerr = readNextTLS17Payload(tlsBR)