#! /bin/sh /usr/share/dpatch/dpatch-run
## 05_add_ssltimeout_option.dpatch by Rene Mayrhofer, adapted from a patch by
## Heiko Schlittermann
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Add SSLTIMEOUT config option

@DPATCH@

--- a/havp/default.h.in
+++ b/havp/default.h.in
@@ -36,6 +36,7 @@
  "USESYSLOG","SYSLOGNAME","SYSLOGFACILITY","SYSLOGLEVEL","SYSLOGVIRUSLEVEL","IGNOREVIRUS", \
  "DISPLAYINITIALMESSAGES","DBRELOAD","SCANTEMPFILE","TEMPLATEPATH","DISABLELOCKINGFOR", \
  "PARENTPROXY","PARENTPORT","MAXSERVERS","FORWARDED_IP","X_FORWARDED_FOR","FAILSCANERROR", \
+ "SSLTIMEOUT", \
  "MAXDOWNLOADSIZE","SCANNERTIMEOUT","STREAMUSERAGENT","STREAMSCANSIZE","SCANIMAGES", \
  "SKIPMIME","SCANMIME", \
  "ENABLECLAMLIB","CLAMDBDIR","CLAMBLOCKBROKEN","CLAMBLOCKMAX","CLAMBLOCKENCRYPTED", \
diff --git a/havp/params.cpp b/havp/params.cpp
index 0f83c0c..5a18913 100644
--- a/havp/params.cpp
+++ b/havp/params.cpp
@@ -86,6 +86,7 @@ void Params::SetDefaults()
     SetConfig("SCANNERTIMEOUT",	"10");
     SetConfig("IGNOREVIRUS",	"");
     SetConfig("DISABLELOCKINGFOR","AVG:ALL");
+    SetConfig("SSLTIMEOUT", "20");
 //SCANNERS
     SetConfig("ENABLECLAMLIB","false");
         SetConfig("CLAMDBDIR","");
diff --git a/havp/sockethandler.cpp b/havp/sockethandler.cpp
index 28a119a..4cb5f24 100644
--- a/havp/sockethandler.cpp
+++ b/havp/sockethandler.cpp
@@ -582,7 +582,7 @@ int SocketHandler::CheckForSSLData( int sockBrowser, int sockServer )
         fds = sockServer;
     }
 
-    Timeout.tv_sec = 20;
+    Timeout.tv_sec = Timeout.tv_sec = Params::GetConfigInt("SSLTIMEOUT");;
     Timeout.tv_usec = 0;
 
     int ret = select_eintr(fds+1, &readfd, NULL, NULL, &Timeout);
