changeset 1592:47fb4f36dacd

Add support for IPv4 addresses in SRV injections
author Ashley Ward <ashley.ward@surevine.com>
date Tue, 20 Jan 2015 11:02:14 +0000
parents 21e439ca7208
children d9f3c66ea938
files mod_srvinjection/mod_srvinjection.lua
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mod_srvinjection/mod_srvinjection.lua	Sun Jan 18 01:21:53 2015 +0100
+++ b/mod_srvinjection/mod_srvinjection.lua	Tue Jan 20 11:02:14 2015 +0000
@@ -32,9 +32,16 @@
 			handler(mapping);
 			return;
 		end
-	elseif qtype == "A" and (qname == "localhost." or qname == "127.0.0.1.") then
-		handler({{ a = "127.0.0.1" }});
-		return;
+	elseif qtype == "A" then
+		if (qname == "localhost." or qname == "127.0.0.1.") then
+			handler({{ a = "127.0.0.1" }});
+			return;
+		end
+		local ip = qname:match("^(%d+.%d+.%d+.%d+).$");
+		if ip then
+			handler({{ a = ip }});
+			return;
+		end
 	end
 	return original_lookup(handler, qname, qtype, qclass);
 end