Coder Social home page Coder Social logo

cyphernet-dao / rust-netservices Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 10.0 441 KB

P2P network service crates (alternative to rust-microservices)

License: Apache License 2.0

Rust 100.00%
microservice-framework microservices p2p p2p-node concurrency concurrent-programming

rust-netservices's Introduction

Cyphernet network services: library for privacy-preserving microservices.

Build Tests Lints codecov

crates.io Docs Apache-2 licensed

A set of tools for building scalable microservice-based apps and P2P nodes in a privacy-preserving way using cyphernet library with its Noise protocol framework end-to-end encryption, mixnet support, P2P decentralized node ids, io-reactor concurrent scalable network services.

Documentation

API reference documentation for the library can be accessed at https://docs.rs/netservices/.

Licensing

The libraries are distributed on the terms of Apache 2.0 opensource license. See LICENCE file for the license details.

rust-netservices's People

Contributors

canndrew avatar cloudhead avatar dr-orlovsky avatar thabokani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rust-netservices's Issues

Expose waker functionality from controller

Currently, reactor::Controller::wake is private. We should either make it public, or have the ability to return a new waker. The advantage of the alter would be that for workers that only care about waking, they wouldn't have to provide a type for the generic T: reactor::Handler.

Panic on connect

I'm able to trigger this panic via a simple tcp connect port scan with nmap:

nmap -sT 127.0.0.1 -p8776
panicked netservices-0.5.0/src/connection.rs:108:36:
TCP stream doesn't know remote peer address: Os { code: 107, kind: NotConnected, message: "Transport endpoint is not connected" }
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/result.rs:1652:5
   3: core::result::Result<T,E>::expect
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/result.rs:1034:23
   4: <std::net::tcp::TcpStream as netservices::connection::NetConnection>::remote_addr
             at /home/cloudhead/.cargo/registry/src/index.crates.io-6f17d22bba15001f/netservices-0.5.0/src/connection.rs:108:9
   5: <radicle_node::wire::protocol::Wire<D,S,G> as reactor::reactor::Handler>::handle_listener_event
             at ./radicle-node/src/wire/protocol.rs:447:28
   6: reactor::reactor::Runtime<H,P>::handle_events
             at /home/cloudhead/.cargo/registry/src/index.crates.io-6f17d22bba15001f/io-reactor-0.3.0/src/reactor.rs:535:33
   7: reactor::reactor::Runtime<H,P>::run
             at /home/cloudhead/.cargo/registry/src/index.crates.io-6f17d22bba15001f/io-reactor-0.3.0/src/reactor.rs:486:26
   8: reactor::reactor::Reactor<C,P>::with::{{closure}}
             at /home/cloudhead/.cargo/registry/src/index.crates.io-6f17d22bba15001f/io-reactor-0.3.0/src/reactor.rs:300:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Debugging reactor

I have a setup in which:

  1. Client use blocking connection to a server
  2. Server uses reactor non-blocking connection to a peer (second server)
  3. Second server receives connection in a non-blocking way (reactor) and executes command

Here are the logs:
Server 1
Screenshot from 2023-01-08 22-37-03

Server 2
Screenshot from 2023-01-08 22-37-11

@cloudhead as you can see, echo command from the client reaches the second server successfully.

Noise handshake error not propagated

// session.rs
            let output = self.state.advance(&input).map_err(|err| {
                #[cfg(feature = "log")]
                log::error!(target: M::NAME, "Handshake failure: {err}");

                io::Error::from(io::ErrorKind::ConnectionAborted)
            })?;

It would be good if the error was propagated so that it could be handled in the layer above. This error is common if you get the responder NodeId wrong.

The other issue is that this error is only even detected on the responder side. On the initiator side, if you get the remote id wrong, you just get a "peer disconnected" error. Is there a way we can get a more specific error there? At least a "handshake failed" error of sorts?

Use waker from `popol`

The waker code, both for waking and for resetting the waker are both copied from popol. It would make more sense to just use the waker from popol.

Consider changing `LinkDirection` to `Link`

I am currently aliasing LinkDirection to Link because the former is too long and I'm required to import it now. I know you're not a fan of Link, but while searching for an alternative just now I tried asking ChatGPT, and...

image

๐Ÿคทโ€โ™‚๏ธ

Log feature error

With the log feature disabled, I get this error:

error[E0433]: failed to resolve: use of undeclared crate or module `log`
   --> /home/cloudhead/.cargo/git/checkouts/rust-netservices-a9a25ad1cba0d250/ee0ae68/io-reactor/src/reactor.rs:457:21
    |
457 |                     log::error!(target: "reactor", "Polling waker has failed: {err}");
    |                     ^^^ use of undeclared crate or module `log`

Depend on upstream `popol`

We're currently depending on a fork of popol with a different API. It would be good to move back to the upstream version.

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.