1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
17 /* Now with added unF! ;) */
21 #include "inspircd_config.h"
23 #include "inspircd_io.h"
26 #include <sys/errno.h>
27 #include <sys/ioctl.h>
28 #include <sys/utsname.h>
32 #include <ext/hash_map>
54 #include "inspstring.h"
56 #include "helperfuncs.h"
58 #include "socketengine.h"
59 #include "userprocess.h"
64 InspIRCd* ServerInstance;
66 int WHOWAS_STALE = 48; // default WHOWAS Entries last 2 days before they go 'stale'
67 int WHOWAS_MAX = 100; // default 100 people maximum in the WHOWAS list
69 extern std::vector<Module*> modules;
70 extern std::vector<ircd_module*> factory;
71 std::vector<InspSocket*> module_sockets;
74 int openSockfd[MAXSOCKS];
75 sockaddr_in client,server;
78 extern InspSocket* socket_ref[65535];
80 time_t TIME = time(NULL), OLDTIME = time(NULL);
82 SocketEngine* SE = NULL;
84 // This table references users by file descriptor.
85 // its an array to make it VERY fast, as all lookups are referenced
86 // by an integer, meaning there is no need for a scan/search operation.
87 userrec* fd_ref_table[65536];
89 serverstats* stats = new serverstats;
90 Server* MyServer = new Server;
91 ServerConfig *Config = new ServerConfig;
96 command_table cmdlist;
97 servernamelist servernames;
98 int BoundPortCount = 0;
101 void AddServerName(std::string servername)
103 log(DEBUG,"Adding server name: %s",servername.c_str());
104 for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++)
106 if (*a == servername)
109 servernames.push_back(servername);
112 const char* FindServerNamePtr(std::string servername)
114 for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++)
116 if (*a == servername)
119 AddServerName(servername);
120 return FindServerNamePtr(servername);
123 std::string InspIRCd::GetRevision()
125 /* w00t got me to replace a bunch of strtok_r
126 * with something nicer, so i did this. Its the
127 * same thing really, only in C++. It places the
128 * text into a std::stringstream which is a readable
129 * and writeable buffer stream, and then pops two
130 * words off it, space delimited. Because it reads
131 * into the same variable twice, the first word
132 * is discarded, and the second one returned.
134 std::stringstream Revision("$Revision$");
136 Revision >> single >> single;
141 /* This function pokes and hacks at a parameter list like the following:
143 * PART #winbot,#darkgalaxy :m00!
145 * to turn it into a series of individual calls like this:
148 * PART #darkgalaxy :m00!
150 * The seperate calls are sent to a callback function provided by the caller
151 * (the caller will usually call itself recursively). The callback function
152 * must be a command handler. Calling this function on a line with no list causes
153 * no action to be taken. You must provide a starting and ending parameter number
154 * where the range of the list can be found, useful if you have a terminating
155 * parameter as above which is actually not part of the list, or parameters
156 * before the actual list as well. This code is used by many functions which
157 * can function as "one to list" (see the RFC) */
159 int loop_call(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins)
164 char blog[32][MAXBUF];
165 char blog2[32][MAXBUF];
166 int j = 0, q = 0, total = 0, t = 0, t2 = 0, total2 = 0;
170 for (int i = 0; i <32; i++)
173 for (int i = 0; i <32; i++)
177 for (int i = 0; i <10; i++)
186 if (pcnt > 1) /* we have a key to copy */
188 strlcpy(keystr,parameters[1],MAXBUF);
192 if (!parameters[start])
196 if (!strchr(parameters[start],','))
201 for (int i = start; i <= end; i++)
205 strlcat(plist,parameters[i],MAXBUF);
213 for (int i = 0; i < t; i++)
218 strlcpy(blog[j++],param,MAXBUF);
222 WriteServ(u->fd,"407 %s %s :Too many targets in list, message not delivered.",u->nick,blog[j-1]);
227 strlcpy(blog[j++],param,MAXBUF);
230 if ((joins) && (keystr) && (total>0)) // more than one channel and is joining
235 if ((joins) && (keystr))
237 if (strchr(keystr,','))
242 for (int i = 0; i < t2; i++)
244 if (keystr[i] == ',')
247 strlcpy(blog2[j++],param,MAXBUF);
251 strlcpy(blog2[j++],param,MAXBUF);
256 for (j = 0; j < total; j++)
262 for (q = end; q < pcnt-1; q++)
266 pars[q-end+1] = parameters[q+1];
269 if ((joins) && (parameters[1]))
280 /* repeatedly call the function with the hacked parameter list */
281 if ((joins) && (pcnt > 1))
285 // pars[1] already set up and containing key from blog2[j]
290 pars[1] = parameters[1];
296 fn(pars,pcnt-(end-start),u);
305 InspIRCd::InspIRCd(int argc, char** argv)
308 module_sockets.clear();
309 this->startup_time = time(NULL);
311 log(DEBUG,"*** InspIRCd starting up!");
312 if (!FileExists(CONFIG_FILE))
314 printf("ERROR: Cannot open config file: %s\nExiting...\n",CONFIG_FILE);
315 log(DEFAULT,"main: no config");
316 printf("ERROR: Your config file is missing, this IRCd will self destruct in 10 seconds!\n");
320 for (int i = 1; i < argc; i++)
322 if (!strcmp(argv[i],"-nofork")) {
323 Config->nofork = true;
325 if (!strcmp(argv[i],"-wait")) {
328 if (!strcmp(argv[i],"-nolimit")) {
329 Config->unlimitcore = true;
334 strlcpy(Config->MyExecutable,argv[0],MAXBUF);
336 // initialize the lowercase mapping table
337 for (unsigned int cn = 0; cn < 256; cn++)
339 // lowercase the uppercase chars
340 for (unsigned int cn = 65; cn < 91; cn++)
341 lowermap[cn] = tolower(cn);
342 // now replace the specific chars for scandanavian comparison
343 lowermap[(unsigned)'['] = '{';
344 lowermap[(unsigned)']'] = '}';
345 lowermap[(unsigned)'\\'] = '|';
349 Config->ClearStack();
350 Config->Read(true,NULL);
353 AddServerName(Config->ServerName);
355 BoundPortCount = BindPorts();
360 if (DaemonSeed() == ERROR)
362 printf("ERROR: could not go into daemon mode. Shutting down.\n");
367 /* Because of limitations in kqueue on freebsd, we must fork BEFORE we
368 * initialize the socket engine.
370 SE = new SocketEngine();
372 /* We must load the modules AFTER initializing the socket engine, now */
375 printf("\nInspIRCd is now running!\n");
381 void* dns_task(void* arg)
383 userrec* u = (userrec*)arg;
384 log(DEBUG,"DNS thread for user %s",u->nick);
389 if (dns1.ReverseLookup(u->ip))
391 log(DEBUG,"DNS Step 1");
392 while (!dns1.HasResult())
396 host = dns1.GetResult();
399 log(DEBUG,"DNS Step 2: '%s'",host.c_str());
400 if (dns2.ForwardLookup(host))
402 while (!dns2.HasResult())
406 ip = dns2.GetResultIP();
407 log(DEBUG,"DNS Step 3 '%s'(%d) '%s'(%d)",ip.c_str(),ip.length(),u->ip,strlen(u->ip));
408 if (ip == std::string(u->ip))
410 log(DEBUG,"DNS Step 4");
411 if (host.length() < 160)
413 log(DEBUG,"DNS Step 5");
414 strcpy(u->host,host.c_str());
415 strcpy(u->dhost,host.c_str());
426 std::string InspIRCd::GetVersionString()
428 char versiondata[MAXBUF];
430 char dnsengine[] = "multithread";
432 char dnsengine[] = "singlethread";
434 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);
439 bool is_valid_cmd(std::string &commandname, int pcnt, userrec * user)
441 for (unsigned int i = 0; i < cmdlist.size(); i++)
443 if (!strcasecmp(cmdlist[i].command,commandname.c_str()))
445 if (cmdlist[i].handler_function)
447 if ((pcnt>=cmdlist[i].min_params) && (strcasecmp(cmdlist[i].source,"<core>")))
449 if ((strchr(user->modes,cmdlist[i].flags_needed)) || (!cmdlist[i].flags_needed))
451 if (cmdlist[i].flags_needed)
453 if ((user->HasPermission(commandname)) || (is_uline(user->server)))
471 // calls a handler function for a command
473 void call_handler(std::string &commandname,char **parameters, int pcnt, userrec *user)
475 for (unsigned int i = 0; i < cmdlist.size(); i++)
477 if (!strcasecmp(cmdlist[i].command,commandname.c_str()))
479 if (cmdlist[i].handler_function)
481 if (pcnt>=cmdlist[i].min_params)
483 if ((strchr(user->modes,cmdlist[i].flags_needed)) || (!cmdlist[i].flags_needed))
485 if (cmdlist[i].flags_needed)
487 if ((user->HasPermission(commandname)) || (is_uline(user->server)))
489 cmdlist[i].handler_function(parameters,pcnt,user);
494 cmdlist[i].handler_function(parameters,pcnt,user);
503 int process_parameters(char **command_p,char *parameters)
506 int q = strlen(parameters);
509 /* no parameters, command_p invalid! */
512 if (parameters[0] == ':')
514 command_p[0] = parameters+1;
519 if ((strchr(parameters,' ')==NULL) || (parameters[0] == ':'))
521 /* only one parameter */
522 command_p[0] = parameters;
523 if (parameters[0] == ':')
525 if (strchr(parameters,' ') != NULL)
533 command_p[j++] = parameters;
534 for (int i = 0; i <= q; i++)
536 if (parameters[i] == ' ')
538 command_p[j++] = parameters+i+1;
539 parameters[i] = '\0';
540 if (command_p[j-1][0] == ':')
542 *command_p[j-1]++; /* remove dodgy ":" */
544 /* parameter like this marks end of the sequence */
548 return j; /* returns total number of items in the list */
551 void process_command(userrec *user, char* cmd)
555 char *command_p[127];
556 char p[MAXBUF], temp[MAXBUF];
557 int j, items, cmd_found;
559 for (int i = 0; i < 127; i++)
575 int total_params = 0;
578 for (unsigned int q = 0; q < strlen(cmd)-1; q++)
580 if ((cmd[q] == ' ') && (cmd[q+1] == ':'))
583 // found a 'trailing', we dont count them after this.
591 // another phidjit bug...
592 if (total_params > 126)
594 *(strchr(cmd,' ')) = '\0';
595 WriteServ(user->fd,"421 %s %s :Too many parameters given",user->nick,cmd);
599 strlcpy(temp,cmd,MAXBUF);
601 std::string tmp = cmd;
602 for (int i = 0; i <= MODCOUNT; i++)
604 std::string oldtmp = tmp;
605 modules[i]->OnServerRaw(tmp,true,user);
608 log(DEBUG,"A Module changed the input string!");
609 log(DEBUG,"New string: %s",tmp.c_str());
610 log(DEBUG,"Old string: %s",oldtmp.c_str());
614 strlcpy(cmd,tmp.c_str(),MAXBUF);
615 strlcpy(temp,cmd,MAXBUF);
617 if (!strchr(cmd,' '))
619 /* no parameters, lets skip the formalities and not chop up
621 log(DEBUG,"About to preprocess command with no params");
625 for (unsigned int i = 0; i <= strlen(cmd); i++)
627 cmd[i] = toupper(cmd[i]);
635 /* strip out extraneous linefeeds through mirc's crappy pasting (thanks Craig) */
636 for (unsigned int i = 0; i < strlen(temp); i++)
638 if ((temp[i] != 10) && (temp[i] != 13) && (temp[i] != 0) && (temp[i] != 7))
644 /* split the full string into a command plus parameters */
650 for (unsigned int i = 0; i <= strlen(cmd); i++)
652 /* capitalise the command ONLY, leave params intact */
653 cmd[i] = toupper(cmd[i]);
654 /* are we nearly there yet?! :P */
658 parameters = cmd+i+1;
666 for (unsigned int i = 0; i <= strlen(cmd); i++)
668 cmd[i] = toupper(cmd[i]);
675 if (strlen(command)>MAXCOMMAND)
677 WriteServ(user->fd,"421 %s %s :Command too long",user->nick,command);
681 for (unsigned int x = 0; x < strlen(command); x++)
683 if (((command[x] < 'A') || (command[x] > 'Z')) && (command[x] != '.'))
685 if (((command[x] < '0') || (command[x]> '9')) && (command[x] != '-'))
687 if (strchr("@!\"$%^&*(){}[]_=+;:'#~,<>/?\\|`",command[x]))
689 stats->statsUnknown++;
690 WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command);
697 std::string xcommand = command;
698 for (unsigned int i = 0; i != cmdlist.size(); i++)
700 if (cmdlist[i].command[0])
702 if (strlen(command)>=(strlen(cmdlist[i].command))) if (!strncmp(command, cmdlist[i].command,MAXCOMMAND))
708 items = process_parameters(command_p,parameters);
724 /* activity resets the ping pending timer */
725 user->nping = TIME + user->pingmax;
726 if ((items) < cmdlist[i].min_params)
728 log(DEBUG,"process_command: not enough parameters: %s %s",user->nick,command);
729 WriteServ(user->fd,"461 %s %s :Not enough parameters",user->nick,command);
732 if ((!strchr(user->modes,cmdlist[i].flags_needed)) && (cmdlist[i].flags_needed))
734 log(DEBUG,"process_command: permission denied: %s %s",user->nick,command);
735 WriteServ(user->fd,"481 %s :Permission Denied- You do not have the required operator privilages",user->nick);
739 if ((cmdlist[i].flags_needed) && (!user->HasPermission(xcommand)))
741 log(DEBUG,"process_command: permission denied: %s %s",user->nick,command);
742 WriteServ(user->fd,"481 %s :Permission Denied- Oper type %s does not have access to command %s",user->nick,user->oper,command);
746 /* if the command isnt USER, PASS, or NICK, and nick is empty,
748 if ((strncmp(command,"USER",4)) && (strncmp(command,"NICK",4)) && (strncmp(command,"PASS",4)))
750 if ((!isnick(user->nick)) || (user->registered != 7))
752 log(DEBUG,"process_command: not registered: %s %s",user->nick,command);
753 WriteServ(user->fd,"451 %s :You have not registered",command);
757 if ((user->registered == 7) && (!strchr(user->modes,'o')))
759 std::stringstream dcmds(Config->DisabledCommands);
764 if (!strcasecmp(thiscmd.c_str(),command))
766 // command is disabled!
767 WriteServ(user->fd,"421 %s %s :This command has been disabled.",user->nick,command);
772 if ((user->registered == 7) || (!strncmp(command,"USER",4)) || (!strncmp(command,"NICK",4)) || (!strncmp(command,"PASS",4)))
774 if (cmdlist[i].handler_function)
777 /* ikky /stats counters */
780 cmdlist[i].use_count++;
781 cmdlist[i].total_bytes+=strlen(temp);
785 FOREACH_RESULT(OnPreCommand(command,command_p,items,user));
786 if (MOD_RESULT == 1) {
790 /* WARNING: nothing may come after the
791 * command handler call, as the handler
792 * may free the user structure! */
794 cmdlist[i].handler_function(command_p,items,user);
800 WriteServ(user->fd,"451 %s :You have not registered",command);
808 if ((!cmd_found) && (user))
810 stats->statsUnknown++;
811 WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command);
815 bool removecommands(const char* source)
817 bool go_again = true;
821 for (std::deque<command_t>::iterator i = cmdlist.begin(); i != cmdlist.end(); i++)
823 if (!strcmp(i->source,source))
825 log(DEBUG,"removecommands(%s) Removing dependent command: %s",i->source,i->command);
836 void process_buffer(const char* cmdbuf,userrec *user)
840 log(DEFAULT,"*** BUG *** process_buffer was given an invalid parameter");
846 log(DEFAULT,"*** BUG *** process_buffer was given an invalid parameter");
853 while (*cmdbuf == ' ') cmdbuf++; // strip leading spaces
855 strlcpy(cmd,cmdbuf,MAXBUF);
860 int sl = strlen(cmd)-1;
861 if ((cmd[sl] == 13) || (cmd[sl] == 10))
866 if ((cmd[sl] == 13) || (cmd[sl] == 10))
871 while (cmd[sl] == ' ') // strip trailing spaces
881 log(DEBUG,"CMDIN: %s %s",user->nick,cmd);
885 process_command(user,cmd);
889 char* InspIRCd::ModuleError()
894 void InspIRCd::erase_factory(int j)
897 for (std::vector<ircd_module*>::iterator t = factory.begin(); t != factory.end(); t++)
902 factory.push_back(NULL);
909 void InspIRCd::erase_module(int j)
912 for (std::vector<Module*>::iterator m = modules.begin(); m!= modules.end(); m++)
918 modules.push_back(NULL);
924 for (std::vector<std::string>::iterator v = Config->module_names.begin(); v != Config->module_names.end(); v++)
928 Config->module_names.erase(v);
936 bool InspIRCd::UnloadModule(const char* filename)
938 std::string filename_str = filename;
939 for (unsigned int j = 0; j != Config->module_names.size(); j++)
941 if (Config->module_names[j] == filename_str)
943 if (modules[j]->GetVersion().Flags & VF_STATIC)
945 log(DEFAULT,"Failed to unload STATIC module %s",filename);
946 snprintf(MODERR,MAXBUF,"Module not unloadable (marked static)");
949 /* Give the module a chance to tidy out all its metadata */
950 for (chan_hash::iterator c = chanlist.begin(); c != chanlist.end(); c++)
952 modules[j]->OnCleanup(TYPE_CHANNEL,c->second);
954 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
956 modules[j]->OnCleanup(TYPE_USER,u->second);
958 FOREACH_MOD OnUnloadModule(modules[j],Config->module_names[j]);
960 log(DEBUG,"Deleting module...");
962 log(DEBUG,"Erasing module entry...");
964 log(DEBUG,"Removing dependent commands...");
965 removecommands(filename);
966 log(DEFAULT,"Module %s unloaded",filename);
971 log(DEFAULT,"Module %s is not loaded, cannot unload it!",filename);
972 snprintf(MODERR,MAXBUF,"Module not loaded");
976 bool InspIRCd::LoadModule(const char* filename)
978 char modfile[MAXBUF];
980 snprintf(modfile,MAXBUF,"%s",filename);
982 snprintf(modfile,MAXBUF,"%s/%s",Config->ModPath,filename);
984 std::string filename_str = filename;
986 if (!DirValid(modfile))
988 log(DEFAULT,"Module %s is not within the modules directory.",modfile);
989 snprintf(MODERR,MAXBUF,"Module %s is not within the modules directory.",modfile);
993 log(DEBUG,"Loading module: %s",modfile);
995 if (FileExists(modfile))
998 for (unsigned int j = 0; j < Config->module_names.size(); j++)
1000 if (Config->module_names[j] == filename_str)
1002 log(DEFAULT,"Module %s is already loaded, cannot load a module twice!",modfile);
1003 snprintf(MODERR,MAXBUF,"Module already loaded");
1007 ircd_module* a = new ircd_module(modfile);
1008 factory[MODCOUNT+1] = a;
1009 if (factory[MODCOUNT+1]->LastError())
1011 log(DEFAULT,"Unable to load %s: %s",modfile,factory[MODCOUNT+1]->LastError());
1012 snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
1016 if (factory[MODCOUNT+1]->factory)
1018 Module* m = factory[MODCOUNT+1]->factory->CreateModule(MyServer);
1019 modules[MODCOUNT+1] = m;
1020 /* save the module and the module's classfactory, if
1021 * this isnt done, random crashes can occur :/ */
1022 Config->module_names.push_back(filename);
1026 log(DEFAULT,"Unable to load %s",modfile);
1027 snprintf(MODERR,MAXBUF,"Factory function failed!");
1034 log(DEFAULT,"InspIRCd: startup: Module Not Found %s",modfile);
1035 snprintf(MODERR,MAXBUF,"Module file could not be found");
1040 FOREACH_MOD OnLoadModule(modules[MODCOUNT],filename_str);
1046 bool expire_run = false;
1047 std::vector<int> activefds;
1051 InspSocket* s = NULL;
1052 InspSocket* s_del = NULL;
1054 unsigned int numberactive;
1055 sockaddr_in sock_us; // our port number
1056 socklen_t uslen; // length of our port number
1058 if (!Config->nofork)
1060 freopen("/dev/null","w",stdout);
1061 freopen("/dev/null","w",stderr);
1064 /* Add the listening sockets used for client inbound connections
1065 * to the socket engine
1067 for (int count = 0; count < BoundPortCount; count++)
1068 SE->AddFd(openSockfd[count],true,X_LISTEN);
1070 WritePID(Config->PID);
1072 /* main loop, this never returns */
1075 /* time() seems to be a pretty expensive syscall, so avoid calling it too much.
1076 * Once per loop iteration is pleanty.
1081 /* Run background module timers every few seconds
1082 * (the docs say modules shouldnt rely on accurate
1083 * timing using this event, so we dont have to
1084 * time this exactly).
1086 if (((TIME % 8) == 0) && (!expire_run))
1089 FOREACH_MOD OnBackgroundTimer(TIME);
1093 if ((TIME % 8) == 1)
1096 /* Once a second, do the background processing */
1097 if (TIME != OLDTIME)
1098 while (DoBackgroundUserStuff(TIME));
1100 /* Call the socket engine to wait on the active
1101 * file descriptors. The socket engine has everything's
1102 * descriptors in its list... dns, modules, users,
1103 * servers... so its nice and easy, just one call.
1105 SE->Wait(activefds);
1108 * Now process each of the fd's. For users, we have a fast
1109 * lookup table which can find a user by file descriptor, so
1110 * processing them by fd isnt expensive. If we have a lot of
1111 * listening ports or module sockets though, things could get
1114 numberactive = activefds.size();
1115 for (unsigned int activefd = 0; activefd < numberactive; activefd++)
1117 int socket_type = SE->GetType(activefds[activefd]);
1118 switch (socket_type)
1120 case X_ESTAB_CLIENT:
1122 cu = fd_ref_table[activefds[activefd]];
1128 case X_ESTAB_MODULE:
1130 /* Process module-owned sockets.
1131 * Modules are encouraged to inherit their sockets from
1132 * InspSocket so we can process them neatly like this.
1134 s = socket_ref[activefds[activefd]];
1136 if ((s) && (!s->Poll()))
1138 log(DEBUG,"Socket poll returned false, close and bail");
1139 SE->DelFd(s->GetFd());
1140 for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
1142 s_del = (InspSocket*)*a;
1143 if ((s_del) && (s_del->GetFd() == activefds[activefd]))
1145 module_sockets.erase(a);
1157 /* When we are using single-threaded dns,
1158 * the sockets for dns end up in our mainloop.
1159 * When we are using multi-threaded dns,
1160 * each thread has its own basic poll() loop
1161 * within it, making them 'fire and forget'
1162 * and independent of the mainloop.
1164 #ifndef THREADED_DNS
1165 dns_poll(activefds[activefd]);
1171 /* It's a listener */
1172 uslen = sizeof(sock_us);
1173 length = sizeof(client);
1174 incomingSockfd = accept (activefds[activefd],(struct sockaddr*)&client,&length);
1175 if (!getsockname(incomingSockfd,(sockaddr*)&sock_us,&uslen))
1177 in_port = ntohs(sock_us.sin_port);
1178 log(DEBUG,"Accepted socket %d",incomingSockfd);
1179 target = (char*)inet_ntoa(client.sin_addr);
1180 /* Years and years ago, we used to resolve here
1181 * using gethostbyaddr(). That is sucky and we
1182 * don't do that any more...
1184 if (incomingSockfd >= 0)
1186 FOREACH_MOD OnRawSocketAccept(incomingSockfd, target, in_port);
1187 stats->statsAccept++;
1188 AddClient(incomingSockfd, target, in_port, false, target);
1189 log(DEBUG,"Adding client on port %lu fd=%lu",(unsigned long)in_port,(unsigned long)incomingSockfd);
1193 WriteOpers("*** WARNING: accept() failed on port %lu (%s)",(unsigned long)in_port,target);
1194 log(DEBUG,"accept failed: %lu",(unsigned long)in_port);
1195 stats->statsRefused++;
1200 log(DEBUG,"Couldnt look up the port number for fd %lu (OS BROKEN?!)",incomingSockfd);
1201 shutdown(incomingSockfd,2);
1202 close(incomingSockfd);
1207 /* Something went wrong if we're in here.
1208 * In fact, so wrong, im not quite sure
1209 * what we would do, so for now, its going
1210 * to safely do bugger all.
1217 /* This is never reached -- we hope! */
1221 /**********************************************************************************/
1224 * An ircd in four lines! bwahahaha. ahahahahaha. ahahah *cough*.
1227 int main(int argc, char** argv)
1229 ServerInstance = new InspIRCd(argc, argv);
1230 ServerInstance->Run();
1231 delete ServerInstance;