|
|
@ -11,10 +11,29 @@ |
|
|
|
#include <libp2p/common/literals.hpp> |
|
|
|
#include <libp2p/host/basic_host.hpp> |
|
|
|
#include <libp2p/injector/host_injector.hpp> |
|
|
|
#include <libp2p/log/configurator.hpp> |
|
|
|
#include <libp2p/log/logger.hpp> |
|
|
|
#include <libp2p/protocol/echo.hpp> |
|
|
|
#include <libp2p/security/noise.hpp> |
|
|
|
#include <libp2p/security/plaintext.hpp> |
|
|
|
|
|
|
|
namespace { |
|
|
|
const std::string logger_config(R"( |
|
|
|
# ---------------- |
|
|
|
sinks: |
|
|
|
- name: console |
|
|
|
type: console |
|
|
|
color: true |
|
|
|
groups: |
|
|
|
- name: main |
|
|
|
sink: console |
|
|
|
level: info |
|
|
|
children: |
|
|
|
- name: libp2p |
|
|
|
# ---------------- |
|
|
|
)"); |
|
|
|
} // namespace
|
|
|
|
|
|
|
|
bool isInsecure(int argc, char **argv) { |
|
|
|
if (2 == argc) { |
|
|
|
const std::string insecure{"-insecure"}; |
|
|
@ -56,6 +75,24 @@ int main(int argc, char **argv) { |
|
|
|
using libp2p::crypto::PublicKey; |
|
|
|
using libp2p::common::operator""_unhex; |
|
|
|
|
|
|
|
// prepare log system
|
|
|
|
auto logging_system = std::make_shared<soralog::LoggingSystem>( |
|
|
|
std::make_shared<libp2p::log::Configurator>(logger_config)); |
|
|
|
auto r = logging_system->configure(); |
|
|
|
if (not r.message.empty()) { |
|
|
|
(r.has_error ? std::cerr : std::cout) << r.message << std::endl; |
|
|
|
} |
|
|
|
if (r.has_error) { |
|
|
|
exit(EXIT_FAILURE); |
|
|
|
} |
|
|
|
|
|
|
|
libp2p::log::setLoggingSystem(logging_system); |
|
|
|
if (std::getenv("TRACE_DEBUG") != nullptr) { |
|
|
|
libp2p::log::setLevelOfGroup("*", soralog::Level::TRACE); |
|
|
|
} else { |
|
|
|
libp2p::log::setLevelOfGroup("*", soralog::Level::ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
// resulting PeerId should be
|
|
|
|
// 12D3KooWEgUjBV5FJAuBSoNMRYFRHjV7PjZwRQ7b43EKX9g7D6xV
|
|
|
|
KeyPair keypair{PublicKey{{Key::Type::Ed25519, |
|
|
|