mirror of https://github.com/oxen-io/oxen-mq.git
Fix truncated pubkey
Fix bug from quorumnet transition; quorumnet set the user id to something like "S:abc..." or "C:abc..." to indicate SN or non-SN, but now that gets carried in a separate message property but the +2 on the copying position was still erroneously being used.
This commit is contained in:
parent
b11d2870bd
commit
58e45db996
|
@ -178,8 +178,8 @@ void extract_pubkey(zmq::message_t& msg, std::string& pubkey, bool& service_node
|
|||
if (pubkey_hex.size() != 64)
|
||||
throw std::logic_error("bad user-id");
|
||||
assert(is_hex(pubkey_hex.begin(), pubkey_hex.end()));
|
||||
pubkey.reserve(32);
|
||||
from_hex(pubkey_hex.begin() + 2, pubkey_hex.end(), std::back_inserter(pubkey));
|
||||
pubkey.resize(32, 0);
|
||||
from_hex(pubkey_hex.begin(), pubkey_hex.end(), pubkey.begin());
|
||||
|
||||
service_node = false;
|
||||
try {
|
||||
|
@ -439,6 +439,8 @@ void LokiMQ::worker_thread(unsigned int index) {
|
|||
message.service_node = run.service_node;
|
||||
message.data.clear();
|
||||
|
||||
LMQ_TRACE("Got incoming command from pubkey ", to_hex(message.pubkey), " (SN=", (int) message.service_node, ")");
|
||||
|
||||
if (run.callback->second /*is_request*/) {
|
||||
message.reply_tag = {run.data_parts[0].data<char>(), run.data_parts[0].size()};
|
||||
for (auto it = run.data_parts.begin() + 1; it != run.data_parts.end(); ++it)
|
||||
|
@ -1568,7 +1570,7 @@ void LokiMQ::process_zap_requests(zmq::socket_t &zap_auth) {
|
|||
}
|
||||
LMQ_LOG(info, "Accepted incoming ", (sn ? "service node" : "non-SN client"),
|
||||
" connection with authentication level ", to_string(result.auth),
|
||||
" from ", string_view{&user_id[2], user_id.size()-2}, " at ", ip);
|
||||
" from ", user_id, " at ", ip);
|
||||
|
||||
auto& metadata = response_vals[5];
|
||||
if (result.remote_sn)
|
||||
|
|
|
@ -23,6 +23,11 @@ TEST_CASE("basic commands", "[commands]") {
|
|||
if (hellos++ % 2 == 0)
|
||||
m.send_back("public.hi");
|
||||
});
|
||||
std::string client_pubkey;
|
||||
server.add_command("public", "client.pubkey", [&](Message& m) {
|
||||
client_pubkey = m.pubkey;
|
||||
});
|
||||
|
||||
server.start();
|
||||
|
||||
LokiMQ client{
|
||||
|
@ -54,9 +59,12 @@ TEST_CASE("basic commands", "[commands]") {
|
|||
REQUIRE( pubkey == server.get_pubkey() );
|
||||
|
||||
client.send(pubkey, "public.hello");
|
||||
client.send(pubkey, "public.client.pubkey");
|
||||
|
||||
std::this_thread::sleep_for(50ms);
|
||||
REQUIRE( hellos == 1 );
|
||||
REQUIRE( his == 1 );
|
||||
REQUIRE( client_pubkey == client.get_pubkey() );
|
||||
|
||||
for (int i = 0; i < 50; i++)
|
||||
client.send(pubkey, "public.hello");
|
||||
|
|
Loading…
Reference in New Issue