summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-14 18:58:25 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2004-04-14 18:58:25 +0000
commit8be0c0008766de9003c7e8dd2ae74bf7c9dcd525 (patch)
tree25034a9d41c26eba067bacd9a72fd47c17914e7a
parent84d9f0dc9aa9eff59ec606882821e82bf9194752 (diff)
More fixes to connection buffer handling
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@579 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/connection.h2
-rw-r--r--src/InspIRCd.layout18
-rw-r--r--src/connection.cpp32
-rw-r--r--src/inspircd.cpp24
4 files changed, 51 insertions, 25 deletions
diff --git a/include/connection.h b/include/connection.h
index a18d201ef..d92cc6354 100644
--- a/include/connection.h
+++ b/include/connection.h
@@ -110,7 +110,7 @@ class connection : public classbase
bool BeginLink(char* targethost, int port, char* password, char* servername);
void TerminateLink(char* targethost);
bool SendPacket(char *message, char* host);
- bool RecvPacket(char *message, char* host);
+ bool RecvPacket(string_list &messages, char* host);
ircd_connector* FindHost(std::string host);
bool AddIncoming(int fd,char* targethost);
long GenKey();
diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout
index c14000142..e046c5074 100644
--- a/src/InspIRCd.layout
+++ b/src/InspIRCd.layout
@@ -13,9 +13,9 @@ LeftChar=1
[Editor_1]
Open=1
Top=1
-CursorCol=58
-CursorRow=6681
-TopLine=6621
+CursorCol=24
+CursorRow=7093
+TopLine=7056
LeftChar=1
[Editor_2]
@@ -109,9 +109,9 @@ LeftChar=1
[Editor_13]
Open=1
Top=0
-CursorCol=28
-CursorRow=21
-TopLine=4
+CursorCol=39
+CursorRow=113
+TopLine=57
LeftChar=1
[Editor_14]
@@ -197,9 +197,9 @@ LeftChar=1
[Editor_24]
Open=1
Top=0
-CursorCol=36
-CursorRow=177
-TopLine=149
+CursorCol=62
+CursorRow=266
+TopLine=239
LeftChar=1
[Editor_25]
Open=1
diff --git a/src/connection.cpp b/src/connection.cpp
index 513ac69db..19424afc4 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -256,20 +256,40 @@ bool connection::SendPacket(char *message, char* host)
// receives a packet from any where there is data waiting, first come, first served
// fills the message and host values with the host where the data came from.
-bool connection::RecvPacket(char *message, char* host)
+bool connection::RecvPacket(string_list &messages, char* host)
{
+ char data[32767];
for (int i = 0; i < this->connectors.size(); i++)
{
// returns false if the packet could not be sent (e.g. target host down)
int rcvsize = 0;
- if (rcvsize = recv(this->connectors[i].GetDescriptor(),message,MAXBUF,0))
+ if (rcvsize = recv(this->connectors[i].GetDescriptor(),data,32767,0))
{
if (rcvsize > 0)
{
- // something new on this socket, fill the return values and bail
- strncpy(host,this->connectors[i].GetServerName().c_str(),160);
- message[rcvsize-1] = 0;
- log(DEBUG,"main: Connection::RecvPacket() got '%s' from %s",message,host);
+ char* l = strtok(data,"\n");
+ while (l)
+ {
+ char sanitized[32767];
+ memset(sanitized, 0, 32767);
+ int ptt = 0;
+ for (int pt = 0; pt < strlen(l); pt++)
+ {
+ if (l[pt] != '\r')
+ {
+ sanitized[ptt++] = l[pt];
+ }
+ }
+ sanitized[ptt] = '\0';
+ if (strlen(sanitized))
+ {
+ messages.push_back(sanitized);
+ strncpy(host,this->connectors[i].GetServerName().c_str(),160);
+ log(DEBUG,"main: Connection::RecvPacket() got '%s' from %s",sanitized,host);
+
+ }
+ l = strtok(NULL,"\n");
+ }
return true;
}
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 5b85093c1..b43734073 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -7082,16 +7082,22 @@ int InspIRCd(void)
for (int x = 0; x != UDPportCount; x++)
{
- long theirkey = 0;
- if (me[x]->RecvPacket(udp_msg, udp_host))
+ string_list msgs;
+ msgs.clear();
+ if (me[x]->RecvPacket(msgs, udp_host))
{
- if (strlen(udp_msg)<1) {
- log(DEBUG,"Invalid string from %s [route%d]",udp_host,x);
- }
- else
- {
- FOREACH_MOD OnPacketReceive(udp_msg);
- handle_link_packet(udp_msg, udp_host, me[x]);
+ for (int ctr = 0; ctr < msgs.size(); ctr++)
+ {
+ char udp_msg[MAXBUF];
+ strncpy(udp_msg,MAXBUF,msgs[ctr].c_str());
+ if (strlen(udp_msg)<1)
+ {
+ log(DEBUG,"Invalid string from %s [route%d]",udp_host,x);
+ break;
+ }
+ FOREACH_MOD OnPacketReceive(udp_msg);
+ handle_link_packet(udp_msg, udp_host, me[x]);
+ }
goto label;
}
}