Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Peer testing fix #343

Merged
merged 2 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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