aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_protocol
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-11-22 13:43:44 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-01-26 00:33:41 +0000
commit56a4469ef302bba92844c408d3b97425abe5bfc2 (patch)
tree64a90b40a3c9db62ebbda7ac678b80730bd8aa76 /src/cryptonote_protocol
parentMerge pull request #6093 (diff)
downloadmonero-56a4469ef302bba92844c408d3b97425abe5bfc2.tar.xz
network: log traffic and add a simple traffic analysis script
Diffstat (limited to 'src/cryptonote_protocol')
-rw-r--r--src/cryptonote_protocol/levin_notify.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cryptonote_protocol/levin_notify.cpp b/src/cryptonote_protocol/levin_notify.cpp
index a0a4bbbb1..e45c34e02 100644
--- a/src/cryptonote_protocol/levin_notify.cpp
+++ b/src/cryptonote_protocol/levin_notify.cpp
@@ -44,6 +44,14 @@
#include "net/dandelionpp.h"
#include "p2p/net_node.h"
+namespace
+{
+ int get_command_from_message(const cryptonote::blobdata &msg)
+ {
+ return msg.size() >= sizeof(epee::levin::bucket_head2) ? SWAP32LE(((epee::levin::bucket_head2*)msg.data())->m_command) : 0;
+ }
+}
+
namespace cryptonote
{
namespace levin
@@ -164,6 +172,10 @@ namespace levin
bool make_payload_send_txs(connections& p2p, std::vector<blobdata>&& txs, const boost::uuids::uuid& destination, const bool pad)
{
const cryptonote::blobdata blob = make_tx_payload(std::move(txs), pad);
+ p2p.for_connection(destination, [&blob](detail::p2p_context& context) {
+ on_levin_traffic(context, true, true, false, blob.size(), get_command_from_message(blob));
+ return true;
+ });
return p2p.notify(NOTIFY_NEW_TRANSACTIONS::ID, epee::strspan<std::uint8_t>(blob), destination);
}
@@ -539,6 +551,10 @@ namespace levin
else
message = zone_->noise.clone();
+ zone_->p2p->for_connection(channel.connection, [&](detail::p2p_context& context) {
+ on_levin_traffic(context, true, true, false, message.size(), "noise");
+ return true;
+ });
if (zone_->p2p->send(std::move(message), channel.connection))
{
if (!channel.queue.empty() && channel.active.empty())