29 releases

0.6.7 Jan 2, 2025
0.6.6 Dec 4, 2024
0.6.4 Nov 20, 2024
0.6.1 Jun 13, 2024
0.2.0-alpha.1 Mar 14, 2019

#76 in Network programming

Download history 619/week @ 2024-10-29 179/week @ 2024-11-05 1005/week @ 2024-11-12 1434/week @ 2024-11-19 934/week @ 2024-11-26 1700/week @ 2024-12-03 1727/week @ 2024-12-10 1522/week @ 2024-12-17 1214/week @ 2024-12-24 1248/week @ 2024-12-31 1259/week @ 2025-01-07 1719/week @ 2025-01-14 1105/week @ 2025-01-21 126/week @ 2025-01-28 383/week @ 2025-02-04 846/week @ 2025-02-11

2,583 downloads per month
Used in 20 crates (6 directly)

MIT license

1MB
20K SLoC

Tentacle

Build Status image

Overview

This is a minimal implementation for a multiplexed p2p network based on yamux that supports mounting custom protocols.

Architecture

  1. Data stream transmission
+----+      +----------------+      +-----------+      +-------------+      +----------+      +------+
|user| <--> | custom streams | <--> |Yamux frame| <--> |Secure stream| <--> |TCP stream| <--> |remote|
+----+      +----------------+      +-----------+      +-------------+      +----------+      +------+
  1. Code implementation

All data is passed through the futures channel, yamux splits the actual tcp/websocket stream into multiple substreams, and the service layer wraps the yamux substream into a protocol stream.

Detailed introduction: 中文/English

Note: It is not compatible with libp2p.

Status

The API of this project is basically usable. However we still need more tests. PR is welcome.

The codes in the protocols/ directory are no longer maintained and only used as reference

Usage

From cargo

[dependencies]
tentacle = { version = "0.6.0" }

Example

  1. Clone
$ git clone https://github.com/nervosnetwork/tentacle.git
  1. On one terminal:

Listen on 127.0.0.1:1337

$ RUST_LOG=simple=info,tentacle=debug cargo run --example simple --features ws -- server
  1. On another terminal:
$ RUST_LOG=simple=info,tentacle=debug cargo run --example simple
  1. Now you can see some data interaction information on the terminal.

You can see more detailed example in these three repos:

Run on browser and test

  1. setup a ws server:
$ cd tentacle && RUST_LOG=info cargo run --example simple --features ws -- server
  1. setup a browser client
$ cd simple_wasm && wasm-pack build
$ npm install && npm run serve

all wasm code generate from book

  1. Use a browser to visit http://localhost:8080/

  2. Now you can see the connection on the server workbench or on browser's console

Other Languages

Implementations in other languages

Why?

Because when I use rust-libp2p, I have encountered some difficult problems, and it is difficult to locate whether it is my problem or the library itself, it is better to implement one myself.

Dependencies

~11–28MB
~421K SLoC

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy