global::dns

Functions used to query the DNS.

fn lookup

fn lookup(name: String) -> Array
fn lookup(name: SharedObject) -> Array
details

Performs a dual-stack DNS lookup for the given hostname.

Args

  • host - A valid hostname to search.

Return

  • array - an array of IPs. The array is empty if no IPs were found for the host.

Effective smtp stage

All of them.

Errors

  • Root resolver was not found.
  • Lookup failed.

Examples

#{
  preq: [
    action "lookup recipients" || {
      let domain = "gmail.com";
      let ips = dns::lookup(domain);

      print(`ips found for ${domain}`);
      for ip in ips { print(`- ${ip}`); }
    },
  ],
}

fn rlookup

fn rlookup(name: SharedObject) -> Array
fn rlookup(name: String) -> Array
details

Performs a reverse lookup for the given IP.

Args

  • ip - The IP to query.

Return

  • array - an array of FQDNs. The array is empty if nothing was found.

Effective smtp stage

All of them.

Errors

  • Failed to convert the ip parameter from a string into an IP.
  • Reverse lookup failed.

Examples

#{
  connect: [
    rule "rlookup" || {
      state::accept(`250 client ip: ${"127.0.0.1"} -> ${dns::rlookup("127.0.0.1")}`);
    }
  ],
}