cli/third-party/github.com/letsencrypt/boulder/observer/probers/tcp/tcp.go
2025-05-30 12:50:20 -04:00

36 lines
765 B
Go

package tcp
import (
"context"
"time"
"github.com/letsencrypt/boulder/observer/obsdialer"
)
type TCPProbe struct {
hostport string
}
// Name returns a string that uniquely identifies the monitor.
func (p TCPProbe) Name() string {
return p.hostport
}
// Kind returns a name that uniquely identifies the `Kind` of `Prober`.
func (p TCPProbe) Kind() string {
return "TCP"
}
// Probe performs the configured TCP dial.
func (p TCPProbe) Probe(timeout time.Duration) (bool, time.Duration) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
start := time.Now()
c, err := obsdialer.Dialer.DialContext(ctx, "tcp", p.hostport)
if err != nil {
return false, time.Since(start)
}
c.Close()
return true, time.Since(start)
}