Created
July 31, 2023 15:05
-
-
Save niedbalski/efbe904a5c56b0b4a664b07c41a4cc55 to your computer and use it in GitHub Desktop.
lookup.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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