std/net/dns

Standard Library documentation

DNS lookup helpers.

Module

Name
std/net/dns
Area
Standard Library
Source
modules/std/net/dns.zzm

NAME

std/net/dns - DNS lookup helpers.

SYNOPSIS

  from std/net/dns import lookup, addresses, reverse;

  let ips := addresses("example.com");
  let mx  := lookup("example.com", "MX");
  let ptr := reverse("127.0.0.1");

IMPLEMENTATION SUPPORT

This module is supported by zuzu.pl, zuzu-rust, and zuzu-js on Node and Electron. It is not supported by zuzu-js in the browser.

DESCRIPTION

This runtime-supported module provides small DNS helper functions for forward lookups, common DNS record queries, and reverse DNS.

EXPORTS

Functions

  • lookup(name, type = "A")

    Parameters: name is a DNS name and type is the record type. Returns: Array. Looks up records for name.

    Returns an array of dictionaries. All records include type, name, value, and ttl. Backends return ttl: null when TTLs are not available.

    Record-specific keys include:

    • address for A and AAAA
    • target for CNAME, NS, PTR, and SRV
    • exchange and preference for MX
    • text and strings for TXT
    • port, priority, and weight for SRV
  • lookup_async(name, type = "A")

    Parameters: same as lookup. Returns: Task. Asynchronous version of lookup.

  • addresses(name, family = "any")

    Parameters: name is a DNS name and family is any, ipv4, or ipv6. Returns: Array. Returns address strings for name.

  • addresses_async(name, family = "any")

    Parameters: same as addresses. Returns: Task. Asynchronous version of addresses.

  • reverse(address)

    Parameters: address is an IPv4 or IPv6 address. Returns: Array. Returns PTR names for the address.

  • reverse_async(address)

    Parameters: same as reverse. Returns: Task. Asynchronous version of reverse.

No-data and NXDOMAIN responses return an empty array. Invalid input, internal resolver timeouts, and resolver failures throw runtime exceptions.

COPYRIGHT AND LICENCE

std/net/dns is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.