]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/connection.cpp
Added documentation to manpages of Request, Event and ModuleMessage
[user/henk/code/inspircd.git] / src / connection.cpp
index 97619619f30452a03e83a8e67e133016765890b1..b197caef1a43097200e71771fece4e344a885e9c 100644 (file)
@@ -25,6 +25,7 @@
 #include <deque>
 #include "inspircd.h"
 #include "modules.h"
+#include "inspstring.h"
 
 using namespace std;
 
@@ -34,7 +35,7 @@ extern std::vector<ircd_module*> factory;
 
 extern int MODCOUNT;
 
-
+extern time_t TIME;
 
 connection::connection()
 {
@@ -60,7 +61,7 @@ bool connection::CreateListener(char* host, int p)
 
        setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,(const char*)&on,sizeof(on));
        linger.l_onoff = 1;
-       linger.l_linger = 0;
+       linger.l_linger = 1;
        setsockopt(fd,SOL_SOCKET,SO_LINGER,(const char*)&linger,sizeof(linger));
        
        // attempt to increase socket sendq and recvq as high as its possible
@@ -202,7 +203,7 @@ bool connection::BeginLink(char* targethost, int port, char* password, char* ser
                        // targethost has been turned into an ip...
                        // we dont want this as the server name.
                        connector.SetServerName(servername);
-                       sprintf(connect,"S %s %s %d %d :%s",getservername().c_str(),password,myport,GetRevision(),getserverdesc().c_str());
+                       snprintf(connect,MAXBUF,"S %s %s %d %d :%s",getservername().c_str(),password,myport,GetRevision(),getserverdesc().c_str());
                        connector.SetState(STATE_NOAUTH_OUTBOUND);
                        connector.SetHostAndPort(targethost, port);
                        this->connectors.push_back(connector);
@@ -232,7 +233,7 @@ bool connection::MeshCookie(char* targethost, int port, long cookie, char* serve
                        // targethost has been turned into an ip...
                        // we dont want this as the server name.
                        connector.SetServerName(servername);
-                       sprintf(connect,"- %d %s :%s",cookie,getservername().c_str(),getserverdesc().c_str());
+                       snprintf(connect,MAXBUF,"- %d %s :%s",cookie,getservername().c_str(),getserverdesc().c_str());
                        connector.SetState(STATE_NOAUTH_OUTBOUND);
                        connector.SetHostAndPort(targethost, port);
                        connector.SetState(STATE_CONNECTED);
@@ -357,7 +358,7 @@ bool connection::SendPacket(char *message, const char* host)
        
        if (!strchr(message,'\n'))
        {
-               strncat(message,"\n",MAXBUF);
+               strlcat(message,"\n",MAXBUF);
        }
 
        if (cn)
@@ -368,7 +369,7 @@ bool connection::SendPacket(char *message, const char* host)
                {
                        log(DEBUG,"Main route to %s is down, seeking alternative",host);
                        // fix: can only route one hop to avoid a loop
-                       if (strncat(message,"R ",2))
+                       if (strlcat(message,"R ",2))
                        {
                                // this route is down, we must re-route the packet through an available point in the mesh.
                                for (int k = 0; k < this->connectors.size(); k++)
@@ -452,7 +453,7 @@ bool connection::RecvPacket(std::deque<std::string> &messages, char* host)
                                        if (strlen(sanitized))
                                        {
                                                messages.push_back(sanitized);
-                                               strncpy(host,this->connectors[i].GetServerName().c_str(),160);
+                                               strlcpy(host,this->connectors[i].GetServerName().c_str(),160);
                                                log(DEBUG,"main: Connection::RecvPacket() got '%s' from %s",sanitized,host);
                                                
                                        }
@@ -468,7 +469,6 @@ bool connection::RecvPacket(std::deque<std::string> &messages, char* host)
 
 long connection::GenKey()
 {
-       srand(time(NULL));
        return (random()*time(NULL));
 }