summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-09-07 20:07:50 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-09-07 20:07:50 +0000
commit78c14ffcc5429f4855e2f3a6c822a1d37f9f591a (patch)
treeb40781d00ea751f1728090ca0733e6fe334bbf4b
parentefee3a4d4ec21a32bb46185e1b997947c9d5daf2 (diff)
Merge the second interface for socket hooking into one, so it's all done by Add/Del/GetIOHook now.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10457 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/users.h4
-rw-r--r--src/cull_list.cpp4
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp16
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp10
-rw-r--r--src/modules/m_xmlsocket.cpp8
-rw-r--r--src/usermanager.cpp4
-rw-r--r--src/userprocess.cpp4
-rw-r--r--src/users.cpp5
8 files changed, 25 insertions, 30 deletions
diff --git a/include/users.h b/include/users.h
index 269dfd65f..508681ddd 100644
--- a/include/users.h
+++ b/include/users.h
@@ -463,10 +463,6 @@ class CoreExport User : public connection
bool* AllowedChanModes;
public:
- /** Module responsible for raw i/o
- */
- Module* io;
-
/** Contains a pointer to the connect class a user is on from - this will be NULL for remote connections.
* The pointer is guarenteed to *always* be valid. :)
*/
diff --git a/src/cull_list.cpp b/src/cull_list.cpp
index db07c30ae..bfbe518cb 100644
--- a/src/cull_list.cpp
+++ b/src/cull_list.cpp
@@ -78,11 +78,11 @@ int CullList::Apply()
if (IS_LOCAL(u))
{
- if (u->io)
+ if (u->GetIOHook())
{
try
{
- u->io->OnRawSocketClose(u->GetFd());
+ u->GetIOHook()->OnRawSocketClose(u->GetFd());
}
catch (CoreException& modexcept)
{
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 93fdcc8a1..d7be8b12b 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -81,10 +81,10 @@ class CommandStartTLS : public Command
}
else
{
- if (!user->io)
+ if (!user->GetIOHook())
{
user->WriteNumeric(670, "%s :STARTTLS successful, go ahead with TLS handshake", user->nick.c_str());
- user->io = Caller;
+ user->AddIOHook(Caller);
Caller->OnRawSocketAccept(user->GetFd(), user->GetIPString(), user->GetPort());
}
else
@@ -303,12 +303,12 @@ class ModuleSSLGnuTLS : public Module
{
User* user = (User*)item;
- if (user->io == this)
+ if (user->GetIOHook() == this)
{
// User is using SSL, they're a local user, and they're using one of *our* SSL ports.
// Potentially there could be multiple SSL modules loaded at once on different ports.
ServerInstance->Users->QuitUser(user, "SSL module unloading");
- user->io = NULL;
+ user->DelIOHook();
}
if (user->GetExt("ssl_cert", dummy))
{
@@ -346,10 +346,10 @@ class ModuleSSLGnuTLS : public Module
virtual void OnHookUserIO(User* user, const std::string &targetip)
{
- if (!user->io && isin(targetip,user->GetPort(),listenports))
+ if (!user->GetIOHook() && isin(targetip,user->GetPort(),listenports))
{
/* Hook the user with our module */
- user->io = this;
+ user->AddIOHook(this);
}
}
@@ -646,7 +646,7 @@ class ModuleSSLGnuTLS : public Module
return;
// Bugfix, only send this numeric for *our* SSL users
- if (dest->GetExt("ssl", dummy) || ((IS_LOCAL(dest) && (dest->io == this))))
+ if (dest->GetExt("ssl", dummy) || ((IS_LOCAL(dest) && (dest->GetIOHook() == this))))
{
ServerInstance->SendWhoisLine(source, dest, 320, "%s %s :is using a secure connection", source->nick.c_str(), dest->nick.c_str());
}
@@ -929,7 +929,7 @@ class ModuleSSLGnuTLS : public Module
if (data->user->Shrink("tls"))
{
/* Not in our spec?!?! */
- data->user->io = this;
+ data->user->AddIOHook(this);
OnRawSocketAccept(data->user->GetFd(), data->user->GetIPString(),
data->user->GetPort());
}
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 63159c519..d234cb6e5 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -167,10 +167,10 @@ class ModuleSSLOpenSSL : public Module
virtual void OnHookUserIO(User* user, const std::string &targetip)
{
- if (!user->io && isin(targetip,user->GetPort(), listenports))
+ if (!user->GetIOHook() && isin(targetip,user->GetPort(), listenports))
{
/* Hook the user with our module */
- user->io = this;
+ user->AddIOHook(this);
}
}
@@ -321,12 +321,12 @@ class ModuleSSLOpenSSL : public Module
{
User* user = (User*)item;
- if (user->io == this)
+ if (user->GetIOHook() == this)
{
// User is using SSL, they're a local user, and they're using one of *our* SSL ports.
// Potentially there could be multiple SSL modules loaded at once on different ports.
ServerInstance->Users->QuitUser(user, "SSL module unloading");
- user->io = NULL;
+ user->DelIOHook()
}
if (user->GetExt("ssl_cert", dummy))
{
@@ -687,7 +687,7 @@ class ModuleSSLOpenSSL : public Module
return;
// Bugfix, only send this numeric for *our* SSL users
- if (dest->GetExt("ssl", dummy) || ((IS_LOCAL(dest) && dest->io == this)))
+ if (dest->GetExt("ssl", dummy) || ((IS_LOCAL(dest) && dest->GetIOHook() == this)))
{
ServerInstance->SendWhoisLine(source, dest, 320, "%s %s :is using a secure connection", source->nick.c_str(), dest->nick.c_str());
}
diff --git a/src/modules/m_xmlsocket.cpp b/src/modules/m_xmlsocket.cpp
index cc14dee97..a60512d30 100644
--- a/src/modules/m_xmlsocket.cpp
+++ b/src/modules/m_xmlsocket.cpp
@@ -102,8 +102,8 @@ class ModuleXMLSocket : public Module
if(target_type == TYPE_USER)
{
User* user = (User*)item;
- if(user->io == this)
- user->io = NULL;
+ if(user->GetIOHook() == this)
+ user->DelIOHook();
}
}
@@ -114,10 +114,10 @@ class ModuleXMLSocket : public Module
virtual void OnHookUserIO(User* user, const std::string &targetip)
{
- if (!user->io && isin(targetip,user->GetPort(),listenports))
+ if (!user->GetIOHook() && isin(targetip,user->GetPort(),listenports))
{
/* Hook the user with our module */
- user->io = this;
+ user->AddIOHook(this);
}
}
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index 35d455c45..e5fdb7adc 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -49,11 +49,11 @@ void UserManager::AddUser(InspIRCd* Instance, int socket, int port, bool iscache
/* Give each of the modules an attempt to hook the user for I/O */
FOREACH_MOD_I(Instance, I_OnHookUserIO, OnHookUserIO(New, targetip));
- if (New->io)
+ if (New->GetIOHook())
{
try
{
- New->io->OnRawSocketAccept(socket, ipaddr, port);
+ New->GetIOHook()->OnRawSocketAccept(socket, ipaddr, port);
}
catch (CoreException& modexcept)
{
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index bdd7e7e8a..b179622aa 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -45,14 +45,14 @@ void ProcessUserHandler::Call(User* cu)
char* ReadBuffer = Server->GetReadBuffer();
- if (cu->io)
+ if (cu->GetIOHook())
{
int result2 = 0;
int MOD_RESULT = 0;
try
{
- MOD_RESULT = cu->io->OnRawSocketRead(cu->GetFd(), ReadBuffer, Server->Config->NetBufferSize, result2);
+ MOD_RESULT = cu->GetIOHook()->OnRawSocketRead(cu->GetFd(), ReadBuffer, Server->Config->NetBufferSize, result2);
}
catch (CoreException& modexcept)
{
diff --git a/src/users.cpp b/src/users.cpp
index 5c06e8d08..01a973dea 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -216,7 +216,6 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance
Visibility = NULL;
ip = NULL;
MyClass = NULL;
- io = NULL;
AllowedUserModes = NULL;
AllowedChanModes = NULL;
AllowedOperCommands = NULL;
@@ -1280,14 +1279,14 @@ void User::Write(std::string text)
return;
}
- if (this->io)
+ if (this->GetIOHook())
{
/* XXX: The lack of buffering here is NOT a bug, modules implementing this interface have to
* implement their own buffering mechanisms
*/
try
{
- this->io->OnRawSocketWrite(this->fd, text.data(), text.length());
+ this->GetIOHook()->OnRawSocketWrite(this->fd, text.data(), text.length());
}
catch (CoreException& modexcept)
{