diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/configreader.cpp | 3 | ||||
-rw-r--r-- | src/inspircd.cpp | 11 | ||||
-rw-r--r-- | src/socket.cpp | 7 |
3 files changed, 17 insertions, 4 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index b8719fcd8..b0f2d6872 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -772,7 +772,8 @@ void ServerConfig::Read(bool bail, userrec* user) if (!bail) { int found_ports; - ServerInstance->stats->BoundPortCount = ServerInstance->BindPorts(false, found_ports); + FailedPortList pl; + ServerInstance->stats->BoundPortCount = ServerInstance->BindPorts(false, found_ports, pl); if (!removed_modules.empty()) for (std::vector<std::string>::iterator removing = removed_modules.begin(); removing != removed_modules.end(); removing++) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 9521f1b22..f182f7169 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -183,6 +183,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : ModCount(-1), duration_m(60), duration_h(60*60), duration_d(60*60*24), duration_w(60*60*24*7), duration_y(60*60*24*365) { int found_ports = 0; + FailedPortList pl; modules.resize(255); factory.resize(255); @@ -260,7 +261,7 @@ InspIRCd::InspIRCd(int argc, char** argv) this->AddServerName(Config->ServerName); CheckDie(); InitializeDisabledCommands(Config->DisabledCommands, this); - stats->BoundPortCount = BindPorts(true, found_ports); + stats->BoundPortCount = BindPorts(true, found_ports, pl); for(int t = 0; t < 255; t++) Config->global_implementation[t] = 0; @@ -299,7 +300,13 @@ InspIRCd::InspIRCd(int argc, char** argv) if (stats->BoundPortCount != (unsigned int)found_ports) { - printf("\nWARNING: Not all your client ports could be bound --\n starting anyway with %ld of %d client ports bound.\n", stats->BoundPortCount, found_ports); + printf("\nWARNING: Not all your client ports could be bound --\nstarting anyway with %ld of %d client ports bound.\n\n", stats->BoundPortCount, found_ports); + printf("The following %lu port%s failed to bind:\n", found_ports - stats->BoundPortCount, found_ports - stats->BoundPortCount != 1 ? "s" : ""); + int j = 1; + for (FailedPortList::iterator i = pl.begin(); i != pl.end(); i++, j++) + { + printf("%d.\tIP: %s\tPort: %lu\n", j, i->first.empty() ? "<all>" : i->first.c_str(), (unsigned long)i->second); + } } /* Add the listening sockets used for client inbound connections diff --git a/src/socket.cpp b/src/socket.cpp index 284e51a4a..d5ad7b4ce 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -389,7 +389,7 @@ bool InspIRCd::HasPort(int port, char* addr) } /* XXX: Probably belongs in class InspIRCd */ -int InspIRCd::BindPorts(bool bail, int &ports_found) +int InspIRCd::BindPorts(bool bail, int &ports_found, FailedPortList &failed_ports) { char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF]; insp_sockaddr client, server; @@ -439,6 +439,7 @@ int InspIRCd::BindPorts(bool bail, int &ports_found) if (fd == ERROR) { this->Log(DEBUG,"Bad fd %d binding port [%s:%d]",fd,Config->addrs[count],Config->ports[count]); + failed_ports.push_back(std::make_pair(Config->addrs[count],Config->ports[count])); } else { @@ -451,6 +452,7 @@ int InspIRCd::BindPorts(bool bail, int &ports_found) 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++; @@ -475,6 +477,7 @@ int InspIRCd::BindPorts(bool bail, int &ports_found) if (fd == ERROR) { this->Log(DEBUG,"Bad fd %d binding port [%s:%d]",fd,Config->addrs[count],Config->ports[count]); + failed_ports.push_back(std::make_pair(Config->addrs[count],Config->ports[count])); } else { @@ -483,6 +486,8 @@ int InspIRCd::BindPorts(bool bail, int &ports_found) { BoundPortCount++; } + else + failed_ports.push_back(std::make_pair(Config->addrs[count],Config->ports[count])); } } return BoundPortCount; |