- 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);
- 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++;
- this->Log(DEBUG,"NEW binding %s:%d [%s] from config",Addr, portno, Type);
- }
- }
- }
-
- if (!bail)
- {
- int PortCount = clientportcount;
- if (PortCount)
- {
- BoundPortCount = stats->BoundPortCount;
- for (int count = InitialPortCount; count < InitialPortCount + PortCount; count++)
- {
- int fd = OpenTCPSocket();
- if (fd == ERROR)
- {
- this->Log(DEBUG,"Bad fd %d binding port [%s:%d]",fd,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];
- }
- else
- BoundPortCount++;
- }
- }
- }
- return InitialPortCount + BoundPortCount;
- }
- else
- {
- this->Log(DEBUG,"There is nothing new to bind!");
- }
- return InitialPortCount;
- }