diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-23 18:28:42 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-05-23 18:28:42 +0000 |
commit | bac7dea75b15323bb678ed56ca54606ee92c0afd (patch) | |
tree | 252691ab0e7240cd9dd1ccf26891e7ce66e6c178 /src | |
parent | 426368db9d57376a47393cf22504f1d71b4ce0d8 (diff) |
Buffer size limits (hard coded to 1mb for now, will allow to raise in config later)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1478 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/connection.cpp | 5 | ||||
-rw-r--r-- | src/servers.cpp | 7 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/connection.cpp b/src/connection.cpp index 7d5df66f9..c7221ce74 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -117,7 +117,7 @@ void ircd_connector::SetServerPort(int p) this->port = p; } -void ircd_connector::AddBuffer(std::string a) +bool ircd_connector::AddBuffer(std::string a) { std::string b = ""; for (int i = 0; i < a.length(); i++) @@ -128,6 +128,7 @@ void ircd_connector::AddBuffer(std::string a) stream << b; log(DEBUG,"AddBuffer: %s",b.c_str()); ircdbuffer = stream.str(); + return (ircdbuffer.length() < 1048576); } bool ircd_connector::BufferIsComplete() @@ -170,7 +171,7 @@ bool ircd_connector::AddWriteBuf(std::string data) std::stringstream stream; stream << sendq << data; sendq = stream.str(); - return true; + return (sendq.length() < 1048576); } bool ircd_connector::HasBufferedOutput() diff --git a/src/servers.cpp b/src/servers.cpp index d2ace18e8..15929345f 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -392,7 +392,12 @@ bool serverrec::RecvPacket(std::deque<std::string> &messages, char* recvhost,std int pushed = 0; if (rcvsize > 0) { - this->connectors[i].AddBuffer(data); + if (!this->connectors[i].AddBuffer(data)) + { + WriteOpers("*** Read buffer for %s exceeds maximum, closing connection!",this->connectors[i].GetServerName().c_str()); + this->connectors[i].CloseConnection(); + this->connectors[i].SetState(STATE_DISCONNECTED); + } if (this->connectors[i].BufferIsComplete()) { while (this->connectors[i].BufferIsComplete()) |