Clamd client for Erlang
Minimal local virus scanner with Erlang and ClamAV.
Build
Compile
Compile this package with:
rebar3 compile
Install clamav
On Linux
sudo apt-get install clamav-daemon
On OSX
brew install clamav
Configuration
Copy and edit the sample configuration
cd /usr/local/etc/clamav
cp clamd.conf.sample clamd.conf
edit conf.sample
Changes:
- ~line 8 comment out
Example
- ~line 14 enable logging in a folder you have rights e.g.
LogFile /var/log/clamavd/clamd.log
- ~line 93
LocalSocket /tmp/clamd.socket
- ~line 97
LocalSocketGroup wheel
Start daemon
On Linux
sudo /etc/init.d/clamd start
On OSX
/usr/local/sbin/clamd
Unit test
Point the tests at your daemon in clamd_sup with [{local, "/tmp/clamd.socket"}, 0]
and run:
rebar3 eunit skip_deps=true
Example
application:start(clamd),
{ok, _} = clamd:ping(), %You can ping it
clamd:transaction(fun(Worker) ->
clamd:start_stream(Worker),
clamd:chunk_stream(Worker, "X5O!P%@AP[4\\PZX54(P^)7CC)7}"),
clamd:chunk_stream(Worker, "$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"),
{ok, virus, "Eicar-Test-Signature"} = clamd:end_stream(Worker)
end).
Clamd can be easily flooded, no more worker than CPU, so poolboy is used, and each stream is handled inside a transaction.
Features and todo
- √ Talking to clamd
- √ Connection pool
- _ One session per stream
- _ Some parameters
Licence
MIT. © 2011, Mathieu Lecarme.