Skip to content
Snippets Groups Projects
Commit eda462e0 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- fixed order of "connect" and parameter settings for sockets

- more detailled logging output
parent 4e3e49ff
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@
</fr:x_form>
</pl:initParameters>
<pl:description>SLUB Virus Check Plugin using installed ClamAV daemon via tcp-sockets</pl:description>
<pl:version>1.6</pl:version>
<pl:version>1.9</pl:version>
<pl:materialType>DIGITAL</pl:materialType>
<pl:module>Repository</pl:module>
<pl:generalType>TASK</pl:generalType>
......
/*
2014 by Andreas Romeyke (SLUB Dresden)
2014-2018 by Andreas Romeyke (SLUB Dresden)
The code is partially based on https://code.google.com/p/clamavj/source/browse/trunk/src/main/java/com/philvarner/clamavj/ClamScan.java?r=2
https://github.com/vrtadmin/clamav-devel/blob/master/clamdscan/client.c and
......@@ -51,7 +51,7 @@ import java.util.Map;
*/
public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
//private static final ExLogger log = ExLogger.getExLogger(SLUBVirusCheckClamAVPlugin.class);
private static final int DEFAULT_CHUNK_SIZE = 2048;
private static final int DEFAULT_CHUNK_SIZE = 4096;
private static final byte[] INSTREAM = "zINSTREAM\0".getBytes();
private static final byte[] VERSION = "zVERSION\0".getBytes();
private static final String RESPONSEOK = "stream: OK";
......@@ -178,8 +178,6 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
private Socket openSocket() throws IOException {
// create a socket
Socket socket = new Socket();
//socket.connect( new InetSocketAddress(getHost()));
socket.connect(new InetSocketAddress(getHost(), getPort()));
try {
socket.setSoTimeout(getTimeOut());
} catch (SocketException e) {
......@@ -196,6 +194,15 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
} catch (SocketException e) {
log.error( "Could not set ReUseAddress", e);
}
//socket.connect( new InetSocketAddress(getHost()));
socket.connect(new InetSocketAddress(getHost(), getPort()));
try {
log.debug( "socket has timeout of: " + socket.getSoTimeout() + " ms");
log.debug( "socket has keepalive set: " + socket.getKeepAlive());
log.debug( "socket has reuse adress set: " + socket.getReuseAddress());
} catch (SocketException e) {
log.warn( "Problems to get socket parameters after connect", e);
}
return socket;
}
......@@ -208,7 +215,7 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
if (dos != null) try {
dos.close();
} catch (IOException e) {
log.error("exception closing DOS", e);
log.error("exception closing DataOutputStream", e);
//System.out.println("exception closing DOS " + e);
}
try {
......@@ -342,4 +349,3 @@ public class SLUBVirusCheckClamAVPlugin implements VirusCheckPlugin {
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment