implement sending "path control" (onioned control) message

TODO: handle at transit hop, handle at terminal hop, create and handle responses
pull/2213/head
Thomas Winget 8 months ago committed by dr7ana
parent f173186696
commit 4755269458

@ -107,8 +107,33 @@ namespace llarp::path
Path::send_path_control_message(
std::string method, std::string body, std::function<void(oxen::quic::message m)> func)
{
oxenc::bt_dict_producer btdp;
btdp.append("METHOD", method);
btdp.append("BODY", body);
auto payload = std::move(btdp).str();
auto* payload_ptr = reinterpret_cast<unsigned char*>(payload.data());
// TODO: old impl padded messages if smaller than a certain size; do we still want to?
auto crypto = CryptoManager::instance();
TunnelNonce nonce;
outer_nonce.Randomize();
for (const auto& hop : hops)
{
// do a round of chacha for each hop and mutate the nonce with that hop's nonce
CryptoManager::instance()->xchacha20(payload_ptr, hop.shared, nonce);
nonce ^= hop.nonceXOR;
}
oxenc::bt_dict_producer outer_dict;
outer_dict.append("PATHID", TXID().ToView());
outer_dict.append("NONCE", nonce.ToView());
outer_dict.append("PAYLOAD", payload);
return router.send_control_message(
upstream(), std::move(method), std::move(body), std::move(func));
upstream(), "path_control", std::move(outer_dict.str()), std::move(func));
}
bool

Loading…
Cancel
Save