extern time_t TIME;
-extern std::vector<int> fd_reap;
extern std::vector<std::string> module_names;
extern char MyExecutable[1024];
char a[MAXBUF],b[MAXBUF];
strlcpy(a,s1.c_str(),MAXBUF);
strlcpy(b,s2.c_str(),MAXBUF);
+ strlower(a);
+ strlower(b);
return (strcasecmp(a,b) == 0);
}
}
// this must be propogated so that channel membership is kept in step network-wide
-
char buffer[MAXBUF];
snprintf(buffer,MAXBUF,"k %s %s %s :%s",user->nick,u->nick,Ptr->name,reason);
NetSendToAll(buffer);
sleep(1);
for (int i = 0; i < 65536; i++)
{
- int on = 0;
+ int on = 1;
struct linger linger = { 0 };
setsockopt(i, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on));
linger.l_onoff = 1;
- linger.l_linger = 0;
+ linger.l_linger = 1;
setsockopt(i, SOL_SOCKET, SO_LINGER, (const char*)&linger,sizeof(linger));
Blocking(i);
close(i);
}
- sleep(5);
+ sleep(2);
execv(MyExecutable,argv);
log(DEBUG,"kill: %s %s",parameters[0],parameters[1]);
if (u)
{
+ log(DEBUG,"into kill mechanism");
int MOD_RESULT = 0;
FOREACH_RESULT(OnKill(user,u,parameters[1]));
if (MOD_RESULT) {
+ log(DEBUG,"A module prevented the kill with result %d",MOD_RESULT);
return;
}
log(DEBUG,"deleting user hash value %d",iter->second);
if ((iter->second) && (user->registered == 7)) {
delete iter->second;
- }
- clientlist.erase(iter);
+ }
+ clientlist.erase(iter);
}
purge_empty_chans();
}
else
{
// local kill
+ log(DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick, ServerName,user->dhost,user->nick,parameters[1]);
WriteTo(user, u, "KILL %s :%s!%s!%s (%s)", u->nick, ServerName,user->dhost,user->nick,parameters[1]);
WriteOpers("*** Local Kill by %s: %s!%s@%s (%s)",user->nick,u->nick,u->ident,u->host,parameters[1]);
snprintf(killreason,MAXBUF,"Killed (%s (%s))",user->nick,parameters[1]);
WriteServ(user->fd,"462 %s :You may not reregister",user->nick);
return;
}
+ strlcpy(user->password,parameters[0],MAXBUF);
if (!strcasecmp(parameters[0],Passwd(user)))
{
user->haspassed = true;
WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel", user->nick, Ptr->name);
return;
}
-
+
char topic[MAXBUF];
strlcpy(topic,parameters[1],MAXBUF);
if (strlen(topic)>MAXTOPIC)
{
topic[MAXTOPIC-1] = '\0';
}
-
+
+ if (!strcasecmp(user->server,ServerName))
+ {
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(OnLocalTopicChange(user,Ptr,topic));
+ if (MOD_RESULT)
+ return;
+ }
+
strlcpy(Ptr->topic,topic,MAXBUF);
strlcpy(Ptr->setby,user->nick,NICKMAX);
Ptr->topicset = TIME;
{
chanrec* c;
+ if (!pcnt)
+ {
+ WriteServ(user->fd,"366 %s * :End of /NAMES list.",user->nick);
+ return;
+ }
+
if (loop_call(handle_names,parameters,pcnt,user,0,pcnt-1,0))
return;
c = FindChan(parameters[0]);
void handle_info(char **parameters, int pcnt, userrec *user)
{
- WriteServ(user->fd,"371 %s :The Inspire IRCd Project Has been brought to you by the following people..",user->nick);
- WriteServ(user->fd,"371 %s :Craig Edwards, Craig McLure, and Others..",user->nick);
- WriteServ(user->fd,"371 %s :Will finish this later when i can be arsed :p",user->nick);
+ WriteServ(user->fd,"371 %s :. o O (The Inspire Internet Relay Chat Server) O o .",user->nick);
+ WriteServ(user->fd,"371 %s : ",user->nick);
+ WriteServ(user->fd,"371 %s :Core developers: Craig Edwards (Brain)",user->nick);
+ WriteServ(user->fd,"371 %s : Craig McLure",user->nick);
+ WriteServ(user->fd,"371 %s : ",user->nick);
+ WriteServ(user->fd,"371 %s :Contributors: typobox43",user->nick);
+ WriteServ(user->fd,"371 %s : w00t",user->nick);
+ WriteServ(user->fd,"371 %s : Om",user->nick);
+ WriteServ(user->fd,"371 %s : Jazza",user->nick);
+ WriteServ(user->fd,"371 %s : ",user->nick);
+ WriteServ(user->fd,"371 %s :Testers: CC",user->nick);
+ WriteServ(user->fd,"371 %s : Piggles",user->nick);
+ WriteServ(user->fd,"371 %s : Foamy",user->nick);
+ WriteServ(user->fd,"371 %s : Hart",user->nick);
+ WriteServ(user->fd,"371 %s : RageD",user->nick);
+ WriteServ(user->fd,"371 %s : [ed]",user->nick);
+ WriteServ(user->fd,"371 %s : Azhrarn",user->nick);
+ WriteServ(user->fd,"371 %s : nenolod",user->nick);
+ WriteServ(user->fd,"371 %s : luigiman",user->nick);
+ WriteServ(user->fd,"371 %s : Chu",user->nick);
+ WriteServ(user->fd,"371 %s : aquanight",user->nick);
+ WriteServ(user->fd,"371 %s : xptek",user->nick);
+ WriteServ(user->fd,"371 %s : Grantlinks",user->nick);
+ WriteServ(user->fd,"371 %s : Rob",user->nick);
+ WriteServ(user->fd,"371 %s : angelic",user->nick);
+ WriteServ(user->fd,"371 %s : Jason",user->nick);
+ WriteServ(user->fd,"371 %s : ",user->nick);
+ WriteServ(user->fd,"371 %s :Thanks to irc-junkie and searchirc",user->nick);
+ WriteServ(user->fd,"371 %s :for the nice comments and the help",user->nick);
+ WriteServ(user->fd,"371 %s :you gave us in attracting users to",user->nick);
+ WriteServ(user->fd,"371 %s :this software.",user->nick);
+ WriteServ(user->fd,"371 %s : ",user->nick);
+ WriteServ(user->fd,"371 %s :Best experienced with: An IRC client.",user->nick);
FOREACH_MOD OnInfo(user);
WriteServ(user->fd,"374 %s :End of /INFO list",user->nick);
}
AddWhoWas(user);
}
+ FOREACH_MOD OnUserDisconnect(user);
+
/* push the socket on a stack of sockets due to be closed at the next opportunity */
- fd_reap.push_back(user->fd);
+ if (user->fd > -1)
+ {
+ shutdown(user->fd,2);
+ close(user->fd);
+ }
if (iter != clientlist.end())
{
WriteServ(user->fd,"461 %s USER :Not enough parameters",user->nick);
}
else {
- WriteServ(user->fd,"NOTICE Auth :No ident response, ident prefixed with ~");
strcpy(user->ident,"~"); /* we arent checking ident... but these days why bother anyway? */
strlcat(user->ident,parameters[0],IDENTMAX);
strlcpy(user->fullname,parameters[3],128);
if (user->registered == 3)
{
/* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
+ FOREACH_MOD OnUserRegister(user);
ConnectUser(user);
}
}
{
for (int i = 0; i < module_names.size(); i++)
{
- Version V = modules[i]->GetVersion();
- char modulename[MAXBUF];
- strlcpy(modulename,module_names[i].c_str(),256);
- WriteServ(user->fd,"900 %s :0x%08lx %d.%d.%d.%d %s",user->nick,modules[i],V.Major,V.Minor,V.Revision,V.Build,CleanFilename(modulename));
+ Version V = modules[i]->GetVersion();
+ char modulename[MAXBUF];
+ char flagstate[MAXBUF];
+ strcpy(flagstate,"");
+ if (V.Flags & VF_STATIC)
+ strlcat(flagstate,", static",MAXBUF);
+ if (V.Flags & VF_VENDOR)
+ strlcat(flagstate,", vendor",MAXBUF);
+ if (V.Flags & VF_COMMON)
+ strlcat(flagstate,", common",MAXBUF);
+ if (V.Flags & VF_SERVICEPROVIDER)
+ strlcat(flagstate,", service provider",MAXBUF);
+ if (!strlen(flagstate))
+ strcpy(flagstate," <no flags>");
+ strlcpy(modulename,module_names[i].c_str(),256);
+ if (strchr(user->modes,'o'))
+ {
+ WriteServ(user->fd,"900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,modules[i],V.Major,V.Minor,V.Revision,V.Build,CleanFilename(modulename),flagstate+2);
+ }
+ else
+ {
+ WriteServ(user->fd,"900 %s :%s",user->nick,CleanFilename(modulename));
+ }
}
}
}
+ FOREACH_MOD OnStats(*parameters[0]);
+
if (!strcasecmp(parameters[0],"c"))
{
for (int i = 0; i < ConfValueEnum("link",&config_f); i++)
char Link_Pass[1024];
int LinkPort;
bool found = false;
-
+
for (int i = 0; i < ConfValueEnum("link",&config_f); i++)
{
if (!found)
}
return false;
}
-
+int operstrcmp(char* data,char* input)
+{
+ int MOD_RESULT = 0;
+ FOREACH_RESULT(OnOperCompare(data,input))
+ if (MOD_RESULT == 1)
+ return 0;
+ if (MOD_RESULT == -1)
+ return 1;
+ return strcmp(data,input);
+}
void handle_oper(char **parameters, int pcnt, userrec *user)
{
ConfValue("oper","password",i,Password,&config_f);
ConfValue("oper","type",i,OperType,&config_f);
ConfValue("oper","host",i,HostName,&config_f);
- if ((!strcmp(LoginName,parameters[0])) && (!strcmp(Password,parameters[1])) && (match(TheHost,HostName)))
+ if ((!strcmp(LoginName,parameters[0])) && (!operstrcmp(Password,parameters[1])) && (match(TheHost,HostName)))
{
fail2 = true;
for (j =0; j < ConfValueEnum("type",&config_f); j++)
if (!fail2)
{
WriteServ(user->fd,"491 %s :Invalid oper credentials",user->nick);
- WriteOpers("*** WARNING! qFailed oper attempt by %s!%s@%s!",user->nick,user->ident,user->host);
+ WriteOpers("*** WARNING! Failed oper attempt by %s!%s@%s!",user->nick,user->ident,user->host);
log(DEFAULT,"OPER: Failed oper attempt by %s!%s@%s: user, host or password did not match.",user->nick,user->ident,user->host);
}
else
if (user->registered == 3)
{
/* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
+ FOREACH_MOD OnUserRegister(user);
ConnectUser(user);
}
if (user->registered == 7)
void handle_L(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host)
{
- char* nick = strtok(params," ");
- char* channel = strtok(NULL," :");
- char* reason = strtok(NULL,"\r\n");
+ char* nick = NULL;
+ char* channel = NULL;
+ char* reason = NULL;
+ log(DEBUG,"L TOKEN PARS: '%s'",params);
+ if (strstr(params,":#"))
+ {
+ nick = strtok(params," ");
+ channel = strtok(NULL,"\r\n");
+ channel++;
+ reason = "";
+ }
+ else
+ {
+ nick = strtok(params," ");
+ channel = strtok(NULL," :");
+ reason = strtok(NULL,"\r\n");
+ reason++;
+ }
userrec* user = Find(nick);
- reason++;
- if (user)
+ if ((user) && (channel) && (reason))
{
- if (strcmp(reason,""))
+ if ((!reason) && (*reason != '\0'))
{
del_channel(user,channel,reason,true);
}
char* create_time = strtok(NULL," ");
char* duration = strtok(NULL," :");
char* reason = strtok(NULL,"\r\n");
- add_gline(atoi(duration),who,reason,mask);
+ add_gline(atoi(duration),(const char*)who,(const char*)reason,(const char*)mask);
// we must update the creation time on this gline
// now that we've added it, or it wont expire at the right time.
gline_set_creation_time(mask,atoi(create_time));
char* who = strtok(NULL," ");
if (mask)
{
- if (del_gline(mask))
+ if (del_gline((const char*)mask))
{
if (who)
{
char* create_time = strtok(NULL," ");
char* duration = strtok(NULL," :");
char* reason = strtok(NULL,"\r\n");
- add_qline(atoi(duration),who,reason,mask);
+ add_qline(atoi(duration),(const char*)who,(const char*)reason,(const char*)mask);
// we must update the creation time on this gline
// now that we've added it, or it wont expire at the right time.
qline_set_creation_time(mask,atoi(create_time));
char* who = strtok(NULL," ");
if (mask)
{
- if (del_qline(mask))
+ if (del_qline((const char*)mask))
{
if (who)
{
char* create_time = strtok(NULL," ");
char* duration = strtok(NULL," :");
char* reason = strtok(NULL,"\r\n");
- add_zline(atoi(duration),who,reason,mask);
+ add_zline(atoi(duration),(const char*)who,(const char*)reason,(const char*)mask);
// we must update the creation time on this gline
// now that we've added it, or it wont expire at the right time.
zline_set_creation_time(mask,atoi(create_time));
char* who = strtok(NULL," ");
if (mask)
{
- if (del_zline(mask))
+ if (del_zline((const char*)mask))
{
if (who)
{
void process_restricted_commands(char token,char* params,serverrec* source,serverrec* reply, char* tcp_host,char* ipaddr,int port)
{
char buffer[MAXBUF];
+ int MOD_RESULT = 0;
switch(token)
{
break;
// anything else
default:
- WriteOpers("WARNING! Unknown datagram type '%c'",token);
+ MOD_RESULT = 0;
+ string_list s;
+ char* data = strtok(params," ");
+ while (data)
+ {
+ if (*data == ':')
+ {
+ // the last item is a special case
+ data++;
+ char datalast[MAXBUF];
+ strlcpy(datalast,data,MAXBUF);
+ data = strtok(NULL," ");
+ while (data)
+ {
+ strlcpy(datalast," ",MAXBUF);
+ strlcpy(datalast,data,MAXBUF);
+ data = strtok(NULL," ");
+ }
+ s.push_back(data);
+ break;
+ }
+ s.push_back(data);
+ data = strtok(NULL," ");
+ }
+ FOREACH_RESULT(OnMeshToken(token,s,source,reply,tcp_host,ipaddr,port));
+ if (!MOD_RESULT)
+ WriteOpers("WARNING! Unknown datagram type '%c'",token);
break;
}
}
}
char response[10240];
+ char old2[MAXBUF];
char token = udp_msg[0];
char* old = udp_msg;
+ if ((token != ':') && (strlen(udp_msg)>1) && (udp_msg[1] != ' '))
+ {
+ WriteOpers("*** Discarded %d chars illegal data from %s",strlen(udp_msg),tcp_host);
+ }
+
if (token == ':') // leading :servername or details - strip them off (services does this, sucky)
{
char* src = udp_msg+1;
{
token = '*';
}
+ if (!strcmp(command,"PING"))
+ {
+ token = '*';
+ }
if (!strcmp(command,"NOTICE"))
{
snprintf(udp_msg,MAXBUF,"V %s %s",source,data);
}
-
char* params = udp_msg + 2;
char finalparam[1024];
strcpy(finalparam," :xxxx");
char Link_Pass[1024];
char Link_SendPass[1024];
int LinkPort = 0;
-
+
// search for a corresponding <link> block in the config files
for (int i = 0; i < ConfValueEnum("link",&config_f); i++)
{
char Link_Pass[1024];
char Link_SendPass[1024];
int LinkPort = 0;
+
+ log(DEBUG,"U-token linked server detected.");
+
+
+ for (int j = 0; j < 32; j++)
+ {
+ if (me[j] != NULL)
+ {
+ for (int k = 0; k < me[j]->connectors.size(); k++)
+ {
+ if (!strcasecmp(me[j]->connectors[k].GetServerName().c_str(),servername))
+ {
+ char buffer[MAXBUF];
+ sprintf(buffer,"E :Access is denied (Server exists in the mesh)");
+ serv->SendPacket(buffer,tcp_host);
+ WriteOpers("CONNECT from %s denied, \"%s\" already exists!",tcp_host,servername);
+ RemoveServer(tcp_host);
+ return;
+ }
+ }
+ }
+ }
// search for a corresponding <link> block in the config files
for (int i = 0; i < ConfValueEnum("link",&config_f); i++)
me[j]->connectors[k].SetState(STATE_SERVICES);
sprintf(buffer,"X 0");
serv->SendPacket(buffer,servername);
+ sprintf(buffer,"s %s %s %lu :%s",ServerName,Link_SendPass,LinkPort,ServerDesc);
+ serv->SendPacket(buffer,servername);
DoSync(me[j],servername);
snprintf(buffer,MAXBUF,"H %s",servername);
NetSendToAllExcept(servername,buffer);
}
}
-long duration(char* str)
+long duration(const char* str)
{
char n_field[MAXBUF];
long total = 0;
- char* str_end = str + strlen(str);
+ const char* str_end = str + strlen(str);
n_field[0] = 0;
- for (char* i = str; i < str_end; i++)
+ for (char* i = (char*)str; i < str_end; i++)
{
// if we have digits, build up a string for the value in n_field,
// up to 10 digits in size.