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;
102 void AddServerName(std::string servername)
104 log(DEBUG,"Adding server name: %s",servername.c_str());
105 for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++)
107 if (*a == servername)
110 servernames.push_back(servername);
113 const char* FindServerNamePtr(std::string servername)
115 for (servernamelist::iterator a = servernames.begin(); a < servernames.end(); a++)
117 if (*a == servername)
120 AddServerName(servername);
121 return FindServerNamePtr(servername);
124 std::string InspIRCd::GetRevision()
126 /* w00t got me to replace a bunch of strtok_r
127 * with something nicer, so i did this. Its the
128 * same thing really, only in C++. It places the
129 * text into a std::stringstream which is a readable
130 * and writeable buffer stream, and then pops two
131 * words off it, space delimited. Because it reads
132 * into the same variable twice, the first word
133 * is discarded, and the second one returned.
135 std::stringstream Revision("$Revision$");
137 Revision >> single >> single;
142 /* This function pokes and hacks at a parameter list like the following:
144 * PART #winbot,#darkgalaxy :m00!
146 * to turn it into a series of individual calls like this:
149 * PART #darkgalaxy :m00!
151 * The seperate calls are sent to a callback function provided by the caller
152 * (the caller will usually call itself recursively). The callback function
153 * must be a command handler. Calling this function on a line with no list causes
154 * no action to be taken. You must provide a starting and ending parameter number
155 * where the range of the list can be found, useful if you have a terminating
156 * parameter as above which is actually not part of the list, or parameters
157 * before the actual list as well. This code is used by many functions which
158 * can function as "one to list" (see the RFC) */
160 int loop_call(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins)
165 char blog[32][MAXBUF];
166 char blog2[32][MAXBUF];
167 int j = 0, q = 0, total = 0, t = 0, t2 = 0, total2 = 0;
171 for (int i = 0; i <32; i++)
174 for (int i = 0; i <32; i++)
178 for (int i = 0; i <10; i++)
187 if (pcnt > 1) /* we have a key to copy */
189 strlcpy(keystr,parameters[1],MAXBUF);
193 if (!parameters[start])
197 if (!strchr(parameters[start],','))
202 for (int i = start; i <= end; i++)
206 strlcat(plist,parameters[i],MAXBUF);
214 for (int i = 0; i < t; i++)
219 strlcpy(blog[j++],param,MAXBUF);
223 WriteServ(u->fd,"407 %s %s :Too many targets in list, message not delivered.",u->nick,blog[j-1]);
228 strlcpy(blog[j++],param,MAXBUF);
231 if ((joins) && (keystr) && (total>0)) // more than one channel and is joining
236 if ((joins) && (keystr))
238 if (strchr(keystr,','))
243 for (int i = 0; i < t2; i++)
245 if (keystr[i] == ',')
248 strlcpy(blog2[j++],param,MAXBUF);
252 strlcpy(blog2[j++],param,MAXBUF);
257 for (j = 0; j < total; j++)
263 for (q = end; q < pcnt-1; q++)
267 pars[q-end+1] = parameters[q+1];
270 if ((joins) && (parameters[1]))
281 /* repeatedly call the function with the hacked parameter list */
282 if ((joins) && (pcnt > 1))
286 // pars[1] already set up and containing key from blog2[j]
291 pars[1] = parameters[1];
297 fn(pars,pcnt-(end-start),u);
306 InspIRCd::InspIRCd(int argc, char** argv)
309 module_sockets.clear();
310 this->startup_time = time(NULL);
312 log(DEBUG,"*** InspIRCd starting up!");
313 if (!FileExists(CONFIG_FILE))
315 printf("ERROR: Cannot open config file: %s\nExiting...\n",CONFIG_FILE);
316 log(DEFAULT,"main: no config");
317 printf("ERROR: Your config file is missing, this IRCd will self destruct in 10 seconds!\n");
321 for (int i = 1; i < argc; i++)
323 if (!strcmp(argv[i],"-nofork")) {
324 Config->nofork = true;
326 if (!strcmp(argv[i],"-wait")) {
329 if (!strcmp(argv[i],"-nolimit")) {
330 Config->unlimitcore = true;
335 strlcpy(Config->MyExecutable,argv[0],MAXBUF);
337 // initialize the lowercase mapping table
338 for (unsigned int cn = 0; cn < 256; cn++)
340 // lowercase the uppercase chars
341 for (unsigned int cn = 65; cn < 91; cn++)
342 lowermap[cn] = tolower(cn);
343 // now replace the specific chars for scandanavian comparison
344 lowermap[(unsigned)'['] = '{';
345 lowermap[(unsigned)']'] = '}';
346 lowermap[(unsigned)'\\'] = '|';
350 Config->ClearStack();
351 Config->Read(true,NULL);
354 AddServerName(Config->ServerName);
356 stats->BoundPortCount = BindPorts();
361 if (DaemonSeed() == ERROR)
363 printf("ERROR: could not go into daemon mode. Shutting down.\n");
368 /* Because of limitations in kqueue on freebsd, we must fork BEFORE we
369 * initialize the socket engine.
371 SE = new SocketEngine();
373 /* We must load the modules AFTER initializing the socket engine, now */
376 printf("\nInspIRCd is now running!\n");
382 void* dns_task(void* arg)
384 userrec* u = (userrec*)arg;
385 log(DEBUG,"DNS thread for user %s",u->nick);
390 if (dns1.ReverseLookup(u->ip))
392 log(DEBUG,"DNS Step 1");
393 while (!dns1.HasResult())
397 host = dns1.GetResult();
400 log(DEBUG,"DNS Step 2: '%s'",host.c_str());
401 if (dns2.ForwardLookup(host))
403 while (!dns2.HasResult())
407 ip = dns2.GetResultIP();
408 log(DEBUG,"DNS Step 3 '%s'(%d) '%s'(%d)",ip.c_str(),ip.length(),u->ip,strlen(u->ip));
409 if (ip == std::string(u->ip))
411 log(DEBUG,"DNS Step 4");
412 if (host.length() < 160)
414 log(DEBUG,"DNS Step 5");
415 strcpy(u->host,host.c_str());
416 strcpy(u->dhost,host.c_str());
427 std::string InspIRCd::GetVersionString()
429 char versiondata[MAXBUF];
431 char dnsengine[] = "multithread";
433 char dnsengine[] = "singlethread";
435 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);
440 bool is_valid_cmd(std::string &commandname, int pcnt, userrec * user)
442 for (unsigned int i = 0; i < cmdlist.size(); i++)
444 if (!strcasecmp(cmdlist[i].command,commandname.c_str()))
446 if (cmdlist[i].handler_function)
448 if ((pcnt>=cmdlist[i].min_params) && (strcasecmp(cmdlist[i].source,"<core>")))
450 if ((strchr(user->modes,cmdlist[i].flags_needed)) || (!cmdlist[i].flags_needed))
452 if (cmdlist[i].flags_needed)
454 if ((user->HasPermission(commandname)) || (is_uline(user->server)))
472 // calls a handler function for a command
474 void call_handler(std::string &commandname,char **parameters, int pcnt, userrec *user)
476 for (unsigned int i = 0; i < cmdlist.size(); i++)
478 if (!strcasecmp(cmdlist[i].command,commandname.c_str()))
480 if (cmdlist[i].handler_function)
482 if (pcnt>=cmdlist[i].min_params)
484 if ((strchr(user->modes,cmdlist[i].flags_needed)) || (!cmdlist[i].flags_needed))
486 if (cmdlist[i].flags_needed)
488 if ((user->HasPermission(commandname)) || (is_uline(user->server)))
490 cmdlist[i].handler_function(parameters,pcnt,user);
495 cmdlist[i].handler_function(parameters,pcnt,user);
504 int process_parameters(char **command_p,char *parameters)
507 int q = strlen(parameters);
510 /* no parameters, command_p invalid! */
513 if (parameters[0] == ':')
515 command_p[0] = parameters+1;
520 if ((strchr(parameters,' ')==NULL) || (parameters[0] == ':'))
522 /* only one parameter */
523 command_p[0] = parameters;
524 if (parameters[0] == ':')
526 if (strchr(parameters,' ') != NULL)
534 command_p[j++] = parameters;
535 for (int i = 0; i <= q; i++)
537 if (parameters[i] == ' ')
539 command_p[j++] = parameters+i+1;
540 parameters[i] = '\0';
541 if (command_p[j-1][0] == ':')
543 *command_p[j-1]++; /* remove dodgy ":" */
545 /* parameter like this marks end of the sequence */
549 return j; /* returns total number of items in the list */
552 void process_command(userrec *user, char* cmd)
556 char *command_p[127];
557 char p[MAXBUF], temp[MAXBUF];
558 int j, items, cmd_found;
560 for (int i = 0; i < 127; i++)
576 int total_params = 0;
579 for (unsigned int q = 0; q < strlen(cmd)-1; q++)
581 if ((cmd[q] == ' ') && (cmd[q+1] == ':'))
584 // found a 'trailing', we dont count them after this.
592 // another phidjit bug...
593 if (total_params > 126)
595 *(strchr(cmd,' ')) = '\0';
596 WriteServ(user->fd,"421 %s %s :Too many parameters given",user->nick,cmd);
600 strlcpy(temp,cmd,MAXBUF);
602 std::string tmp = cmd;
603 for (int i = 0; i <= MODCOUNT; i++)
605 std::string oldtmp = tmp;
606 modules[i]->OnServerRaw(tmp,true,user);
609 log(DEBUG,"A Module changed the input string!");
610 log(DEBUG,"New string: %s",tmp.c_str());
611 log(DEBUG,"Old string: %s",oldtmp.c_str());
615 strlcpy(cmd,tmp.c_str(),MAXBUF);
616 strlcpy(temp,cmd,MAXBUF);
618 if (!strchr(cmd,' '))
620 /* no parameters, lets skip the formalities and not chop up
622 log(DEBUG,"About to preprocess command with no params");
626 for (unsigned int i = 0; i <= strlen(cmd); i++)
628 cmd[i] = toupper(cmd[i]);
636 /* strip out extraneous linefeeds through mirc's crappy pasting (thanks Craig) */
637 for (unsigned int i = 0; i < strlen(temp); i++)
639 if ((temp[i] != 10) && (temp[i] != 13) && (temp[i] != 0) && (temp[i] != 7))
645 /* split the full string into a command plus parameters */
651 for (unsigned int i = 0; i <= strlen(cmd); i++)
653 /* capitalise the command ONLY, leave params intact */
654 cmd[i] = toupper(cmd[i]);
655 /* are we nearly there yet?! :P */
659 parameters = cmd+i+1;
667 for (unsigned int i = 0; i <= strlen(cmd); i++)
669 cmd[i] = toupper(cmd[i]);
676 if (strlen(command)>MAXCOMMAND)
678 WriteServ(user->fd,"421 %s %s :Command too long",user->nick,command);
682 for (unsigned int x = 0; x < strlen(command); x++)
684 if (((command[x] < 'A') || (command[x] > 'Z')) && (command[x] != '.'))
686 if (((command[x] < '0') || (command[x]> '9')) && (command[x] != '-'))
688 if (strchr("@!\"$%^&*(){}[]_=+;:'#~,<>/?\\|`",command[x]))
690 stats->statsUnknown++;
691 WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command);
698 std::string xcommand = command;
699 for (unsigned int i = 0; i != cmdlist.size(); i++)
701 if (cmdlist[i].command[0])
703 if (strlen(command)>=(strlen(cmdlist[i].command))) if (!strncmp(command, cmdlist[i].command,MAXCOMMAND))
709 items = process_parameters(command_p,parameters);
725 /* activity resets the ping pending timer */
726 user->nping = TIME + user->pingmax;
727 if ((items) < cmdlist[i].min_params)
729 log(DEBUG,"process_command: not enough parameters: %s %s",user->nick,command);
730 WriteServ(user->fd,"461 %s %s :Not enough parameters",user->nick,command);
733 if ((!strchr(user->modes,cmdlist[i].flags_needed)) && (cmdlist[i].flags_needed))
735 log(DEBUG,"process_command: permission denied: %s %s",user->nick,command);
736 WriteServ(user->fd,"481 %s :Permission Denied- You do not have the required operator privilages",user->nick);
740 if ((cmdlist[i].flags_needed) && (!user->HasPermission(xcommand)))
742 log(DEBUG,"process_command: permission denied: %s %s",user->nick,command);
743 WriteServ(user->fd,"481 %s :Permission Denied- Oper type %s does not have access to command %s",user->nick,user->oper,command);
747 /* if the command isnt USER, PASS, or NICK, and nick is empty,
749 if ((strncmp(command,"USER",4)) && (strncmp(command,"NICK",4)) && (strncmp(command,"PASS",4)))
751 if ((!isnick(user->nick)) || (user->registered != 7))
753 log(DEBUG,"process_command: not registered: %s %s",user->nick,command);
754 WriteServ(user->fd,"451 %s :You have not registered",command);
758 if ((user->registered == 7) && (!strchr(user->modes,'o')))
760 std::stringstream dcmds(Config->DisabledCommands);
765 if (!strcasecmp(thiscmd.c_str(),command))
767 // command is disabled!
768 WriteServ(user->fd,"421 %s %s :This command has been disabled.",user->nick,command);
773 if ((user->registered == 7) || (!strncmp(command,"USER",4)) || (!strncmp(command,"NICK",4)) || (!strncmp(command,"PASS",4)))
775 if (cmdlist[i].handler_function)
778 /* ikky /stats counters */
781 cmdlist[i].use_count++;
782 cmdlist[i].total_bytes+=strlen(temp);
786 FOREACH_RESULT(OnPreCommand(command,command_p,items,user));
787 if (MOD_RESULT == 1) {
791 /* WARNING: nothing may come after the
792 * command handler call, as the handler
793 * may free the user structure! */
795 cmdlist[i].handler_function(command_p,items,user);
801 WriteServ(user->fd,"451 %s :You have not registered",command);
809 if ((!cmd_found) && (user))
811 stats->statsUnknown++;
812 WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command);
816 bool removecommands(const char* source)
818 bool go_again = true;
822 for (std::deque<command_t>::iterator i = cmdlist.begin(); i != cmdlist.end(); i++)
824 if (!strcmp(i->source,source))
826 log(DEBUG,"removecommands(%s) Removing dependent command: %s",i->source,i->command);
837 void process_buffer(const char* cmdbuf,userrec *user)
841 log(DEFAULT,"*** BUG *** process_buffer was given an invalid parameter");
847 log(DEFAULT,"*** BUG *** process_buffer was given an invalid parameter");
854 while (*cmdbuf == ' ') cmdbuf++; // strip leading spaces
856 strlcpy(cmd,cmdbuf,MAXBUF);
861 int sl = strlen(cmd)-1;
862 if ((cmd[sl] == 13) || (cmd[sl] == 10))
867 if ((cmd[sl] == 13) || (cmd[sl] == 10))
872 while (cmd[sl] == ' ') // strip trailing spaces
882 log(DEBUG,"CMDIN: %s %s",user->nick,cmd);
886 process_command(user,cmd);
890 char* InspIRCd::ModuleError()
895 void InspIRCd::erase_factory(int j)
898 for (std::vector<ircd_module*>::iterator t = factory.begin(); t != factory.end(); t++)
903 factory.push_back(NULL);
910 void InspIRCd::erase_module(int j)
913 for (std::vector<Module*>::iterator m = modules.begin(); m!= modules.end(); m++)
919 modules.push_back(NULL);
925 for (std::vector<std::string>::iterator v = Config->module_names.begin(); v != Config->module_names.end(); v++)
929 Config->module_names.erase(v);
937 bool InspIRCd::UnloadModule(const char* filename)
939 std::string filename_str = filename;
940 for (unsigned int j = 0; j != Config->module_names.size(); j++)
942 if (Config->module_names[j] == filename_str)
944 if (modules[j]->GetVersion().Flags & VF_STATIC)
946 log(DEFAULT,"Failed to unload STATIC module %s",filename);
947 snprintf(MODERR,MAXBUF,"Module not unloadable (marked static)");
950 /* Give the module a chance to tidy out all its metadata */
951 for (chan_hash::iterator c = chanlist.begin(); c != chanlist.end(); c++)
953 modules[j]->OnCleanup(TYPE_CHANNEL,c->second);
955 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
957 modules[j]->OnCleanup(TYPE_USER,u->second);
959 FOREACH_MOD OnUnloadModule(modules[j],Config->module_names[j]);
961 log(DEBUG,"Deleting module...");
963 log(DEBUG,"Erasing module entry...");
965 log(DEBUG,"Removing dependent commands...");
966 removecommands(filename);
967 log(DEFAULT,"Module %s unloaded",filename);
972 log(DEFAULT,"Module %s is not loaded, cannot unload it!",filename);
973 snprintf(MODERR,MAXBUF,"Module not loaded");
977 bool InspIRCd::LoadModule(const char* filename)
979 char modfile[MAXBUF];
981 snprintf(modfile,MAXBUF,"%s",filename);
983 snprintf(modfile,MAXBUF,"%s/%s",Config->ModPath,filename);
985 std::string filename_str = filename;
987 if (!DirValid(modfile))
989 log(DEFAULT,"Module %s is not within the modules directory.",modfile);
990 snprintf(MODERR,MAXBUF,"Module %s is not within the modules directory.",modfile);
994 log(DEBUG,"Loading module: %s",modfile);
996 if (FileExists(modfile))
999 for (unsigned int j = 0; j < Config->module_names.size(); j++)
1001 if (Config->module_names[j] == filename_str)
1003 log(DEFAULT,"Module %s is already loaded, cannot load a module twice!",modfile);
1004 snprintf(MODERR,MAXBUF,"Module already loaded");
1008 ircd_module* a = new ircd_module(modfile);
1009 factory[MODCOUNT+1] = a;
1010 if (factory[MODCOUNT+1]->LastError())
1012 log(DEFAULT,"Unable to load %s: %s",modfile,factory[MODCOUNT+1]->LastError());
1013 snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
1017 if (factory[MODCOUNT+1]->factory)
1019 Module* m = factory[MODCOUNT+1]->factory->CreateModule(MyServer);
1020 modules[MODCOUNT+1] = m;
1021 /* save the module and the module's classfactory, if
1022 * this isnt done, random crashes can occur :/ */
1023 Config->module_names.push_back(filename);
1027 log(DEFAULT,"Unable to load %s",modfile);
1028 snprintf(MODERR,MAXBUF,"Factory function failed!");
1035 log(DEFAULT,"InspIRCd: startup: Module Not Found %s",modfile);
1036 snprintf(MODERR,MAXBUF,"Module file could not be found");
1041 FOREACH_MOD OnLoadModule(modules[MODCOUNT],filename_str);
1047 bool expire_run = false;
1048 std::vector<int> activefds;
1052 InspSocket* s = NULL;
1053 InspSocket* s_del = NULL;
1055 unsigned int numberactive;
1056 sockaddr_in sock_us; // our port number
1057 socklen_t uslen; // length of our port number
1059 if (!Config->nofork)
1061 freopen("/dev/null","w",stdout);
1062 freopen("/dev/null","w",stderr);
1065 /* Add the listening sockets used for client inbound connections
1066 * to the socket engine
1068 for (int count = 0; count < stats->BoundPortCount; count++)
1069 SE->AddFd(openSockfd[count],true,X_LISTEN);
1071 WritePID(Config->PID);
1073 /* main loop, this never returns */
1076 /* time() seems to be a pretty expensive syscall, so avoid calling it too much.
1077 * Once per loop iteration is pleanty.
1082 /* Run background module timers every few seconds
1083 * (the docs say modules shouldnt rely on accurate
1084 * timing using this event, so we dont have to
1085 * time this exactly).
1087 if (((TIME % 8) == 0) && (!expire_run))
1090 FOREACH_MOD OnBackgroundTimer(TIME);
1094 if ((TIME % 8) == 1)
1097 /* Once a second, do the background processing */
1098 if (TIME != OLDTIME)
1099 while (DoBackgroundUserStuff(TIME));
1101 /* Call the socket engine to wait on the active
1102 * file descriptors. The socket engine has everything's
1103 * descriptors in its list... dns, modules, users,
1104 * servers... so its nice and easy, just one call.
1106 SE->Wait(activefds);
1109 * Now process each of the fd's. For users, we have a fast
1110 * lookup table which can find a user by file descriptor, so
1111 * processing them by fd isnt expensive. If we have a lot of
1112 * listening ports or module sockets though, things could get
1115 numberactive = activefds.size();
1116 for (unsigned int activefd = 0; activefd < numberactive; activefd++)
1118 int socket_type = SE->GetType(activefds[activefd]);
1119 switch (socket_type)
1121 case X_ESTAB_CLIENT:
1123 cu = fd_ref_table[activefds[activefd]];
1129 case X_ESTAB_MODULE:
1131 /* Process module-owned sockets.
1132 * Modules are encouraged to inherit their sockets from
1133 * InspSocket so we can process them neatly like this.
1135 s = socket_ref[activefds[activefd]];
1137 if ((s) && (!s->Poll()))
1139 log(DEBUG,"Socket poll returned false, close and bail");
1140 SE->DelFd(s->GetFd());
1141 for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++)
1143 s_del = (InspSocket*)*a;
1144 if ((s_del) && (s_del->GetFd() == activefds[activefd]))
1146 module_sockets.erase(a);
1158 /* When we are using single-threaded dns,
1159 * the sockets for dns end up in our mainloop.
1160 * When we are using multi-threaded dns,
1161 * each thread has its own basic poll() loop
1162 * within it, making them 'fire and forget'
1163 * and independent of the mainloop.
1165 #ifndef THREADED_DNS
1166 dns_poll(activefds[activefd]);
1172 /* It's a listener */
1173 uslen = sizeof(sock_us);
1174 length = sizeof(client);
1175 incomingSockfd = accept (activefds[activefd],(struct sockaddr*)&client,&length);
1176 if (!getsockname(incomingSockfd,(sockaddr*)&sock_us,&uslen))
1178 in_port = ntohs(sock_us.sin_port);
1179 log(DEBUG,"Accepted socket %d",incomingSockfd);
1180 target = (char*)inet_ntoa(client.sin_addr);
1181 /* Years and years ago, we used to resolve here
1182 * using gethostbyaddr(). That is sucky and we
1183 * don't do that any more...
1185 if (incomingSockfd >= 0)
1189 IOHookModule->OnRawSocketAccept(incomingSockfd, target, in_port);
1191 stats->statsAccept++;
1192 AddClient(incomingSockfd, target, in_port, false, target);
1193 log(DEBUG,"Adding client on port %lu fd=%lu",(unsigned long)in_port,(unsigned long)incomingSockfd);
1197 WriteOpers("*** WARNING: accept() failed on port %lu (%s)",(unsigned long)in_port,target);
1198 log(DEBUG,"accept failed: %lu",(unsigned long)in_port);
1199 stats->statsRefused++;
1204 log(DEBUG,"Couldnt look up the port number for fd %lu (OS BROKEN?!)",incomingSockfd);
1205 shutdown(incomingSockfd,2);
1206 close(incomingSockfd);
1211 /* Something went wrong if we're in here.
1212 * In fact, so wrong, im not quite sure
1213 * what we would do, so for now, its going
1214 * to safely do bugger all.
1221 /* This is never reached -- we hope! */
1225 /**********************************************************************************/
1228 * An ircd in four lines! bwahahaha. ahahahahaha. ahahah *cough*.
1231 int main(int argc, char** argv)
1233 ServerInstance = new InspIRCd(argc, argv);
1234 ServerInstance->Run();
1235 delete ServerInstance;