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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user