diff options
-rw-r--r-- | include/dns.h | 4 | ||||
-rw-r--r-- | src/dns.cpp | 5 | ||||
-rw-r--r-- | src/inspsocket.cpp | 50 | ||||
-rw-r--r-- | src/modules/extra/m_pgsql.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_cgiirc.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_ident.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 6 | ||||
-rw-r--r-- | src/socket.cpp | 15 | ||||
-rw-r--r-- | src/users.cpp | 10 |
10 files changed, 18 insertions, 91 deletions
diff --git a/include/dns.h b/include/dns.h index 3deb7d3c8..e5f721770 100644 --- a/include/dns.h +++ b/include/dns.h @@ -167,12 +167,10 @@ enum QueryType #ifdef IPV6 const QueryType DNS_QUERY_FORWARD = DNS_QUERY_AAAA; -const QueryType DNS_QUERY_REVERSE = DNS_QUERY_PTR; #else const QueryType DNS_QUERY_FORWARD = DNS_QUERY_A; -const QueryType DNS_QUERY_REVERSE = DNS_QUERY_PTR; #endif - +const QueryType DNS_QUERY_REVERSE = DNS_QUERY_PTR; /** * Used internally to force PTR lookups to use a certain protocol scemantics, * e.g. x.x.x.x.in-addr.arpa for v4, and *.ip6.arpa for v6. diff --git a/src/dns.cpp b/src/dns.cpp index 49cfa3f1f..99b156bf1 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -651,14 +651,11 @@ DNSResult DNS::GetResult() port_from = ntohs(((sockaddr_in6*)from)->sin6_port); } else +#endif { ipaddr_from = inet_ntoa(((sockaddr_in*)from)->sin_addr); port_from = ntohs(((sockaddr_in*)from)->sin_port); } -#else - ipaddr_from = inet_ntoa(((sockaddr_in*)from)->sin_addr); - port_from = ntohs(((sockaddr_in*)from)->sin_port); -#endif delete[] from; diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 2e8d6fd68..80e916c00 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -107,16 +107,12 @@ InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool ipvalid = false; } else +#endif { in_addr n; if (inet_aton(host,&n) < 1) ipvalid = false; } -#else - in_addr n; - if (inet_aton(host,&n) < 1) - ipvalid = false; -#endif if (!ipvalid) { this->Instance->Log(DEBUG,"BUG: Hostname passed to InspSocket, rather than an IP address!"); @@ -203,6 +199,7 @@ bool InspSocket::BindAddr(const std::string &ip) } } else +#endif { in_addr n; if (inet_aton(IP.c_str(), &n) > 0) @@ -218,21 +215,6 @@ bool InspSocket::BindAddr(const std::string &ip) continue; } } -#else - in_addr n; - if (insp_aton(IP.c_str(), &n) > 0) - { - ((sockaddr_in*)s)->sin_addr = n; - ((sockaddr_in*)s)->sin_port = 0; - ((sockaddr_in*)s)->sin_family = AF_INET; - } - else - { - delete[] s; - j++; - continue; - } -#endif if (bind(this->fd, s, size) < 0) { @@ -274,6 +256,7 @@ bool InspSocket::DoConnect() } } else +#endif { this->fd = socket(AF_INET, SOCK_STREAM, 0); if (this->fd > -1) @@ -285,17 +268,6 @@ bool InspSocket::DoConnect() } } } -#else - this->fd = socket(AF_INET, SOCK_STREAM, 0); - if (this->fd > -1) - { - if (!this->BindAddr(this->cbindip)) - { - delete[] addr; - return false; - } - } -#endif if (this->fd == -1) { @@ -318,6 +290,7 @@ bool InspSocket::DoConnect() } } else +#endif { in_addr addy; if (inet_aton(this->host, &addy) > 0) @@ -327,15 +300,6 @@ bool InspSocket::DoConnect() ((sockaddr_in*)addr)->sin_port = htons(this->port); } } -#else - in_addr addy; - if (inet_aton(this->host, &addy) > 0) - { - ((sockaddr_in*)addr)->sin_family = AF_INET; - ((sockaddr_in*)addr)->sin_addr = addy; - ((sockaddr_in*)addr)->sin_port = htons(this->port); - } -#endif #ifndef WIN32 int flags = fcntl(this->fd, F_GETFL, 0); fcntl(this->fd, F_SETFL, flags | O_NONBLOCK); @@ -661,12 +625,8 @@ bool InspSocket::Poll() 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 + recvip = inet_ntoa(((sockaddr_in*)client)->sin_addr); this->OnIncomingConnection(incoming, (char*)recvip.c_str()); if (this->IsIOHooked) diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 9ec369859..57c049f30 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -817,14 +817,11 @@ class ModulePgSQL : public Module ipvalid = inet_pton(AF_INET6, host.host.c_str(), &blargle); } else +#endif { in_addr blargle; ipvalid = inet_aton(host.host.c_str(), &blargle); } -#else - in_addr blargle; - ipvalid = inet_aton(host.host.c_str(), &blargle); -#endif if(ipvalid > 0) { diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index a866d938d..3ab2f50be 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -385,10 +385,8 @@ public: if (user->GetProtocolFamily() == AF_INET6) inet_pton(AF_INET6, newip, &((sockaddr_in6*)user->ip)->sin6_addr); else - inet_aton(newip, &((sockaddr_in*)user->ip)->sin_addr); -#else - inet_aton(newip, &((sockaddr_in*)user->ip)->sin_addr); #endif + inet_aton(newip, &((sockaddr_in*)user->ip)->sin_addr); try { diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 00d7524c7..eb9f3f365 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -163,10 +163,8 @@ class RFC1413 : public InspSocket if (this->u->GetProtocolFamily() == AF_INET6) snprintf(ident_request,127,"%d,%d\r\n",ntohs(((sockaddr_in6*)sock_them)->sin6_port),ntohs(((sockaddr_in6*)sock_us)->sin6_port)); else - snprintf(ident_request,127,"%d,%d\r\n",ntohs(((sockaddr_in*)sock_them)->sin_port),ntohs(((sockaddr_in*)sock_us)->sin_port)); -#else - snprintf(ident_request,127,"%d,%d\r\n",ntohs(((sockaddr_in*)sock_them)->sin_port),ntohs(((sockaddr_in*)sock_us)->sin_port)); #endif + snprintf(ident_request,127,"%d,%d\r\n",ntohs(((sockaddr_in*)sock_them)->sin_port),ntohs(((sockaddr_in*)sock_us)->sin_port)); this->Write(ident_request); delete[] sock_us; delete[] sock_them; diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 0fddd6e0e..a134d95e1 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -510,16 +510,12 @@ void ModuleSpanningTree::ConnectServer(Link* x) ipvalid = false; } else +#endif { in_addr n; if (inet_aton(x->IPAddr.c_str(),&n) < 1) ipvalid = false; } -#else - in_addr n; - if (inet_aton(x->IPAddr.c_str(),&n) < 1) - ipvalid = false; -#endif /* Do we already have an IP? If so, no need to resolve it. */ if (ipvalid) diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 854e38e76..6c4001503 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -428,16 +428,12 @@ void SpanningTreeUtilities::RefreshIPCache() ipvalid = false; } else +#endif { in_addr n; if (inet_aton(L->IPAddr.c_str(),&n) < 1) ipvalid = false; } -#else - in_addr n; - if (inet_aton(L->IPAddr.c_str(),&n) < 1) - ipvalid = false; -#endif if (!ipvalid) { try diff --git a/src/socket.cpp b/src/socket.cpp index 132846b3c..68b93a4b4 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -47,10 +47,8 @@ ListenSocket::ListenSocket(InspIRCd* Instance, int port, char* addr) : ServerIns if ((!*addr) || (strchr(addr,':'))) this->family = AF_INET6; else - this->family = AF_INET; -#else - this->family = AF_INET; #endif + this->family = AF_INET; Instance->SE->AddFd(this); } } @@ -80,14 +78,11 @@ void ListenSocket::HandleEvent(EventType et, int errornum) length = sizeof(sockaddr_in6); } else +#endif { uslen = sizeof(sockaddr_in); length = sizeof(sockaddr_in); } -#else - uslen = sizeof(sockaddr_in); - length = sizeof(sockaddr_in); -#endif /* * This loop may make you wonder 'why' - simple reason. If we just sit here accept()ing until the @@ -112,14 +107,12 @@ void ListenSocket::HandleEvent(EventType et, int errornum) in_port = ntohs(((sockaddr_in6*)sock_us)->sin6_port); } else +#endif { inet_ntop(AF_INET, &((const sockaddr_in*)client)->sin_addr, buf, sizeof(buf)); in_port = ntohs(((sockaddr_in*)sock_us)->sin_port); } -#else - inet_ntop(AF_INET, &((const sockaddr_in*)client)->sin_addr, buf, sizeof(buf)); - in_port = ntohs(((sockaddr_in*)sock_us)->sin_port); -#endif + NonBlocking(incomingSockfd); if (ServerInstance->Config->GetIOHook(in_port)) { diff --git a/src/users.cpp b/src/users.cpp index 906a2e9c3..77642ba04 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -183,14 +183,10 @@ void UserResolver::OnLookupComplete(const std::string &result, unsigned int ttl, bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, (!strncmp(ip, "0::ffff:", 8) ? DNS_QUERY_A : DNS_QUERY_AAAA), cached); } else - { /* IPV4 lookup (mixed protocol mode) */ - bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, DNS_QUERY_A, cached); - } -#else +#endif /* IPV4 lookup (ipv4 only mode) */ bound_user->res_forward = new UserResolver(this->ServerInstance, this->bound_user, result, DNS_QUERY_A, cached); -#endif this->ServerInstance->AddResolver(bound_user->res_forward, cached); } } @@ -864,10 +860,8 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, if (socketfamily == AF_INET6) inet_ntop(AF_INET6, &((const sockaddr_in6*)ip)->sin6_addr, ipaddr, sizeof(ipaddr)); else - inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr)); -#else - inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr)); #endif + inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr)); userrec* New; int j = 0; |