Enhance MTProxy checker functionality by introducing a new -probe flag for selecting between fast and deep probing modes. Update README and Docker documentation to reflect this change, including details on timeout handling and exit codes for improved clarity.
Publish mtproxy_checker Docker image / test (push) Successful in 6s
Publish mtproxy_checker Docker image / build-and-push (push) Successful in 51s

This commit is contained in:
Denozordec committed 2026-04-11 13:48:02 +07:00
1 parent 6f2dbcbca3
commit 935401b1f8
7 files changed
+105 -17

No files matched your search

+11 -8
View File
@@ -31,11 +31,12 @@ func main() {
}
type config struct {
listFile string
checkInterval time.Duration
httpAddr string
checkTimeout time.Duration
dcID int16
listFile string
checkInterval time.Duration
httpAddr string
checkTimeout time.Duration
dcID int16
probe checker.ProbeMode
allowedPrefixes []netip.Prefix
}
@@ -79,12 +80,14 @@ func loadConfig() (*config, error) {
if err != nil {
return nil, err
}
probe := checker.ParseProbe(os.Getenv("MTPROXY_PROBE"))
return &config{
listFile: listFile,
checkInterval: interval,
httpAddr: httpAddr,
checkTimeout: checkTimeout,
dcID: int16(dcParsed),
probe: probe,
allowedPrefixes: prefixes,
}, nil
}
@@ -146,7 +149,7 @@ func readProxyLines(path string) ([]string, error) {
return lines, nil
}
func checkOneLine(ctx context.Context, line string, dcID int16) proxyEntry {
func checkOneLine(ctx context.Context, line string, dcID int16, probe checker.ProbeMode) proxyEntry {
now := time.Now().UTC().Format(time.RFC3339)
ent := proxyEntry{RawLine: line, CheckedAt: now}
t, err := parseurl.ParseTGProxy(line)
@@ -164,7 +167,7 @@ func checkOneLine(ctx context.Context, line string, dcID int16) proxyEntry {
ent.Error = ent.ParseError
return ent
}
err = checker.Check(ctx, t.Host, t.Port, parsed, dcID)
err = checker.Check(ctx, t.Host, t.Port, parsed, dcID, &checker.Options{Probe: probe})
code, msg := checkresult.Classify(err)
ent.ExitCode = code
ent.OK = err == nil
@@ -191,7 +194,7 @@ func runCycle(cfg *config, st *store) {
entries := make([]proxyEntry, 0, len(lines))
for _, line := range lines {
ctx, cancel := context.WithTimeout(context.Background(), cfg.checkTimeout)
ent := checkOneLine(ctx, line, cfg.dcID)
ent := checkOneLine(ctx, line, cfg.dcID, cfg.probe)
cancel()
entries = append(entries, ent)
}