fastn-net

Crates.iofastn-net
lib.rsfastn-net
version0.1.2
created_at2025-08-15 09:25:52.266904+00
updated_at2025-08-15 12:17:47.125989+00
descriptionNetwork utilities for fastn
homepagehttps://fastn.com
repository
max_upload_size
id1796499
size179,871
Amit Upadhyay (amitu)

documentation

README

fastn-net

Crates.io Documentation License

Network utilities and P2P communication for the fastn ecosystem.

Overview

fastn-net provides P2P networking capabilities for fastn entities using Iroh. Each fastn instance is called an "entity" in the P2P network, identified by a unique ID52 (52-character encoded Ed25519 public key).

Features

  • P2P networking between fastn entities with NAT traversal
  • HTTP and TCP proxying between entities
  • Connection pooling for HTTP clients
  • Protocol multiplexing (HTTP, TCP, SOCKS5, Ping) over single connections
  • Entity identification via ID52 encoding
  • Graceful shutdown management for async tasks

Installation

[dependencies]
fastn-net = "0.1"

Usage

Basic Connection and Ping

use fastn_net::{global_iroh_endpoint, ping};

// Get the global Iroh endpoint for entity connections
let endpoint = global_iroh_endpoint().await;

// Connect to another entity
let connection = endpoint.connect(entity_node_addr, b"").await?;

// Test connectivity with ping
ping(&connection).await?;

Graceful Shutdown

use fastn_net::Graceful;

let graceful = Graceful::new();

// Spawn tracked tasks
graceful.spawn(async move {
    // Your async work here
    Ok::<(), eyre::Error>(())
});

// Shutdown gracefully on Ctrl+C
graceful.shutdown().await?;

Supported Protocols

  • Protocol::Ping - Connectivity testing
  • Protocol::Http - HTTP request proxying
  • Protocol::Tcp - TCP tunneling
  • Protocol::Socks5 - SOCKS5 proxy
  • Protocol::HttpProxy - HTTP proxy protocol

License

UPL-1.0

Commit count: 0

cargo fmt