mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
More fixes to connection buffer handling
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@579 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
84d9f0dc9a
commit
8be0c00087
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user