+/* $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(int newsock)
+{
+ bool found = false;
+ int port;
+ std::string incomingip;
+ irc::sockets::satoap(&client, incomingip, port);
+ char *ip = const_cast<char*>(incomingip.c_str());
+
+ 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)
+ {
+ ServerInstance->SNO->WriteToSnoMask('l', "Server connection from %s denied (no link blocks with that IP address)", ip);
+ ServerInstance->SE->Close(newsock);
+ return;
+ }
+ }
+
+ /* we don't need to do anything with the pointer, creating it stores it in the necessary places */
+ TreeSocket* ts = new TreeSocket(Utils, newsock, ip, NULL, Hook);
+
+ if (Hook)
+ Hook->OnStreamSocketAccept(ts, &client, &server);
+
+ return;
+}