+/* $ModDep: m_spanningtree/resolvers.h m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
+
+/* Create server sockets off a listener. */
+void ServerSocketListener::OnAcceptReady(const std::string &ipconnectedto, int newsock, const std::string &incomingip)
+{
+ bool found = false;
+ char *ip = (char *)incomingip.c_str(); // XXX ugly cast
+
+ found = (std::find(Utils->ValidIPs.begin(), Utils->ValidIPs.end(), ip) != Utils->ValidIPs.end());
+ if (!found)
+ {
+ for (std::vector<std::string>::iterator i = Utils->ValidIPs.begin(); i != Utils->ValidIPs.end(); i++)
+ {
+ if (*i == "*" || irc::sockets::MatchCIDR(ip, *i))
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ this->ServerInstance->SNO->WriteToSnoMask('l', "Server connection from %s denied (no link blocks with that IP address)", ip);
+ ServerInstance->SE->Close(newsock);
+ return;
+ }
+ }
+
+ if (this->GetIOHook())
+ {
+ this->GetIOHook()->OnRawSocketAccept(newsock, incomingip.c_str(), this->bind_port);
+ }
+
+ /* we don't need a pointer to this, creating it stores it in the necessary places */
+ new TreeSocket(this->Utils, this->ServerInstance, newsock, ip, this->GetIOHook());
+ return;
+}