From 8b9dcc861e9d62a743a7362b21266bbce10afc5e Mon Sep 17 00:00:00 2001 From: dr7ana Date: Wed, 24 Apr 2024 06:02:09 -0700 Subject: [PATCH] Datagram remote_key getter - Added method to get remote_key from dgram_interface wrapper. In lokinet, this is the upstream RouterID; it is easier to grab it directly from the dgram_interface rather than having to create an std::shared_ptr every time - It would be weird to return a ustring_view like the connection_interface method being called, as the dgram_interface makes no assurances of keeping the underlying connection objects alive - Making a copy of the ustring ensures that we are not pointing a view at data that we are not managing --- include/oxen/quic/datagram.hpp | 2 ++ src/datagram.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/oxen/quic/datagram.hpp b/include/oxen/quic/datagram.hpp index 56933654..c716839b 100644 --- a/include/oxen/quic/datagram.hpp +++ b/include/oxen/quic/datagram.hpp @@ -26,6 +26,8 @@ namespace oxen::quic std::shared_ptr get_conn_interface(); + ustring remote_key() const; + template < typename CharType, std::enable_if_t, int> = 0> diff --git a/src/datagram.cpp b/src/datagram.cpp index 5ac6d147..ecdb96ef 100644 --- a/src/datagram.cpp +++ b/src/datagram.cpp @@ -34,15 +34,18 @@ namespace oxen::quic log::trace(log_cat, "{} called", __PRETTY_FUNCTION__); return false; } + bool DatagramIO::sent_fin() const { log::trace(log_cat, "{} called", __PRETTY_FUNCTION__); return false; } + void DatagramIO::set_fin(bool) { log::trace(log_cat, "{} called", __PRETTY_FUNCTION__); } + size_t DatagramIO::unsent_impl() const { log::trace(log_cat, "{} called", __PRETTY_FUNCTION__); @@ -53,14 +56,17 @@ namespace oxen::quic sum += entry.size(); return sum; } + bool DatagramIO::has_unsent_impl() const { return not is_empty_impl(); } + void DatagramIO::wrote(size_t) { log::trace(log_cat, "{} called", __PRETTY_FUNCTION__); } + std::vector DatagramIO::pending() { log::trace(log_cat, "{} called", __PRETTY_FUNCTION__); @@ -74,6 +80,11 @@ namespace oxen::quic return ci.shared_from_this(); } + ustring dgram_interface::remote_key() const + { + return ustring{ci.remote_key()}; + } + void dgram_interface::reply(bstring_view data, std::shared_ptr keep_alive) { ci.send_datagram(data, std::move(keep_alive));