r11113 - prelude-correlator/trunk/plugins/lua/ruleset

[email protected]
Newsgroups gmane.comp.security.ids.prelude.cvs
Message-ID <[email protected]>
Author: yoann
Date: 2009-04-03 16:45:24 +0200 (Fri, 03 Apr 2009)
New Revision: 11113

Modified:
   prelude-correlator/trunk/plugins/lua/ruleset/dshield.lua
Log:
Re-implement normalize_ip() using string.format(). This speedup and simplify
the function greatly.

Modified: prelude-correlator/trunk/plugins/lua/ruleset/dshield.lua
===================================================================
--- prelude-correlator/trunk/plugins/lua/ruleset/dshield.lua	2009-04-03 14:45:20 UTC (rev 11112)
+++ prelude-correlator/trunk/plugins/lua/ruleset/dshield.lua	2009-04-03 14:45:24 UTC (rev 11113)
@@ -32,28 +32,13 @@
 
 
 
-function make_zeroed_str(quad)
-        if tonumber(quad) < 100 and tonumber(quad) >= 10 then
-                return "0" .. quad
-        end
-        if tonumber(quad) < 10 then
-                return "00" .. quad
-        end
-
-        return quad
+function normalize_ip(ipaddr)
+        quads = string.split(ipaddr, ".")
+        return string.format("%.3d.%.3d.%.3d.%.3d", quads[1], quads[2], quads[3], quads[4])
 end
 
-function normalize_ip(ipaddr)
-        quads = string.split(ipaddr,".")
 
-        q1 = make_zeroed_str(quads[0])
-        q2 = make_zeroed_str(quads[1])
-        q3 = make_zeroed_str(quads[2])
-        q4 = make_zeroed_str(quads[3])
 
-        return q1 .. "." .. q2 .. "." .. q3 .. "." .. q4
-end
-
 function dshield(INPUT)
 
 io.input("/etc/prelude-correlator/ipsascii.html")

_______________________________________________
Prelude-cvslog site list
[email protected]
http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.