From ac8feb1a7081667a5985cdd942a8eab39eb46191 Mon Sep 17 00:00:00 2001 From: dr7ana Date: Tue, 29 Oct 2024 14:12:00 -0700 Subject: [PATCH] path message addressing to the right rxid --- llarp/contact/client_intro.hpp | 2 +- llarp/handlers/session.cpp | 10 +++++++--- llarp/link/link_manager.cpp | 8 ++++++-- llarp/messages/dht.hpp | 5 +++-- llarp/messages/path.hpp | 6 ++++-- llarp/path/path.cpp | 3 ++- llarp/path/path.hpp | 3 +-- 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/llarp/contact/client_intro.hpp b/llarp/contact/client_intro.hpp index 9322352e20..c0af73d4c8 100644 --- a/llarp/contact/client_intro.hpp +++ b/llarp/contact/client_intro.hpp @@ -13,7 +13,7 @@ namespace llarp struct ClientIntro { RouterID pivot_rid; - HopID pivot_hid; + HopID pivot_hid; // TXID at the pivot std::chrono::milliseconds expiry{0s}; uint64_t version{llarp::constants::proto_version}; diff --git a/llarp/handlers/session.cpp b/llarp/handlers/session.cpp index c31adc53db..f0f346c447 100644 --- a/llarp/handlers/session.cpp +++ b/llarp/handlers/session.cpp @@ -405,7 +405,7 @@ namespace llarp::handlers { bool ret{true}; - log::critical(logcat, "Publishing new EncryptedClientContact: {}", ecc.bt_payload()); + log::critical(logcat, "Publishing new EncryptedClientContact: {}", buffer_printer{ecc.bt_payload()}); { Lock_t l{paths_mutex}; @@ -430,8 +430,12 @@ namespace llarp::handlers log::warning(logcat, "Exception: {}", e.what()); } - log::warning( - logcat, "Call to PublishClientContact failed -- status:{}", status.value_or("")); + auto b = status.value_or("") == "SUCCESS"; + + log::critical( + logcat, + "Call to PublishClientContact {}", + b ? "SUCCEEDED" : "FAILED -- status:{}"_format(status.value_or(""))); }); } } diff --git a/llarp/link/link_manager.cpp b/llarp/link/link_manager.cpp index 70b62d3ca5..9f241ffb86 100644 --- a/llarp/link/link_manager.cpp +++ b/llarp/link/link_manager.cpp @@ -1080,7 +1080,9 @@ namespace llarp "Received PublishClientContact for which we are index {}... storing client contact...", relay_order); _router.contact_db().put_cc(std::move(enc)); - return respond(messages::OK_RESPONSE); + // return respond(messages::OK_RESPONSE); + // TESTNET: + return respond(PublishClientContact::SUCCESS); } log::info(logcat, "Received PublishClientContact; propagating to peer index {}...", relay_order); @@ -1112,7 +1114,9 @@ namespace llarp dht_key, relay_order); _router.contact_db().put_cc(std::move(enc)); - return respond(messages::OK_RESPONSE); + // return respond(messages::OK_RESPONSE); + // TESTNET: + return respond(PublishClientContact::SUCCESS); } } diff --git a/llarp/messages/dht.hpp b/llarp/messages/dht.hpp index 6c6e943d15..7661d79b42 100644 --- a/llarp/messages/dht.hpp +++ b/llarp/messages/dht.hpp @@ -80,7 +80,7 @@ namespace llarp try { - btdp.append("c", location.to_view()); + btdp.append("k", location.to_view()); btdp.append("o", relay_order); btdp.append("r", is_relayed); } @@ -106,7 +106,7 @@ namespace llarp try { oxenc::bt_dict_consumer btdc{buf}; - key.from_string(btdc.require("c")); + key.from_string(btdc.require("k")); is_relayed = btdc.require("o"); relay_order = btdc.require("r"); } @@ -123,6 +123,7 @@ namespace llarp namespace PublishClientContact { + inline const auto SUCCESS = messages::serialize_response({{messages::STATUS_KEY, "SUCCESS"}}); inline const auto INVALID = messages::serialize_response({{messages::STATUS_KEY, "INVALID CC"}}); inline const auto EXPIRED = messages::serialize_response({{messages::STATUS_KEY, "EXPIRED CC"}}); inline const auto INSUFFICIENT = messages::serialize_response({{messages::STATUS_KEY, "INSUFFICIENT NODES"}}); diff --git a/llarp/messages/path.hpp b/llarp/messages/path.hpp index e1ad9ef63f..cb0e3c7f52 100644 --- a/llarp/messages/path.hpp +++ b/llarp/messages/path.hpp @@ -26,8 +26,10 @@ namespace llarp - 'n' : Symmetric nonce used to encrypt the layer - 'x' : Encrypted payload transmitted to next recipient */ - template - inline static std::string serialize_hop(K key, const SymmNonce& nonce, T encrypted) + // template + // inline static std::string serialize_hop(K key, const SymmNonce& nonce, T encrypted) + inline static std::string serialize_hop( + std::string_view key, const SymmNonce& nonce, std::string_view encrypted) { oxenc::bt_dict_producer btdp; btdp.append("k", key); diff --git a/llarp/path/path.cpp b/llarp/path/path.cpp index 0cfc25ca95..dd9c1e9cf3 100644 --- a/llarp/path/path.cpp +++ b/llarp/path/path.cpp @@ -163,7 +163,8 @@ namespace llarp::path hop.nonceXOR); } - return ONION::serialize_hop(upstream_txid().to_view(), nonce, std::move(inner_payload)); + // TESTNET: upstream_txid -> upstream_rxid + return ONION::serialize_hop(upstream_rxid().to_view(), nonce, std::move(inner_payload)); } bool Path::send_path_data_message(std::string data) diff --git a/llarp/path/path.hpp b/llarp/path/path.hpp index 51a85aa9f5..8089296ab8 100644 --- a/llarp/path/path.hpp +++ b/llarp/path/path.hpp @@ -63,8 +63,6 @@ namespace llarp nlohmann::json ExtractStatus() const; - std::string to_string() const; - std::string HopsString() const; std::chrono::milliseconds LastRemoteActivityAt() const { return last_recv_msg; } @@ -162,6 +160,7 @@ namespace llarp bool operator!=(const Path& other) const; + std::string to_string() const; static constexpr bool to_string_formattable = true; private: