MCPcopy Index your code
hub / github.com/driftluo/tentacle

github.com/driftluo/tentacle @0.7.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.7.0 ↗ · + Follow
1,874 symbols 5,746 edges 151 files 364 documented · 19%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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.

Extension points exported contracts — how you extend this code

TransportDial (Interface)
Definition of transport dial protocol behavior [7 implementers]
tentacle/src/transports/mod.rs
StreamCipher (Interface)
(no doc) [3 implementers]
secio/src/crypto/mod.rs
AddressManager (Interface)
FIXME: Should be peer store? [1 implementers]
protocols/discovery/src/addr.rs
Callback (Interface)
The trait to communicate with underlying peer storage [1 implementers]
protocols/identify/src/lib.rs
Callback (Interface)
(no doc) [1 implementers]
protocols/ping/src/lib.rs
ServiceHandle (Interface)
(no doc) [20 implementers]
tentacle/src/traits.rs
KeyProvider (Interface)
(no doc) [2 implementers]
secio/src/lib.rs
ServiceProtocol (Interface)
(no doc) [29 implementers]
tentacle/src/traits.rs

Core symbols most depended-on inside this repo

clone
called by 219
tentacle/src/buffer.rs
as_slice
called by 139
protocols/discovery/src/protocol_mol.rs
spawn
called by 133
tentacle/src/runtime/wasm_runtime.rs
send
called by 107
tentacle/src/context.rs
build
called by 90
tentacle/src/builder.rs
as_slice
called by 88
secio/src/handshake/handshake_mol.rs
len
called by 74
protocols/discovery/src/protocol_mol.rs
next
called by 63
tentacle/src/transports/websocket.js

Shape

Method 1,074
Function 406
Class 303
Enum 76
Interface 15

Languages

Rust99%
TypeScript1%

Modules by API surface

protocols/discovery/src/protocol_mol.rs93 symbols
secio/src/handshake/handshake_mol.rs67 symbols
yamux/src/session.rs56 symbols
protocols/identify/src/protocol_mol.rs50 symbols
protocols/ping/src/protocol_mol.rs49 symbols
tentacle/src/protocol_select/protocol_select_mol.rs48 symbols
tentacle/src/service/config.rs46 symbols
yamux/src/stream.rs38 symbols
tentacle/src/context.rs38 symbols
tentacle/src/channel/bound.rs37 symbols
tentacle/src/builder.rs36 symbols
tentacle/src/substream.rs34 symbols

For agents

$ claude mcp add tentacle \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact