Fix for bug ID #6 (excessively long commands)

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@385 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2004-04-05 09:57:15 +00:00
parent 07c6999de2
commit 7ceac8fd6f
4 changed files with 72 additions and 36 deletions

View File

@ -103,12 +103,17 @@
# # # #
# Syntax is as follows: # # Syntax is as follows: #
# <connect allow="ip number"> # # <connect allow="ip number"> #
# <connect allow="ip number" password="blahblah"> # # <connect allow="ip number" password="blahblah"> #
# <connect allow="ip number" password="blah" timeout="10"> #
# <connect deny="ip number"> # # <connect deny="ip number"> #
# #
# You may optionally include timeout="x" on any alllow line, which #
# specifies the amount of time given before an unknown connection #
# is closed if USER/NICK/PASS are not given. This value is in secs #
# # # #
<connect allow="196.12.*" password="tiffany"> <connect allow="196.12.*" password="tiffany">
<connect allow="*"> <connect allow="*" timeout="60">
<connect deny="69.254.*"> <connect deny="69.254.*">

View File

@ -35,8 +35,16 @@ class ConnectClass : public classbase
{ {
public: public:
int type; int type;
int registration_timeout;
char host[MAXBUF]; char host[MAXBUF];
char pass[MAXBUF]; char pass[MAXBUF];
ConnectClass()
{
registration_timeout = 0;
strcpy(host,"");
strcpy(pass,"");
}
}; };
/** Holds a complete list of all channels to which a user has been invited and has not yet joined. /** Holds a complete list of all channels to which a user has been invited and has not yet joined.

View File

@ -13,9 +13,9 @@ LeftChar=1
[Editor_1] [Editor_1]
Open=1 Open=1
Top=1 Top=1
CursorCol=60 CursorCol=54
CursorRow=2398 CursorRow=5298
TopLine=2372 TopLine=5263
LeftChar=1 LeftChar=1
[Editor_2] [Editor_2]
@ -87,7 +87,7 @@ Open=1
Top=0 Top=0
CursorCol=31 CursorCol=31
CursorRow=75 CursorRow=75
TopLine=49 TopLine=1
LeftChar=1 LeftChar=1
[Editor_11] [Editor_11]
@ -179,11 +179,11 @@ TopLine=7
LeftChar=1 LeftChar=1
[Editor_22] [Editor_22]
Open=0 Open=1
Top=0 Top=0
CursorCol=19 CursorCol=34
CursorRow=90 CursorRow=50
TopLine=61 TopLine=1
LeftChar=1 LeftChar=1
[Editor_23] [Editor_23]
@ -211,7 +211,7 @@ LeftChar=1
[Editor_26] [Editor_26]
Open=1 Open=1
Top=0 Top=0
CursorCol=24 CursorCol=1
CursorRow=58 CursorRow=66
TopLine=29 TopLine=29
LeftChar=1 LeftChar=1

View File

@ -372,7 +372,7 @@ void readfile(file_cache &F, const char* fname)
void ReadConfig(void) void ReadConfig(void)
{ {
char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF]; char dbg[MAXBUF],pauseval[MAXBUF],Value[MAXBUF],timeout[MAXBUF];
ConnectClass c; ConnectClass c;
ConfValue("server","name",0,ServerName); ConfValue("server","name",0,ServerName);
@ -408,6 +408,7 @@ void ReadConfig(void)
{ {
strcpy(Value,""); strcpy(Value,"");
ConfValue("connect","allow",i,Value); ConfValue("connect","allow",i,Value);
ConfValue("connect","timeout",i,timeout);
if (strcmp(Value,"")) if (strcmp(Value,""))
{ {
strcpy(c.host,Value); strcpy(c.host,Value);
@ -415,6 +416,11 @@ void ReadConfig(void)
strcpy(Value,""); strcpy(Value,"");
ConfValue("connect","password",i,Value); ConfValue("connect","password",i,Value);
strcpy(c.pass,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); Classes.push_back(c);
log(DEBUG,"Read connect class type ALLOW, host=%s password=%s",c.host,c.pass); log(DEBUG,"Read connect class type ALLOW, host=%s password=%s",c.host,c.pass);
} }
@ -3668,28 +3674,36 @@ void handle_whois(char **parameters, int pcnt, userrec *user)
dest = Find(parameters[0]); dest = Find(parameters[0]);
if (dest) if (dest)
{ {
WriteServ(user->fd,"311 %s %s %s %s * :%s",user->nick, dest->nick, dest->ident, dest->dhost, dest->fullname); // bug found by phidjit - were able to whois an incomplete connection if it had sent a NICK or USER
if ((user == dest) || (strchr(user->modes,'o'))) if (dest->registered == 7)
{ {
WriteServ(user->fd,"378 %s %s :is connecting from *@%s",user->nick, dest->nick, dest->host); 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 (strcmp(chlist(dest),"")) else
{ {
WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, chlist(dest)); WriteServ(user->fd,"401 %s %s :No suck nick/channel",user->nick, parameters[0]);
} }
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);
} }
else else
{ {
@ -3957,14 +3971,13 @@ void ConnectUser(userrec *user)
if (strcmp(Passwd(user),"") && (!user->haspassed)) if (strcmp(Passwd(user),"") && (!user->haspassed))
{ {
Write(user->fd,"ERROR :Closing link: Invalid password");
kill_link(user,"Invalid password"); kill_link(user,"Invalid password");
return; return;
} }
if (IsDenied(user)) if (IsDenied(user))
{ {
Write(user->fd,"ERROR :Closing link: Unauthorized connection");
kill_link(user,"Unauthorised connection"); kill_link(user,"Unauthorised connection");
return;
} }
WriteServ(user->fd,"NOTICE Auth :Welcome to \002%s\002!",Network); WriteServ(user->fd,"NOTICE Auth :Welcome to \002%s\002!",Network);
@ -5259,9 +5272,15 @@ int InspIRCd(void)
{ {
if (count2->second) 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[509] = '\r';
count2->second->inbuf[510] = '\n'; count2->second->inbuf[510] = '\n';
count2->second->inbuf[511] = '\0'; count2->second->inbuf[511] = '\0';
@ -5274,7 +5293,11 @@ int InspIRCd(void)
break; break;
else else
{ {
process_buffer(count2->second); if (strlen(count2->second->inbuf)<513)
{
// double check the length before processing!
process_buffer(count2->second);
}
break; break;
} }
} }