void ReadConfig(void)
{
- char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF];
+ char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF],timeout[MAXBUF];
ConnectClass c;
ConfValue("server","name",0,ServerName);
{
strcpy(Value,"");
ConfValue("connect","allow",i,Value);
+ ConfValue("connect","timeout",i,timeout);
if (strcmp(Value,""))
{
strcpy(c.host,Value);
strcpy(Value,"");
ConfValue("connect","password",i,Value);
strcpy(c.pass,Value);
+ c.registration_timeout = 90; // default is 2 minutes
+ if (atoi(timeout)>0)
+ {
+ c.registration_timeout = atoi(timeout);
+ }
Classes.push_back(c);
log(DEBUG,"Read connect class type ALLOW, host=%s password=%s",c.host,c.pass);
}
dest = Find(parameters[0]);
if (dest)
{
- WriteServ(user->fd,"311 %s %s %s %s * :%s",user->nick, dest->nick, dest->ident, dest->dhost, dest->fullname);
- if ((user == dest) || (strchr(user->modes,'o')))
- {
- WriteServ(user->fd,"378 %s %s :is connecting from *@%s",user->nick, dest->nick, dest->host);
- }
- if (strcmp(chlist(dest),""))
- {
- WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, chlist(dest));
- }
- WriteServ(user->fd,"312 %s %s %s :%s",user->nick, dest->nick, dest->server, ServerDesc);
- if (strcmp(dest->awaymsg,""))
+ // bug found by phidjit - were able to whois an incomplete connection if it had sent a NICK or USER
+ if (dest->registered == 7)
{
- WriteServ(user->fd,"301 %s %s :%s",user->nick, dest->nick, dest->awaymsg);
+ WriteServ(user->fd,"311 %s %s %s %s * :%s",user->nick, dest->nick, dest->ident, dest->dhost, dest->fullname);
+ if ((user == dest) || (strchr(user->modes,'o')))
+ {
+ WriteServ(user->fd,"378 %s %s :is connecting from *@%s",user->nick, dest->nick, dest->host);
+ }
+ if (strcmp(chlist(dest),""))
+ {
+ WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, chlist(dest));
+ }
+ WriteServ(user->fd,"312 %s %s %s :%s",user->nick, dest->nick, dest->server, ServerDesc);
+ if (strcmp(dest->awaymsg,""))
+ {
+ WriteServ(user->fd,"301 %s %s :%s",user->nick, dest->nick, dest->awaymsg);
+ }
+ if (strchr(dest->modes,'o'))
+ {
+ WriteServ(user->fd,"313 %s %s :is an IRC operator",user->nick, dest->nick);
+ }
+ //WriteServ(user->fd,"310 %s %s :is available for help.",user->nick, dest->nick);
+ WriteServ(user->fd,"317 %s %s %d %d :seconds idle, signon time",user->nick, dest->nick, abs((dest->idle_lastmsg)-time(NULL)), dest->signon);
+
+ WriteServ(user->fd,"318 %s %s :End of /WHOIS list.",user->nick, dest->nick);
}
- if (strchr(dest->modes,'o'))
+ else
{
- WriteServ(user->fd,"313 %s %s :is an IRC operator",user->nick, dest->nick);
+ WriteServ(user->fd,"401 %s %s :No suck nick/channel",user->nick, parameters[0]);
}
- //WriteServ(user->fd,"310 %s %s :is available for help.",user->nick, dest->nick);
- WriteServ(user->fd,"317 %s %s %d %d :seconds idle, signon time",user->nick, dest->nick, abs((dest->idle_lastmsg)-time(NULL)), dest->signon);
-
- WriteServ(user->fd,"318 %s %s :End of /WHOIS list.",user->nick, dest->nick);
}
else
{
if (strcmp(Passwd(user),"") && (!user->haspassed))
{
- Write(user->fd,"ERROR :Closing link: Invalid password");
kill_link(user,"Invalid password");
return;
}
if (IsDenied(user))
{
- Write(user->fd,"ERROR :Closing link: Unauthorized connection");
kill_link(user,"Unauthorised connection");
+ return;
}
WriteServ(user->fd,"NOTICE Auth :Welcome to \002%s\002!",Network);
{
if (count2->second)
{
- strncat(count2->second->inbuf, data, result);
+
+ // until the buffer is at 509 chars anything can be inserted into it.
+ if (strlen(count2->second->inbuf) < 509) {
+ strncat(count2->second->inbuf, data, result);
+ }
- if (strlen(count2->second->inbuf) > 509) {
+ // once you reach 509 chars, only a \r or \n can be inserted,
+ // completing the line.
+ if ((strlen(count2->second->inbuf) >= 509) && ((data[0] == '\r') || (data[0] == '\n'))) {
count2->second->inbuf[509] = '\r';
count2->second->inbuf[510] = '\n';
count2->second->inbuf[511] = '\0';
break;
else
{
- process_buffer(count2->second);
+ if (strlen(count2->second->inbuf)<513)
+ {
+ // double check the length before processing!
+ process_buffer(count2->second);
+ }
break;
}
}