You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

357 lines
14 KiB

5 years ago
/**
* Copyright Quadrivium LLC
* All Rights Reserved
5 years ago
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
5 years ago
#include <boost/di.hpp>
// implementations
Connection layers mechanism; Websocket layer (#201) * feature: layers of connections * feature: upgrade layers of connection * fix: tests * feature: test of layers upgrade * refactor: enable disabled upgrader tests * feature: sha-1 hash * feature: websocket layer * fix: read-buffer extending * feature: decide layers for connection upgrade by provided multiaddress * refactor: combine regular and websocket echo-client/-server to single one * refactor: rename peer::Protocol to peer::ProtocolName * refactor: implement addressToBytes, as replacement addressToHex * refactor: mark addressToHex as deprecated * feature: extend ConversionError * fix: multiaddress manipulations * feature: dummy protocols for tests * fix: tests of converters * fix: collision in DI * refactor: update outcome macros for tests * fix: connection upgrader in part of layers * fix: ws read-writer in case big data fragmented by frames * experiment: add delay of sending jumbo message, to give a chance for Id-protocol to end his work * experiment: log difference sent and received data for analyse * feature: control frames (ping/pong/close) * fix: sending huge portions of data * fix: echo sessions * feature: optional hex dump in dumpBin * fix: echo client * update: hunter package manager * fix: hardcoded request and response in http-to-ws upgraded * fix: add ws version header * fix: reduce length of ws-key header * fix: make ws-header check case-insensitive * fix: use locale independent predicate for ci-compare * fix: use boost endian conversion instead endian macros Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt;
2 years ago
#include <libp2p/basic/scheduler/asio_scheduler_backend.hpp>
#include <libp2p/basic/scheduler/scheduler_impl.hpp>
#include <libp2p/crypto/aes_ctr/aes_ctr_impl.hpp>
#include <libp2p/crypto/crypto_provider/crypto_provider_impl.hpp>
#include <libp2p/crypto/ecdsa_provider/ecdsa_provider_impl.hpp>
#include <libp2p/crypto/ed25519_provider/ed25519_provider_impl.hpp>
#include <libp2p/crypto/hmac_provider/hmac_provider_impl.hpp>
#include <libp2p/crypto/key_marshaller/key_marshaller_impl.hpp>
#include <libp2p/crypto/key_validator/key_validator_impl.hpp>
#include <libp2p/crypto/random_generator/boost_generator.hpp>
#include <libp2p/crypto/rsa_provider/rsa_provider_impl.hpp>
#include <libp2p/crypto/secp256k1_provider/secp256k1_provider_impl.hpp>
Connection layers mechanism; Websocket layer (#201) * feature: layers of connections * feature: upgrade layers of connection * fix: tests * feature: test of layers upgrade * refactor: enable disabled upgrader tests * feature: sha-1 hash * feature: websocket layer * fix: read-buffer extending * feature: decide layers for connection upgrade by provided multiaddress * refactor: combine regular and websocket echo-client/-server to single one * refactor: rename peer::Protocol to peer::ProtocolName * refactor: implement addressToBytes, as replacement addressToHex * refactor: mark addressToHex as deprecated * feature: extend ConversionError * fix: multiaddress manipulations * feature: dummy protocols for tests * fix: tests of converters * fix: collision in DI * refactor: update outcome macros for tests * fix: connection upgrader in part of layers * fix: ws read-writer in case big data fragmented by frames * experiment: add delay of sending jumbo message, to give a chance for Id-protocol to end his work * experiment: log difference sent and received data for analyse * feature: control frames (ping/pong/close) * fix: sending huge portions of data * fix: echo sessions * feature: optional hex dump in dumpBin * fix: echo client * update: hunter package manager * fix: hardcoded request and response in http-to-ws upgraded * fix: add ws version header * fix: reduce length of ws-key header * fix: make ws-header check case-insensitive * fix: use locale independent predicate for ci-compare * fix: use boost endian conversion instead endian macros Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt;
2 years ago
#include <libp2p/layer/websocket.hpp>
#include <libp2p/muxer/mplex.hpp>
#include <libp2p/muxer/yamux.hpp>
#include <libp2p/network/impl/connection_manager_impl.hpp>
#include <libp2p/network/impl/dialer_impl.hpp>
#include <libp2p/network/impl/dnsaddr_resolver_impl.hpp>
#include <libp2p/network/impl/listener_manager_impl.hpp>
#include <libp2p/network/impl/network_impl.hpp>
#include <libp2p/network/impl/router_impl.hpp>
#include <libp2p/network/impl/transport_manager_impl.hpp>
#include <libp2p/peer/impl/identity_manager_impl.hpp>
#include <libp2p/protocol_muxer/multiselect.hpp>
#include <libp2p/security/noise.hpp>
#include <libp2p/security/plaintext.hpp>
#include <libp2p/security/plaintext/exchange_message_marshaller_impl.hpp>
#include <libp2p/security/secio.hpp>
#include <libp2p/security/secio/exchange_message_marshaller_impl.hpp>
#include <libp2p/security/secio/propose_message_marshaller_impl.hpp>
#include <libp2p/security/tls.hpp>
#include <libp2p/security/tls/ssl_context.hpp>
#include <libp2p/transport/impl/upgrader_impl.hpp>
#include <libp2p/transport/quic/transport.hpp>
#include <libp2p/transport/tcp.hpp>
5 years ago
// clang-format off
/**
* @file network_injector.hpp
* @brief This header defines DI injector helpers, which can be used instead of
* manual wiring.
*
* The main function in this header is
* @code makeNetworkInjector() @endcode
* Use it to create a Boost.DI container with default types.
*
* By default:
* - TCP is used as transport
* - Plaintext as security
* - Yamux as muxer
* - Random keypair is generated
*
* List of libraries that should be linked to your lib/exe:
* - libp2p_network
* - libp2p_tcp
* - libp2p_yamux
* - libp2p_plaintext
* - libp2p_connection_manager
* - libp2p_transport_manager
* - libp2p_listener_manager
* - libp2p_identity_manager
* - libp2p_dialer
* - libp2p_router
* - multiselect
* - random_generator
* - key_generator
* - marshaller
*
* <b>Example 1</b>: Make default network with Yamux as muxer, Plaintext as
* security, TCP as transport.
* @code
* auto injector = makeNetworkInjector();
* std::shared_ptr<Network> network = injector.create<std::shared_ptr<Network>>();
* assert(network != nullptr);
* @endcode
*
* <b>Example 2</b>: Make network with new transport, muxer and security.
* @code
* struct NewTransport : public TransportAdaptor {...};
* struct NewMuxer : public MuxerAdaptor {...};
* struct NewSecurity : public SecurityAdaptor {...};
*
* auto injector = makeNetworkInjector(
* useTransportAdaptors<NewTransport>(),
* useMuxerAdaptors<NewMuxer>(),
* useSecurityAdaptors<NewSecurity>()
* );
*
* std::shared_ptr<Network> network = injector.create<std::shared_ptr<Network>>();
* assert(network != nullptr);
* @endcode
*
* <b>Example 3</b>: Use mocked router:
* @code
* struct RouterMock : public Router {...};
*
* auto injector = makeNetworkInjector(
* boost::di::bind<Router>.to<RouterMock>()
* );
*
* // build network
* std::shared_ptr<Network> network = injector.create<std::shared_ptr<Network>>();
* assert(network != nullptr);
*
* // get mock
* std::shared_ptr<RouterMock> routerMock = injector.create<std::shared_ptr<RouterMock>>();
* assert(routerMock != nullptr);
* @endcode
*
* <b>Example 4</b>: Use instance of mock.
* @code
* struct RouterMock : public Router {...};
*
* auto routerMock = std::make_shared<RouterMock>();
*
* auto injector = makeNetworkInjector(
* boost::di::bind<Router>.to(routerMock)
* );
*
* // build network
* std::shared_ptr<Network> network = injector.create<std::shared_ptr<Network>>();
* assert(network != nullptr);
* @endcode
*/
// clang-format on
namespace libp2p::injector {
/**
* @brief Instruct injector to use this keypair. Can be used once.
*
* @code
* KeyPair keyPair = {...};
* auto injector = makeNetworkInjector(
* useKeyPair(std::move(keyPair))
* );
* @endcode
*/
inline auto useKeyPair(crypto::KeyPair key_pair) {
5 years ago
return boost::di::bind<crypto::KeyPair>().template to(
std::move(key_pair))[boost::di::override];
5 years ago
}
/**
* @brief Instruct injector to use wss ssl server with key and certificates
* from pem. Can be used once.
*/
inline auto useWssPem(std::string_view pem) {
layer::WssCertificate cert;
if (not pem.empty()) {
if (auto cert_res = layer::WssCertificate::make(pem)) {
cert = std::move(cert_res.value());
} else {
SL_WARN(log::createLogger("libp2p::injector::useWssPem"),
"{}",
cert_res.error());
}
}
return boost::di::bind<layer::WssCertificate>.template to(
std::move(cert))[boost::di::override];
}
5 years ago
/**
* @brief Instruct injector to use specific config type. Can be used many
* times for different types.
* @tparam C config type
* @param c config instance
* @return injector binding
*
* @code
* // config definition
* struct YamuxConfig {
* int a = 5;
* }
*
* // config consumer definition
* struct Yamux {
* Yamux(YamuxConfig config);
* }
*
* // create injector
* auto injector = makeNetworkInjector(
* // change default value a=5 to a=3
* useConfig<YamuxConfig>({.a = 3})
* );
* @endcode
*/
template <typename C>
Feature/reentrancy (#111) * gossip confirmance fixes #1 * gossip: bugfixes * gossip: more fixes * gossip: build related minor changes * gossip: one more fix * gossip: flush hello message asap * experiment with noise protocol * made injector creation fns inline to prevent multiple definitions * gossip restructured, interop issues fixed * Noise::write now reports the correct amount of bytes Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * refactoring: move prev implementation of Kademlia to other namespace Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: kademlia dependency injection Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: improve random generator Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: getting listened multiaddress in tcp listener Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: reduce logging in secio Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: new implementation of kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: validation Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: DSA Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: CIDv1 encoding refactoring: replace deprecated sha256 function by hasher Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: multiaddress operations Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: make PeerId comparable to using in std::set Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: addr repo Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: Go-implementation compatibility Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: rendezvous chat as example of Kademlia using Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: unit-test for kademlia parts Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: StorageBackend interface fix: ContentValue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * wipe: remove previous implementation of Kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: cmake files Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; cmake Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some warnings Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: resolve TODOes, comments, format Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: using timeout for make new stream feature: smart using of peer routing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: kademlia message parsing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize executors&#39; working Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize start of rendezvous chat Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: headers including Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: remaining request executors; naming Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: add handle and timeout as argument of Host::connect Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some log messages Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * injectors temp fix * gossip: uncommented writing bytes checking * removed redundant std::hash definition * Hack yamux to allow weighty messages processing Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * fix vtable * fixes in DI injectors * yamux test corrected according to curent window update policy * added buffering primitives * defer* functions in Reader/Writer interfaces and Yamux redesign pt.1 * scheduler fix regarding move assignment + cancel * write queue interface change * read buffer fix regarding subspan * some diagnostic logging * tcp connection fixes related to closing behavior * yamux bugfixes * yamux tests regression WIP * build fix * . * . * bugfixes * fixes * . * . * suppressed most verbose logging in yamux and multiselect * yamux stream adjustWindowSize adjusted * fixes regarding std::move of r/w callbacks (against possible ptrs invalidation) * test cases with jumbo messages transfer added for yamux on noise/tls/plaintext * bugfixes related to yamux window sizes, overflow, and acknowledgements * echo protocol and examples support very large msgs * changes in tests * all muxers acceptance test recovered * all muxers acceptance test: fixed issue with mock lifetime * CI fixes * yamux refactorings helped to avoid memory issues caused by reentrant callbacks * build fix for mac * another yamux fix to avoid memory issues caused by reentrant callbacks * gossip: hotfix related to unbanning peers * minor fixes reflecting review feedback * temp loggers workaround * Feature/multiselect upd (#121) * multiselect revised, WIP * multiselect: simple outbound stream negotiate * multiselect numerous fixes * multiselect: instances and reuse * multiselect: fixes * multiselect: removed old implementation * multiselect: interop with go impl fixes * multiselect: bugfixes * multiselect: ProtocolMuxer interface abstracts simple outbound stream negotiation * multiselect: cleanups and logging * trigger CI * temporarily disabled tests that required synchronous reaction of multiselect * just removed unused lines * reverted back ci.yml Co-authored-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; Co-authored-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; Co-authored-by: turuslan &lt;turuslan.devbox@gmail.com&gt;
4 years ago
inline auto useConfig(C &&c) {
Gossip pr 3 (#48) * gossip: wire protocol * gossip: peer set and wire protocol utilities revised * gossip: msg cache w/expiration * data structures for gossip: fixes and unittest * changes due to pr 1 feedback * one more fix due to PR requests * one more try against ci * gossip part 2 * gossip: pr1 reflects pr2 * gossip: pr1 reflects pr2 * Fix/gossip pr 1 (#46) * Fix build for macos * Improvements * deprecated logic removed * gossip: cleanups and renamings * gossip: renmings * gossip serialization method signature changed * gossip: serialization signature changed * Gossip pr 1 (#37) * gossip: wire protocol * gossip: peer set and wire protocol utilities revised * gossip: msg cache w/expiration * data structures for gossip: fixes and unittest * changes due to pr 1 feedback * one more fix due to PR requests * one more try against ci * gossip: pr1 reflects pr2 * gossip: pr1 reflects pr2 * Fix/gossip pr 1 (#46) * Fix build for macos * Improvements * deprecated logic removed * gossip: cleanups and renamings * gossip: renmings * gossip serialization method signature changed Co-authored-by: kamilsa &lt;kamilsa16@gmail.com&gt; * refactorings * typo fixed * minor fixes * +gossip-example * +gossip-example * fixes and example * debug things * gossip: subscriptions test and bugfixes * dont forward messages back to their origins * injectors made parametric (to build examples) * gossip: fixes * more fixes in pub-sub * fixes in gossip example * sublogger can set new instance name * message cache fix exp times * chat example * logs and traces added for debug purposes * README.md for gossip examples * small patch for older stdlibs support * more logs and traces * more logs and traces * new inbound protocol streams are allowed for all connections * streams issues fixed * gossip injector fixed * gossip new example * boost_program_options in dependencies * scheduler with config param (strong type for injector) * tests fixed due to recent changes * cleanup in yamux and dialer-listener hotfixes * hotfixes to yamux and dialer * yamux changes * parametrized netork and host injectors * streams regression test * patched mplex connections/streams so that streams get notified about EOF Co-authored-by: kamilsa &lt;kamilsa16@gmail.com&gt;
5 years ago
return boost::di::bind<std::decay<C>>().template to(
std::forward<C>(c))[boost::di::override];
5 years ago
}
Connection layers mechanism; Websocket layer (#201) * feature: layers of connections * feature: upgrade layers of connection * fix: tests * feature: test of layers upgrade * refactor: enable disabled upgrader tests * feature: sha-1 hash * feature: websocket layer * fix: read-buffer extending * feature: decide layers for connection upgrade by provided multiaddress * refactor: combine regular and websocket echo-client/-server to single one * refactor: rename peer::Protocol to peer::ProtocolName * refactor: implement addressToBytes, as replacement addressToHex * refactor: mark addressToHex as deprecated * feature: extend ConversionError * fix: multiaddress manipulations * feature: dummy protocols for tests * fix: tests of converters * fix: collision in DI * refactor: update outcome macros for tests * fix: connection upgrader in part of layers * fix: ws read-writer in case big data fragmented by frames * experiment: add delay of sending jumbo message, to give a chance for Id-protocol to end his work * experiment: log difference sent and received data for analyse * feature: control frames (ping/pong/close) * fix: sending huge portions of data * fix: echo sessions * feature: optional hex dump in dumpBin * fix: echo client * update: hunter package manager * fix: hardcoded request and response in http-to-ws upgraded * fix: add ws version header * fix: reduce length of ws-key header * fix: make ws-header check case-insensitive * fix: use locale independent predicate for ci-compare * fix: use boost endian conversion instead endian macros Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt;
2 years ago
/**
* @brief Bind layer adaptors by type. Can be used once. Technically many
* types can be specified, even the same type, but in the end only 1 instance
* for each type is created.
* @tparam LayerImpl one or many types of layer adaptors to be used
* @return injector binding
*
* @code
* struct SomeNewAdaptor : public LayerAdaptor {...};
*
* auto injector = makeNetworkInjector(
* useLayerAdaptors<WsAdaptor>()
* );
* @endcode
*/
template <typename... AdaptorImpl>
inline auto useLayerAdaptors() {
return boost::di::bind<layer::LayerAdaptor *[]>() // NOLINT
.template to<AdaptorImpl...>()[boost::di::override];
}
5 years ago
/**
* @brief Bind security adaptors by type. Can be used once. Technically many
* types can be specified, even the same type, but in the end only 1 instance
* for each type is created.
* @tparam SecImpl one or many types of security adaptors to be used
* @return injector binding
*
* @code
* struct SomeNewAdaptor : public SecurityAdaptor {...};
*
* auto injector = makeNetworkInjector(
* useSecurityAdaptors<Plaintext, SomeNewAdaptor, SecioAdaptor>()
* );
* @endcode
*/
template <typename... SecImpl>
Feature/reentrancy (#111) * gossip confirmance fixes #1 * gossip: bugfixes * gossip: more fixes * gossip: build related minor changes * gossip: one more fix * gossip: flush hello message asap * experiment with noise protocol * made injector creation fns inline to prevent multiple definitions * gossip restructured, interop issues fixed * Noise::write now reports the correct amount of bytes Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * refactoring: move prev implementation of Kademlia to other namespace Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: kademlia dependency injection Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: improve random generator Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: getting listened multiaddress in tcp listener Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: reduce logging in secio Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: new implementation of kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: validation Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: DSA Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: CIDv1 encoding refactoring: replace deprecated sha256 function by hasher Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: multiaddress operations Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: make PeerId comparable to using in std::set Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: addr repo Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: Go-implementation compatibility Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: rendezvous chat as example of Kademlia using Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: unit-test for kademlia parts Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: StorageBackend interface fix: ContentValue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * wipe: remove previous implementation of Kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: cmake files Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; cmake Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some warnings Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: resolve TODOes, comments, format Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: using timeout for make new stream feature: smart using of peer routing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: kademlia message parsing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize executors&#39; working Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize start of rendezvous chat Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: headers including Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: remaining request executors; naming Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: add handle and timeout as argument of Host::connect Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some log messages Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * injectors temp fix * gossip: uncommented writing bytes checking * removed redundant std::hash definition * Hack yamux to allow weighty messages processing Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * fix vtable * fixes in DI injectors * yamux test corrected according to curent window update policy * added buffering primitives * defer* functions in Reader/Writer interfaces and Yamux redesign pt.1 * scheduler fix regarding move assignment + cancel * write queue interface change * read buffer fix regarding subspan * some diagnostic logging * tcp connection fixes related to closing behavior * yamux bugfixes * yamux tests regression WIP * build fix * . * . * bugfixes * fixes * . * . * suppressed most verbose logging in yamux and multiselect * yamux stream adjustWindowSize adjusted * fixes regarding std::move of r/w callbacks (against possible ptrs invalidation) * test cases with jumbo messages transfer added for yamux on noise/tls/plaintext * bugfixes related to yamux window sizes, overflow, and acknowledgements * echo protocol and examples support very large msgs * changes in tests * all muxers acceptance test recovered * all muxers acceptance test: fixed issue with mock lifetime * CI fixes * yamux refactorings helped to avoid memory issues caused by reentrant callbacks * build fix for mac * another yamux fix to avoid memory issues caused by reentrant callbacks * gossip: hotfix related to unbanning peers * minor fixes reflecting review feedback * temp loggers workaround * Feature/multiselect upd (#121) * multiselect revised, WIP * multiselect: simple outbound stream negotiate * multiselect numerous fixes * multiselect: instances and reuse * multiselect: fixes * multiselect: removed old implementation * multiselect: interop with go impl fixes * multiselect: bugfixes * multiselect: ProtocolMuxer interface abstracts simple outbound stream negotiation * multiselect: cleanups and logging * trigger CI * temporarily disabled tests that required synchronous reaction of multiselect * just removed unused lines * reverted back ci.yml Co-authored-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; Co-authored-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; Co-authored-by: turuslan &lt;turuslan.devbox@gmail.com&gt;
4 years ago
inline auto useSecurityAdaptors() {
5 years ago
return boost::di::bind<security::SecurityAdaptor *[]>() // NOLINT
.template to<SecImpl...>()[boost::di::override];
}
/**
* @brief Bind muxer adaptors by types. Can be used once. Technically many
* types can be specified, even the same type, but in the end only 1 instance
* for each type is created.
* @tparam MuxerImpl one or many types of muxer adaptors to be used
* @return injector binding
*/
template <typename... MuxerImpl>
Feature/reentrancy (#111) * gossip confirmance fixes #1 * gossip: bugfixes * gossip: more fixes * gossip: build related minor changes * gossip: one more fix * gossip: flush hello message asap * experiment with noise protocol * made injector creation fns inline to prevent multiple definitions * gossip restructured, interop issues fixed * Noise::write now reports the correct amount of bytes Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * refactoring: move prev implementation of Kademlia to other namespace Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: kademlia dependency injection Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: improve random generator Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: getting listened multiaddress in tcp listener Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: reduce logging in secio Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: new implementation of kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: validation Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: DSA Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: CIDv1 encoding refactoring: replace deprecated sha256 function by hasher Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: multiaddress operations Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: make PeerId comparable to using in std::set Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: addr repo Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: Go-implementation compatibility Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: rendezvous chat as example of Kademlia using Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: unit-test for kademlia parts Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: StorageBackend interface fix: ContentValue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * wipe: remove previous implementation of Kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: cmake files Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; cmake Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some warnings Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: resolve TODOes, comments, format Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: using timeout for make new stream feature: smart using of peer routing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: kademlia message parsing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize executors&#39; working Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize start of rendezvous chat Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: headers including Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: remaining request executors; naming Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: add handle and timeout as argument of Host::connect Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some log messages Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * injectors temp fix * gossip: uncommented writing bytes checking * removed redundant std::hash definition * Hack yamux to allow weighty messages processing Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * fix vtable * fixes in DI injectors * yamux test corrected according to curent window update policy * added buffering primitives * defer* functions in Reader/Writer interfaces and Yamux redesign pt.1 * scheduler fix regarding move assignment + cancel * write queue interface change * read buffer fix regarding subspan * some diagnostic logging * tcp connection fixes related to closing behavior * yamux bugfixes * yamux tests regression WIP * build fix * . * . * bugfixes * fixes * . * . * suppressed most verbose logging in yamux and multiselect * yamux stream adjustWindowSize adjusted * fixes regarding std::move of r/w callbacks (against possible ptrs invalidation) * test cases with jumbo messages transfer added for yamux on noise/tls/plaintext * bugfixes related to yamux window sizes, overflow, and acknowledgements * echo protocol and examples support very large msgs * changes in tests * all muxers acceptance test recovered * all muxers acceptance test: fixed issue with mock lifetime * CI fixes * yamux refactorings helped to avoid memory issues caused by reentrant callbacks * build fix for mac * another yamux fix to avoid memory issues caused by reentrant callbacks * gossip: hotfix related to unbanning peers * minor fixes reflecting review feedback * temp loggers workaround * Feature/multiselect upd (#121) * multiselect revised, WIP * multiselect: simple outbound stream negotiate * multiselect numerous fixes * multiselect: instances and reuse * multiselect: fixes * multiselect: removed old implementation * multiselect: interop with go impl fixes * multiselect: bugfixes * multiselect: ProtocolMuxer interface abstracts simple outbound stream negotiation * multiselect: cleanups and logging * trigger CI * temporarily disabled tests that required synchronous reaction of multiselect * just removed unused lines * reverted back ci.yml Co-authored-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; Co-authored-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; Co-authored-by: turuslan &lt;turuslan.devbox@gmail.com&gt;
4 years ago
inline auto useMuxerAdaptors() {
5 years ago
return boost::di::bind<muxer::MuxerAdaptor *[]>() // NOLINT
.template to<MuxerImpl...>()[boost::di::override];
}
/**
* @brief Instruct injector to use these transports. Can be used once.
* Technically many types can be specified, even the same type, but in the end
* only 1 instance for each type is created.
* @tparam TransportImpl one or many types of transport adaptors to be used
* @return injector binding
*/
template <typename... TransportImpl>
Feature/reentrancy (#111) * gossip confirmance fixes #1 * gossip: bugfixes * gossip: more fixes * gossip: build related minor changes * gossip: one more fix * gossip: flush hello message asap * experiment with noise protocol * made injector creation fns inline to prevent multiple definitions * gossip restructured, interop issues fixed * Noise::write now reports the correct amount of bytes Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * refactoring: move prev implementation of Kademlia to other namespace Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: kademlia dependency injection Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: improve random generator Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: getting listened multiaddress in tcp listener Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: reduce logging in secio Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: new implementation of kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: validation Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: DSA Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: CIDv1 encoding refactoring: replace deprecated sha256 function by hasher Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: multiaddress operations Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: make PeerId comparable to using in std::set Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: addr repo Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: Go-implementation compatibility Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: rendezvous chat as example of Kademlia using Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: unit-test for kademlia parts Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: StorageBackend interface fix: ContentValue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * wipe: remove previous implementation of Kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: cmake files Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; cmake Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some warnings Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: resolve TODOes, comments, format Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: using timeout for make new stream feature: smart using of peer routing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: kademlia message parsing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize executors&#39; working Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize start of rendezvous chat Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: headers including Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: remaining request executors; naming Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: add handle and timeout as argument of Host::connect Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some log messages Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * injectors temp fix * gossip: uncommented writing bytes checking * removed redundant std::hash definition * Hack yamux to allow weighty messages processing Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * fix vtable * fixes in DI injectors * yamux test corrected according to curent window update policy * added buffering primitives * defer* functions in Reader/Writer interfaces and Yamux redesign pt.1 * scheduler fix regarding move assignment + cancel * write queue interface change * read buffer fix regarding subspan * some diagnostic logging * tcp connection fixes related to closing behavior * yamux bugfixes * yamux tests regression WIP * build fix * . * . * bugfixes * fixes * . * . * suppressed most verbose logging in yamux and multiselect * yamux stream adjustWindowSize adjusted * fixes regarding std::move of r/w callbacks (against possible ptrs invalidation) * test cases with jumbo messages transfer added for yamux on noise/tls/plaintext * bugfixes related to yamux window sizes, overflow, and acknowledgements * echo protocol and examples support very large msgs * changes in tests * all muxers acceptance test recovered * all muxers acceptance test: fixed issue with mock lifetime * CI fixes * yamux refactorings helped to avoid memory issues caused by reentrant callbacks * build fix for mac * another yamux fix to avoid memory issues caused by reentrant callbacks * gossip: hotfix related to unbanning peers * minor fixes reflecting review feedback * temp loggers workaround * Feature/multiselect upd (#121) * multiselect revised, WIP * multiselect: simple outbound stream negotiate * multiselect numerous fixes * multiselect: instances and reuse * multiselect: fixes * multiselect: removed old implementation * multiselect: interop with go impl fixes * multiselect: bugfixes * multiselect: ProtocolMuxer interface abstracts simple outbound stream negotiation * multiselect: cleanups and logging * trigger CI * temporarily disabled tests that required synchronous reaction of multiselect * just removed unused lines * reverted back ci.yml Co-authored-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; Co-authored-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; Co-authored-by: turuslan &lt;turuslan.devbox@gmail.com&gt;
4 years ago
inline auto useTransportAdaptors() {
5 years ago
return boost::di::bind<transport::TransportAdaptor *[]>() // NOLINT
.template to<TransportImpl...>()[boost::di::override];
}
/**
* @brief Main function that creates Network Injector.
* @tparam Ts types of injector bindings
* @param args injector bindings that override default bindings.
* @return complete network injector
*/
Gossip pr 3 (#48) * gossip: wire protocol * gossip: peer set and wire protocol utilities revised * gossip: msg cache w/expiration * data structures for gossip: fixes and unittest * changes due to pr 1 feedback * one more fix due to PR requests * one more try against ci * gossip part 2 * gossip: pr1 reflects pr2 * gossip: pr1 reflects pr2 * Fix/gossip pr 1 (#46) * Fix build for macos * Improvements * deprecated logic removed * gossip: cleanups and renamings * gossip: renmings * gossip serialization method signature changed * gossip: serialization signature changed * Gossip pr 1 (#37) * gossip: wire protocol * gossip: peer set and wire protocol utilities revised * gossip: msg cache w/expiration * data structures for gossip: fixes and unittest * changes due to pr 1 feedback * one more fix due to PR requests * one more try against ci * gossip: pr1 reflects pr2 * gossip: pr1 reflects pr2 * Fix/gossip pr 1 (#46) * Fix build for macos * Improvements * deprecated logic removed * gossip: cleanups and renamings * gossip: renmings * gossip serialization method signature changed Co-authored-by: kamilsa &lt;kamilsa16@gmail.com&gt; * refactorings * typo fixed * minor fixes * +gossip-example * +gossip-example * fixes and example * debug things * gossip: subscriptions test and bugfixes * dont forward messages back to their origins * injectors made parametric (to build examples) * gossip: fixes * more fixes in pub-sub * fixes in gossip example * sublogger can set new instance name * message cache fix exp times * chat example * logs and traces added for debug purposes * README.md for gossip examples * small patch for older stdlibs support * more logs and traces * more logs and traces * new inbound protocol streams are allowed for all connections * streams issues fixed * gossip injector fixed * gossip new example * boost_program_options in dependencies * scheduler with config param (strong type for injector) * tests fixed due to recent changes * cleanup in yamux and dialer-listener hotfixes * hotfixes to yamux and dialer * yamux changes * parametrized netork and host injectors * streams regression test * patched mplex connections/streams so that streams get notified about EOF Co-authored-by: kamilsa &lt;kamilsa16@gmail.com&gt;
5 years ago
template <typename InjectorConfig = BOOST_DI_CFG, typename... Ts>
Connection layers mechanism; Websocket layer (#201) * feature: layers of connections * feature: upgrade layers of connection * fix: tests * feature: test of layers upgrade * refactor: enable disabled upgrader tests * feature: sha-1 hash * feature: websocket layer * fix: read-buffer extending * feature: decide layers for connection upgrade by provided multiaddress * refactor: combine regular and websocket echo-client/-server to single one * refactor: rename peer::Protocol to peer::ProtocolName * refactor: implement addressToBytes, as replacement addressToHex * refactor: mark addressToHex as deprecated * feature: extend ConversionError * fix: multiaddress manipulations * feature: dummy protocols for tests * fix: tests of converters * fix: collision in DI * refactor: update outcome macros for tests * fix: connection upgrader in part of layers * fix: ws read-writer in case big data fragmented by frames * experiment: add delay of sending jumbo message, to give a chance for Id-protocol to end his work * experiment: log difference sent and received data for analyse * feature: control frames (ping/pong/close) * fix: sending huge portions of data * fix: echo sessions * feature: optional hex dump in dumpBin * fix: echo client * update: hunter package manager * fix: hardcoded request and response in http-to-ws upgraded * fix: add ws version header * fix: reduce length of ws-key header * fix: make ws-header check case-insensitive * fix: use locale independent predicate for ci-compare * fix: use boost endian conversion instead endian macros Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt;
2 years ago
inline auto makeNetworkInjector(Ts &&...args) {
namespace di = boost::di;
5 years ago
auto csprng = std::make_shared<crypto::random::BoostRandomGenerator>();
auto ed25519_provider =
std::make_shared<crypto::ed25519::Ed25519ProviderImpl>();
auto rsa_provider = std::make_shared<crypto::rsa::RsaProviderImpl>();
auto ecdsa_provider = std::make_shared<crypto::ecdsa::EcdsaProviderImpl>();
auto secp256k1_provider =
std::make_shared<crypto::secp256k1::Secp256k1ProviderImpl>(csprng);
auto hmac_provider = std::make_shared<crypto::hmac::HmacProviderImpl>();
std::shared_ptr<crypto::CryptoProvider> crypto_provider =
std::make_shared<crypto::CryptoProviderImpl>(csprng,
ed25519_provider,
rsa_provider,
ecdsa_provider,
secp256k1_provider,
hmac_provider);
auto validator =
std::make_shared<crypto::validator::KeyValidatorImpl>(crypto_provider);
5 years ago
// assume no error here. otherwise... just blow up executable
auto keypair =
crypto_provider->generateKeys(crypto::Key::Type::Ed25519).value();
5 years ago
// clang-format off
Gossip pr 3 (#48) * gossip: wire protocol * gossip: peer set and wire protocol utilities revised * gossip: msg cache w/expiration * data structures for gossip: fixes and unittest * changes due to pr 1 feedback * one more fix due to PR requests * one more try against ci * gossip part 2 * gossip: pr1 reflects pr2 * gossip: pr1 reflects pr2 * Fix/gossip pr 1 (#46) * Fix build for macos * Improvements * deprecated logic removed * gossip: cleanups and renamings * gossip: renmings * gossip serialization method signature changed * gossip: serialization signature changed * Gossip pr 1 (#37) * gossip: wire protocol * gossip: peer set and wire protocol utilities revised * gossip: msg cache w/expiration * data structures for gossip: fixes and unittest * changes due to pr 1 feedback * one more fix due to PR requests * one more try against ci * gossip: pr1 reflects pr2 * gossip: pr1 reflects pr2 * Fix/gossip pr 1 (#46) * Fix build for macos * Improvements * deprecated logic removed * gossip: cleanups and renamings * gossip: renmings * gossip serialization method signature changed Co-authored-by: kamilsa &lt;kamilsa16@gmail.com&gt; * refactorings * typo fixed * minor fixes * +gossip-example * +gossip-example * fixes and example * debug things * gossip: subscriptions test and bugfixes * dont forward messages back to their origins * injectors made parametric (to build examples) * gossip: fixes * more fixes in pub-sub * fixes in gossip example * sublogger can set new instance name * message cache fix exp times * chat example * logs and traces added for debug purposes * README.md for gossip examples * small patch for older stdlibs support * more logs and traces * more logs and traces * new inbound protocol streams are allowed for all connections * streams issues fixed * gossip injector fixed * gossip new example * boost_program_options in dependencies * scheduler with config param (strong type for injector) * tests fixed due to recent changes * cleanup in yamux and dialer-listener hotfixes * hotfixes to yamux and dialer * yamux changes * parametrized netork and host injectors * streams regression test * patched mplex connections/streams so that streams get notified about EOF Co-authored-by: kamilsa &lt;kamilsa16@gmail.com&gt;
5 years ago
return di::make_injector<InjectorConfig>(
Connection layers mechanism; Websocket layer (#201) * feature: layers of connections * feature: upgrade layers of connection * fix: tests * feature: test of layers upgrade * refactor: enable disabled upgrader tests * feature: sha-1 hash * feature: websocket layer * fix: read-buffer extending * feature: decide layers for connection upgrade by provided multiaddress * refactor: combine regular and websocket echo-client/-server to single one * refactor: rename peer::Protocol to peer::ProtocolName * refactor: implement addressToBytes, as replacement addressToHex * refactor: mark addressToHex as deprecated * feature: extend ConversionError * fix: multiaddress manipulations * feature: dummy protocols for tests * fix: tests of converters * fix: collision in DI * refactor: update outcome macros for tests * fix: connection upgrader in part of layers * fix: ws read-writer in case big data fragmented by frames * experiment: add delay of sending jumbo message, to give a chance for Id-protocol to end his work * experiment: log difference sent and received data for analyse * feature: control frames (ping/pong/close) * fix: sending huge portions of data * fix: echo sessions * feature: optional hex dump in dumpBin * fix: echo client * update: hunter package manager * fix: hardcoded request and response in http-to-ws upgraded * fix: add ws version header * fix: reduce length of ws-key header * fix: make ws-header check case-insensitive * fix: use locale independent predicate for ci-compare * fix: use boost endian conversion instead endian macros Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt;
2 years ago
di::bind<crypto::random::RandomGenerator>.template to<crypto::random::BoostRandomGenerator>(),
5 years ago
di::bind<crypto::KeyPair>().template to(std::move(keypair)),
di::bind<crypto::random::CSPRNG>().template to(std::move(csprng)),
di::bind<crypto::ed25519::Ed25519Provider>().template to(std::move(ed25519_provider)),
di::bind<crypto::rsa::RsaProvider>().template to(std::move(rsa_provider)),
di::bind<crypto::ecdsa::EcdsaProvider>().template to(std::move(ecdsa_provider)),
di::bind<crypto::secp256k1::Secp256k1Provider>().template to(std::move(secp256k1_provider)),
di::bind<crypto::aes::AesCtr>().template to<crypto::aes::AesCtrImpl>(),
di::bind<crypto::hmac::HmacProvider>().template to<crypto::hmac::HmacProviderImpl>(),
di::bind<crypto::CryptoProvider>().template to<crypto::CryptoProviderImpl>(),
5 years ago
di::bind<crypto::marshaller::KeyMarshaller>().template to<crypto::marshaller::KeyMarshallerImpl>(),
di::bind<peer::IdentityManager>().template to<peer::IdentityManagerImpl>(),
di::bind<crypto::validator::KeyValidator>().template to<crypto::validator::KeyValidatorImpl>(),
di::bind<security::plaintext::ExchangeMessageMarshaller>().template to<security::plaintext::ExchangeMessageMarshallerImpl>(),
di::bind<security::secio::ProposeMessageMarshaller>().template to<security::secio::ProposeMessageMarshallerImpl>(),
di::bind<security::secio::ExchangeMessageMarshaller>().template to<security::secio::ExchangeMessageMarshallerImpl>(),
di::bind<layer::WsConnectionConfig>.template to(layer::WsConnectionConfig{}),
di::bind<layer::WssCertificate>.template to(layer::WssCertificate{}),
5 years ago
di::bind<basic::Scheduler::Config>.template to(basic::Scheduler::Config{}),
di::bind<basic::SchedulerBackend>().template to<basic::AsioSchedulerBackend>(),
di::bind<basic::Scheduler>().template to<basic::SchedulerImpl>(),
5 years ago
// internal
di::bind<network::DnsaddrResolver>().template to <network::DnsaddrResolverImpl>(),
5 years ago
di::bind<network::Router>().template to<network::RouterImpl>(),
di::bind<network::ConnectionManager>().template to<network::ConnectionManagerImpl>(),
di::bind<network::ListenerManager>().template to<network::ListenerManagerImpl>(),
di::bind<network::Dialer>().template to<network::DialerImpl>(),
di::bind<network::Network>().template to<network::NetworkImpl>(),
di::bind<network::TransportManager>().template to<network::TransportManagerImpl>(),
di::bind<transport::Upgrader>().template to<transport::UpgraderImpl>(),
Feature/reentrancy (#111) * gossip confirmance fixes #1 * gossip: bugfixes * gossip: more fixes * gossip: build related minor changes * gossip: one more fix * gossip: flush hello message asap * experiment with noise protocol * made injector creation fns inline to prevent multiple definitions * gossip restructured, interop issues fixed * Noise::write now reports the correct amount of bytes Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * refactoring: move prev implementation of Kademlia to other namespace Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: kademlia dependency injection Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: improve random generator Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: getting listened multiaddress in tcp listener Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: reduce logging in secio Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: new implementation of kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue processing with kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: continue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * draft: kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: validation Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: DSA Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: CIDv1 encoding refactoring: replace deprecated sha256 function by hasher Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: multiaddress operations Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: make PeerId comparable to using in std::set Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: addr repo Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: Go-implementation compatibility Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: rendezvous chat as example of Kademlia using Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: unit-test for kademlia parts Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: StorageBackend interface fix: ContentValue Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * wipe: remove previous implementation of Kademlia Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: cmake files Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; cmake Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some warnings Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: resolve TODOes, comments, format Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: clang-tidy issues Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: using timeout for make new stream feature: smart using of peer routing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: kademlia message parsing Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize executors&#39; working Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: optimize start of rendezvous chat Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: headers including Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * refactoring: remaining request executors; naming Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * feature: add handle and timeout as argument of Host::connect Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * fix: some log messages Signed-off-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; * injectors temp fix * gossip: uncommented writing bytes checking * removed redundant std::hash definition * Hack yamux to allow weighty messages processing Signed-off-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; * fix vtable * fixes in DI injectors * yamux test corrected according to curent window update policy * added buffering primitives * defer* functions in Reader/Writer interfaces and Yamux redesign pt.1 * scheduler fix regarding move assignment + cancel * write queue interface change * read buffer fix regarding subspan * some diagnostic logging * tcp connection fixes related to closing behavior * yamux bugfixes * yamux tests regression WIP * build fix * . * . * bugfixes * fixes * . * . * suppressed most verbose logging in yamux and multiselect * yamux stream adjustWindowSize adjusted * fixes regarding std::move of r/w callbacks (against possible ptrs invalidation) * test cases with jumbo messages transfer added for yamux on noise/tls/plaintext * bugfixes related to yamux window sizes, overflow, and acknowledgements * echo protocol and examples support very large msgs * changes in tests * all muxers acceptance test recovered * all muxers acceptance test: fixed issue with mock lifetime * CI fixes * yamux refactorings helped to avoid memory issues caused by reentrant callbacks * build fix for mac * another yamux fix to avoid memory issues caused by reentrant callbacks * gossip: hotfix related to unbanning peers * minor fixes reflecting review feedback * temp loggers workaround * Feature/multiselect upd (#121) * multiselect revised, WIP * multiselect: simple outbound stream negotiate * multiselect numerous fixes * multiselect: instances and reuse * multiselect: fixes * multiselect: removed old implementation * multiselect: interop with go impl fixes * multiselect: bugfixes * multiselect: ProtocolMuxer interface abstracts simple outbound stream negotiation * multiselect: cleanups and logging * trigger CI * temporarily disabled tests that required synchronous reaction of multiselect * just removed unused lines * reverted back ci.yml Co-authored-by: Igor Egorov &lt;igor@soramitsu.co.jp&gt; Co-authored-by: Dmitriy Khaustov aka xDimon &lt;khaustov.dm@gmail.com&gt; Co-authored-by: turuslan &lt;turuslan.devbox@gmail.com&gt;
4 years ago
di::bind<protocol_muxer::ProtocolMuxer>().template to<protocol_muxer::multiselect::Multiselect>(),
5 years ago
// default adaptors
di::bind<muxer::MuxedConnectionConfig>.template to(muxer::MuxedConnectionConfig{}),
di::bind<layer::LayerAdaptor *[]>().template to<layer::WsAdaptor, layer::WssAdaptor>(), // NOLINT
di::bind<security::SecurityAdaptor *[]>().template to<security::Plaintext, security::Secio, security::Noise, security::TlsAdaptor>(), // NOLINT
di::bind<muxer::MuxerAdaptor *[]>().template to<muxer::Yamux, muxer::Mplex>(), // NOLINT
di::bind<transport::TransportAdaptor *[]>().template to<transport::TcpTransport, transport::QuicTransport>(), // NOLINT
5 years ago
// user-defined overrides...
std::forward<decltype(args)>(args)...
);
// clang-format on
}
} // namespace libp2p::injector