]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix for bug ID #6 (excessively long commands)
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 5 Apr 2004 09:57:15 +0000 (09:57 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 5 Apr 2004 09:57:15 +0000 (09:57 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@385 e03df62e-2008-0410-955e-edbf42e46eb7

docs/inspircd.conf.example
include/users.h
src/InspIRCd.layout
src/inspircd.cpp

index 00de3d415ce95dd41c3710d36a1a79906766cea7..ce24e89d04d091acc7a171de144d44232b938ecf 100644 (file)
 #                                                                    #
 #  Syntax is as follows:                                             #
 #      <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">                                    #
+#                                                                     #
+#   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="*">
+<connect allow="*" timeout="60">
 
 <connect deny="69.254.*">
 
index 901b303215b654cc4f62307ea2c6707b7c7e8984..8a71bf67e147337065c98c6318c63e82af433549 100644 (file)
@@ -35,8 +35,16 @@ class ConnectClass : public classbase
 {
  public:
        int type;
+       int registration_timeout;
        char host[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.
index 11aa9223f9210c4fb8674862aec691218e8ac7b5..325358fb1ca6e17b2ff14a53f9b60e3a31954e03 100644 (file)
@@ -13,9 +13,9 @@ LeftChar=1
 [Editor_1]
 Open=1
 Top=1
-CursorCol=60
-CursorRow=2398
-TopLine=2372
+CursorCol=54
+CursorRow=5298
+TopLine=5263
 LeftChar=1
 
 [Editor_2]
@@ -87,7 +87,7 @@ Open=1
 Top=0
 CursorCol=31
 CursorRow=75
-TopLine=49
+TopLine=1
 LeftChar=1
 
 [Editor_11]
@@ -179,11 +179,11 @@ TopLine=7
 LeftChar=1
 
 [Editor_22]
-Open=0
+Open=1
 Top=0
-CursorCol=19
-CursorRow=90
-TopLine=61
+CursorCol=34
+CursorRow=50
+TopLine=1
 LeftChar=1
 
 [Editor_23]
@@ -211,7 +211,7 @@ LeftChar=1
 [Editor_26]
 Open=1
 Top=0
-CursorCol=24
-CursorRow=58
+CursorCol=1
+CursorRow=66
 TopLine=29
 LeftChar=1
index adde759bf50d7a4782d937b6a93b42c75524d490..b998658f42fdfa928140ffcf2ea1e4eb5f320b6a 100644 (file)
@@ -372,7 +372,7 @@ void readfile(file_cache &F, const char* fname)
 
 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);
@@ -408,6 +408,7 @@ void ReadConfig(void)
   {
        strcpy(Value,"");
        ConfValue("connect","allow",i,Value);
+       ConfValue("connect","timeout",i,timeout);
        if (strcmp(Value,""))
        {
                strcpy(c.host,Value);
@@ -415,6 +416,11 @@ void ReadConfig(void)
                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);
        }
@@ -3668,28 +3674,36 @@ void handle_whois(char **parameters, int pcnt, userrec *user)
        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
        {
@@ -3957,14 +3971,13 @@ void ConnectUser(userrec *user)
 
        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);
@@ -5259,9 +5272,15 @@ int InspIRCd(void)
                        {
                                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';
@@ -5274,7 +5293,11 @@ int InspIRCd(void)
                                                        break;
                                                else
                                                {
-                                                       process_buffer(count2->second);
+                                                       if (strlen(count2->second->inbuf)<513)
+                                                       {
+                                                               // double check the length before processing!
+                                                               process_buffer(count2->second);
+                                                       }
                                                        break;
                                                }
                                        }