Skip to content

stdlib/dnsView source ↗

dns

30 items · generated by scribe fromstdlib/dns.fd· synced 2026-11-15

stdlib/dns30 items

Contents

dns_build_query

Build a DNS query packet for hostname (A record by default). qtype: 1=A, 28=AAAA, 5=CNAME, 15=MX, 16=TXT. Returns a Vecof bytes.

pub fn dns_build_query(hostname: str, qtype: i64) -> Vec {

Parameters:

  • hostname: str
  • qtype: i64

Returns: Vec

Defined at line 29


dns_v6_text

An IPv6 address as text (RFC 5952): lowercase hex groups without leading zeros, the longest run of two or more zero groups as ”::”.

pub fn dns_v6_text(groups: Vec<i64>) -> str {

Parameters:

  • groups: Vec<i64>

Returns: str

Defined at line 129


dns_parse_response

Parse a raw DNS response (malloc’d bytes, len long) and return the resolved IPs as Vec. qtype 1 → dotted-quad, 28 → hex groups.

pub fn dns_parse_response(buf: i64, len: i64) -> Vec<str> {

Parameters:

  • buf: i64
  • len: i64

Returns: Vec<str>

Defined at line 167


DnsRecord

One answer of a response: its type (1 A, 28 AAAA), time to live in seconds, and address as text.

pub struct DnsRecord {

Fields:

NameType
rtypei64
ttli64
addrstr

Defined at line 180


dns_parse_records

The A and AAAA answers of a raw response (len bytes at buf). Every read is checked against len: a truncated packet gives the answers before the cut.

pub fn dns_parse_records(buf: i64, len: i64) -> Vec<DnsRecord> {

Parameters:

  • buf: i64
  • len: i64

Returns: Vec<DnsRecord>

Defined at line 189


DnsCache

pub struct DnsCache {

Fields:

NameType
namesVec<str>
addrsVec<Vec<str>>
expiresVec<i64>

Defined at line 240


dns_cache_new

pub fn dns_cache_new() -> DnsCache {

Returns: DnsCache

Defined at line 246


dns_cache_get

The cached addresses of name at time now; empty when there are none or they have expired.

pub fn dns_cache_get(c: & DnsCache, name: str, now: i64) -> Vec<str> {

Parameters:

  • c: & DnsCache
  • name: str
  • now: i64

Returns: Vec<str>

Defined at line 265


dns_cache_put

Keep addrs for name until now + ttl (seconds; names are not case sensitive). A ttl of 0 or less keeps nothing.

pub fn dns_cache_put(c: & mut DnsCache, name: str, addrs: Vec<str>, ttl: i64, now: i64) {

Parameters:

  • c: & mut DnsCache
  • name: str
  • addrs: Vec<str>
  • ttl: i64
  • now: i64

Defined at line 276


dns_cache_size

How many names the cache holds unexpired at now.

pub fn dns_cache_size(c: & DnsCache, now: i64) -> i64 {

Parameters:

  • c: & DnsCache
  • now: i64

Returns: i64

Defined at line 296


dns_cache_resolve

The A records of hostname: from the cache while they last, else a query to server (its answers then cached for their smallest TTL).

pub fn dns_cache_resolve(c: & mut DnsCache, hostname: str, server: str, now: i64) -> Vec<str> {

Parameters:

  • c: & mut DnsCache
  • hostname: str
  • server: str
  • now: i64

Returns: Vec<str>

Defined at line 310


dns_query

Query server (dotted-quad) for hostname qtype; returns Vecof answer addresses (empty on failure/timeout). Timeout ~2s.

pub fn dns_query(hostname: str, qtype: i64, server: str, port: i64, timeout_ms: i64) -> Vec<str> {

Parameters:

  • hostname: str
  • qtype: i64
  • server: str
  • port: i64
  • timeout_ms: i64

Returns: Vec<str>

Defined at line 334


dns_query_records

The answers to a query, with their TTLs (empty on failure or timeout).

pub fn dns_query_records(hostname: str, qtype: i64, server: str, port: i64, timeout_ms: i64) -> Vec<DnsRecord> {

Parameters:

  • hostname: str
  • qtype: i64
  • server: str
  • port: i64
  • timeout_ms: i64

Returns: Vec<DnsRecord>

Defined at line 346


dns_resolve_all

Resolve hostname to all A records via the default resolver.

pub fn dns_resolve_all(hostname: str) -> Vec<str> {

Parameters:

  • hostname: str

Returns: Vec<str>

Defined at line 380


dns_resolve_all_via

Resolve via a specific resolver IP.

pub fn dns_resolve_all_via(hostname: str, server: str) -> Vec<str> {

Parameters:

  • hostname: str
  • server: str

Returns: Vec<str>

Defined at line 385


dns_resolve

First A record for hostname, or "" on failure.

pub fn dns_resolve(hostname: str) -> str {

Parameters:

  • hostname: str

Returns: str

Defined at line 390


dns_resolve_via

pub fn dns_resolve_via(hostname: str, server: str) -> str {

Parameters:

  • hostname: str
  • server: str

Returns: str

Defined at line 398


dns_resolve_v6

All AAAA records for hostname.

pub fn dns_resolve_v6(hostname: str) -> Vec<str> {

Parameters:

  • hostname: str

Returns: Vec<str>

Defined at line 407


dns_resolve_system

Resolve via the OS resolver: nslookup on Windows, getent on Unix. Returns first IPv4 address or "" on failure. Slower than a wire query (process spawn) but needs no socket FFI.

pub fn dns_resolve_system(hostname: str) -> str {

Parameters:

  • hostname: str

Returns: str

Defined at line 491


dns_lookup

Recommended entry point: resolves through the OS resolver, which works on every backend (the wire-format path needs pledge_net linked and panics under fid run if it isn’t). Use dns_resolve()/dns_resolve_via() explicitly for the UDP path.

pub fn dns_lookup(hostname: str) -> str {

Parameters:

  • hostname: str

Returns: str

Defined at line 519


Generated by scribe, the Fides documentation generator