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
This commit is contained in:
danieldg 2009-07-01 22:55:39 +00:00
parent c9fed3cb0d
commit 50eebfeac8
6 changed files with 19 additions and 19 deletions

View File

@ -672,10 +672,6 @@ class CoreExport ServerConfig : public Extensible
*/
ClassVector Classes;
/** A list of the classes for listening ports
*/
std::vector<ListenSocketBase *> ports;
/** The 005 tokens of this server (ISUPPORT)
* populated/repopulated upon loading or unloading
* modules.

View File

@ -509,6 +509,10 @@ class CoreExport InspIRCd : public classbase
*/
chan_hash* chanlist;
/** List of the open ports
*/
std::vector<ListenSocketBase *> ports;
/** Set to the current signal recieved
*/
int s_signal;

View File

@ -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;

View File

@ -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;
}

View File

@ -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");

View File

@ -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<std::pair<std::string, int> > old_ports;
/* XXX: Make a copy of the old ip/port pairs here */
for (std::vector<ListenSocketBase *>::iterator o = Config->ports.begin(); o != Config->ports.end(); ++o)
for (std::vector<ListenSocketBase *>::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<ListenSocketBase *>::iterator n = Config->ports.begin(); n != Config->ports.end(); ++n)
for (std::vector<ListenSocketBase *>::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<ListenSocketBase *>::iterator n = Config->ports.begin(); n != Config->ports.end(); ++n)
for (std::vector<ListenSocketBase *>::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;
}
}