* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
* E-mail:
* <brain@chatspike.net>
* <Craig@chatspike.net>
// This table references users by file descriptor.
// its an array to make it VERY fast, as all lookups are referenced
// by an integer, meaning there is no need for a scan/search operation.
-userrec* fd_ref_table[65536];
+userrec* fd_ref_table[MAX_DESCRIPTORS];
Server* MyServer = new Server;
ServerConfig *Config = new ServerConfig;
#else
char dnsengine[] = "singlethread";
#endif
- snprintf(versiondata,MAXBUF,"%s Rev. %s %s :%s [FLAGS=%lu,%s,%s]",VERSION,GetRevision().c_str(),Config->ServerName,SYSTEM,(unsigned long)OPTIMISATION,SE->GetName().c_str(),dnsengine);
+ if (*Config->CustomVersion)
+ {
+ snprintf(versiondata,MAXBUF,"%s Rev. %s %s :%s",VERSION,GetRevision().c_str(),Config->ServerName,Config->CustomVersion);
+ }
+ else
+ {
+ snprintf(versiondata,MAXBUF,"%s Rev. %s %s :%s [FLAGS=%lu,%s,%s]",VERSION,GetRevision().c_str(),Config->ServerName,SYSTEM,(unsigned long)OPTIMISATION,SE->GetName().c_str(),dnsengine);
+ }
return versiondata;
}
}
+void InspIRCd::MoveTo(std::string modulename,int slot)
+{
+ unsigned int v2 = 256;
+ log(DEBUG,"Moving %s to slot %d",modulename.c_str(),slot);
+ for (unsigned int v = 0; v < Config->module_names.size(); v++)
+ {
+ if (Config->module_names[v] == modulename)
+ {
+ // found an instance, swap it with the item at MODCOUNT
+ v2 = v;
+ break;
+ }
+ }
+ if (v2 == (unsigned int)slot)
+ {
+ log(DEBUG,"Item %s already in slot %d!",modulename.c_str(),slot);
+ }
+ else if (v2 < 256)
+ {
+ // Swap the module names over
+ Config->module_names[v2] = Config->module_names[slot];
+ Config->module_names[slot] = modulename;
+ // now swap the module factories
+ ircd_module* temp = factory[v2];
+ factory[v2] = factory[slot];
+ factory[slot] = temp;
+ // now swap the module objects
+ Module* temp_module = modules[v2];
+ modules[v2] = modules[slot];
+ modules[slot] = temp_module;
+ // now swap the implement lists (we dont
+ // need to swap the global or recount it)
+ for (int n = 0; n < 255; n++)
+ {
+ char x = Config->implement_lists[v2][n];
+ Config->implement_lists[v2][n] = Config->implement_lists[slot][n];
+ Config->implement_lists[slot][n] = x;
+ }
+ log(DEBUG,"Moved %s to slot successfully",modulename.c_str());
+ }
+ else
+ {
+ log(DEBUG,"Move of %s to slot failed!",modulename.c_str());
+ }
+}
+
+void InspIRCd::MoveToFirst(std::string modulename)
+{
+ MoveTo(modulename,0);
+}
+
+void InspIRCd::MoveToLast(std::string modulename)
+{
+ MoveTo(modulename,MODCOUNT);
+}
+
void InspIRCd::BuildISupport()
{
// the neatest way to construct the initial 005 numeric, considering the number of configure constants to go in it...
std::stringstream v;
- v << "WALLCHOPS MODES=13 CHANTYPES=# PREFIX=(ohv)@%+ MAP SAFELIST MAXCHANNELS=" << MAXCHANS << " MAXBANS=60 NICKLEN=" << NICKMAX;
+ v << "WALLCHOPS MODES=13 CHANTYPES=# PREFIX=(ohv)@%+ MAP SAFELIST MAXCHANNELS=" << MAXCHANS << " MAXBANS=60 NICKLEN=" << NICKMAX-1;
v << " CASEMAPPING=rfc1459 STATUSMSG=@+ CHARSET=ascii TOPICLEN=" << MAXTOPIC << " KICKLEN=" << MAXKICK << " MAXTARGETS=20 AWAYLEN=";
v << MAXAWAY << " CHANMODES=ohvb,k,l,psmnti NETWORK=" << Config->Network;
Config->data005 = v.str();
Config->global_implementation[t] -= Config->implement_lists[j][t];
}
+ /* We have to renumber implement_lists after unload because the module numbers change!
+ */
+ for(int j2 = j; j2 < 254; j2++)
+ {
+ for(int t = 0; t < 255; t++)
+ {
+ Config->implement_lists[j2][t] = Config->implement_lists[j2+1][t];
+ }
+ }
+
FOREACH_MOD(I_OnUnloadModule,OnUnloadModule(modules[j],Config->module_names[j]));
// found the module
log(DEBUG,"Deleting module...");
#endif
MODCOUNT++;
FOREACH_MOD(I_OnLoadModule,OnLoadModule(modules[MODCOUNT],filename_str));
+ // now work out which modules, if any, want to move to the back of the queue,
+ // and if they do, move them there.
+ std::vector<std::string> put_to_back;
+ std::vector<std::string> put_to_front;
+ for (unsigned int j = 0; j < Config->module_names.size(); j++)
+ {
+ if (modules[j]->Prioritize() == PRIORITY_LAST)
+ {
+ put_to_back.push_back(Config->module_names[j]);
+ }
+ else if (modules[j]->Prioritize() == PRIORITY_FIRST)
+ {
+ put_to_front.push_back(Config->module_names[j]);
+ }
+ }
+ for (unsigned int j = 0; j < put_to_back.size(); j++)
+ {
+ MoveToLast(put_to_back[j]);
+ }
+ for (unsigned int j = 0; j < put_to_front.size(); j++)
+ {
+ MoveToFirst(put_to_front[j]);
+ }
BuildISupport();
return true;
}
uslen = sizeof(sock_us);
length = sizeof(client);
incomingSockfd = accept (activefds[activefd],(struct sockaddr*)&client,&length);
- if (!getsockname(incomingSockfd,(sockaddr*)&sock_us,&uslen))
+
+ if ((incomingSockfd > -1) && (!getsockname(incomingSockfd,(sockaddr*)&sock_us,&uslen)))
{
in_port = ntohs(sock_us.sin_port);
log(DEBUG,"Accepted socket %d",incomingSockfd);
* using gethostbyaddr(). That is sucky and we
* don't do that any more...
*/
- if (incomingSockfd >= 0)
- {
- NonBlocking(incomingSockfd);
- if (Config->GetIOHook(in_port))
- {
- Config->GetIOHook(in_port)->OnRawSocketAccept(incomingSockfd, target, in_port);
- }
- stats->statsAccept++;
- AddClient(incomingSockfd, target, in_port, false, target);
- log(DEBUG,"Adding client on port %lu fd=%lu",(unsigned long)in_port,(unsigned long)incomingSockfd);
- }
- else
+ NonBlocking(incomingSockfd);
+ if (Config->GetIOHook(in_port))
{
- WriteOpers("*** WARNING: accept() failed on port %lu (%s)",(unsigned long)in_port,target);
- log(DEBUG,"accept failed: %lu",(unsigned long)in_port);
- stats->statsRefused++;
+ Config->GetIOHook(in_port)->OnRawSocketAccept(incomingSockfd, target, in_port);
}
+ stats->statsAccept++;
+ AddClient(incomingSockfd, target, in_port, false, target);
+ log(DEBUG,"Adding client on port %lu fd=%lu",(unsigned long)in_port,(unsigned long)incomingSockfd);
}
else
{
- log(DEBUG,"Couldnt look up the port number for fd %lu (OS BROKEN?!)",incomingSockfd);
+ log(DEBUG,"Accept failed on fd %lu: %s",(unsigned long)incomingSockfd,strerror(errno));
shutdown(incomingSockfd,2);
close(incomingSockfd);
+ stats->statsRefused++;
}
break;