clamd-client

Crates.ioclamd-client
lib.rsclamd-client
version0.1.2
sourcesrc
created_at2022-11-24 10:29:10.90288
updated_at2022-11-24 14:34:42.217127
descriptionRust 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.
homepagehttps://github.com/LevitatingOrange/clamd-client
repositoryhttps://github.com/LevitatingOrange/clamd-client
max_upload_size
id722141
size67,927
Lennart Vogelsang (LevitatingOrange)

documentation

README

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.
Commit count: 14

cargo fmt