- Config->ConfValue(Config->config_data, "bind", "port", count, configToken, MAXBUF);
- Config->ConfValue(Config->config_data, "bind", "address", count, Addr, MAXBUF);
- Config->ConfValue(Config->config_data, "bind", "type", count, Type, MAXBUF);
-
- if ((!*Type) || (!strcmp(Type,"clients")))
- {
- irc::portparser portrange(configToken, false);
- long portno = -1;
- while ((portno = portrange.GetToken()))
- {
- if (!HasPort(portno, Addr))
- {
- ports_found++;
- Config->ports[clientportcount+InitialPortCount] = portno;
- if (*Addr == '*')
- *Addr = 0;
-
- strlcpy(Config->addrs[clientportcount+InitialPortCount],Addr,256);
- clientportcount++;
- }
- }
- }
-
- if (!bail)
- {
- int PortCount = clientportcount;
- if (PortCount)
- {
- BoundPortCount = stats->BoundPortCount;
- for (int count = InitialPortCount; count < InitialPortCount + PortCount; count++)
- {
- int fd = OpenTCPSocket(Config->addrs[count]);
- if (fd == ERROR)
- {
- failed_ports.push_back(std::make_pair(Config->addrs[count],Config->ports[count]));
- }
- else
- {
- Config->openSockfd[BoundPortCount] = new ListenSocket(this,fd,client,server,Config->ports[count],Config->addrs[count]);
- if (Config->openSockfd[BoundPortCount]->GetFd() > -1)
- {
- if (!SE->AddFd(Config->openSockfd[BoundPortCount]))
- {
- this->Log(DEFAULT,"ERK! Failed to add listening port to socket engine!");
- shutdown(Config->openSockfd[BoundPortCount]->GetFd(),2);
- close(Config->openSockfd[BoundPortCount]->GetFd());
- delete Config->openSockfd[BoundPortCount];
- failed_ports.push_back(std::make_pair(Config->addrs[count],Config->ports[count]));
- }
- else
- BoundPortCount++;
- }
- }
- }
- return InitialPortCount + BoundPortCount;
- }
- return InitialPortCount;
- }