From c890b0748a47a88c832984f95070ddf3d232cc08 Mon Sep 17 00:00:00 2001 From: Aleksi Lindeman Date: Tue, 9 Apr 2019 20:58:18 +0200 Subject: Add debug output --- src/BootstrapConnection.cpp | 5 +++-- src/DirectConnection.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/BootstrapConnection.cpp b/src/BootstrapConnection.cpp index fc2e4ab..58a07d2 100644 --- a/src/BootstrapConnection.cpp +++ b/src/BootstrapConnection.cpp @@ -13,6 +13,7 @@ namespace sibs alive(true), putThreadCount(0) { + Log::debug("Created bootstrap connection, p2p? %s", options.useP2p ? "yes" : "no"); connections.onRemoveDisconnectedPeer([this](std::shared_ptr peer) { std::lock_guard lock(subscribeDataMutex); @@ -97,7 +98,7 @@ namespace sibs return; } - Log::debug("BootstrapConnection::receiveDataFromServer: Received subscriber(s) from bootstrap node"); + //Log::debug("BootstrapConnection::receiveDataFromServer: Received subscriber(s) from bootstrap node"); sibs::SafeDeserializer deserializer((const u8*)data, size); PubsubKey pubsubKey; deserializer.extract(pubsubKey.data.data(), PUBSUB_KEY_LENGTH); @@ -121,7 +122,7 @@ namespace sibs in_addr_t ipv4Address = deserializer.extract(); u16 port = deserializer.extract(); Ipv4 newPeerAddress(addressFamily, ipv4Address, port); - Log::debug("BootstrapConnection::receiveDataFromServer: received subscriber (ip: %s, port: %d) from bootstrap node", newPeerAddress.getAddress().c_str(), newPeerAddress.getPort()); + //Log::debug("BootstrapConnection::receiveDataFromServer: received subscriber (ip: %s, port: %d) from bootstrap node", newPeerAddress.getAddress().c_str(), newPeerAddress.getPort()); connections.connect(newPeerAddress, [this, pubsubKey](std::shared_ptr peer, PubSubResult result, const std::string &resultStr) { std::lock_guard lock(subscribeDataMutex); diff --git a/src/DirectConnection.cpp b/src/DirectConnection.cpp index 6869d05..453f6b6 100644 --- a/src/DirectConnection.cpp +++ b/src/DirectConnection.cpp @@ -194,7 +194,7 @@ namespace sibs std::unique_ptr DirectConnections::createSocket(const Ipv4 &addressToBind, bool rendezvous, bool reuseAddr, bool bind) { - Log::debug("UDT: Creating socket for ipv4 address %s, port: %d", addressToBind.getAddress().c_str(), addressToBind.getPort()); + //Log::debug("UDT: Creating socket for ipv4 address %s, port: %d", addressToBind.getAddress().c_str(), addressToBind.getPort()); UDTSOCKET udtSocket = UDT::socket(AF_INET, SOCK_DGRAM, 0); if(udtSocket == UDT::INVALID_SOCK) { @@ -300,7 +300,9 @@ namespace sibs int socketId = socket->udtSocket; - Log::debug("DirectConnections: Connecting to %s peer (ip: %s, port: %d, rendezvous: %s)", server ? "server" : "client", address.getAddress().c_str(), address.getPort(), rendezvous ? "yes" : "no"); + Log::debug("DirectConnections: Connecting to %s peer (ip: %s, port: %d, rendezvous: %s, p2p: %s)", server ? "server" : "client", + address.getAddress().c_str(), address.getPort(), rendezvous ? "yes" : "no", options.useP2p ? "yes" : "no"); + if((!server && !options.useP2p) || UDT::connect(socketId, (sockaddr*)&address.address, sizeof(address.address)) == UDT::ERROR) { if(!server) -- cgit v1.2.3