36 lines
871 B
Go
36 lines
871 B
Go
package checker
|
|
|
|
import "strings"
|
|
|
|
// ProbeMode selects how strictly we validate after MTProxy init.
|
|
type ProbeMode int
|
|
|
|
const (
|
|
// ProbeFast: handshake + init, then short wait like Telethon TcpMTProxy (#1134): OK if proxy does not close immediately.
|
|
ProbeFast ProbeMode = iota
|
|
// ProbeDeep: MTProto req_pq and expect resPQ from Telegram DC through the tunnel (stricter; slower).
|
|
ProbeDeep
|
|
)
|
|
|
|
// Options configures Check. Nil or zero value uses ProbeFast.
|
|
type Options struct {
|
|
Probe ProbeMode
|
|
}
|
|
|
|
// ParseProbe maps env/flag strings: "", "fast" -> ProbeFast; "deep" -> ProbeDeep.
|
|
func ParseProbe(s string) ProbeMode {
|
|
switch strings.ToLower(strings.TrimSpace(s)) {
|
|
case "deep", "respq", "dc":
|
|
return ProbeDeep
|
|
default:
|
|
return ProbeFast
|
|
}
|
|
}
|
|
|
|
func effectiveOpts(opts *Options) *Options {
|
|
if opts == nil {
|
|
return &Options{Probe: ProbeFast}
|
|
}
|
|
return opts
|
|
}
|