summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-09 18:49:36 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-09 18:49:36 +0000
commit768171fef96d3e0b74b5c750e7887fc20b48331c (patch)
tree449ee5c880d1261fbba98893c7860910249a8adb /src/modules
parentdfa831752c950f16872f3c485f94d408866a2e15 (diff)
Add OnRawSocketConnect, we've not had it till now because we've not needed it :)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5887 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp21
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp27
2 files changed, 46 insertions, 2 deletions
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index dfa22f2f2..d0e2e7df2 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -252,7 +252,7 @@ class ModuleSSLGnuTLS : public Module
void Implements(char* List)
{
- List[I_OnRawSocketAccept] = List[I_OnRawSocketClose] = List[I_OnRawSocketRead] = List[I_OnRawSocketWrite] = List[I_OnCleanup] = 1;
+ List[I_OnRawSocketConnect] = List[I_OnRawSocketAccept] = List[I_OnRawSocketClose] = List[I_OnRawSocketRead] = List[I_OnRawSocketWrite] = List[I_OnCleanup] = 1;
List[I_OnSyncUserMetaData] = List[I_OnDecodeMetaData] = List[I_OnUnloadModule] = List[I_OnRehash] = List[I_OnWhois] = List[I_OnPostConnect] = 1;
}
@@ -284,6 +284,25 @@ class ModuleSSLGnuTLS : public Module
Handshake(session);
}
+ virtual void OnRawSocketConnect(int fd)
+ {
+ issl_session* session = &sessions[fd];
+
+ session->fd = fd;
+ session->inbuf = new char[inbufsize];
+ session->inbufoffset = 0;
+
+ gnutls_init(&session->sess, GNUTLS_SERVER);
+
+ gnutls_set_default_priority(session->sess); // Avoid calling all the priority functions, defaults are adequate.
+ gnutls_credentials_set(session->sess, GNUTLS_CRD_CERTIFICATE, x509_cred);
+ gnutls_dh_set_prime_bits(session->sess, dh_bits);
+
+ gnutls_transport_set_ptr(session->sess, (gnutls_transport_ptr_t) fd); // Give gnutls the fd for the socket.
+
+ Handshake(session);
+ }
+
virtual void OnRawSocketClose(int fd)
{
ServerInstance->Log(DEBUG, "OnRawSocketClose: %d", fd);
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index 760b4c35a..bd0763f4c 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -287,7 +287,7 @@ class ModuleSSLOpenSSL : public Module
void Implements(char* List)
{
- List[I_OnRawSocketAccept] = List[I_OnRawSocketClose] = List[I_OnRawSocketRead] = List[I_OnRawSocketWrite] = List[I_OnCleanup] = 1;
+ List[I_OnRawSocketConnect] = List[I_OnRawSocketAccept] = List[I_OnRawSocketClose] = List[I_OnRawSocketRead] = List[I_OnRawSocketWrite] = List[I_OnCleanup] = 1;
List[I_OnSyncUserMetaData] = List[I_OnDecodeMetaData] = List[I_OnUnloadModule] = List[I_OnRehash] = List[I_OnWhois] = List[I_OnPostConnect] = 1;
}
@@ -316,6 +316,31 @@ class ModuleSSLOpenSSL : public Module
Handshake(session);
}
+ virtual void OnRawSocketConnect(int fd)
+ {
+ issl_session* session = &sessions[fd];
+
+ session->fd = fd;
+ session->inbuf = new char[inbufsize];
+ session->inbufoffset = 0;
+ session->sess = SSL_new(ctx);
+ session->status = ISSL_NONE;
+
+ if (session->sess == NULL)
+ {
+ ServerInstance->Log(DEBUG, "m_ssl.so: Couldn't create SSL object: %s", get_error());
+ return;
+ }
+
+ if (SSL_set_fd(session->sess, fd) == 0)
+ {
+ ServerInstance->Log(DEBUG, "m_ssl.so: Couldn't set fd for SSL object: %s", get_error());
+ return;
+ }
+
+ Handshake(session);
+ }
+
virtual void OnRawSocketClose(int fd)
{
ServerInstance->Log(DEBUG, "m_ssl_openssl.so: OnRawSocketClose: %d", fd);