aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Sadie Powell2020-07-20 07:21:16 +0100
committerGravatar Sadie Powell2020-07-20 07:21:16 +0100
commitf73d200a1ea56aa68ee5df3935eb83e04537c59f (patch)
tree5d539d81502968cdf3b1aba249bd5dd4ecffff45
parentMerge branch 'insp3' into master. (diff)
Split OnSetEndPoint into two events.
-rw-r--r--include/inspsocket.h13
-rw-r--r--include/users.h3
-rw-r--r--src/inspsocket.cpp5
-rw-r--r--src/modules/m_haproxy.cpp2
-rw-r--r--src/users.cpp11
5 files changed, 20 insertions, 14 deletions
diff --git a/include/inspsocket.h b/include/inspsocket.h
index aa6194794..623720f97 100644
--- a/include/inspsocket.h
+++ b/include/inspsocket.h
@@ -323,12 +323,17 @@ class CoreExport StreamSocket : public EventHandler
/** Called when the socket gets an error from socket engine or IO hook */
virtual void OnError(BufferedSocketError e) = 0;
- /** Called when the endpoint addresses are changed.
- * @param local The new local endpoint.
- * @param remote The new remote endpoint.
+ /** Called when the local endpoint address is changed.
+ * @param ep The new local endpoint.
* @return true if the connection is still open, false if it has been closed
*/
- virtual bool OnSetEndPoint(const irc::sockets::sockaddrs& local, const irc::sockets::sockaddrs& remote);
+ virtual bool OnSetLocalEndPoint(const irc::sockets::sockaddrs& ep) { return true; }
+
+ /** Called when the remote endpoint address is changed.
+ * @param ep The new remote endpoint.
+ * @return true if the connection is still open, false if it has been closed
+ */
+ virtual bool OnSetRemoteEndPoint(const irc::sockets::sockaddrs& ep) { return true; }
/** Send the given data out the socket, either now or when writes unblock
*/
diff --git a/include/users.h b/include/users.h
index eeec0295a..d336478fc 100644
--- a/include/users.h
+++ b/include/users.h
@@ -634,7 +634,8 @@ class CoreExport UserIOHandler : public StreamSocket
{
}
void OnDataReady() override;
- bool OnSetEndPoint(const irc::sockets::sockaddrs& local, const irc::sockets::sockaddrs& remote) override;
+ bool OnSetLocalEndPoint(const irc::sockets::sockaddrs& ep) override;
+ bool OnSetRemoteEndPoint(const irc::sockets::sockaddrs& ep) override;
void OnError(BufferedSocketError error) override;
/** Adds to the user's write buffer.
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index f91a5b053..9de4a47da 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -362,11 +362,6 @@ void StreamSocket::FlushSendQ(SendQueue& sq)
}
}
-bool StreamSocket::OnSetEndPoint(const irc::sockets::sockaddrs& local, const irc::sockets::sockaddrs& remote)
-{
- return false;
-}
-
void StreamSocket::WriteData(const std::string &data)
{
if (!HasFd())
diff --git a/src/modules/m_haproxy.cpp b/src/modules/m_haproxy.cpp
index 3bb78ef7a..03c2a4745 100644
--- a/src/modules/m_haproxy.cpp
+++ b/src/modules/m_haproxy.cpp
@@ -272,7 +272,7 @@ class HAProxyHook : public IOHookMiddle
break;
}
- if (!sock->OnSetEndPoint(server, client))
+ if (!sock->OnSetLocalEndPoint(server) || !sock->OnSetRemoteEndPoint(client))
return -1;
// Parse any available TLVs.
diff --git a/src/users.cpp b/src/users.cpp
index 85685ec90..04c13ed84 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -332,10 +332,15 @@ void UserIOHandler::SwapInternals(UserIOHandler& other)
std::swap(checked_until, other.checked_until);
}
-bool UserIOHandler::OnSetEndPoint(const irc::sockets::sockaddrs& server, const irc::sockets::sockaddrs& client)
+bool UserIOHandler::OnSetLocalEndPoint(const irc::sockets::sockaddrs& ep)
{
- memcpy(&user->server_sa, &server, sizeof(irc::sockets::sockaddrs));
- user->SetClientIP(client);
+ memcpy(&user->server_sa, &ep, sizeof(irc::sockets::sockaddrs));
+ return true;
+}
+
+bool UserIOHandler::OnSetRemoteEndPoint(const irc::sockets::sockaddrs& ep)
+{
+ user->SetClientIP(ep);
return !user->quitting;
}