Skip to content

Commit

Permalink
Merge pull request #343 from msgmaxim/peer-testing-fix
Browse files Browse the repository at this point in the history
Peer testing fix
  • Loading branch information
msgmaxim committed Apr 6, 2020
2 parents bdeadc1 + ef8435b commit b6a24ea
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
9 changes: 9 additions & 0 deletions httpserver/lmq_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ void LokimqServer::handle_onion_request(lokimq::Message& message) {
lokimq_->send(origin_pk, "REPLY", reply_tag, std::move(status), res.message());
};

if (message.data.size() == 1 && message.data[0] == "ping") {
// Before 2.0.3 we reply with a bad request, below, but reply here to avoid putting the
// error message in the log on 2.0.3+ nodes. (the reply code here doesn't actually matter;
// the ping test only requires that we provide *some* response).
LOKI_LOG(debug, "Remote pinged me");
on_response(loki::Response{Status::OK, "pong"});
return;
}

if (message.data.size() != 2) {
LOKI_LOG(error, "Expected 2 message parts, got {}", message.data.size());
on_response(loki::Response{Status::BAD_REQUEST, "Incorrect number of messages"});
Expand Down
21 changes: 10 additions & 11 deletions httpserver/service_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,18 +953,17 @@ void ServiceNode::test_reachability(const sn_record_t& sn) {
make_sn_request(ioc_, sn, req, std::move(callback));

// test lmq port:
lmq_server_.lmq()->connect_remote(
fmt::format("tcp://{}:{}", sn.ip(), sn.lmq_port()),
[this, sn](lokimq::ConnectionID c) {
this->process_reach_test_result(sn.pub_key_base32z(),
ReachType::ZMQ, true);
this->lmq_server_.lmq()->disconnect(c);
lmq_server_.lmq()->request(sn.pubkey_x25519_bin(), "sn.onion_req",
[this, sn](bool success, const auto&) {
LOKI_LOG(debug, "Got success={} testing response from {}",
success, sn.pubkey_x25519_hex());
process_reach_test_result(
sn.pub_key_base32z(), ReachType::ZMQ, success);
},
[this, sn](lokimq::ConnectionID c, lokimq::string_view err) {
this->process_reach_test_result(sn.pub_key_base32z(),
ReachType::ZMQ, false);
},
sn.pubkey_x25519_bin());
"ping",
// Only use an existing (or new) outgoing connection:
lokimq::send_option::outgoing{}
);
}

void ServiceNode::lokid_ping_timer_tick() {
Expand Down
2 changes: 1 addition & 1 deletion vendors/loki-mq

0 comments on commit b6a24ea

Please sign in to comment.