prelude-correlator/master: Dshield connection timeout

[email protected] Thu, 18 Jun 2009 15:33:16 +0200 (CEST)
Newsgroups gmane.comp.security.ids.prelude.cvs
Message-ID <[email protected]>
commit 3af1674916e3850ae4af9dce2341113180edf484
Author: Yoann Vandoorselaere <[email protected]>
Date:   Thu Jun 18 13:06:16 2009 +0200

    Dshield connection timeout
    
    Implement a timeout for Dshield.org server connection. The default
    is 10 seconds, and might be modified from the prelude-correlator.conf
    configuration file. This prevent Dshield host list loading from
    blocking forever, and fixes #353.


========================================

 PreludeCorrelator/plugins/dshield.py |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

========================================

diff --git a/PreludeCorrelator/plugins/dshield.py b/PreludeCorrelator/plugins/dshield.py
index f382347..5df12d1 100644
--- a/PreludeCorrelator/plugins/dshield.py
+++ b/PreludeCorrelator/plugins/dshield.py
@@ -29,6 +29,7 @@ class DshieldPlugin(Plugin):
     DSHIELD_RELOAD = 7 * 24 * 60 * 60
     DSHIELD_SERVER = "www.dshield.org"
     DSHIELD_URI = "/ipsascii.html?limit=10000"
+    DSHIELD_TIMEOUT = 10
 
     def __loadData(self, fname, age=0):
         cnt = 0
@@ -53,7 +54,7 @@ class DshieldPlugin(Plugin):
 
         self.env.logger.info("Downloading host list from dshield, this might take some time...")
 
-        con = httplib.HTTPConnection(self.__server)
+        con = httplib.HTTPConnection(self.__server, timeout=self.__timeout)
         con.request("GET", self.__uri)
         r = con.getresponse()
         if r.status != 200:
@@ -74,7 +75,7 @@ class DshieldPlugin(Plugin):
         self.__reload = self.getConfigValue("reload", self.DSHIELD_RELOAD)
         self.__server = self.getConfigValue("server", self.DSHIELD_SERVER)
         self.__uri = self.getConfigValue("uri", self.DSHIELD_URI)
-
+        self.__timeout = self.getConfigValue("timeout", self.DSHIELD_TIMEOUT)
         self.__retrieveData()
 
     def run(self, idmef):
_______________________________________________
Prelude-cvslog site list
[email protected]
http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog