| Crates.io | p2p-foundation |
| lib.rs | p2p-foundation |
| version | 0.1.8 |
| created_at | 2025-06-26 16:07:51.991935+00 |
| updated_at | 2025-06-26 21:55:44.215886+00 |
| description | Complete P2P networking foundation with flexible contacts panel, collapsible system menu, sparkly interactive help, DHT inboxes with infinite TTL, embedded Flutter PWA with auto-scroll chat, native app support, three-word addresses, and built-in AI capabilities |
| homepage | https://github.com/dirvine/p2p |
| repository | https://github.com/dirvine/p2p |
| max_upload_size | |
| id | 1727537 |
| size | 2,423,919 |
A next-generation peer-to-peer networking foundation built in Rust, featuring QUIC transport, IPv6-first architecture, comprehensive tunneling support, and fully integrated AI capabilities through Model Context Protocol (MCP) servers at each node.
global.fast.eagle instead of complex multiaddrs - revolutionary UX!use p2p_foundation::{P2PNode, NodeConfig};
use p2p_foundation::mcp::{Tool, FunctionToolHandler};
use serde_json::json;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create a P2P node with MCP server
let node = P2PNode::builder()
.listen_on("/ip6/::/tcp/9000")
.with_mcp_server()
.build()
.await?;
// Register an MCP tool
let echo_tool = Tool::new(
"echo",
"Echo service that returns input",
json!({
"type": "object",
"properties": {
"message": {"type": "string"}
},
"required": ["message"]
})
).handler(FunctionToolHandler::new(|args| async move {
Ok(json!({"echo": args["message"]}))
})).build()?;
node.register_mcp_tool(echo_tool).await?;
// Start the node
node.start().await?;
// Connect to peers and discover services
let peer_id = node.connect_peer("/ip6/2001:db8::1/tcp/9000").await?;
let remote_tools = node.list_remote_mcp_tools(&peer_id).await?;
// Call remote tools
let result = node.call_remote_mcp_tool(
&peer_id,
"calculator",
json!({"a": 5, "b": 3, "operation": "add"})
).await?;
println!("Result: {}", result);
Ok(())
}
Add to your Cargo.toml:
[dependencies]
p2p-foundation = "0.1.0"
┌─────────────────────────────────────┐
│ MCP Server Layer (AI Tools) │ ← Tool discovery, remote execution
├─────────────────────────────────────┤
│ Security & Authentication Layer │ ← JWT auth, permissions, audit
├─────────────────────────────────────┤
│ S/Kademlia DHT (Secure Routing) │ ← Disjoint paths, IPv6 diversity
├─────────────────────────────────────┤
│ libp2p Core (Network) │ ← Peer discovery, messaging
├─────────────────────────────────────┤
│ QUIC Transport Layer │ ← Modern, secure transport
├─────────────────────────────────────┤
│ IPv6/IPv4 Tunneling (Auto-Select) │ ← 6to4, Teredo, 6in4
└─────────────────────────────────────┘
Revolutionary user experience that transforms complex multiaddrs into memorable phrases:
# Traditional way (hard to share)
/ip6/2001:db8:85a3::8a2e:370:7334/udp/9001/quic
# Three-word way (easy to remember and share)
global.fast.eagle
forest.lightning.compass vs /ip6/::/udp/9000/quic# Bootstrap with three-word addresses
cargo run --example chat -- --bootstrap-words 'global.fast.eagle'
# Traditional bootstrap still works
cargo run --example chat -- --bootstrap '/ip6/::1/tcp/9000'
use p2p_foundation::bootstrap::{WordEncoder, ThreeWordAddress};
let encoder = WordEncoder::new();
let multiaddr = "/ip6/2001:db8::1/udp/9000/quic".parse()?;
let words = encoder.encode_multiaddr(&multiaddr)?;
println!("Share: {}", words); // "outer.sharp.eagle"
The Ant Connect app showcases the complete three-word experience:
See the examples/ directory for:
# Clone the repository
git clone https://github.com/dirvine/p2p.git
cd p2p
# Build the project
cargo build --release
# Run tests
cargo test --all-features
# Run benchmarks
cargo bench
# Run all tests
cargo test --all-features
# Core module tests
cargo test --lib dht # DHT and S/Kademlia tests
cargo test --lib transport # QUIC transport tests
cargo test --lib tunneling # IPv6 tunneling tests
cargo test --lib mcp # MCP protocol tests
# Comprehensive test suites
cargo test --test mcp_integration_tests # MCP integration
cargo test --test mcp_security_tests # MCP security features
cargo test --test mcp_remote_tests # Remote tool execution
cargo test --test dslite_tests # DS-Lite tunneling
cargo test --test tunneling_tests # Tunneling protocols
cargo test --test security_tests # S/Kademlia security
# Integration tests (requires fixes)
# cargo test --test integration
# With debug logging
RUST_LOG=debug cargo test test_teredo_tunneling
RUST_LOG=debug cargo test test_mcp_remote_calling
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
The P2P Foundation implements comprehensive defense-in-depth security across all layers:
📋 Complete Security Framework Documentation →
Licensed under either of:
at your option.
Built on top of excellent open source projects:
Building the decentralized future, one node at a time.