X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fmodules%2Fextra%2Fm_mysql.cpp;h=7f2b96227177b4786cacc98337e6ddd8ea94b23a;hb=4488e477136ea3daa60a744bac272cc37a604136;hp=035d0b49876a416286589be82912280f9e42017f;hpb=196b1b09d32130c1806108904ded406844fd90e0;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 035d0b498..7f2b96227 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -660,14 +660,18 @@ void* DispatcherThread(void* arg); class Notifier : public InspSocket { - sockaddr_in sock_us; + insp_sockaddr sock_us; socklen_t uslen; Server* Srv; public: /* Create a socket on a random port. Let the tcp stack allocate us an available port */ +#ifdef IPV6 + Notifier(Server* S) : InspSocket("::1", 0, true, 3000), Srv(S) +#else Notifier(Server* S) : InspSocket("127.0.0.1", 0, true, 3000), Srv(S) +#endif { uslen = sizeof(sock_us); if (getsockname(this->fd,(sockaddr*)&sock_us,&uslen)) @@ -684,7 +688,11 @@ class Notifier : public InspSocket /* Using getsockname and ntohs, we can determine which port number we were allocated */ int GetPort() { +#ifdef IPV6 + return ntohs(sock_us.sin6_port); +#else return ntohs(sock_us.sin_port); +#endif } virtual int OnIncomingConnection(int newsock, char* ip) @@ -832,7 +840,7 @@ void* DispatcherThread(void* arg) /* Connect back to the Notifier */ - if ((QueueFD = socket(AF_INET, SOCK_STREAM, 0)) == -1) + if ((QueueFD = socket(AF_FAMILY, SOCK_STREAM, 0)) == -1) { /* crap, we're out of sockets... */ log(DEBUG,"QueueFD cant be created"); @@ -841,12 +849,19 @@ void* DispatcherThread(void* arg) log(DEBUG,"Initialize QueueFD to %d",QueueFD); - sockaddr_in addr; - in_addr ia; - inet_aton("127.0.0.1", &ia); - addr.sin_family = AF_INET; + insp_sockaddr addr; + +#ifdef IPV6 + insp_aton("::1", &addr.sin6_addr); + addr.sin6_family = AF_FAMILY; + addr.sin6_port = htons(MessagePipe->GetPort()); +#else + insp_inaddr ia; + insp_aton("127.0.0.1", &ia); + addr.sin_family = AF_FAMILY; addr.sin_addr = ia; addr.sin_port = htons(MessagePipe->GetPort()); +#endif if (connect(QueueFD, (sockaddr*)&addr,sizeof(addr)) == -1) {