Module interactsh_rs::client

source ·
Available on (crate features rustls-tls or native-tls) and (crate features rustcrypto or openssl) only.
Expand description

Contains the primary structures necessary for registering and polling an Interactsh server.

In order to start a session with an Interactsh server, you must first build an UnregisteredClient using a ClientBuilder. Then, call the register function on the client to turn it into a RegisteredClient that can be used to poll the server. Once you are done with the client, you should call the deregister function on the client to deregister with the Interactsh server and dispose of the client.

The poll function can be used to poll the server once successfully registered. If there are new logs, they will be returned as a vec of LogEntry (see the LogEntry page for more details).

use std::time::Duration;
use interactsh_rs::prelude::*;

async fn run() {
    // When using ClientBuilder::new(), make sure to set
    // all required options (server and rsa key size).
    let mut builder = ClientBuilder::new()

    // These settings are optional or have default values
    builder = builder
        .with_auth_token("some-token-string".into()) // optional
        .with_timeout(Duration::from_secs(20)) // defaults to 15 seconds
        .verify_ssl(true) // defaults to false
        .parse_logs(false); // defaults to true

    // Build the client, then register with the server.
    let unregistered_client = builder
        .expect("Error when building the client");

    let registered_client = unregistered_client
        .expect("Error when registering the client");

    println!("INTERACTION URL: https://{}", registered_client.get_interaction_fqdn());

    // Start a poll loop
    loop {
        // --- (omitted) sleep and check if loop should break ---

        // Poll the server for new logs
        let poll_data = registered_client
            .expect("Error when polling the server");

        let logs = match poll_data {
            Some(logs) => logs,
            None => continue,

        // In the returned vec, each log may be either raw or parsed.
        // Note: Parsed logs do not implement Display; log formatting
        // should be handled by the application using this crate.
        for log_entry in logs.iter() {
            let output = match log_entry {
                LogEntry::ParsedLog(log) => format_logs(log),
                LogEntry::RawLog(log) => log.log_entry.clone(),

            println!("LOG:\n{}", output);

    // Deregister the client once completed
        .expect("Error when deregistering the client");

fn format_logs(log_entry: &ParsedLogEntry) -> String {
    // --- (omitted) format the parsed logs ---


The client type returned when an UnregisteredClient successfully registers with its configured Interactsh server.
The client type returned by the ClientBuilder build function.