Skip to content

Commit

Permalink
path message addressing to the right rxid
Browse files Browse the repository at this point in the history
  • Loading branch information
dr7ana committed Oct 29, 2024
1 parent bf02987 commit ac8feb1
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion llarp/contact/client_intro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
10 changes: 7 additions & 3 deletions llarp/handlers/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -430,8 +430,12 @@ namespace llarp::handlers
log::warning(logcat, "Exception: {}", e.what());
}

log::warning(
logcat, "Call to PublishClientContact failed -- status:{}", status.value_or("<none given>"));
auto b = status.value_or("<none given>") == "SUCCESS";

log::critical(
logcat,
"Call to PublishClientContact {}",
b ? "SUCCEEDED" : "FAILED -- status:{}"_format(status.value_or("<none given>")));
});
}
}
Expand Down
8 changes: 6 additions & 2 deletions llarp/link/link_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}

Expand Down
5 changes: 3 additions & 2 deletions llarp/messages/dht.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -106,7 +106,7 @@ namespace llarp
try
{
oxenc::bt_dict_consumer btdc{buf};
key.from_string(btdc.require<std::string_view>("c"));
key.from_string(btdc.require<std::string_view>("k"));
is_relayed = btdc.require<bool>("o");
relay_order = btdc.require<uint64_t>("r");
}
Expand All @@ -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"}});
Expand Down
6 changes: 4 additions & 2 deletions llarp/messages/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ namespace llarp
- 'n' : Symmetric nonce used to encrypt the layer
- 'x' : Encrypted payload transmitted to next recipient
*/
template <oxenc::string_like K, oxenc::string_like T>
inline static std::string serialize_hop(K key, const SymmNonce& nonce, T encrypted)
// template <oxenc::string_like K, oxenc::string_like T>
// 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);
Expand Down
3 changes: 2 additions & 1 deletion llarp/path/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions llarp/path/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ac8feb1

Please sign in to comment.