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:
nameis a DNS name andtypeis the record type. Returns:Array. Looks up records forname.Returns an array of dictionaries. All records include
type,name,value, andttl. Backends returnttl: nullwhen TTLs are not available.Record-specific keys include:
addressforAandAAAAtargetforCNAME,NS,PTR, andSRVexchangeandpreferenceforMXtextandstringsforTXTport,priority, andweightforSRV
lookup_async(name, type = "A")Parameters: same as
lookup. Returns:Task. Asynchronous version oflookup.addresses(name, family = "any")Parameters:
nameis a DNS name andfamilyisany,ipv4, oripv6. Returns:Array. Returns address strings forname.addresses_async(name, family = "any")Parameters: same as
addresses. Returns:Task. Asynchronous version ofaddresses.reverse(address)Parameters:
addressis an IPv4 or IPv6 address. Returns:Array. Returns PTR names for the address.reverse_async(address)Parameters: same as
reverse. Returns:Task. Asynchronous version ofreverse.
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.