From a488fe52f613f72412505237549927e924d711b8 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sat, 24 Jul 2021 18:54:53 +0100 Subject: Change ForEachNeighbour to return the already sent id. --- src/users.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/users.cpp b/src/users.cpp index 850909e47..55b659cc4 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -921,7 +921,7 @@ void User::WriteCommonRaw(ClientProtocol::Event& protoev, bool include_self) ForEachNeighbor(handler, include_self); } -void User::ForEachNeighbor(ForEachNeighborHandler& handler, bool include_self) +already_sent_t User::ForEachNeighbor(ForEachNeighborHandler& handler, bool include_self) { // The basic logic for visiting the neighbors of a user is to iterate the channel list of the user // and visit all users on those channels. Because two users may share more than one common channel, @@ -972,6 +972,8 @@ void User::ForEachNeighbor(ForEachNeighborHandler& handler, bool include_self) } } } + + return newid; } void User::WriteRemoteNumeric(const Numeric::Numeric& numeric) -- cgit v1.3.1-10-gc9f91 From 0651f91bda6e770dadfe68613d28966d3ee14b95 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 7 Jul 2021 14:19:55 +0100 Subject: Fix a race condition with hostname lookups when using haproxy. If a user's origin has been changed before the first DNS lookup returns then the result of the lookup for that origin may overwrite their host. Closes #1914. --- src/coremods/core_hostname_lookup.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/coremods/core_hostname_lookup.cpp b/src/coremods/core_hostname_lookup.cpp index 4195e5a78..4c4ab95dc 100644 --- a/src/coremods/core_hostname_lookup.cpp +++ b/src/coremods/core_hostname_lookup.cpp @@ -33,6 +33,9 @@ namespace class UserResolver : public DNS::Request { private: + /** The socket address that the user we are looking up is connected from. */ + const irc::sockets::sockaddrs sa; + /** UUID we are looking up */ const std::string uuid; @@ -57,6 +60,7 @@ class UserResolver : public DNS::Request */ UserResolver(DNS::Manager* mgr, Module* me, LocalUser* user, const std::string& to_resolve, DNS::QueryType qt) : DNS::Request(mgr, me, to_resolve, qt) + , sa(user->client_sa) , uuid(user->uuid) { } @@ -68,11 +72,8 @@ class UserResolver : public DNS::Request void OnLookupComplete(const DNS::Query* r) CXX11_OVERRIDE { LocalUser* bound_user = IS_LOCAL(ServerInstance->FindUUID(uuid)); - if (!bound_user) - { - ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Resolution finished for user '%s' who is gone", uuid.c_str()); + if (!bound_user || bound_user->client_sa != sa) return; - } const DNS::ResourceRecord* ans_record = r->FindAnswerOfType(this->question.type); if (ans_record == NULL) @@ -145,7 +146,7 @@ class UserResolver : public DNS::Request void OnError(const DNS::Query* query) CXX11_OVERRIDE { LocalUser* bound_user = IS_LOCAL(ServerInstance->FindUUID(uuid)); - if (bound_user) + if (bound_user && bound_user->client_sa == sa) HandleError(bound_user, "Could not resolve your hostname: " + this->manager->GetErrorStr(query->error)); } }; -- cgit v1.3.1-10-gc9f91