From bf6724c049ba0f156544c49aab2008d6280e5ffa Mon Sep 17 00:00:00 2001 From: danieldg Date: Sat, 17 Oct 2009 02:14:44 +0000 Subject: Rewrite ConfigReader again git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11879 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/socket.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/socket.cpp') diff --git a/src/socket.cpp b/src/socket.cpp index efe799bfc..c4be23a60 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -105,29 +105,28 @@ int irc::sockets::OpenTCPSocket(const std::string& addr, int socktype) // XXX: it would be VERY nice to genericize this so all listen stuff (server/client) could use the one function. -- w00t int InspIRCd::BindPorts(FailedPortList &failed_ports) { - char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF], Desc[MAXBUF]; int bound = 0; std::vector old_ports(ports.begin(), ports.end()); - for (int count = 0; count < Config->ConfValueEnum("bind"); count++) + for (int count = 0;; count++) { - Config->ConfValue("bind", "port", count, configToken, MAXBUF); - Config->ConfValue("bind", "address", count, Addr, MAXBUF); - Config->ConfValue("bind", "type", count, Type, MAXBUF); - Config->ConfValue("bind", "ssl", count, Desc, MAXBUF); + ConfigTag* tag = ServerInstance->Config->ConfValue("bind", count); + if (!tag) + break; + std::string porttag = tag->getString("port"); + std::string Addr = tag->getString("address"); + std::string Type = tag->getString("type"); + std::string Desc = tag->getString("ssl"); - if (strncmp(Addr, "::ffff:", 7) == 0) + if (strncmp(Addr.c_str(), "::ffff:", 7) == 0) this->Logs->Log("SOCKET",DEFAULT, "Using 4in6 (::ffff:) isn't recommended. You should bind IPv4 addresses directly instead."); - if ((!*Type) || (!strcmp(Type,"clients"))) + if (Type.empty() || Type == "clients") { - irc::portparser portrange(configToken, false); + irc::portparser portrange(porttag, false); int portno = -1; while (0 != (portno = portrange.GetToken())) { - if (*Addr == '*') - *Addr = 0; - irc::sockets::sockaddrs bindspec; irc::sockets::aptosa(Addr, portno, &bindspec); std::string bind_readable = irc::sockets::satouser(&bindspec); @@ -144,7 +143,7 @@ int InspIRCd::BindPorts(FailedPortList &failed_ports) } if (!skip) { - ClientListenSocket *ll = new ClientListenSocket(portno, Addr, "clients", *Desc ? Desc : "plaintext"); + ClientListenSocket *ll = new ClientListenSocket(portno, Addr, "clients", Desc.empty() ? "plaintext" : Desc); if (ll->GetFd() > -1) { bound++; -- cgit v1.2.3