Skip to content

Instantly share code, notes, and snippets.

@niedbalski
Created July 31, 2023 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niedbalski/efbe904a5c56b0b4a664b07c41a4cc55 to your computer and use it in GitHub Desktop.
Save niedbalski/efbe904a5c56b0b4a664b07c41a4cc55 to your computer and use it in GitHub Desktop.
lookup.lua
function forward_lookup(hostname)
local ip = ""
local success, socket = pcall(require, "socket")
if success then
ip = socket.dns.toip(hostname)
end
print(ip, success, socket)
return ip
end
function on_record(tag, timestamp, record)
if record["client_hostname"] then
local hostname = record["client_hostname"]
local ip = forward_lookup(hostname)
if ip then
record["client_ip"] = ip
end
end
return 1, timestamp, record
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment