- length = sizeof (client);
- incoming = accept (this->fd, (sockaddr*)&client,&length);
+ {
+ sockaddr* client = new sockaddr[2];
+ length = sizeof (sockaddr_in);
+ std::string recvip;
+#ifdef IPV6
+ if ((!*this->host) || strchr(this->host, ':'))
+ length = sizeof(sockaddr_in6);
+#endif
+ incoming = accept (this->fd, client, &length);
+#ifdef IPV6
+ if ((!*this->host) || strchr(this->host, ':'))
+ {
+ char buf[1024];
+ recvip = inet_ntop(AF_INET6, &((sockaddr_in6*)client)->sin6_addr, buf, sizeof(buf));
+ }
+ else
+ {
+ recvip = inet_ntoa(((sockaddr_in*)client)->sin_addr);
+ }
+#else
+ recvip = inet_ntoa(((sockaddr_in*)client)->sin_addr);
+#endif
+ this->OnIncomingConnection(incoming, (char*)recvip.c_str());
+
+ if (this->IsIOHooked)
+ {
+ try
+ {
+ Instance->Config->GetIOHook(this)->OnRawSocketAccept(incoming, recvip.c_str(), this->port);
+ }
+ catch (CoreException& modexcept)
+ {
+ Instance->Log(DEBUG,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
+ }
+ }
+