From 50eebfeac8ebe501b021ebf62b0b01464fd79a21 Mon Sep 17 00:00:00 2001 From: danieldg Date: Wed, 1 Jul 2009 22:55:39 +0000 Subject: Move list of open ports out of Config object git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11423 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/configreader.h | 4 ---- include/inspircd.h | 4 ++++ src/commands/cmd_stats.cpp | 8 ++++---- src/dns.cpp | 2 +- src/inspircd.cpp | 8 ++++---- src/socket.cpp | 12 ++++++------ 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/configreader.h b/include/configreader.h index d0feaccbb..60adbf868 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -672,10 +672,6 @@ class CoreExport ServerConfig : public Extensible */ ClassVector Classes; - /** A list of the classes for listening ports - */ - std::vector ports; - /** The 005 tokens of this server (ISUPPORT) * populated/repopulated upon loading or unloading * modules. diff --git a/include/inspircd.h b/include/inspircd.h index 6b13a5ed8..afe4dcd7c 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -509,6 +509,10 @@ class CoreExport InspIRCd : public classbase */ chan_hash* chanlist; + /** List of the open ports + */ + std::vector ports; + /** Set to the current signal recieved */ int s_signal; diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index 09a6c4394..4af8dcb91 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -82,14 +82,14 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str /* stats p (show listening ports and registered clients on each) */ case 'p': { - for (size_t i = 0; i < ServerInstance->Config->ports.size(); i++) + for (size_t i = 0; i < ServerInstance->ports.size(); i++) { - std::string ip = ServerInstance->Config->ports[i]->GetIP(); + std::string ip = ServerInstance->ports[i]->GetIP(); if (ip.empty()) ip.assign("*"); - results.push_back(sn+" 249 "+user->nick+" :"+ ip + ":"+ConvToStr(ServerInstance->Config->ports[i]->GetPort())+" (client, " + - ServerInstance->Config->ports[i]->GetDescription() + ")"); + results.push_back(sn+" 249 "+user->nick+" :"+ ip + ":"+ConvToStr(ServerInstance->ports[i]->GetPort())+" (client, " + + ServerInstance->ports[i]->GetDescription() + ")"); } } break; diff --git a/src/dns.cpp b/src/dns.cpp index ed2eff2bb..75108d577 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -1162,6 +1162,6 @@ unsigned long DNS::PRNG() gettimeofday(&n,NULL); val = (n.tv_usec ^ (getpid() ^ geteuid()) ^ ((this->currid++)) ^ s->statsAccept) + n.tv_sec; val = val + (s->statsCollisions ^ s->statsDnsGood) - s->statsDnsBad; - val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv) - ServerInstance->Config->ports.size(); + val += (s->statsConnects ^ (unsigned long)s->statsSent ^ (unsigned long)s->statsRecv) - ServerInstance->ports.size(); return val; } diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 23ef19aef..630216d6e 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -95,13 +95,13 @@ void InspIRCd::Cleanup() { if (Config) { - for (unsigned int i = 0; i < Config->ports.size(); i++) + for (unsigned int i = 0; i < ports.size(); i++) { /* This calls the constructor and closes the listening socket */ - delete Config->ports[i]; + delete ports[i]; } - Config->ports.clear(); + ports.clear(); } /* Close all client sockets, or the new process inherits them */ @@ -628,7 +628,7 @@ InspIRCd::InspIRCd(int argc, char** argv) this->BuildISupport(); InitializeDisabledCommands(Config->DisabledCommands, this); - if (Config->ports.size() != (unsigned int)found_ports) + if (ports.size() != (unsigned int)found_ports) { printf("\nWARNING: Not all your client ports could be bound --\nstarting anyway with %d of %d client ports bound.\n\n", bounditems, found_ports); printf("The following port(s) failed to bind:\n"); diff --git a/src/socket.cpp b/src/socket.cpp index cdf624321..35feda01f 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -183,11 +183,11 @@ int InspIRCd::BindPorts(bool, int &ports_found, FailedPortList &failed_ports) { char configToken[MAXBUF], Addr[MAXBUF], Type[MAXBUF]; int bound = 0; - bool started_with_nothing = (Config->ports.size() == 0); + bool started_with_nothing = (ports.size() == 0); std::vector > old_ports; /* XXX: Make a copy of the old ip/port pairs here */ - for (std::vector::iterator o = Config->ports.begin(); o != Config->ports.end(); ++o) + for (std::vector::iterator o = ports.begin(); o != ports.end(); ++o) old_ports.push_back(make_pair((*o)->GetIP(), (*o)->GetPort())); for (int count = 0; count < Config->ConfValueEnum(Config->config_data, "bind"); count++) @@ -209,7 +209,7 @@ int InspIRCd::BindPorts(bool, int &ports_found, FailedPortList &failed_ports) *Addr = 0; bool skip = false; - for (std::vector::iterator n = Config->ports.begin(); n != Config->ports.end(); ++n) + for (std::vector::iterator n = ports.begin(); n != ports.end(); ++n) { if (((*n)->GetIP() == Addr) && ((*n)->GetPort() == portno)) { @@ -231,7 +231,7 @@ int InspIRCd::BindPorts(bool, int &ports_found, FailedPortList &failed_ports) if (ll->GetFd() > -1) { bound++; - Config->ports.push_back(ll); + ports.push_back(ll); } else { @@ -248,13 +248,13 @@ int InspIRCd::BindPorts(bool, int &ports_found, FailedPortList &failed_ports) { for (size_t k = 0; k < old_ports.size(); ++k) { - for (std::vector::iterator n = Config->ports.begin(); n != Config->ports.end(); ++n) + for (std::vector::iterator n = ports.begin(); n != ports.end(); ++n) { if (((*n)->GetIP() == old_ports[k].first) && ((*n)->GetPort() == old_ports[k].second)) { this->Logs->Log("SOCKET",DEFAULT,"Port binding %s:%d was removed from the config file, closing.", old_ports[k].first.c_str(), old_ports[k].second); delete *n; - Config->ports.erase(n); + ports.erase(n); break; } } -- cgit v1.2.3