#sdk #tunnel #server #rust #letngorok

bin+lib letngorok-rs-sdk

Rust SDK for creating tunnel connections to Letngorok servers

1 unstable release

new 0.1.0 May 10, 2025

#1900 in Network programming

MIT license

40KB
859 lines

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.

Dependencies

~10–24MB
~320K SLoC