#clam-av #tcp-socket #unix-socket #clamd #tokio #virus-scanning

clamd-client

Rust async tokio client for clamd. Works with a tcp socket or with the unix socket. At the moment it will open a new socket for each command. Work in progress.

3 releases

0.1.2 Nov 24, 2022
0.1.1 Nov 24, 2022
0.1.0 Nov 24, 2022

#4 in #clamd

28 downloads per month

MIT license

27KB
476 lines

clamd-client, WIP

Rust async tokio client for clamd. Works with a tcp socket or with the unix socket. At the moment it will open a new socket for each command. Work in progress.

Example

See also examples/simple.rs. There should be a running clamd instance on your machine (see Notes).

#[tokio::main]
async fn main() -> Result<()> {
    let address = "127.0.0.1:3310";
    let mut clamd_client = ClamdClientBuilder::tcp_socket(address).build();

    let eicar_bytes = reqwest::get("https://secure.eicar.org/eicarcom2.zip")
        .await?
        .bytes()
        .await?;

    let err = clamd_client.scan_bytes(&eicar_bytes).await.unwrap_err();
    let msg = err.scan_error().unwrap();
    println!("Eicar scan returned that its a virus: {}", msg);
    Ok(())
}

Notes

Running Clamd

To run cargo test or the examples you have to have a running clamd instance on your machine. Easiest would be to use docker:

docker run -p 3310:3310  -v /run/clamav/:/run/clamav/  clamav/clamav:unstable

TODOS

  • Implement missing clamd functionality
  • Implement keepalive tcp connection
  • check whether this can also be used with other async runtimes
  • github actions cargo test
  • using unix socket requires setting <String, str> type bounds.

Dependencies

~4–15MB
~156K SLoC