Code Monkey home page Code Monkey logo

tentacle's Introduction

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.4.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/www && wasm-pack build
$ npm install && npm run start

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.

tentacle's People

Contributors

aimeedeer avatar chanhsu001 avatar dependabot-support avatar doitian avatar driftluo avatar jjyr avatar keroro520 avatar kingwel-xie avatar liya2017 avatar pencil-yao avatar quake avatar rtzoeller avatar thewawar avatar thomasdezeeuw avatar umiro avatar yangby-cryptape avatar yejiayu avatar zonyitoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tentacle's Issues

Reinstate original copyright

This code is a fork of rust-libp2p but this is not mentioned anywhere (which is required by the license). Can you please put back the original copyright notice?

Run example error

After clone the repo, Run the example:

RUST_LOG=simple=info,p2p=debug cargo run --example simple -- server

and get the following compile error:

error: failed to parse manifest at `/Volumes/x/gettingStart/rust/p2p/Cargo.toml`

Caused by:
  editions are unstable

Caused by:
  feature `edition` is required

consider adding `cargo-features = ["edition"]` to the manifest

Is better to have a rust-toolchain file?

Run example error

After clone the repo, Run the example:

RUST_LOG=simple=info,p2p=debug cargo run --example simple -- server

and get the following compile error:

error: failed to parse manifest at `/Volumes/x/gettingStart/rust/p2p/Cargo.toml`

Caused by:
  editions are unstable

Caused by:
  feature `edition` is required

consider adding `cargo-features = ["edition"]` to the manifest

Is better to have a rust-toolchain file?

build error

`error: Please choose a serialization format via feature. Possible choices: flatc, molc
--> secio/src/handshake/mod.rs:13:1
|
13 | compile_error!("Please choose a serialization format via feature. Possible choices: flatc, molc");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: no method named encode found for struct handshake::handshake_struct::Exchange in the current scope
--> secio/src/handshake/procedure.rs:120:37
|
120 | let local_exchanges = exchanges.encode();
| ^^^^^^ method not found in handshake::handshake_struct::Exchange
|
::: secio/src/handshake/handshake_struct.rs:139:1
|
139 | pub struct Exchange {
| ------------------- method encode not found for this
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following traits define an item encode, perhaps you need to implement one of them:
candidate #1: tokio_util::codec::encoder::Encoder
candidate #2: ring::rsa::padding::RsaEncoding

error[E0599]: no function or associated item named decode found for struct handshake::handshake_struct::Exchange in the current scope
--> secio/src/handshake/procedure.rs:137:44
|
137 | let remote_exchanges = match Exchange::decode(&raw_exchanges) {
| ^^^^^^ function or associated item not found in handshake::handshake_struct::Exchange
|
::: secio/src/handshake/handshake_struct.rs:139:1
|
139 | pub struct Exchange {
| ------------------- function or associated item decode not found for this
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item decode, perhaps you need to implement it:
candidate #1: tokio_util::codec::decoder::Decoder

error: aborting due to 3 previous errors

For more information about this error, try rustc --explain E0599.
error: could not compile tentacle-secio.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.