Lua Requires Chilkat v9.5.0.96+
Lua
DNS Query NS Records
See more DNS Examples
Shows how to perform a DNS query to retrieve NS records.Chilkat Lua Downloads
local chilkat = require("chilkat")
local dns = chilkat.Dns.new()
local json = chilkat.JsonObject.new()
json.emit_compact = false
local success = dns:query("NS", "x.com", json)
if not success then
print(dns.last_error_text)
return
end
print(json:emit())
-- Sample response.
-- Parsing code below..
-- {
-- "answer": {
-- "ns": [
-- {
-- "name": "x.com",
-- "ttl": 86400,
-- "domain": "alexia.ns.cloudflare.com"
-- },
-- {
-- "name": "x.com",
-- "ttl": 86400,
-- "domain": "tosana.ns.cloudflare.com"
-- }
-- ]
-- }
-- }
-- Use this online tool to generate parsing code from sample JSON:
-- Generate Parsing Code from JSON
local name = ""
local ttl = 0
local domain = ""
local i = 0
local count_i = json:size_of_array("answer.ns")
while i < count_i do
json.i = i
name = json:string_of("answer.ns[i].name")
ttl = json:int_of("answer.ns[i].ttl")
domain = json:string_of("answer.ns[i].domain")
i = i + 1
end