18 releases

0.1.5 Nov 8, 2024
0.1.3 May 22, 2024
0.1.2 Jun 3, 2023
0.1.0 Feb 27, 2023
0.0.8 Jul 22, 2022

#1317 in Network programming

Download history 36/week @ 2024-09-19 27/week @ 2024-09-26 1/week @ 2024-10-10 76/week @ 2024-10-24 58/week @ 2024-10-31 114/week @ 2024-11-07 9/week @ 2024-11-14 8/week @ 2024-11-21 1/week @ 2024-11-28

134 downloads per month
Used in localtunnel-cli

MIT license

51KB
797 lines

Localtunnel

localtunnel localtunnel-client localtunnel-server

Localtunnel exposes your localhost endpoint to the world, user cases are:

  • API testing
  • multiple devices access to single data store
  • peer to peer connection, workaround for NAT hole punching.

Client Usage

Known issue: the public proxy server is down, please setup your own server.

Use in CLI:

cargo install localtunnel

localtunnel client --host https://init.so --subdomain kaichao --port 3000

Use as a Rust library:

cargo add localtunnel-client
use localtunnel_client::{open_tunnel, broadcast, ClientConfig};

let (notify_shutdown, _) = broadcast::channel(1);

let config = ClientConfig {
    server: Some("https://init.so".to_string()),
    subdomain: Some("demo".to_string()),
    local_host: Some("localhost".to_string()),
    local_port: 3000,
    shutdown_signal: notify_shutdown.clone(),
    max_conn: 10,
    credential: None,
};
let result = open_tunnel(config).await?;

// Shutdown the background tasks by sending a signal.
let _ = notify_shutdown.send(());

Server Usage

Use in CLI:

localtunnel server --domain init.so --port 3000 --proxy-port 3001 --secure

Use as a Rust library,

cargo install localtunnel-server
use localtunnel_server::{start, ServerConfig};

let config = ServerConfig {
    domain: "init.so".to_string(),
    api_port: 3000,
    secure: true,
    max_sockets: 10,
    proxy_port: 3001,
    require_auth: false,
};

start(config).await?

Sponsor

Please help me build OSS 👉 GitHub Sponsors

Resources

Dependencies

~22–38MB
~685K SLoC