clamav-client

A solid client in Java to communicate with ClamAV

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

hu.alphabox
ArtifactId

ArtifactId

clamav-client
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

clamav-client
A solid client in Java to communicate with ClamAV
Project URL

Project URL

https://github.com/alphabox/clamav-client
Source Code Management

Source Code Management

https://github.com/alphabox/clamav-client

Download clamav-client

How to add to project

<!-- https://jarcasting.com/artifacts/hu.alphabox/clamav-client/ -->
<dependency>
    <groupId>hu.alphabox</groupId>
    <artifactId>clamav-client</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/hu.alphabox/clamav-client/
implementation 'hu.alphabox:clamav-client:0.1'
// https://jarcasting.com/artifacts/hu.alphabox/clamav-client/
implementation ("hu.alphabox:clamav-client:0.1")
'hu.alphabox:clamav-client:jar:0.1'
<dependency org="hu.alphabox" name="clamav-client" rev="0.1">
  <artifact name="clamav-client" type="jar" />
</dependency>
@Grapes(
@Grab(group='hu.alphabox', module='clamav-client', version='0.1')
)
libraryDependencies += "hu.alphabox" % "clamav-client" % "0.1"
[hu.alphabox/clamav-client "0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.25

test (1)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.2.3

Project Modules

There are no modules declared in this project.

clamav-client

Introduction

clamav-client is a simple, solid library in Java to communicate with ClamaAV daemon. You can send any message type (typically email) for ClamAV to check for viruses.

The library implements all commands, except which only works on UNIX domain sockets. You can find more information on clamd manual.

Maven dependency

<dependency>
    <groupId>hu.alphabox</groupId>
    <artifactId>clamav-client</artifactId>
    <version>0.1</version>
</dependency>

Building

To make the clamav-client-0.1-SNAPSHOT.jar, you will need the Apache Maven installed. Run the following command:

mvn clean package

Simple Usage

A simple usage example to send EICAR message with the simplest implementation.

public static void main(String[] args) throws Exception {
    ClamAVClient client = new ClamAVClient("localhost", 3310);
    //EICAR message string
    String message = "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*";
    String reply = client.sendCommand(new InStreamCommand(message));
    LOGGER.info("Reply of the message: {}", reply);
}

Async usage

Send messages in async mode with only one connection (Session mode). You get the results as a Future.

public static void main(String[] args) throws Exception {
	List<Future<String>> result = new ArrayList<>();
	try (ClamAVAsyncSessionClient client = new ClamAVAsyncSessionClient("192.168.1.105", 3310)) {
		String message = "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*";		
		for(int i = 0; i < 1000; i++) {
			result.add(client.sendCommand(new InStreamCommand(message)));
		}
		//Collections.shuffle(result);
		for(Future<String> future : result) {
			LOGGER.info(future.get());
		}
	}
}

License

This project licensed under Apache 2.0 License - see the LICENSE file for details

Versions

Version
0.1