letngorok-rs-sdk

Crates.ioletngorok-rs-sdk
lib.rsletngorok-rs-sdk
version0.1.0
created_at2025-05-10 16:19:48.906048+00
updated_at2025-05-10 16:19:48.906048+00
descriptionRust SDK for creating tunnel connections to Letngorok servers
homepagehttps://letngorok.studio/
repositoryhttps://github.com/seiortech/letngorok-rs-sdk
max_upload_size
id1668532
size88,937
Raden Mohamad Rishwan (radenrishwan)

documentation

https://docs.letngorok.studio/

README

Letngorok Rust SDK

letngorok-rs-sdk is a Rust SDK for creating tunnel connections to Letngorok servers.

Usage

First, you need to get an authentication token from the Letngorok Dashboard.

Then, Add this to your Cargo.toml:

[dependencies]
letngorok-rs-sdk = "0.1.0"
tokio = { version = "1", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "fmt"] }

Here is a basic example:

use letngorok_rs_sdk::TunnelClient;
use tracing_subscriber::FmtSubscriber;

#[tokio::main]
async fn main() {
    let subscriber = FmtSubscriber::builder()
        .with_max_level(tracing::Level::INFO)
        .finish();
    tracing::subscriber::set_global_default(subscriber)
        .expect("Setting default tracing subscriber failed.");

    let token = "set-your-token-here";
    let local_port = "set-your-local-port-here";

    let client = match TunnelClient::new(None, token.to_string()) {
        Ok(c) => c,
        Err(e) => {
            tracing::error!("Failed to create TunnelClient: {:?}", e);
            return;
        }
    };
    tracing::info!("TunnelClient created.");

    if let Err(e) = client.start(local_port.to_string(), None).await {
        tracing::error!("Failed to start tunnel for port {}: {:?}", local_port, e);
        return;
    }
    tracing::info!(
        "Tunnel initiation for local port {} requested. Check logs for connection status.",
        local_port
    );

    tracing::info!("Tunnel is active. Press Ctrl+C to stop and exit.");
    tokio::signal::ctrl_c()
        .await
        .expect("Failed to listen for Ctrl+C signal");

    tracing::info!("Ctrl+C received. Shutting down tunnel(s)...");
    if let Err(e) = client.stop_all().await {
        tracing::error!("Error during tunnel shutdown: {:?}", e);
    }

    tracing::info!("Application has exited.");
}å

License

This SDK is licensed under the MIT License. See LICENSE for details.

Commit count: 3

cargo fmt