net: Cache -capturemessages setting
This commit is contained in:
1 parent
cea443e246
commit
5f5c1ea019
4 files changed
+14
-3
No files matched your search
@@ -2043,6 +2043,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
connOptions.m_peer_connect_timeout = peer_connect_timeout;
|
connOptions.m_peer_connect_timeout = peer_connect_timeout;
|
||||||
connOptions.whitelist_forcerelay = args.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY);
|
connOptions.whitelist_forcerelay = args.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY);
|
||||||
connOptions.whitelist_relay = args.GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY);
|
connOptions.whitelist_relay = args.GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY);
|
||||||
|
connOptions.m_capture_messages = args.GetBoolArg("-capturemessages", false);
|
||||||
|
|
||||||
// Port to bind to if `-bind=addr` is provided without a `:port` suffix.
|
// Port to bind to if `-bind=addr` is provided without a `:port` suffix.
|
||||||
const uint16_t default_bind_port =
|
const uint16_t default_bind_port =
|
||||||
|
|||||||
+1
-1
@@ -3901,7 +3901,7 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
|
|||||||
AssertLockNotHeld(m_total_bytes_sent_mutex);
|
AssertLockNotHeld(m_total_bytes_sent_mutex);
|
||||||
size_t nMessageSize = msg.data.size();
|
size_t nMessageSize = msg.data.size();
|
||||||
LogDebug(BCLog::NET, "sending %s (%d bytes) peer=%d\n", msg.m_type, nMessageSize, pnode->GetId());
|
LogDebug(BCLog::NET, "sending %s (%d bytes) peer=%d\n", msg.m_type, nMessageSize, pnode->GetId());
|
||||||
if (gArgs.GetBoolArg("-capturemessages", false)) {
|
if (m_capture_messages) {
|
||||||
CaptureMessage(pnode->addr, msg.m_type, msg.data, /*is_incoming=*/false);
|
CaptureMessage(pnode->addr, msg.m_type, msg.data, /*is_incoming=*/false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1086,6 +1086,7 @@ public:
|
|||||||
bool m_i2p_accept_incoming;
|
bool m_i2p_accept_incoming;
|
||||||
bool whitelist_forcerelay = DEFAULT_WHITELISTFORCERELAY;
|
bool whitelist_forcerelay = DEFAULT_WHITELISTFORCERELAY;
|
||||||
bool whitelist_relay = DEFAULT_WHITELISTRELAY;
|
bool whitelist_relay = DEFAULT_WHITELISTRELAY;
|
||||||
|
bool m_capture_messages = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Init(const Options& connOptions) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex, !m_total_bytes_sent_mutex)
|
void Init(const Options& connOptions) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex, !m_total_bytes_sent_mutex)
|
||||||
@@ -1123,8 +1124,12 @@ public:
|
|||||||
m_onion_binds = connOptions.onion_binds;
|
m_onion_binds = connOptions.onion_binds;
|
||||||
whitelist_forcerelay = connOptions.whitelist_forcerelay;
|
whitelist_forcerelay = connOptions.whitelist_forcerelay;
|
||||||
whitelist_relay = connOptions.whitelist_relay;
|
whitelist_relay = connOptions.whitelist_relay;
|
||||||
|
m_capture_messages = connOptions.m_capture_messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test only
|
||||||
|
void SetCaptureMessages(bool cap) { m_capture_messages = cap; }
|
||||||
|
|
||||||
CConnman(uint64_t seed0,
|
CConnman(uint64_t seed0,
|
||||||
uint64_t seed1,
|
uint64_t seed1,
|
||||||
AddrMan& addrman,
|
AddrMan& addrman,
|
||||||
@@ -1666,6 +1671,11 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool whitelist_relay;
|
bool whitelist_relay;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* flag for whether messages are captured
|
||||||
|
*/
|
||||||
|
bool m_capture_messages{false};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutex protecting m_i2p_sam_sessions.
|
* Mutex protecting m_i2p_sam_sessions.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -814,7 +814,7 @@ BOOST_AUTO_TEST_CASE(initial_advertise_from_version_message)
|
|||||||
// Pretend that we bound to this port.
|
// Pretend that we bound to this port.
|
||||||
const uint16_t bind_port = 20001;
|
const uint16_t bind_port = 20001;
|
||||||
m_node.args->ForceSetArg("-bind", strprintf("3.4.5.6:%u", bind_port));
|
m_node.args->ForceSetArg("-bind", strprintf("3.4.5.6:%u", bind_port));
|
||||||
m_node.args->ForceSetArg("-capturemessages", "1");
|
m_node.connman->SetCaptureMessages(true);
|
||||||
|
|
||||||
// Our address:port as seen from the peer - 2.3.4.5:20002 (different from the above).
|
// Our address:port as seen from the peer - 2.3.4.5:20002 (different from the above).
|
||||||
in_addr peer_us_addr;
|
in_addr peer_us_addr;
|
||||||
@@ -892,7 +892,7 @@ BOOST_AUTO_TEST_CASE(initial_advertise_from_version_message)
|
|||||||
|
|
||||||
CaptureMessage = CaptureMessageOrig;
|
CaptureMessage = CaptureMessageOrig;
|
||||||
chainman.ResetIbd();
|
chainman.ResetIbd();
|
||||||
m_node.args->ForceSetArg("-capturemessages", "0");
|
m_node.connman->SetCaptureMessages(false);
|
||||||
m_node.args->ForceSetArg("-bind", "");
|
m_node.args->ForceSetArg("-bind", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user