Home  Contents

rawio.resolver

Rawio Core4 Lua Event System

SYNOPSIS

  1. resolver = rawio.resolver(app)
  2. functionresolver:result(question, success, result_or_error) ... end

DESCRIPTION

Creates DNS resolver instance. This instance can be used to run one DNS query at a time. To run multiple concurrent DNS queries, instantiate multiple resolvers.

To do a DNS query, call resolver:resolve(question). The question is a host name or an IP address in string form.

Processing of the query is done from within the event:poll() mainloop.

On completion, successful or not, the method resolver:result() is called. This callback is always called from within event:poll(), even on a cache hit.

A successful query is cached for as long as the TTL (time-to-live) data in the response indicates. Other queries for the same question will be fulfilled from the cache.

A failed query is cached for five seconds to prevent flooding the server. During that time, further queries for that question will fail immediately.

Up to two servers can be configured through the kconfig mechanism. Alternatively, servers can be set prior to a query by calling resolver:setServers().

RETURN VALUE

A new resolver instance.

SEE ALSO

EXAMPLE

-- -- This example needs a running event loop -- MyResolver = rawio.resolver(app) function MyResolver:result(question, success, result_or_error) print(string.format("Result for question '%s' is %s: %s", question, success, result_or_error)) end MyResolver:resolve("zombo.com") -- Reverse lookup i.e.: -- MyResolver:resolve("1.1.1.1")