Lua Requires Chilkat v9.5.0.96+
Lua
DNS Query CAA Records
See more DNS Examples
Shows how to perform a DNS query to retrieve CAA 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("CAA", "zoom.us", json)
if not success then
print(dns.last_error_text)
return
end
print(json:emit())
-- Sample response.
-- Parsing code below..
-- {
-- "answer": {
-- "caa": [
-- {
-- "name": "zoom.us",
-- "ttl": 300,
-- "flags": 0,
-- "tag": "iodef",
-- "value": "mailto:security@zoom.us"
-- },
-- {
-- "name": "zoom.us",
-- "ttl": 300,
-- "flags": 0,
-- "tag": "issue",
-- "value": "amazon.com"
-- },
-- {
-- "name": "zoom.us",
-- "ttl": 300,
-- "flags": 0,
-- "tag": "issue",
-- "value": "digicert.com"
-- },
-- {
-- "name": "zoom.us",
-- "ttl": 300,
-- "flags": 0,
-- "tag": "issue",
-- "value": "godaddy.com"
-- },
-- {
-- "name": "zoom.us",
-- "ttl": 300,
-- "flags": 0,
-- "tag": "issue",
-- "value": "letsencrypt.org"
-- },
-- {
-- "name": "zoom.us",
-- "ttl": 300,
-- "flags": 0,
-- "tag": "issue",
-- "value": "pki.goog"
-- },
-- {
-- "name": "zoom.us",
-- "ttl": 300,
-- "flags": 0,
-- "tag": "issue",
-- "value": "sectigo.com"
-- }
-- ]
-- }
-- }
-- Use this online tool to generate parsing code from sample JSON:
-- Generate Parsing Code from JSON
local name = ""
local ttl = 0
local flags = 0
local tag = ""
local value = ""
local i = 0
local count_i = json:size_of_array("answer.caa")
while i < count_i do
json.i = i
name = json:string_of("answer.caa[i].name")
ttl = json:int_of("answer.caa[i].ttl")
flags = json:int_of("answer.caa[i].flags")
tag = json:string_of("answer.caa[i].tag")
value = json:string_of("answer.caa[i].value")
i = i + 1
end