- handle the 'from' argument in RCONSession::handle_packet to filter out packets from foreign hosts

Mon, 15 Dec 2014 02:03:08 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Mon, 15 Dec 2014 02:03:08 +0200
changeset 29
e534f2f78196
parent 28
3cc042af3090
child 30
21fba5183768

- handle the 'from' argument in RCONSession::handle_packet to filter out packets from foreign hosts
- some code simplification in the interface code

sources/interface.cpp file | annotate | diff | comparison | revisions
sources/network/rconsession.cpp file | annotate | diff | comparison | revisions
--- a/sources/interface.cpp	Mon Dec 15 01:47:40 2014 +0200
+++ b/sources/interface.cpp	Mon Dec 15 02:03:08 2014 +0200
@@ -306,13 +306,8 @@
 
 		case RCON_CONNECTED:
 			{
-				String adminText;
-
-				if (session->num_admins() == 0)
-					adminText = "No other admins";
-				else
-					adminText = format ("%1 other admin%s1", session->num_admins());
-
+				String adminText = (session->num_admins() == 0) ? "No other admins"
+					: format ("%1 other admin%s1", session->num_admins());
 				text = format ("%1 | %2 | %3", session->address().to_string (IP_WITH_PORT),
 					session->level(), adminText);
 			}
--- a/sources/network/rconsession.cpp	Mon Dec 15 01:47:40 2014 +0200
+++ b/sources/network/rconsession.cpp	Mon Dec 15 02:03:08 2014 +0200
@@ -119,6 +119,9 @@
 METHOD
 RCONSession::handle_packet (Bytestream& packet, const IPAddress& from) -> void
 {
+	if (from != m_address)
+		return;
+
 	try
 	{
 		while (packet.bytes_left() > 0)

mercurial