Skip to main content

Crate zpinger

Crate zpinger 

Source

Modules§

uri

Structs§

ClientConfig
Common configuration for (typically) all connections made by a program.
DnsPinger
DNS pinger — sends one UDP query to server, waits for a well-formed response, and reports the round trip. The query content (query + record_type) is sent as-is; the response is validated only structurally (matching ID, response bit set, RCODE = NoError). Whether the answer section carries useful records is not checked — this is a “did the server respond” probe, not a resolver.
GrpcPinger
GrpcStreamPinger
gRPC server-streaming pinger — calls the standard grpc.health.v1.Health/Watch RPC and waits for the broker’s first HealthCheckResponse. Per the spec, the server must send the current status immediately on subscribe, so this measures the real “open server stream → first message” RTT, not just connection setup.
HlsPinger
HttpPinger
HTTP / HTTPS pinger — opens a TCP connection (optionally wrapped in TLS for https://), writes a single HTTP/1.1 request, reads the response, and reports success based on the status line.
MqttPinger
MQTT pinger.
NtpPinger
NTP pinger — sends a 48-byte NTP v4 client packet to server and waits for a server reply. Default port 123. Doesn’t decode the timestamps — this is a “did the time server respond well-formedly” probe, not a clock-discipline tool.
QuicPinger
QUIC pinger. Reports the time taken to complete the QUIC handshake (UDP + Initial / Handshake / 1-RTT keys ready). Doesn’t open streams or speak HTTP/3 frames — handshake completion IS the success signal.
RtmpPinger
RTMP pinger.
RtspPinger
RTSP pinger.
StunPinger
STUN pinger — sends a Binding Request to server and waits for a Binding Success Response. Default port 3478. Doesn’t extract the XOR-MAPPED-ADDRESS attribute — this is a “did the STUN server answer correctly” probe, not a NAT-mapping discovery tool.
TcpPinger
TCP pinger — opens a TCP connection to target, sends one byte, and waits for any response byte before closing.
TlsPinger
TLS handshake pinger — measures the time to complete a TLS handshake against target. The handshake covers TCP connect + ClientHello + ServerHello + Certificate + (key exchange) + Finished; we don’t send any application data on top, just bring the session to the point where it’s ready and close.
TurnPinger
TURN pinger — sends an unauthenticated Allocate Request to server and considers the expected 401 Unauthorized Allocate Error Response a successful ping (it proves the server is alive and speaks RFC 5766). Default port 3478. Doesn’t actually allocate any relay state, so it’s safe to spam against shared TURN infrastructure.
UdpPinger
UDP pinger — sends one datagram to target from an ephemeral local socket and waits for a datagram in reply.
WebSocketPinger
WebSocket pinger — runs the full RFC 6455 client flow:

Enums§

HttpMethod
MqttVersion
MQTT protocol version. Defaults to 3.1.1 (MQTT-3.1.1-os); pick V5 to advertise MQTT 5.0 in the CONNECT packet.
RecordType
Subset of DNS resource-record TYPE codes (RFC 1035 + extensions). Only the ones a “speed test” CLI is likely to want; not exhaustive.

Traits§

Pinger
Trait every protocol implementation provides. async fn is wrapped by async-trait so the trait stays object-safe — knockknock dispatches via Box<dyn Pinger> and that requires dyn-safety.

Functions§

default_client_config
resolve
Resolve url’s host:port to a list of socket addresses for display. Falls back to scheme default ports (http → 80, https → 443) when the URL has no explicit port. Returns an empty Vec if DNS lookup fails or the host is empty — callers (the CLI in particular) treat the result as informational and let the actual pinger surface the real error.
timed
Time a single ping. Generic over ?Sized so it accepts both concrete pinger types and &dyn Pinger.