From 66a058a2af939174f95da8a28534509c4beac586 Mon Sep 17 00:00:00 2001 From: Stephen Shelton Date: Fri, 6 Dec 2019 10:13:09 -0700 Subject: [PATCH] Make format --- llarp/config/key_manager.cpp | 103 +++++++++++++++---------------- llarp/config/key_manager.hpp | 40 ++++++------ llarp/dht/messages/findintro.cpp | 2 +- llarp/dht/messages/gotrouter.cpp | 4 +- llarp/ev/ev_win32.cpp | 4 +- llarp/iwp/iwp.cpp | 4 +- llarp/iwp/iwp.hpp | 4 +- llarp/iwp/linklayer.cpp | 10 +-- llarp/iwp/linklayer.hpp | 3 +- llarp/link/factory.hpp | 6 +- llarp/link/server.cpp | 5 +- llarp/link/server.hpp | 4 +- llarp/messages/relay.cpp | 4 +- llarp/messages/relay_commit.cpp | 4 +- llarp/messages/relay_status.cpp | 6 +- llarp/router/router.cpp | 17 +++-- llarp/router/router.hpp | 2 +- llarp/service/protocol.cpp | 4 +- llarp/util/bencode.cpp | 5 +- llarp/util/bencode.h | 3 +- llarp/util/bencode.hpp | 4 +- 21 files changed, 115 insertions(+), 123 deletions(-) diff --git a/llarp/config/key_manager.cpp b/llarp/config/key_manager.cpp index c4f2cfb29..6eda6f238 100644 --- a/llarp/config/key_manager.cpp +++ b/llarp/config/key_manager.cpp @@ -12,40 +12,38 @@ /// curl callback static size_t -curl_RecvIdentKey(char *ptr, size_t, size_t nmemb, void *userdata) +curl_RecvIdentKey(char* ptr, size_t, size_t nmemb, void* userdata) { for(size_t idx = 0; idx < nmemb; idx++) - static_cast< std::vector< char > * >(userdata)->push_back(ptr[idx]); + static_cast< std::vector< char >* >(userdata)->push_back(ptr[idx]); return nmemb; } namespace llarp { - KeyManager::KeyManager() - : m_initialized(false) + KeyManager::KeyManager() : m_initialized(false) { } bool KeyManager::initialize(const llarp::Config& config, bool genIfAbsent) { - if (m_initialized) + if(m_initialized) return false; - m_rcPath = config.router.ourRcFile(); - m_idKeyPath = config.router.identKeyfile(); - m_encKeyPath = config.router.encryptionKeyfile(); + m_rcPath = config.router.ourRcFile(); + m_idKeyPath = config.router.identKeyfile(); + m_encKeyPath = config.router.encryptionKeyfile(); m_transportKeyPath = config.router.transportKeyfile(); - m_usingLokid = config.lokid.whitelistRouters; - m_lokidRPCAddr = config.lokid.lokidRPCAddr; - m_lokidRPCUser = config.lokid.lokidRPCUser; + m_usingLokid = config.lokid.whitelistRouters; + m_lokidRPCAddr = config.lokid.lokidRPCAddr; + m_lokidRPCUser = config.lokid.lokidRPCUser; m_lokidRPCPassword = config.lokid.lokidRPCPassword; - RouterContact rc; bool exists = rc.Read(m_rcPath.c_str()); - if (not exists and not genIfAbsent) + if(not exists and not genIfAbsent) { LogError("Could not read RouterContact at path ", m_rcPath); return false; @@ -54,9 +52,9 @@ namespace llarp // if our RC file can't be verified, assume it is out of date (e.g. uses // older encryption) and needs to be regenerated. before doing so, backup // files that will be overwritten - if (exists and not rc.VerifySignature()) + if(exists and not rc.VerifySignature()) { - if (! genIfAbsent) + if(!genIfAbsent) { LogError("Our RouterContact ", m_rcPath, " is invalid or out of date"); return false; @@ -64,49 +62,47 @@ namespace llarp else { LogWarn("Our RouterContact ", m_rcPath, - " seems out of date, backing up and regenerating private keys"); + " seems out of date, backing up and regenerating private keys"); - if (! backupKeyFilesByMoving()) + if(!backupKeyFilesByMoving()) { - LogError("Could not mv some key files, please ensure key files" + LogError( + "Could not mv some key files, please ensure key files" " are backed up if needed and remove"); return false; } } } - if (not m_usingLokid) + if(not m_usingLokid) { // load identity key or create if needed - auto identityKeygen = [](llarp::SecretKey& key) - { + auto identityKeygen = [](llarp::SecretKey& key) { // TODO: handle generating from service node seed llarp::CryptoManager::instance()->identity_keygen(key); }; - if (not loadOrCreateKey(m_idKeyPath, m_idKey, identityKeygen)) + if(not loadOrCreateKey(m_idKeyPath, m_idKey, identityKeygen)) return false; } else { - if (not loadIdentityFromLokid()) + if(not loadIdentityFromLokid()) return false; } // load encryption key - auto encryptionKeygen = [](llarp::SecretKey& key) - { + auto encryptionKeygen = [](llarp::SecretKey& key) { llarp::CryptoManager::instance()->encryption_keygen(key); }; - if (not loadOrCreateKey(m_encKeyPath, m_encKey, encryptionKeygen)) + if(not loadOrCreateKey(m_encKeyPath, m_encKey, encryptionKeygen)) return false; // TODO: transport key (currently done in LinkLayer) - auto transportKeygen = [](llarp::SecretKey& key) - { + auto transportKeygen = [](llarp::SecretKey& key) { key.Zero(); CryptoManager::instance()->encryption_keygen(key); }; - if (not loadOrCreateKey(m_transportKeyPath, m_transportKey, transportKeygen)) + if(not loadOrCreateKey(m_transportKeyPath, m_transportKey, transportKeygen)) return false; m_initialized = true; @@ -153,52 +149,51 @@ namespace llarp KeyManager::backupKeyFilesByMoving() const { auto findFreeBackupFilename = [](const fs::path& filepath) { - for (int i=0; i<9; i++) + for(int i = 0; i < 9; i++) { std::string ext("." + std::to_string(i) + ".bak"); fs::path newPath = filepath; newPath += ext; - if (not fs::exists(newPath)) + if(not fs::exists(newPath)) return newPath; } return fs::path(); }; - std::vector files = { - m_rcPath, - m_idKeyPath, - m_encKeyPath, - m_transportKeyPath - }; + std::vector< std::string > files = {m_rcPath, m_idKeyPath, m_encKeyPath, + m_transportKeyPath}; - for (auto& filepath : files) + for(auto& filepath : files) { std::error_code ec; bool exists = fs::exists(filepath, ec); - if (ec) + if(ec) { - LogError("Could not determine status of file ", filepath, ": ", ec.message()); + LogError("Could not determine status of file ", filepath, ": ", + ec.message()); return false; } - if (not exists) + if(not exists) { LogInfo("File ", filepath, " doesn't exist; no backup needed"); continue; } fs::path newFilepath = findFreeBackupFilename(filepath); - if (newFilepath.empty()) + if(newFilepath.empty()) { LogWarn("Could not find an appropriate backup filename for", filepath); return false; } - LogInfo("Backing up (moving) key file ", filepath, " to ", newFilepath, "..."); + LogInfo("Backing up (moving) key file ", filepath, " to ", newFilepath, + "..."); fs::rename(filepath, newFilepath, ec); - if (ec) { + if(ec) + { LogError("Failed to move key file ", ec.message()); return false; } @@ -209,15 +204,14 @@ namespace llarp bool KeyManager::loadOrCreateKey( - const std::string& filepath, - llarp::SecretKey& key, - std::function keygen) + const std::string& filepath, llarp::SecretKey& key, + std::function< void(llarp::SecretKey& key) > keygen) { fs::path path(filepath); std::error_code ec; - if (! fs::exists(path, ec)) + if(!fs::exists(path, ec)) { - if (ec) + if(ec) { LogError("Error checking key", filepath, ec.message()); return false; @@ -226,7 +220,7 @@ namespace llarp LogInfo("Generating new key", filepath); keygen(key); - if (! key.SaveToFile(filepath.c_str())) + if(!key.SaveToFile(filepath.c_str())) { LogError("Failed to save new key"); return false; @@ -240,7 +234,7 @@ namespace llarp bool KeyManager::loadIdentityFromLokid() { - CURL *curl = curl_easy_init(); + CURL* curl = curl_easy_init(); if(curl) { bool ret = false; @@ -251,7 +245,7 @@ namespace llarp curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY); const auto auth = m_lokidRPCUser + ":" + m_lokidRPCPassword; curl_easy_setopt(curl, CURLOPT_USERPWD, auth.c_str()); - curl_slist *list = nullptr; + curl_slist* list = nullptr; list = curl_slist_append(list, "Content-Type: application/json"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list); @@ -307,7 +301,7 @@ namespace llarp LogError("lokid gave bogus identity key"); } } - catch(nlohmann::json::exception &ex) + catch(nlohmann::json::exception& ex) { LogError("Bad response from lokid: ", ex.what()); } @@ -318,7 +312,8 @@ namespace llarp } if(ret) { - LogInfo("Got Identity Keys from lokid: ", RouterID(seckey_topublic(m_idKey))); + LogInfo("Got Identity Keys from lokid: ", + RouterID(seckey_topublic(m_idKey))); break; } else diff --git a/llarp/config/key_manager.hpp b/llarp/config/key_manager.hpp index e3c9af9e5..5d88f728c 100644 --- a/llarp/config/key_manager.hpp +++ b/llarp/config/key_manager.hpp @@ -8,30 +8,31 @@ namespace llarp { - - /// KeyManager manages the cryptographic keys stored on disk for the local node. - /// This includes private keys as well as the self-signed router contact file - /// (e.g. "self.signed"). + /// KeyManager manages the cryptographic keys stored on disk for the local + /// node. This includes private keys as well as the self-signed router contact + /// file (e.g. "self.signed"). /// - /// Keys are either read from disk if they exist and are valid (see below) or are - /// generated and written to disk. - /// - /// In addition, the KeyManager detects when the keys obsolete (e.g. as a result - /// of a software upgrade) and backs up existing keys before writing out new ones. - - struct KeyManager { + /// Keys are either read from disk if they exist and are valid (see below) or + /// are generated and written to disk. + /// + /// In addition, the KeyManager detects when the keys obsolete (e.g. as a + /// result of a software upgrade) and backs up existing keys before writing + /// out new ones. + struct KeyManager + { /// Constructor KeyManager(); - /// Initializes keys using the provided config, loading from disk and/or lokid - /// via HTTP request. + /// Initializes keys using the provided config, loading from disk and/or + /// lokid via HTTP request. /// /// NOTE: Must be called prior to obtaining any keys. /// NOTE: blocks on I/O /// /// @param config should be a prepared config object - /// @param genIfAbsent determines whether or not we will create files if they + /// @param genIfAbsent determines whether or not we will create files if + /// they /// do not exist. /// @return true on success, false otherwise bool @@ -80,15 +81,14 @@ namespace llarp bool getRouterContact(llarp::RouterContact& rc) const; - private: - + private: std::string m_rcPath; std::string m_idKeyPath; std::string m_encKeyPath; std::string m_transportKeyPath; std::atomic_bool m_initialized; - bool m_usingLokid = false; + bool m_usingLokid = false; std::string m_lokidRPCAddr = "127.0.0.1:22023"; std::string m_lokidRPCUser; std::string m_lokidRPCPassword; @@ -105,10 +105,8 @@ namespace llarp /// /// @param keygen is a function that will generate the key if needed static bool - loadOrCreateKey( - const std::string& filepath, - llarp::SecretKey& key, - std::function keygen); + loadOrCreateKey(const std::string& filepath, llarp::SecretKey& key, + std::function< void(llarp::SecretKey& key) > keygen); /// Requests the identity key from lokid via HTTP (curl) bool diff --git a/llarp/dht/messages/findintro.cpp b/llarp/dht/messages/findintro.cpp index fcac8e893..f317bf1e5 100644 --- a/llarp/dht/messages/findintro.cpp +++ b/llarp/dht/messages/findintro.cpp @@ -27,7 +27,7 @@ namespace llarp return false; if(!BEncodeMaybeVerifyVersion("V", version, LLARP_PROTO_VERSION, read, k, - val)) + val)) return false; return read; diff --git a/llarp/dht/messages/gotrouter.cpp b/llarp/dht/messages/gotrouter.cpp index a6c6b1d87..e66b59907 100644 --- a/llarp/dht/messages/gotrouter.cpp +++ b/llarp/dht/messages/gotrouter.cpp @@ -71,8 +71,8 @@ namespace llarp return bencode_read_integer(val, &txid); } bool read = false; - if(!BEncodeMaybeVerifyVersion("V", version, LLARP_PROTO_VERSION, read, key, - val)) + if(!BEncodeMaybeVerifyVersion("V", version, LLARP_PROTO_VERSION, read, + key, val)) return false; return read; diff --git a/llarp/ev/ev_win32.cpp b/llarp/ev/ev_win32.cpp index 18fa91c44..9ec07c6b4 100644 --- a/llarp/ev/ev_win32.cpp +++ b/llarp/ev/ev_win32.cpp @@ -143,8 +143,8 @@ tun_ev_loop(void* unused) while(true) { - alert = - GetQueuedCompletionStatus(tun_event_queue, &size, &listener, &ovl, EV_TICK_INTERVAL); + alert = GetQueuedCompletionStatus(tun_event_queue, &size, &listener, &ovl, + EV_TICK_INTERVAL); if(!alert) { diff --git a/llarp/iwp/iwp.cpp b/llarp/iwp/iwp.cpp index eddaa6c3d..d6c323938 100644 --- a/llarp/iwp/iwp.cpp +++ b/llarp/iwp/iwp.cpp @@ -9,7 +9,7 @@ namespace llarp namespace iwp { LinkLayer_ptr - NewInboundLink(std::shared_ptr keyManager, GetRCFunc getrc, + NewInboundLink(std::shared_ptr< KeyManager > keyManager, GetRCFunc getrc, LinkMessageHandler h, SignBufferFunc sign, SessionEstablishedHandler est, SessionRenegotiateHandler reneg, TimeoutHandler timeout, @@ -21,7 +21,7 @@ namespace llarp } LinkLayer_ptr - NewOutboundLink(std::shared_ptr keyManager, GetRCFunc getrc, + NewOutboundLink(std::shared_ptr< KeyManager > keyManager, GetRCFunc getrc, LinkMessageHandler h, SignBufferFunc sign, SessionEstablishedHandler est, SessionRenegotiateHandler reneg, TimeoutHandler timeout, diff --git a/llarp/iwp/iwp.hpp b/llarp/iwp/iwp.hpp index 86433eb58..bec91fe3f 100644 --- a/llarp/iwp/iwp.hpp +++ b/llarp/iwp/iwp.hpp @@ -11,13 +11,13 @@ namespace llarp namespace iwp { LinkLayer_ptr - NewInboundLink(std::shared_ptr keyManager, GetRCFunc getrc, + NewInboundLink(std::shared_ptr< KeyManager > keyManager, GetRCFunc getrc, LinkMessageHandler h, SignBufferFunc sign, SessionEstablishedHandler est, SessionRenegotiateHandler reneg, TimeoutHandler timeout, SessionClosedHandler closed, PumpDoneHandler pumpDone); LinkLayer_ptr - NewOutboundLink(std::shared_ptr keyManager, GetRCFunc getrc, + NewOutboundLink(std::shared_ptr< KeyManager > keyManager, GetRCFunc getrc, LinkMessageHandler h, SignBufferFunc sign, SessionEstablishedHandler est, SessionRenegotiateHandler reneg, TimeoutHandler timeout, diff --git a/llarp/iwp/linklayer.cpp b/llarp/iwp/linklayer.cpp index 4cc1aefa6..5b7de3807 100644 --- a/llarp/iwp/linklayer.cpp +++ b/llarp/iwp/linklayer.cpp @@ -8,14 +8,14 @@ namespace llarp { namespace iwp { - LinkLayer::LinkLayer(std::shared_ptr keyManager, GetRCFunc getrc, - LinkMessageHandler h, SignBufferFunc sign, - SessionEstablishedHandler est, + LinkLayer::LinkLayer(std::shared_ptr< KeyManager > keyManager, + GetRCFunc getrc, LinkMessageHandler h, + SignBufferFunc sign, SessionEstablishedHandler est, SessionRenegotiateHandler reneg, TimeoutHandler timeout, SessionClosedHandler closed, PumpDoneHandler pumpDone, bool allowInbound) - : ILinkLayer(keyManager, getrc, h, sign, est, reneg, timeout, - closed, pumpDone) + : ILinkLayer(keyManager, getrc, h, sign, est, reneg, timeout, closed, + pumpDone) , permitInbound{allowInbound} { } diff --git a/llarp/iwp/linklayer.hpp b/llarp/iwp/linklayer.hpp index 50d8fc4fe..075f5e9f1 100644 --- a/llarp/iwp/linklayer.hpp +++ b/llarp/iwp/linklayer.hpp @@ -17,7 +17,7 @@ namespace llarp { struct LinkLayer final : public ILinkLayer { - LinkLayer(std::shared_ptr keyManager, GetRCFunc getrc, + LinkLayer(std::shared_ptr< KeyManager > keyManager, GetRCFunc getrc, LinkMessageHandler h, SignBufferFunc sign, SessionEstablishedHandler est, SessionRenegotiateHandler reneg, TimeoutHandler timeout, SessionClosedHandler closed, @@ -29,7 +29,6 @@ namespace llarp NewOutboundSession(const RouterContact &rc, const AddressInfo &ai) override; - const char * Name() const override; diff --git a/llarp/link/factory.hpp b/llarp/link/factory.hpp index 648a9be77..4b4bb43ee 100644 --- a/llarp/link/factory.hpp +++ b/llarp/link/factory.hpp @@ -22,9 +22,9 @@ namespace llarp }; using Factory = std::function< LinkLayer_ptr( - std::shared_ptr, GetRCFunc, LinkMessageHandler, SignBufferFunc, - SessionEstablishedHandler, SessionRenegotiateHandler, TimeoutHandler, - SessionClosedHandler, PumpDoneHandler) >; + std::shared_ptr< KeyManager >, GetRCFunc, LinkMessageHandler, + SignBufferFunc, SessionEstablishedHandler, SessionRenegotiateHandler, + TimeoutHandler, SessionClosedHandler, PumpDoneHandler) >; /// get link type by name string /// if invalid returns eLinkUnspec diff --git a/llarp/link/server.cpp b/llarp/link/server.cpp index 7ade923ae..b3e9ffadc 100644 --- a/llarp/link/server.cpp +++ b/llarp/link/server.cpp @@ -11,8 +11,9 @@ namespace llarp { static constexpr size_t MaxSessionsPerKey = 16; - ILinkLayer::ILinkLayer(std::shared_ptr keyManager, GetRCFunc getrc, - LinkMessageHandler handler, SignBufferFunc signbuf, + ILinkLayer::ILinkLayer(std::shared_ptr< KeyManager > keyManager, + GetRCFunc getrc, LinkMessageHandler handler, + SignBufferFunc signbuf, SessionEstablishedHandler establishedSession, SessionRenegotiateHandler reneg, TimeoutHandler timeout, SessionClosedHandler closed, diff --git a/llarp/link/server.hpp b/llarp/link/server.hpp index 41acb9592..64900e5e5 100644 --- a/llarp/link/server.hpp +++ b/llarp/link/server.hpp @@ -52,7 +52,7 @@ namespace llarp struct ILinkLayer { - ILinkLayer(std::shared_ptr keyManager, GetRCFunc getrc, + ILinkLayer(std::shared_ptr< KeyManager > keyManager, GetRCFunc getrc, LinkMessageHandler handler, SignBufferFunc signFunc, SessionEstablishedHandler sessionEstablish, SessionRenegotiateHandler renegotiate, TimeoutHandler timeout, @@ -179,7 +179,7 @@ namespace llarp SessionClosedHandler SessionClosed; SessionRenegotiateHandler SessionRenegotiate; PumpDoneHandler PumpDone; - std::shared_ptr keyManager; + std::shared_ptr< KeyManager > keyManager; std::shared_ptr< Logic > logic() diff --git a/llarp/messages/relay.cpp b/llarp/messages/relay.cpp index 3c54b078b..3497665a8 100644 --- a/llarp/messages/relay.cpp +++ b/llarp/messages/relay.cpp @@ -42,7 +42,7 @@ namespace llarp if(!BEncodeMaybeReadDictEntry("p", pathid, read, key, buf)) return false; if(!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, key, - buf)) + buf)) return false; if(!BEncodeMaybeReadDictEntry("x", X, read, key, buf)) return false; @@ -98,7 +98,7 @@ namespace llarp if(!BEncodeMaybeReadDictEntry("p", pathid, read, key, buf)) return false; if(!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, key, - buf)) + buf)) return false; if(!BEncodeMaybeReadDictEntry("x", X, read, key, buf)) return false; diff --git a/llarp/messages/relay_commit.cpp b/llarp/messages/relay_commit.cpp index 7d0630fee..f8cc5585c 100644 --- a/llarp/messages/relay_commit.cpp +++ b/llarp/messages/relay_commit.cpp @@ -27,7 +27,7 @@ namespace llarp } bool read = false; if(!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, key, - buf)) + buf)) return false; return read; @@ -135,7 +135,7 @@ namespace llarp return nextRC->BDecode(buffer); } if(!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, *key, - buffer)) + buffer)) return false; if(*key == "w") { diff --git a/llarp/messages/relay_status.cpp b/llarp/messages/relay_status.cpp index 46f4d38ac..7b9c32685 100644 --- a/llarp/messages/relay_status.cpp +++ b/llarp/messages/relay_status.cpp @@ -76,8 +76,8 @@ namespace llarp } else if(key == "v") { - if(!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, key, - buf)) + if(!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, + key, buf)) { return false; } @@ -263,7 +263,7 @@ namespace llarp if(!BEncodeMaybeReadDictInt("s", status, read, *key, buffer)) return false; if(!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, *key, - buffer)) + buffer)) return false; return read; diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp index 90958777f..74777093b 100644 --- a/llarp/router/router.cpp +++ b/llarp/router/router.cpp @@ -49,7 +49,7 @@ namespace llarp , inbound_link_msg_parser(this) , _hiddenServiceContext(this) { - m_keyManager = std::make_shared(); + m_keyManager = std::make_shared< KeyManager >(); // set rational defaults this->ip4addr.sin_family = AF_INET; @@ -195,7 +195,6 @@ namespace llarp bool Router::EnsureIdentity() { - if(whitelistRouters) { #if defined(ANDROID) || defined(IOS) @@ -209,12 +208,12 @@ namespace llarp #endif } - _identity = m_keyManager->getIdentityKey(); + _identity = m_keyManager->getIdentityKey(); _encryption = m_keyManager->getEncryptionKey(); - if (_identity.IsZero()) + if(_identity.IsZero()) return false; - if (_encryption.IsZero()) + if(_encryption.IsZero()) return false; return true; @@ -231,7 +230,7 @@ namespace llarp } _nodedb = nodedb; - if (not m_keyManager->initialize(*conf, true)) + if(not m_keyManager->initialize(*conf, true)) return false; if(!FromConfig(conf)) @@ -524,8 +523,7 @@ namespace llarp util::memFn(&IOutboundSessionMaker::OnConnectTimeout, &_outboundSessionMaker), util::memFn(&AbstractRouter::SessionClosed, this), - util::memFn(&AbstractRouter::PumpLL, this) - ); + util::memFn(&AbstractRouter::PumpLL, this)); const auto &key = std::get< LinksConfig::Interface >(serverConfig); int af = std::get< LinksConfig::AddressFamily >(serverConfig); @@ -1161,8 +1159,7 @@ namespace llarp util::memFn(&IOutboundSessionMaker::OnConnectTimeout, &_outboundSessionMaker), util::memFn(&AbstractRouter::SessionClosed, this), - util::memFn(&AbstractRouter::PumpLL, this) - ); + util::memFn(&AbstractRouter::PumpLL, this)); if(!link) return false; diff --git a/llarp/router/router.hpp b/llarp/router/router.hpp index 1bdddb9b3..f0fe8b944 100644 --- a/llarp/router/router.hpp +++ b/llarp/router/router.hpp @@ -461,7 +461,7 @@ namespace llarp llarp_time_t m_LastStatsReport = 0; - std::shared_ptr m_keyManager; + std::shared_ptr< llarp::KeyManager > m_keyManager; bool ShouldReportStats(llarp_time_t now) const; diff --git a/llarp/service/protocol.cpp b/llarp/service/protocol.cpp index a74e80b85..68d47ad3a 100644 --- a/llarp/service/protocol.cpp +++ b/llarp/service/protocol.cpp @@ -163,8 +163,8 @@ namespace llarp return false; if(!BEncodeMaybeReadDictEntry("T", T, read, key, val)) return false; - if(!BEncodeMaybeVerifyVersion("V", version, LLARP_PROTO_VERSION, read, key, - val)) + if(!BEncodeMaybeVerifyVersion("V", version, LLARP_PROTO_VERSION, read, + key, val)) return false; if(!BEncodeMaybeReadDictEntry("Z", Z, read, key, val)) return false; diff --git a/llarp/util/bencode.cpp b/llarp/util/bencode.cpp index aef39d385..bb40b13c4 100644 --- a/llarp/util/bencode.cpp +++ b/llarp/util/bencode.cpp @@ -139,9 +139,10 @@ bencode_discard(llarp_buffer_t* buf) } bool -bencode_write_uint64_entry(llarp_buffer_t* buff, const void* name, size_t sz, uint64_t i) +bencode_write_uint64_entry(llarp_buffer_t* buff, const void* name, size_t sz, + uint64_t i) { - if (! bencode_write_bytestring(buff, name, sz)) + if(!bencode_write_bytestring(buff, name, sz)) return false; return bencode_write_uint64(buff, i); diff --git a/llarp/util/bencode.h b/llarp/util/bencode.h index 07a612338..4caac8dcf 100644 --- a/llarp/util/bencode.h +++ b/llarp/util/bencode.h @@ -31,7 +31,8 @@ bencode_write_uint64(llarp_buffer_t* buff, uint64_t i); /// Write a dictionary entry with a uint64_t value bool -bencode_write_uint64_entry(llarp_buffer_t* buff, const void* name, size_t sz, uint64_t i); +bencode_write_uint64_entry(llarp_buffer_t* buff, const void* name, size_t sz, + uint64_t i); bool bencode_start_list(llarp_buffer_t* buff); diff --git a/llarp/util/bencode.hpp b/llarp/util/bencode.hpp index 05cd575f4..a3f062ee0 100644 --- a/llarp/util/bencode.hpp +++ b/llarp/util/bencode.hpp @@ -104,8 +104,8 @@ namespace llarp template < typename Item_t > bool BEncodeMaybeVerifyVersion(const char* k, Item_t& item, uint64_t expect, - bool& read, const llarp_buffer_t& key, - llarp_buffer_t* buf) + bool& read, const llarp_buffer_t& key, + llarp_buffer_t* buf) { if(key == k) {