From d8f97028b58d5985aa660cb8e31e069dce4d109f Mon Sep 17 00:00:00 2001 From: dr7ana Date: Mon, 18 Mar 2024 05:52:01 -0700 Subject: [PATCH] templated remoteaddress object - eliminated {client,relay}address - better loops in new key types --- llarp/address/address.cpp | 116 +------------------------- llarp/address/address.hpp | 158 +++++++++++++++--------------------- llarp/address/keys.cpp | 24 ++++-- llarp/address/keys.hpp | 67 +++++++++------ llarp/address/utils.hpp | 32 ++++++++ llarp/config/config.cpp | 2 +- llarp/config/config.hpp | 5 +- llarp/crypto/types.cpp | 52 ++++++------ llarp/crypto/types.hpp | 40 ++++----- llarp/handlers/remote.hpp | 2 +- llarp/link/link_manager.cpp | 6 +- llarp/link/link_manager.hpp | 16 ++-- llarp/service/intro_set.cpp | 4 +- 13 files changed, 218 insertions(+), 306 deletions(-) diff --git a/llarp/address/address.cpp b/llarp/address/address.cpp index 8fd4920aa..b1400f82a 100644 --- a/llarp/address/address.cpp +++ b/llarp/address/address.cpp @@ -3,118 +3,4 @@ #include "utils.hpp" namespace llarp -{ - auto parse_addr_string = [](std::string_view arg, std::string_view tld) -> std::optional { - std::optional ret = std::nullopt; - - if (auto pos = arg.find_first_of('.'); pos != std::string_view::npos) - { - auto _prefix = arg.substr(0, pos); - // check the pubkey prefix is the right length - if (_prefix.length() != PUBKEYSIZE) - return ret; - - // verify the tld is allowed - auto _tld = arg.substr(pos + 1); - - if (_tld == tld and TLD::allowed.count(_tld)) - ret = _prefix; - } - - return ret; - }; - - RemoteAddr& RemoteAddr::operator=(RemoteAddr&& other) - { - _pubkey = std::move(other._pubkey); - _name = std::move(other._name); - _tld = std::move(other._tld); - return *this; - } - - bool RemoteAddr::operator<(const RemoteAddr& other) const - { - return std::tie(_pubkey, _name, _tld) < std::tie(other._pubkey, other._name, other._tld); - } - - bool RemoteAddr::operator==(const RemoteAddr& other) const - { - return _pubkey == other._pubkey and _name == other._name && _tld == other._tld; - } - - bool RemoteAddr::operator!=(const RemoteAddr& other) const - { - return not(*this == other); - } - - RelayAddress& RelayAddress::operator=(RelayAddress&& other) - { - _pubkey = std::move(other._pubkey); - _name = std::move(other._name); - _tld = std::move(other._tld); - return *this; - } - - bool RelayAddress::operator<(const RelayAddress& other) const - { - return std::tie(_pubkey, _name, _tld) < std::tie(other._pubkey, other._name, other._tld); - } - - bool RelayAddress::operator==(const RelayAddress& other) const - { - return _pubkey == other._pubkey and _name == other._name && _tld == other._tld; - } - - bool RelayAddress::operator!=(const RelayAddress& other) const - { - return not(*this == other); - } - - ClientAddress& ClientAddress::operator=(ClientAddress&& other) - { - _pubkey = std::move(other._pubkey); - _name = std::move(other._name); - _tld = std::move(other._tld); - return *this; - } - - bool ClientAddress::operator<(const ClientAddress& other) const - { - return std::tie(_pubkey, _name, _tld) < std::tie(other._pubkey, other._name, other._tld); - } - - bool ClientAddress::operator==(const ClientAddress& other) const - { - return _pubkey == other._pubkey and _name == other._name && _tld == other._tld; - } - - bool ClientAddress::operator!=(const ClientAddress& other) const - { - return not(*this == other); - } - - bool RelayAddress::from_pubkey_addr(std::string arg) - { - if (auto maybe_addr = parse_addr_string(arg, TLD::RELAY)) - { - _pubkey.from_string(*maybe_addr); - _tld = TLD::RELAY; - return true; - } - - return false; - } - - bool ClientAddress::from_pubkey_addr(std::string arg) - { - if (auto maybe_addr = parse_addr_string(arg, TLD::CLIENT)) - { - _pubkey.from_string(*maybe_addr); - _tld = TLD::CLIENT; - return true; - } - - return false; - } - -} // namespace llarp +{} // namespace llarp diff --git a/llarp/address/address.hpp b/llarp/address/address.hpp index bb3b02f98..3100a6215 100644 --- a/llarp/address/address.hpp +++ b/llarp/address/address.hpp @@ -1,58 +1,77 @@ #pragma once #include "keys.hpp" +#include "utils.hpp" #include #include -#include #include -#include #include namespace llarp { - namespace TLD + template , int> = 0> + struct RemoteAddress { - inline constexpr auto RELAY = ".snode"sv; - inline constexpr auto CLIENT = ".loki"sv; + pubkey_t _pubkey; + std::optional _name = std::nullopt; + std::string _tld; - std::set allowed = {RELAY, CLIENT}; - } // namespace TLD + RemoteAddress() = default; - struct RemoteAddr - { - public: - RemoteAddr() = default; + explicit RemoteAddress(std::string addr) : _name{std::move(addr)} + { + _pubkey.from_string(*_name); - explicit RemoteAddr(PublicKey pk, std::string_view tld, std::optional n = std::nullopt) + if constexpr (std::is_same_v) + _tld = std::string{TLD::CLIENT}; + else if constexpr (std::is_same_v) + _tld = std::string{TLD::RELAY}; + else + throw std::invalid_argument{"Something seriously weird just happened."}; + } + + explicit RemoteAddress(PubKey pk, std::string_view tld, std::optional n = std::nullopt) : _pubkey{std::move(pk)}, _name{std::move(n)}, _tld{tld} {} - RemoteAddr(const RemoteAddr& other) : RemoteAddr{other._pubkey, other._tld, other._name} + RemoteAddress(const RemoteAddress& other) : RemoteAddress{other._pubkey, other._tld, other._name} {} - RemoteAddr(RemoteAddr&& other) - : RemoteAddr{std::move(other._pubkey), std::move(other._tld), std::move(other._name)} + RemoteAddress(RemoteAddress&& other) + : RemoteAddress{std::move(other._pubkey), std::move(other._tld), std::move(other._name)} {} - RemoteAddr& operator=(const RemoteAddr& other) = default; - RemoteAddr& operator=(RemoteAddr&& other); - bool operator<(const RemoteAddr& other) const; - bool operator==(const RemoteAddr& other) const; - bool operator!=(const RemoteAddr& other) const; + RemoteAddress& operator=(const RemoteAddress& other) = default; - virtual ~RemoteAddr() = default; + RemoteAddress& operator=(RemoteAddress&& other) + { + _pubkey = std::move(other._pubkey); + _name = std::move(other._name); + _tld = std::move(other._tld); + return *this; + } + + bool operator<(const RemoteAddress& other) const + { + return std::tie(_pubkey, _name, _tld) < std::tie(other._pubkey, other._name, other._tld); + } + bool operator==(const RemoteAddress& other) const + { + return _pubkey == other._pubkey and _name == other._name && _tld == other._tld; + } + bool operator!=(const RemoteAddress& other) const + { + return not(*this == other); + } + + ~RemoteAddress() = default; std::string to_string() const { return remote_name(); } - protected: - PublicKey _pubkey; - std::optional _name = std::nullopt; - std::string _tld; - std::string name() const { return _name.value_or(_pubkey.to_string()); @@ -67,85 +86,36 @@ namespace llarp { return name() + tld(); } + }; - /// This function currently assumes the remote address string is a pubkey, rather than - /// an ONS name (TODO:) - virtual bool from_pubkey_addr(std::string) + /// This function currently assumes the remote address string is a pubkey, rather than + /// an ONS name (TODO:) + template + std::optional> from_pubkey_addr(const std::string& arg) + { + if (auto maybe_addr = parse_addr_string(arg, TLD::CLIENT)) { - return true; + return RemoteAddress(*maybe_addr); + } + if (auto maybe_addr = parse_addr_string(arg, TLD::RELAY)) + { + return RemoteAddress(*maybe_addr); } - }; - - struct RelayAddress final : public RemoteAddr - { - RelayAddress() = default; - - explicit RelayAddress(RelayPubKey rpk, std::optional n = std::nullopt) - : RemoteAddr{std::move(rpk), TLD::RELAY, std::move(n)} - {} - RelayAddress(const RelayAddress& other) : RemoteAddr{other._pubkey, TLD::RELAY, other._name} - {} - RelayAddress(RelayAddress&& other) : RemoteAddr{std::move(other._pubkey), TLD::RELAY, std::move(other._name)} - {} - RelayAddress& operator=(const RelayAddress& other) = default; - RelayAddress& operator=(RelayAddress&& other); - - bool operator<(const RelayAddress& other) const; - bool operator==(const RelayAddress& other) const; - bool operator!=(const RelayAddress& other) const; - - ~RelayAddress() override = default; - - bool from_pubkey_addr(std::string arg) override; - }; - - struct ClientAddress final : public RemoteAddr - { - ClientAddress() = default; - - explicit ClientAddress(ClientPubKey cpk, std::optional n = std::nullopt) - : RemoteAddr{std::move(cpk), TLD::CLIENT, std::move(n)} - {} - ClientAddress(const ClientAddress& other) : RemoteAddr{other._pubkey, TLD::RELAY, other._name} - {} - ClientAddress(ClientAddress&& other) : RemoteAddr{std::move(other._pubkey), TLD::RELAY, std::move(other._name)} - {} - ClientAddress& operator=(const ClientAddress& other) = default; - ClientAddress& operator=(ClientAddress&& other); - - bool operator<(const ClientAddress& other) const; - bool operator==(const ClientAddress& other) const; - bool operator!=(const ClientAddress& other) const; - - ~ClientAddress() override = default; - - bool from_pubkey_addr(std::string arg) override; - }; - - template <> - inline constexpr bool IsToStringFormattable = true; - - template - inline constexpr bool IsToStringFormattable>> = true; + return std::nullopt; + } + template + inline constexpr bool IsToStringFormattable> = true; } // namespace llarp namespace std { - template <> - struct hash + template + struct hash> { - virtual size_t operator()(const llarp::RemoteAddr& r) const + virtual size_t operator()(const llarp::RemoteAddress& r) const { return std::hash{}(r.to_string()); } }; - - template <> - struct hash : public hash - {}; - - template <> - struct hash : public hash - {}; } // namespace std diff --git a/llarp/address/keys.cpp b/llarp/address/keys.cpp index f0553ffba..fa00f5df0 100644 --- a/llarp/address/keys.cpp +++ b/llarp/address/keys.cpp @@ -4,28 +4,42 @@ namespace llarp { - std::string PublicKey::to_string() const + bool PubKey::from_hex(const std::string& str) + { + if (str.size() != 2 * size()) + return false; + oxenc::from_hex(str.begin(), str.end(), begin()); + return true; + } + + std::string PubKey::to_string() const { return oxenc::to_hex(begin(), end()); } - PublicKey& PublicKey::operator=(const PublicKey& other) + PubKey& PubKey::operator=(const uint8_t* ptr) + { + std::copy(ptr, ptr + SIZE, begin()); + return *this; + } + + PubKey& PubKey::operator=(const PubKey& other) { std::memcpy(begin(), other.begin(), PUBKEYSIZE); return *this; } - bool PublicKey::operator<(const PublicKey& other) const + bool PubKey::operator<(const PubKey& other) const { return as_array() < other.as_array(); } - bool PublicKey::operator==(const PublicKey& other) const + bool PubKey::operator==(const PubKey& other) const { return as_array() == other.as_array(); } - bool PublicKey::operator!=(const PublicKey& other) const + bool PubKey::operator!=(const PubKey& other) const { return !(*this == other); } diff --git a/llarp/address/keys.hpp b/llarp/address/keys.hpp index 82a30ac92..4134be86f 100644 --- a/llarp/address/keys.hpp +++ b/llarp/address/keys.hpp @@ -10,41 +10,46 @@ namespace llarp { - struct PublicKey : public AlignedBuffer + struct PubKey : public AlignedBuffer { - PublicKey() = default; + PubKey() = default; + + bool from_hex(const std::string& str); std::string to_string() const; - explicit PublicKey(const uint8_t* data) : AlignedBuffer{data} + explicit PubKey(const uint8_t* data) : AlignedBuffer{data} {} - explicit PublicKey(const std::array& data) : AlignedBuffer{data} + explicit PubKey(const std::array& data) : AlignedBuffer{data} {} - explicit PublicKey(ustring_view data) : AlignedBuffer{data.data()} + explicit PubKey(ustring_view data) : AlignedBuffer{data.data()} {} - explicit PublicKey(std::string_view data) : PublicKey{to_usv(data)} + explicit PubKey(std::string_view data) : PubKey{to_usv(data)} {} - PublicKey(const PublicKey& other) : PublicKey{other.data()} + PubKey(const PubKey& other) : PubKey{other.data()} {} - PublicKey(PublicKey&& other) : PublicKey{other.data()} + PubKey(PubKey&& other) : PubKey{other.data()} {} - PublicKey& operator=(const PublicKey& other); + PubKey& operator=(const PubKey& other); - bool operator<(const PublicKey& other) const; - bool operator==(const PublicKey& other) const; - bool operator!=(const PublicKey& other) const; + // revisit this + PubKey& operator=(const uint8_t* ptr); + + bool operator<(const PubKey& other) const; + bool operator==(const PubKey& other) const; + bool operator!=(const PubKey& other) const; }; - struct RelayPubKey final : public PublicKey + struct RelayPubKey final : public PubKey { - RelayPubKey() = delete; + RelayPubKey() = default; - explicit RelayPubKey(const uint8_t* data) : PublicKey{data} + explicit RelayPubKey(const uint8_t* data) : PubKey{data} {} - explicit RelayPubKey(const std::array& data) : PublicKey{data} + explicit RelayPubKey(const std::array& data) : PubKey{data} {} - explicit RelayPubKey(ustring_view data) : PublicKey{data.data()} + explicit RelayPubKey(ustring_view data) : PubKey{data.data()} {} explicit RelayPubKey(std::string_view data) : RelayPubKey{to_usv(data)} {} @@ -60,15 +65,15 @@ namespace llarp bool operator!=(const RelayPubKey& other) const; }; - struct ClientPubKey final : public PublicKey + struct ClientPubKey final : public PubKey { - ClientPubKey() = delete; + ClientPubKey() = default; - explicit ClientPubKey(const uint8_t* data) : PublicKey{data} + explicit ClientPubKey(const uint8_t* data) : PubKey{data} {} - explicit ClientPubKey(const std::array& data) : PublicKey{data} + explicit ClientPubKey(const std::array& data) : PubKey{data} {} - explicit ClientPubKey(ustring_view data) : PublicKey{data.data()} + explicit ClientPubKey(ustring_view data) : PubKey{data.data()} {} explicit ClientPubKey(std::string_view data) : ClientPubKey{to_usv(data)} {} @@ -85,24 +90,32 @@ namespace llarp }; template <> - inline constexpr bool IsToStringFormattable = true; + inline constexpr bool IsToStringFormattable = true; template - inline constexpr bool IsToStringFormattable>> = true; + inline constexpr bool IsToStringFormattable>> = true; + + template , int> = 0> + PK_t make_from_hex(const std::string& str) + { + PK_t p; + oxenc::from_hex(str.begin(), str.end(), p.begin()); + return p; + } } // namespace llarp namespace std { template <> - struct hash : public hash> + struct hash : public hash> {}; template <> - struct hash : public hash + struct hash : public hash {}; template <> - struct hash : public hash + struct hash : public hash {}; } // namespace std diff --git a/llarp/address/utils.hpp b/llarp/address/utils.hpp index fa8ef9655..ccf920f67 100644 --- a/llarp/address/utils.hpp +++ b/llarp/address/utils.hpp @@ -2,15 +2,26 @@ #include "types.hpp" +#include #include +#include #include #include +#include #include #include namespace llarp { + namespace TLD + { + inline constexpr auto RELAY = ".snode"sv; + inline constexpr auto CLIENT = ".loki"sv; + + std::set allowed = {RELAY, CLIENT}; + } // namespace TLD + uint16_t checksum_ipv4(const void *header, uint8_t header_len); uint32_t tcpudp_checksum_ipv4(uint32_t src, uint32_t dest, uint32_t len, uint8_t proto, uint32_t sum); @@ -19,6 +30,27 @@ namespace llarp uint32_t udp_checksum_ipv6(const struct in6_addr *saddr, const struct in6_addr *daddr, uint32_t len, uint32_t csum); + inline static std::optional parse_addr_string(std::string_view arg, std::string_view tld) + { + std::optional ret = std::nullopt; + + if (auto pos = arg.find_first_of('.'); pos != std::string_view::npos) + { + auto _prefix = arg.substr(0, pos); + // check the pubkey prefix is the right length + if (_prefix.length() != PUBKEYSIZE) + return ret; + + // verify the tld is allowed + auto _tld = arg.substr(pos); + + if (_tld == tld and TLD::allowed.count(_tld)) + ret = _prefix; + } + + return ret; + }; + template static bool parse_int(const std::string_view str, T &value, int base = 10) { diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index 9c424454d..803d13e6a 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -642,7 +642,7 @@ namespace llarp throw std::invalid_argument{"[endpoint]:mapaddr invalid entry: {}"_format(arg)}; } - ClientAddress remote; + RemoteAddress remote; if (not remote.from_pubkey_addr(arg.substr(0, pos))) { diff --git a/llarp/config/config.hpp b/llarp/config/config.hpp index d321f1d01..29d4457d0 100644 --- a/llarp/config/config.hpp +++ b/llarp/config/config.hpp @@ -149,9 +149,10 @@ namespace llarp IPRange _local_ip_range; // rename to _local_ip_range std::optional _base_ipv6_range = std::nullopt; - std::unordered_map _addr_map; - std::unordered_map _range_map; + std::unordered_map, oxen::quic::Address> _addr_map; + + std::unordered_map, IPRange> _range_map; std::unordered_map _ons_range_map; std::set _owned_ranges; diff --git a/llarp/crypto/types.cpp b/llarp/crypto/types.cpp index 4652bf197..05bcc0cba 100644 --- a/llarp/crypto/types.cpp +++ b/llarp/crypto/types.cpp @@ -10,36 +10,36 @@ namespace llarp { - bool PubKey::from_hex(const std::string& str) - { - if (str.size() != 2 * size()) - return false; - oxenc::from_hex(str.begin(), str.end(), begin()); - return true; - } + // bool PubKey::from_hex(const std::string& str) + // { + // if (str.size() != 2 * size()) + // return false; + // oxenc::from_hex(str.begin(), str.end(), begin()); + // return true; + // } - PubKey PubKey::make_from_hex(const std::string& s) - { - PubKey p; - oxenc::from_hex(s.begin(), s.end(), p.begin()); - return p; - } + // PubKey PubKey::make_from_hex(const std::string& s) + // { + // PubKey p; + // oxenc::from_hex(s.begin(), s.end(), p.begin()); + // return p; + // } - std::string PubKey::to_string() const - { - return oxenc::to_hex(begin(), end()); - } + // std::string PubKey::to_string() const + // { + // return oxenc::to_hex(begin(), end()); + // } - PubKey& PubKey::operator=(const uint8_t* ptr) - { - std::copy(ptr, ptr + SIZE, begin()); - return *this; - } + // PubKey& PubKey::operator=(const uint8_t* ptr) + // { + // std::copy(ptr, ptr + SIZE, begin()); + // return *this; + // } - bool operator==(const PubKey& lhs, const PubKey& rhs) - { - return lhs.as_array() == rhs.as_array(); - } + // bool operator==(const PubKey& lhs, const PubKey& rhs) + // { + // return lhs.as_array() == rhs.as_array(); + // } bool SecretKey::load_from_file(const fs::path& fname) { diff --git a/llarp/crypto/types.hpp b/llarp/crypto/types.hpp index 1c08b8f9b..6ee8d8fcb 100644 --- a/llarp/crypto/types.hpp +++ b/llarp/crypto/types.hpp @@ -2,6 +2,7 @@ #include "constants.hpp" +#include #include #include #include @@ -14,29 +15,29 @@ namespace llarp using SharedSecret = AlignedBuffer; using KeyExchangeNonce = AlignedBuffer<32>; - struct PubKey : public AlignedBuffer - { - PubKey() = default; + // struct PubKey : public AlignedBuffer + // { + // PubKey() = default; - explicit PubKey(const uint8_t* ptr) : AlignedBuffer(ptr) - {} + // explicit PubKey(const uint8_t* ptr) : AlignedBuffer(ptr) + // {} - explicit PubKey(const std::array& data) : AlignedBuffer(data) - {} + // explicit PubKey(const std::array& data) : AlignedBuffer(data) + // {} - explicit PubKey(const AlignedBuffer& other) : AlignedBuffer(other) - {} + // explicit PubKey(const AlignedBuffer& other) : AlignedBuffer(other) + // {} - std::string to_string() const; + // std::string to_string() const; - bool from_hex(const std::string& str); + // bool from_hex(const std::string& str); - static PubKey make_from_hex(const std::string& s); + // static PubKey make_from_hex(const std::string& s); - PubKey& operator=(const uint8_t* ptr); - }; + // PubKey& operator=(const uint8_t* ptr); + // }; - bool operator==(const PubKey& lhs, const PubKey& rhs); + // bool operator==(const PubKey& lhs, const PubKey& rhs); struct PrivateKey; @@ -121,8 +122,6 @@ namespace llarp bool to_pubkey(PubKey& pubkey) const; }; - template <> - inline constexpr bool IsToStringFormattable = true; template <> inline constexpr bool IsToStringFormattable = true; template <> @@ -150,10 +149,3 @@ namespace llarp /// SH(result, body) using shorthash_func = bool (*)(ShortHash&, const llarp_buffer_t&); } // namespace llarp - -namespace std -{ - template <> - struct hash : hash> - {}; -}; // namespace std diff --git a/llarp/handlers/remote.hpp b/llarp/handlers/remote.hpp index e9a3224f2..a29d1a090 100644 --- a/llarp/handlers/remote.hpp +++ b/llarp/handlers/remote.hpp @@ -27,7 +27,7 @@ namespace llarp { protected: std::string _name; - std::unordered_map _ip_map; + std::unordered_map, oxen::quic::Address> _ip_map; DnsConfig _dns_config; NetworkConfig _net_config; diff --git a/llarp/link/link_manager.cpp b/llarp/link/link_manager.cpp index 3e3ada729..c4ae8b491 100644 --- a/llarp/link/link_manager.cpp +++ b/llarp/link/link_manager.cpp @@ -531,7 +531,7 @@ namespace llarp const auto& remote_addr = rc->addr(); if (auto rv = ep.establish_and_send( - oxen::quic::RemoteAddress{router.ToView(), remote_addr}, + KeyedAddress{router.ToView(), remote_addr}, *rc, std::move(endpoint), std::move(body), @@ -563,7 +563,7 @@ namespace llarp const auto& remote_addr = rc.addr(); if (auto rv = ep.establish_connection( - oxen::quic::RemoteAddress{rid.ToView(), remote_addr}, rc, std::move(on_open), std::move(on_close)); + KeyedAddress{rid.ToView(), remote_addr}, rc, std::move(on_open), std::move(on_close)); rv) { log::info(logcat, "Begun establishing connection to {}", remote_addr); @@ -1156,7 +1156,7 @@ namespace llarp if (rc_index >= 0) { - log::info(logcat, "Received PublishIntroMessage for {} (TXID: {}); we are candidate {}"); + log::info(logcat, "Received PublishIntroMessage for {}; we are candidate {}", addr, relay_order); _router.contacts().put_intro(std::move(enc)); respond(serialize_response({{messages::STATUS_KEY, ""}})); diff --git a/llarp/link/link_manager.hpp b/llarp/link/link_manager.hpp index ad51521ab..339081bfb 100644 --- a/llarp/link/link_manager.hpp +++ b/llarp/link/link_manager.hpp @@ -38,6 +38,8 @@ namespace llarp using static_secret = oxen::quic::opt::static_secret; + using KeyedAddress = oxen::quic::RemoteAddress; + inline const keep_alive ROUTER_KEEP_ALIVE{10s}; inline const keep_alive CLIENT_KEEP_ALIVE{10s}; @@ -95,11 +97,11 @@ namespace llarp size_t num_router_conns() const; template - bool establish_connection(const oxen::quic::RemoteAddress& remote, const RemoteRC& rc, Opt&&... opts); + bool establish_connection(const KeyedAddress& remote, const RemoteRC& rc, Opt&&... opts); template bool establish_and_send( - const oxen::quic::RemoteAddress& remote, + const KeyedAddress& remote, const RemoteRC& rc, std::optional endpoint, std::string body, @@ -318,9 +320,11 @@ namespace llarp namespace link { + static auto logcat = log::Cat("link_manager"); + template bool Endpoint::establish_and_send( - const oxen::quic::RemoteAddress& remote, + const KeyedAddress& remote, const RemoteRC& rc, std::optional ep, std::string body, @@ -383,14 +387,14 @@ namespace llarp } catch (...) { - log::error(quic_cat, "Error: failed to establish connection to {}", remote); + log::error(logcat, "Error: failed to establish connection to {}", remote); return false; } }); } template - bool Endpoint::establish_connection(const oxen::quic::RemoteAddress& remote, const RemoteRC& rc, Opt&&... opts) + bool Endpoint::establish_connection(const KeyedAddress& remote, const RemoteRC& rc, Opt&&... opts) { return link_manager.router().loop()->call_get([&]() { try @@ -430,7 +434,7 @@ namespace llarp } catch (...) { - log::error(quic_cat, "Error: failed to establish connection to {}", remote); + log::error(logcat, "Error: failed to establish connection to {}", remote); return false; } }); diff --git a/llarp/service/intro_set.cpp b/llarp/service/intro_set.cpp index cafae2c39..f89bb600d 100644 --- a/llarp/service/intro_set.cpp +++ b/llarp/service/intro_set.cpp @@ -18,7 +18,7 @@ namespace llarp::service introset_payload{reinterpret_cast(enc_payload.data()), enc_payload.size()}, nonce{reinterpret_cast(nonce.data())} { - derived_signing_key = PubKey::make_from_hex(signing_key); + derived_signing_key = make_from_hex(signing_key); sig.from_string(std::move(s)); } @@ -28,7 +28,7 @@ namespace llarp::service { oxenc::bt_dict_consumer btdc{bt_payload}; - derived_signing_key = PubKey::make_from_hex(btdc.require("d")); + derived_signing_key = make_from_hex(btdc.require("d")); nonce.from_string(btdc.require("n")); signed_at = std::chrono::milliseconds{btdc.require("s")}; introset_payload = btdc.require("x");