Documentation
¶
Overview ¶
Package tcpcheck probes bounded TCP targets and distinguishes a Mistgate answer from another listener.
Index ¶
- Constants
- Variables
- func MarkBody(token, answer []byte) []byte
- func MarkPath(token []byte) string
- func Probe(ctx context.Context, host string, targets []Target) (family string, verdicts map[uint16]string, err error)
- func ProbeTimed(ctx context.Context, host string, targets []Target) (family string, verdicts map[uint16]string, ms map[uint16]int64, err error)
- func ResolveDestination(ctx context.Context, host string) (netip.Addr, error)
- func Validate(host string, targets []Target) error
- type Target
Constants ¶
const ( KindHTTPMark = "http_mark" KindTLS = "tls" // KindConnect is a plain TCP connect with no payload (the agent's "probe/1"): ours = connected. KindConnect = "connect" VerdictOurs = "ours" VerdictOther = "other" VerdictRefused = "refused" VerdictTimeout = "timeout" MaxTargets = 8 // MarkSize is the length of a mark's token and of its answer in bytes (Let's Encrypt's token is 32 bytes). MarkSize = 32 )
Variables ¶
Functions ¶
func MarkBody ¶
MarkBody is the response body of a mark, shaped like an ACME key authorization: <token>.<base64url of the answer>.
func MarkPath ¶
MarkPath is the request path of an HTTP-01 mark: Let's Encrypt's own, with the base64url token.
func Probe ¶
func Probe(ctx context.Context, host string, targets []Target) (family string, verdicts map[uint16]string, err error)
Probe resolves host once, preferring IPv4, then probes each target concurrently. A failed port is a verdict; only invalid input or failure to resolve the destination fails the whole call.
func ProbeTimed ¶
func ProbeTimed(ctx context.Context, host string, targets []Target) (family string, verdicts map[uint16]string, ms map[uint16]int64, err error)
ProbeTimed is Probe that also returns, per port, the milliseconds until the verdict (the connect, plus the handshake or the request when the kind has one). A cancelled or refused-in-no-time port reads 0..1 ms; a timeout reads its timeout.
func ResolveDestination ¶
ResolveDestination resolves host the way a probe does (IPv4 first) and refuses a destination that is no node (ErrNoRoute when it does not resolve, ErrUnsupportedHost for an unspecified, multicast, broadcast or link-local address).