Skip to content

hbliu007/peerlink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PeerLink

PeerLink Logo

High-Performance P2P Communication Library

🌐 WebRTC Native β€’ πŸ”’ TLS 1.3 + Noise β€’ ⚑ 500 Mbps β€’ πŸ”„ libp2p Compatible

License: MIT C++20 CMake Platform Stars Contributors

Quick Start β€’ Features β€’ Architecture β€’ Documentation β€’ Contributing

English β€’ δΈ­ζ–‡


PeerLink P2P Network


πŸš€ Quick Start

Prerequisites

  • CMake 3.20+
  • C++20 Compiler (GCC 11+, Clang 14+, MSVC 2022+)
  • OpenSSL 3.0+

Build

git clone https://github.com/hbliu007/peerlink.git
cd peerlink/p2p-cpp

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)

cd build && ctest -V

Docker

docker run -it hbliu007/peerlink:latest

✨ Features

πŸ” Security Protocols

  • TLS 1.3 (/tls/1.0.0)
  • Noise Protocol (/noise)

πŸ”€ Stream Multiplexing

  • mplex (/mplex/6.7.0)
  • yamux (/yamux/1.0.0)

🌐 Transport

Protocol Description
TCP IPv4/IPv6
QUIC UDP-based multiplexing
WebRTC Browser-to-browser
WebTransport HTTP/3-based

🧭 Peer Routing

  • Kademlia DHT β€” Distributed hash table
  • Bootstrap Nodes β€” Initial peer discovery

πŸ“’ PubSub

  • GossipSub v1.1 β€” Scalable publish/subscribe

πŸ”“ NAT Traversal

Method Description
STUN NAT type detection
TURN Relay fallback
ICE Candidate gathering
Hole Punching Direct connection

πŸ“Š Performance

Metric Value
P2P Throughput 500 Mbps
Connection Latency 20ms
Concurrent Connections 10,000+
Memory Usage ~50 MB

Throughput by Protocol

Protocol Throughput Latency
TCP Direct ~500 Mbps ~20ms
QUIC ~450 Mbps ~15ms
WebRTC ~400 Mbps ~25ms
Relay (TURN) ~50 Mbps ~100ms

πŸ“‚ Project Structure

peerlink/
β”œβ”€β”€ p2p-cpp/                  # C++ Core Library
β”‚   β”œβ”€β”€ include/              # Public headers
β”‚   β”‚   └── p2p/              # Core API
β”‚   β”‚       β”œβ”€β”€ core/         # Engine, connection, session
β”‚   β”‚       β”œβ”€β”€ crypto/       # TLS, Noise, Ed25519
β”‚   β”‚       β”œβ”€β”€ multiaddr/    # Multiaddr implementation
β”‚   β”‚       β”œβ”€β”€ net/          # Async I/O (Asio)
β”‚   β”‚       β”œβ”€β”€ protocol/     # libp2p protocols
β”‚   β”‚       └── transport/    # TCP, QUIC, WebRTC
β”‚   β”œβ”€β”€ src/                  # Implementation
β”‚   β”‚   β”œβ”€β”€ servers/          # STUN, TURN, Signaling, DID
β”‚   β”‚   └── tests/            # Unit & integration tests
β”‚   └── examples/             # Usage examples
β”œβ”€β”€ signaling-server-cpp/      # WebSocket signaling server
└── docs/                      # Architecture & API docs

πŸ’» API Usage

#include <p2p/engine.hpp>

int main() {
    p2p::Config config;
    config.listen_addresses = {"/ip4/0.0.0.0/tcp/0"};
    config.enable_webrtc = true;

    auto engine = p2p::Engine::Create(config);
    engine->Start();

    auto conn = engine->Connect(p2p::PeerId::FromString("QmPeer..."));
    conn->Send("Hello, P2P!");

    engine->Stop();
    return 0;
}

πŸ“– Documentation


🀝 Contributing

Contributions are welcome!

git clone https://github.com/hbliu007/peerlink.git
git checkout -b feature/amazing-feature
cmake -B build -DBUILD_TESTS=ON
cmake --build build
git commit -m "feat: add amazing feature"
git push origin feature/amazing-feature

πŸ“„ License

PeerLink is licensed under the MIT License.


⭐ Star this repo if you find it useful! ⭐

GitHub Star GitHub issues GitHub PRs

Made with ❀️ by hbliu007

About

High-performance P2P communication platform with WebRTC and libp2p - 3-5x faster, cross-platform C++ implementation

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors