bool AddIOHook(int port, Module* iomod);
bool DelIOHook(int port);
Module* GetIOHook(InspSocket* is);
- bool AddIOHook(InspSocket* is, Module* iomod);
+ bool AddIOHook(Module* iomod, InspSocket* is);
bool DelIOHook(InspSocket* is);
static std::string GetFullProgDir(char** argv, int argc);
}
}
-bool ServerConfig::AddIOHook(InspSocket* is, Module* iomod)
+bool ServerConfig::AddIOHook(Module* iomod, InspSocket* is)
{
if (!GetIOHook(is))
{
culllist = new CullList(ServerInstance);
+
+ ServerInstance->PublishInterface("InspSocketHook", this);
// Not rehashable...because I cba to reduce all the sizes of existing buffers.
inbufsize = ServerInstance->Config->NetBufferSize;
void Implements(char* List)
{
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;
+ List[I_OnRequest] = List[I_OnSyncUserMetaData] = List[I_OnDecodeMetaData] = List[I_OnUnloadModule] = List[I_OnRehash] = List[I_OnWhois] = List[I_OnPostConnect] = 1;
}
+ virtual char* OnRequest(Request* request)
+ {
+ ISHRequest* ISR = (ISHRequest*)request;
+ if (strcmp("IS_NAME", request->GetId()) == 0)
+ {
+ return "gnutls";
+ }
+ else if (strcmp("IS_HOOK", request->GetId()) == 0)
+ {
+ return ServerInstance->Config->AddIOHook((Module*)this, (InspSocket*)ISR->Sock) ? (char*)"OK" : NULL;
+ }
+ else if (strcmp("IS_UNHOOK", request->GetId()) == 0)
+ {
+ return ServerInstance->Config->DelIOHook((InspSocket*)ISR->Sock) ? (char*)"OK" : NULL;
+ }
+ return NULL;
+ }
+
+
virtual void OnRawSocketAccept(int fd, const std::string &ip, int localport)
{
issl_session* session = &sessions[fd];
session->status = ISSL_NONE;
}
- void VerifyCertificate(issl_session* session, userrec* user)
+ void VerifyCertificate(issl_session* session, Extensible* user)
{
unsigned int status;
const gnutls_datum_t* cert_list;
else
{
certinfo->data.insert(std::make_pair("fingerprint",irc::hex(digest, digest_size)));
- user->WriteServ("NOTICE %s :*** Your SSL Certificate fingerprint is: %s", user->nick, irc::hex(digest, digest_size).c_str());
}
/* Beware here we do not check for errors.
: Module::Module(Me)
{
culllist = new CullList(ServerInstance);
+
+ ServerInstance->PublishInterface("InspSocketHook", this);
// Not rehashable...because I cba to reduce all the sizes of existing buffers.
inbufsize = ServerInstance->Config->NetBufferSize;
void Implements(char* List)
{
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;
+ List[I_OnRequest] = List[I_OnSyncUserMetaData] = List[I_OnDecodeMetaData] = List[I_OnUnloadModule] = List[I_OnRehash] = List[I_OnWhois] = List[I_OnPostConnect] = 1;
+ }
+
+ virtual char* OnRequest(Request* request)
+ {
+ ISHRequest* ISR = (ISHRequest*)request;
+ if (strcmp("IS_NAME", request->GetId()) == 0)
+ {
+ return "openssl";
+ }
+ else if (strcmp("IS_HOOK", request->GetId()) == 0)
+ {
+ return ServerInstance->Config->AddIOHook((Module*)this, (InspSocket*)ISR->Sock) ? (char*)"OK" : NULL;
+ }
+ else if (strcmp("IS_UNHOOK", request->GetId()) == 0)
+ {
+ return ServerInstance->Config->DelIOHook((InspSocket*)ISR->Sock) ? (char*)"OK" : NULL;
+ }
+ return NULL;
}
+
virtual void OnRawSocketAccept(int fd, const std::string &ip, int localport)
{
issl_session* session = &sessions[fd];
session->status = ISSL_NONE;
}
- void VerifyCertificate(issl_session* session, userrec* user)
+ void VerifyCertificate(issl_session* session, Extensible* user)
{
X509* cert;
ssl_cert* certinfo = new ssl_cert;
certinfo->data.insert(std::make_pair("fingerprint",irc::hex(md, n)));
}
- user->WriteServ("NOTICE %s :*** Your SSL Certificate fingerprint is: %s", user->nick, irc::hex(md, n).c_str());
-
if ((ASN1_UTCTIME_cmp_time_t(X509_get_notAfter(cert), time(NULL)) == -1) || (ASN1_UTCTIME_cmp_time_t(X509_get_notBefore(cert), time(NULL)) == 0))
{
certinfo->data.insert(std::make_pair("error","Not activated, or expired certificate"));
}
};
+class ISHRequest : public Request
+{
+ public:
+ const InspSocket* Sock;
+
+ ISHRequest(Module* Me, Module* Target, const char* rtype, InspSocket* sock) : Request(Me, Target, rtype), Sock(sock)
+ {
+ }
+};
+
+class InspSocketHookRequest : public ISHRequest
+{
+ public:
+ /** Initialize request as a hook message */
+ InspSocketHookRequest(InspSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_HOOK", is)
+ {
+ }
+};
+
+class InspSocketUnhookRequest : public ISHRequest
+{
+ public:
+ /** Initialize request as an unhook message */
+ InspSocketUnhookRequest(InspSocket* is, Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_UNHOOK", is)
+ {
+ }
+};
+
+class InspSocketNameRequest : public ISHRequest
+{
+ public:
+ /** Initialize request as a get name message */
+ InspSocketNameRequest(Module* Me, Module* Target) : ISHRequest(Me, Target, "IS_NAME", NULL)
+ {
+ }
+};
+
#endif