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;
72 std::vector<userrec*> local_users;
75 int openSockfd[MAXSOCKS];
76 sockaddr_in client,server;
78 extern Module* IOHookModule;
80 extern InspSocket* socket_ref[65535];
82 time_t TIME = time(NULL), OLDTIME = time(NULL);
84 SocketEngine* SE = NULL;
86 // This table references users by file descriptor.
87 // its an array to make it VERY fast, as all lookups are referenced
88 // by an integer, meaning there is no need for a scan/search operation.
89 userrec* fd_ref_table[65536];
91 serverstats* stats = new serverstats;
92 Server* MyServer = new Server;
93 ServerConfig *Config = new ServerConfig;
98 command_table cmdlist;
99 servernamelist servernames;
100 int BoundPortCount = 0;
103 void AddServerName(std::string servername)
105 log(DEBUG,"Adding server name: %s",servername.c_str());
106 for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++)
108 if (*a == servername)
111 servernames.push_back(servername);
114 const char* FindServerNamePtr(std::string servername)
116 for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++)
118 if (*a == servername)
121 AddServerName(servername);
122 return FindServerNamePtr(servername);
125 std::string InspIRCd::GetRevision()
127 /* w00t got me to replace a bunch of strtok_r
128 * with something nicer, so i did this. Its the
129 * same thing really, only in C++. It places the
130 * text into a std::stringstream which is a readable
131 * and writeable buffer stream, and then pops two
132 * words off it, space delimited. Because it reads
133 * into the same variable twice, the first word
134 * is discarded, and the second one returned.
136 std::stringstream Revision("$Revision$");
138 Revision >> single >> single;
143 /* This function pokes and hacks at a parameter list like the following:
145 * PART #winbot,#darkgalaxy :m00!
147 * to turn it into a series of individual calls like this:
150 * PART #darkgalaxy :m00!
152 * The seperate calls are sent to a callback function provided by the caller
153 * (the caller will usually call itself recursively). The callback function
154 * must be a command handler. Calling this function on a line with no list causes
155 * no action to be taken. You must provide a starting and ending parameter number
156 * where the range of the list can be found, useful if you have a terminating
157 * parameter as above which is actually not part of the list, or parameters
158 * before the actual list as well. This code is used by many functions which
159 * can function as "one to list" (see the RFC) */
161 int loop_call(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins)
166 char blog[32][MAXBUF];
167 char blog2[32][MAXBUF];
168 int j = 0, q = 0, total = 0, t = 0, t2 = 0, total2 = 0;
172 for (int i = 0; i <32; i++)
175 for (int i = 0; i <32; i++)
179 for (int i = 0; i <10; i++)
188 if (pcnt > 1) /* we have a key to copy */
190 strlcpy(keystr,parameters[1],MAXBUF);
194 if (!parameters[start])
198 if (!strchr(parameters[start],','))
203 for (int i = start; i <= end; i++)
207 strlcat(plist,parameters[i],MAXBUF);
215 for (int i = 0; i < t; i++)
220 strlcpy(blog[j++],param,MAXBUF);
224 WriteServ(u->fd,"407 %s %s :Too many targets in list, message not delivered.",u->nick,blog[j-1]);
229 strlcpy(blog[j++],param,MAXBUF);
232 if ((joins) && (keystr) && (total>0)) // more than one channel and is joining
237 if ((joins) && (keystr))
239 if (strchr(keystr,','))
244 for (int i = 0; i < t2; i++)
246 if (keystr[i] == ',')
249 strlcpy(blog2[j++],param,MAXBUF);
253 strlcpy(blog2[j++],param,MAXBUF);
258 for (j = 0; j < total; j++)
264 for (q = end; q < pcnt-1; q++)
268 pars[q-end+1] = parameters[q+1];
271 if ((joins) && (parameters[1]))
282 /* repeatedly call the function with the hacked parameter list */
283 if ((joins) && (pcnt > 1))
287 // pars[1] already set up and containing key from blog2[j]
292 pars[1] = parameters[1];
298 fn(pars,pcnt-(end-start),u);
307 InspIRCd::InspIRCd(int argc, char** argv)
310 module_sockets.clear();
311 this->startup_time = time(NULL);
313 log(DEBUG,"*** InspIRCd starting up!");
314 if (!FileExists(CONFIG_FILE))
316 printf("ERROR: Cannot open config file: %s\nExiting...\n",CONFIG_FILE);
317 log(DEFAULT,"main: no config");
318 printf("ERROR: Your config file is missing, this IRCd will self destruct in 10 seconds!\n");
322 for (int i = 1; i < argc; i++)
324 if (!strcmp(argv[i],"-nofork")) {
325 Config->nofork = true;
327 if (!strcmp(argv[i],"-wait")) {
330 if (!strcmp(argv[i],"-nolimit")) {
331 Config->unlimitcore = true;
336 strlcpy(Config->MyExecutable,argv[0],MAXBUF);
338 // initialize the lowercase mapping table
339 for (unsigned int cn = 0; cn < 256; cn++)
341 // lowercase the uppercase chars
342 for (unsigned int cn = 65; cn < 91; cn++)
343 lowermap[cn] = tolower(cn);
344 // now replace the specific chars for scandanavian comparison
345 lowermap[(unsigned)'['] = '{';
346 lowermap[(unsigned)']'] = '}';
347 lowermap[(unsigned)'\\'] = '|';
351 Config->ClearStack();
352 Config->Read(true,NULL);
355 AddServerName(Config->ServerName);
357 BoundPortCount = BindPorts();
362 if (DaemonSeed() == ERROR)
364 printf("ERROR: could not go into daemon mode. Shutting down.\n");
369 /* Because of limitations in kqueue on freebsd, we must fork BEFORE we
370 * initialize the socket engine.
372 SE = new SocketEngine();
374 /* We must load the modules AFTER initializing the socket engine, now */
377 printf("\nInspIRCd is now running!\n");
383 void* dns_task(void* arg)
385 userrec* u = (userrec*)arg;
386 log(DEBUG,"DNS thread for user %s",u->nick);
391 if (dns1.ReverseLookup(u->ip))
393 log(DEBUG,"DNS Step 1");
394 while (!dns1.HasResult())
398 host = dns1.GetResult();
401 log(DEBUG,"DNS Step 2: '%s'",host.c_str());
402 if (dns2.ForwardLookup(host))
404 while (!dns2.HasResult())
408 ip = dns2.GetResultIP();
409 log(DEBUG,"DNS Step 3 '%s'(%d) '%s'(%d)",ip.c_str(),ip.length(),u->ip,strlen(u->ip));
410 if (ip == std::string(u->ip))
412 log(DEBUG,"DNS Step 4");
413 if (host.length() < 160)
415 log(DEBUG,"DNS Step 5");
416 strcpy(u->host,host.c_str());
417 strcpy(u->dhost,host.c_str());
428 std::string InspIRCd::GetVersionString()
430 char versiondata[MAXBUF];
432 char dnsengine[] = "multithread";
434 char dnsengine[] = "singlethread";
436 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);
441 bool is_valid_cmd(std::string &commandname, int pcnt, userrec * user)
443 for (unsigned int i = 0; i < cmdlist.size(); i++)
445 if (!strcasecmp(cmdlist[i].command,commandname.c_str()))
447 if (cmdlist[i].handler_function)
449 if ((pcnt>=cmdlist[i].min_params) && (strcasecmp(cmdlist[i].source,"<core>")))
451 if ((strchr(user->modes,cmdlist[i].flags_needed)) || (!cmdlist[i].flags_needed))
453 if (cmdlist[i].flags_needed)
455 if ((user->HasPermission(commandname)) || (is_uline(user->server)))
473 // calls a handler function for a command
475 void call_handler(std::string &commandname,char **parameters, int pcnt, userrec *user)
477 for (unsigned int i = 0; i < cmdlist.size(); i++)
479 if (!strcasecmp(cmdlist[i].command,commandname.c_str()))
481 if (cmdlist[i].handler_function)
483 if (pcnt>=cmdlist[i].min_params)
485 if ((strchr(user->modes,cmdlist[i].flags_needed)) || (!cmdlist[i].flags_needed))
487 if (cmdlist[i].flags_needed)
489 if ((user->HasPermission(commandname)) || (is_uline(user->server)))
491 cmdlist[i].handler_function(parameters,pcnt,user);
496 cmdlist[i].handler_function(parameters,pcnt,user);
505 int process_parameters(char **command_p,char *parameters)
508 int q = strlen(parameters);
511 /* no parameters, command_p invalid! */
514 if (parameters[0] == ':')
516 command_p[0] = parameters+1;
521 if ((strchr(parameters,' ')==NULL) || (parameters[0] == ':'))
523 /* only one parameter */
524 command_p[0] = parameters;
525 if (parameters[0] == ':')
527 if (strchr(parameters,' ') != NULL)
535 command_p[j++] = parameters;
536 for (int i = 0; i <= q; i++)
538 if (parameters[i] == ' ')
540 command_p[j++] = parameters+i+1;
541 parameters[i] = '\0';
542 if (command_p[j-1][0] == ':')
544 *command_p[j-1]++; /* remove dodgy ":" */
546 /* parameter like this marks end of the sequence */
550 return j; /* returns total number of items in the list */
553 void process_command(userrec *user, char* cmd)
557 char *command_p[127];
558 char p[MAXBUF], temp[MAXBUF];
559 int j, items, cmd_found;
561 for (int i = 0; i < 127; i++)
577 int total_params = 0;
580 for (unsigned int q = 0; q < strlen(cmd)-1; q++)
582 if ((cmd[q] == ' ') && (cmd[q+1] == ':'))
585 // found a 'trailing', we dont count them after this.
593 // another phidjit bug...
594 if (total_params > 126)
596 *(strchr(cmd,' ')) = '\0';
597 WriteServ(user->fd,"421 %s %s :Too many parameters given",user->nick,cmd);
601 strlcpy(temp,cmd,MAXBUF);
603 std::string tmp = cmd;
604 for (int i = 0; i <= MODCOUNT; i++)
606 std::string oldtmp = tmp;
607 modules[i]->OnServerRaw(tmp,true,user);
610 log(DEBUG,"A Module changed the input string!");
611 log(DEBUG,"New string: %s",tmp.c_str());
612 log(DEBUG,"Old string: %s",oldtmp.c_str());
616 strlcpy(cmd,tmp.c_str(),MAXBUF);
617 strlcpy(temp,cmd,MAXBUF);
619 if (!strchr(cmd,' '))
621 /* no parameters, lets skip the formalities and not chop up
623 log(DEBUG,"About to preprocess command with no params");
627 for (unsigned int i = 0; i <= strlen(cmd); i++)
629 cmd[i] = toupper(cmd[i]);
637 /* strip out extraneous linefeeds through mirc's crappy pasting (thanks Craig) */
638 for (unsigned int i = 0; i < strlen(temp); i++)
640 if ((temp[i] != 10) && (temp[i] != 13) && (temp[i] != 0) && (temp[i] != 7))
646 /* split the full string into a command plus parameters */
652 for (unsigned int i = 0; i <= strlen(cmd); i++)
654 /* capitalise the command ONLY, leave params intact */
655 cmd[i] = toupper(cmd[i]);
656 /* are we nearly there yet?! :P */
660 parameters = cmd+i+1;
668 for (unsigned int i = 0; i <= strlen(cmd); i++)
670 cmd[i] = toupper(cmd[i]);
677 if (strlen(command)>MAXCOMMAND)
679 WriteServ(user->fd,"421 %s %s :Command too long",user->nick,command);
683 for (unsigned int x = 0; x < strlen(command); x++)
685 if (((command[x] < 'A') || (command[x] > 'Z')) && (command[x] != '.'))
687 if (((command[x] < '0') || (command[x]> '9')) && (command[x] != '-'))
689 if (strchr("@!\"$%^&*(){}[]_=+;:'#~,<>/?\\|`",command[x]))
691 stats->statsUnknown++;
692 WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command);
699 std::string xcommand = command;
700 for (unsigned int i = 0; i != cmdlist.size(); i++)
702 if (cmdlist[i].command[0])
704 if (strlen(command)>=(strlen(cmdlist[i].command))) if (!strncmp(command, cmdlist[i].command,MAXCOMMAND))
710 items = process_parameters(command_p,parameters);
726 /* activity resets the ping pending timer */
727 user->nping = TIME + user->pingmax;
728 if ((items) < cmdlist[i].min_params)
730 log(DEBUG,"process_command: not enough parameters: %s %s",user->nick,command);
731 WriteServ(user->fd,"461 %s %s :Not enough parameters",user->nick,command);
734 if ((!strchr(user->modes,cmdlist[i].flags_needed)) && (cmdlist[i].flags_needed))
736 log(DEBUG,"process_command: permission denied: %s %s",user->nick,command);
737 WriteServ(user->fd,"481 %s :Permission Denied- You do not have the required operator privilages",user->nick);
741 if ((cmdlist[i].flags_needed) && (!user->HasPermission(xcommand)))
743 log(DEBUG,"process_command: permission denied: %s %s",user->nick,command);
744 WriteServ(user->fd,"481 %s :Permission Denied- Oper type %s does not have access to command %s",user->nick,user->oper,command);
748 /* if the command isnt USER, PASS, or NICK, and nick is empty,
750 if ((strncmp(command,"USER",4)) && (strncmp(command,"NICK",4)) && (strncmp(command,"PASS",4)))
752 if ((!isnick(user->nick)) || (user->registered != 7))
754 log(DEBUG,"process_command: not registered: %s %s",user->nick,command);
755 WriteServ(user->fd,"451 %s :You have not registered",command);
759 if ((user->registered == 7) && (!strchr(user->modes,'o')))
761 std::stringstream dcmds(Config->DisabledCommands);
766 if (!strcasecmp(thiscmd.c_str(),command))
768 // command is disabled!
769 WriteServ(user->fd,"421 %s %s :This command has been disabled.",user->nick,command);
774 if ((user->registered == 7) || (!strncmp(command,"USER",4)) || (!strncmp(command,"NICK",4)) || (!strncmp(command,"PASS",4)))
776 if (cmdlist[i].handler_function)
779 /* ikky /stats counters */
782 cmdlist[i].use_count++;
783 cmdlist[i].total_bytes+=strlen(temp);
787 FOREACH_RESULT(OnPreCommand(command,command_p,items,user));
788 if (MOD_RESULT == 1) {
792 /* WARNING: nothing may come after the
793 * command handler call, as the handler
794 * may free the user structure! */
796 cmdlist[i].handler_function(command_p,items,user);
802 WriteServ(user->fd,"451 %s :You have not registered",command);
810 if ((!cmd_found) && (user))
812 stats->statsUnknown++;
813 WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command);
817 bool removecommands(const char* source)
819 bool go_again = true;
823 for (std::deque<command_t>::iterator i = cmdlist.begin(); i != cmdlist.end(); i++)
825 if (!strcmp(i->source,source))
827 log(DEBUG,"removecommands(%s) Removing dependent command: %s",i->source,i->command);
838 void process_buffer(const char* cmdbuf,userrec *user)
842 log(DEFAULT,"*** BUG *** process_buffer was given an invalid parameter");
848 log(DEFAULT,"*** BUG *** process_buffer was given an invalid parameter");
855 while (*cmdbuf == ' ') cmdbuf++; // strip leading spaces
857 strlcpy(cmd,cmdbuf,MAXBUF);
862 int sl = strlen(cmd)-1;
863 if ((cmd[sl] == 13) || (cmd[sl] == 10))
868 if ((cmd[sl] == 13) || (cmd[sl] == 10))
873 while (cmd[sl] == ' ') // strip trailing spaces
883 log(DEBUG,"CMDIN: %s %s",user->nick,cmd);
887 process_command(user,cmd);
891 char* InspIRCd::ModuleError()
896 void InspIRCd::erase_factory(int j)
899 for (std::vector<ircd_module*>::iterator t = factory.begin(); t != factory.end(); t++)
904 factory.push_back(NULL);
911 void InspIRCd::erase_module(int j)
914 for (std::vector<Module*>::iterator m = modules.begin(); m!= modules.end(); m++)
920 modules.push_back(NULL);
926 for (std::vector<std::string>::iterator v = Config->module_names.begin(); v != Config->module_names.end(); v++)
930 Config->module_names.erase(v);
938 bool InspIRCd::UnloadModule(const char* filename)
940 std::string filename_str = filename;
941 for (unsigned int j = 0; j != Config->module_names.size(); j++)
943 if (Config->module_names[j] == filename_str)
945 if (modules[j]->GetVersion().Flags & VF_STATIC)
947 log(DEFAULT,"Failed to unload STATIC module %s",filename);
948 snprintf(MODERR,MAXBUF,"Module not unloadable (marked static)");
951 /* Give the module a chance to tidy out all its metadata */
952 for (chan_hash::iterator c = chanlist.begin(); c != chanlist.end(); c++)
954 modules[j]->OnCleanup(TYPE_CHANNEL,c->second);
956 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
958 modules[j]->OnCleanup(TYPE_USER,u->second);
960 FOREACH_MOD OnUnloadModule(modules[j],Config->module_names[j]);
962 log(DEBUG,"Deleting module...");
964 log(DEBUG,"Erasing module entry...");
966 log(DEBUG,"Removing dependent commands...");
967 removecommands(filename);
968 log(DEFAULT,"Module %s unloaded",filename);
973 log(DEFAULT,"Module %s is not loaded, cannot unload it!",filename);
974 snprintf(MODERR,MAXBUF,"Module not loaded");
978 bool InspIRCd::LoadModule(const char* filename)
980 char modfile[MAXBUF];
982 snprintf(modfile,MAXBUF,"%s",filename);
984 snprintf(modfile,MAXBUF,"%s/%s",Config->ModPath,filename);
986 std::string filename_str = filename;
988 if (!DirValid(modfile))
990 log(DEFAULT,"Module %s is not within the modules directory.",modfile);
991 snprintf(MODERR,MAXBUF,"Module %s is not within the modules directory.",modfile);
995 log(DEBUG,"Loading module: %s",modfile);
997 if (FileExists(modfile))
1000 for (unsigned int j = 0; j < Config->module_names.size(); j++)
1002 if (Config->module_names[j] == filename_str)
1004 log(DEFAULT,"Module %s is already loaded, cannot load a module twice!",modfile);
1005 snprintf(MODERR,MAXBUF,"Module already loaded");
1009 ircd_module* a = new ircd_module(modfile);
1010 factory[MODCOUNT+1] = a;
1011 if (factory[MODCOUNT+1]->LastError())
1013 log(DEFAULT,"Unable to load %s: %s",modfile,factory[MODCOUNT+1]->LastError());
1014 snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
1018 if (factory[MODCOUNT+1]->factory)
1020 Module* m = factory[MODCOUNT+1]->factory->CreateModule(MyServer);
1021 modules[MODCOUNT+1] = m;
1022 /* save the module and the module's classfactory, if
1023 * this isnt done, random crashes can occur :/ */
1024 Config->module_names.push_back(filename);
1028 log(DEFAULT,"Unable to load %s",modfile);
1029 snprintf(MODERR,MAXBUF,"Factory function failed!");
1036 log(DEFAULT,"InspIRCd: startup: Module Not Found %s",modfile);
1037 snprintf(MODERR,MAXBUF,"Module file could not be found");
1042 FOREACH_MOD OnLoadModule(modules[MODCOUNT],filename_str);
1048 bool expire_run = false;
1049 std::vector<int> activefds;
1053 InspSocket* s = NULL;
1054 InspSocket* s_del = NULL;
1056 unsigned int numberactive;
1057 sockaddr_in sock_us; // our port number
1058 socklen_t uslen; // length of our port number
1060 if (!Config->nofork)
1062 freopen("/dev/null","w",stdout);
1063 freopen("/dev/null","w",stderr);
1066 /* Add the listening sockets used for client inbound connections
1067 * to the socket engine
1069 for (int count = 0; count < BoundPortCount; count++)
1070 SE->AddFd(openSockfd[count],true,X_LISTEN);
1072 WritePID(Config->PID);
1074 /* main loop, this never returns */
1077 /* time() seems to be a pretty expensive syscall, so avoid calling it too much.
1078 * Once per loop iteration is pleanty.
1083 /* Run background module timers every few seconds
1084 * (the docs say modules shouldnt rely on accurate
1085 * timing using this event, so we dont have to
1086 * time this exactly).
1088 if (((TIME % 8) == 0) && (!expire_run))
1091 FOREACH_MOD OnBackgroundTimer(TIME);
1095 if ((TIME % 8) == 1)
1098 /* Once a second, do the background processing */
1099 if (TIME != OLDTIME)
1100 while (DoBackgroundUserStuff(TIME));
1102 /* Call the socket engine to wait on the active
1103 * file descriptors. The socket engine has everything's
1104 * descriptors in its list... dns, modules, users,
1105 * servers... so its nice and easy, just one call.
1107 SE->Wait(activefds);
1110 * Now process each of the fd's. For users, we have a fast
1111 * lookup table which can find a user by file descriptor, so
1112 * processing them by fd isnt expensive. If we have a lot of
1113 * listening ports or module sockets though, things could get
1116 numberactive = activefds.size();
1117 for (unsigned int activefd = 0; activefd < numberactive; activefd++)
1119 int socket_type = SE->GetType(activefds[activefd]);
1120 switch (socket_type)
1122 case X_ESTAB_CLIENT:
1124 cu = fd_ref_table[activefds[activefd]];
1130 case X_ESTAB_MODULE:
1132 /* Process module-owned sockets.
1133 * Modules are encouraged to inherit their sockets from
1134 * InspSocket so we can process them neatly like this.
1136 s = socket_ref[activefds[activefd]];
1138 if ((s) && (!s->Poll()))
1140 log(DEBUG,"Socket poll returned false, close and bail");
1141 SE->DelFd(s->GetFd());
1142 for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
1144 s_del = (InspSocket*)*a;
1145 if ((s_del) && (s_del->GetFd() == activefds[activefd]))
1147 module_sockets.erase(a);
1159 /* When we are using single-threaded dns,
1160 * the sockets for dns end up in our mainloop.
1161 * When we are using multi-threaded dns,
1162 * each thread has its own basic poll() loop
1163 * within it, making them 'fire and forget'
1164 * and independent of the mainloop.
1166 #ifndef THREADED_DNS
1167 dns_poll(activefds[activefd]);
1173 /* It's a listener */
1174 uslen = sizeof(sock_us);
1175 length = sizeof(client);
1176 incomingSockfd = accept (activefds[activefd],(struct sockaddr*)&client,&length);
1177 if (!getsockname(incomingSockfd,(sockaddr*)&sock_us,&uslen))
1179 in_port = ntohs(sock_us.sin_port);
1180 log(DEBUG,"Accepted socket %d",incomingSockfd);
1181 target = (char*)inet_ntoa(client.sin_addr);
1182 /* Years and years ago, we used to resolve here
1183 * using gethostbyaddr(). That is sucky and we
1184 * don't do that any more...
1186 if (incomingSockfd >= 0)
1190 IOHookModule->OnRawSocketAccept(incomingSockfd, target, in_port);
1192 stats->statsAccept++;
1193 AddClient(incomingSockfd, target, in_port, false, target);
1194 log(DEBUG,"Adding client on port %lu fd=%lu",(unsigned long)in_port,(unsigned long)incomingSockfd);
1198 WriteOpers("*** WARNING: accept() failed on port %lu (%s)",(unsigned long)in_port,target);
1199 log(DEBUG,"accept failed: %lu",(unsigned long)in_port);
1200 stats->statsRefused++;
1205 log(DEBUG,"Couldnt look up the port number for fd %lu (OS BROKEN?!)",incomingSockfd);
1206 shutdown(incomingSockfd,2);
1207 close(incomingSockfd);
1212 /* Something went wrong if we're in here.
1213 * In fact, so wrong, im not quite sure
1214 * what we would do, so for now, its going
1215 * to safely do bugger all.
1222 /* This is never reached -- we hope! */
1226 /**********************************************************************************/
1229 * An ircd in four lines! bwahahaha. ahahahahaha. ahahah *cough*.
1232 int main(int argc, char** argv)
1234 ServerInstance = new InspIRCd(argc, argv);
1235 ServerInstance->Run();
1236 delete ServerInstance;