From eff5fd14f815080f333ac763a470c9ac8ee2781f Mon Sep 17 00:00:00 2001 From: Louis Moureaux Date: Sun, 25 Jul 2021 02:13:22 +0200 Subject: [PATCH] Stop sending and showing ping times There is little value in showing everyone's ping time and it might leak private data. Stop sending it from the server and showing it in the client. The packet definition is kept for compatibility with servers prior to this patch. Original patch by ilkkachu for 2.6. See #558. Co-authored-by: Ilkka Virta --- client/packhand.cpp | 23 ++++++----------------- common/networking/packets.def | 4 ++++ server/sernet.cpp | 25 ------------------------- server/sernet.h | 1 - server/server.cpp | 3 --- 5 files changed, 10 insertions(+), 46 deletions(-) diff --git a/client/packhand.cpp b/client/packhand.cpp index d559204405..73209da753 100644 --- a/client/packhand.cpp +++ b/client/packhand.cpp @@ -2768,27 +2768,16 @@ void handle_conn_info(const struct packet_conn_info *pinfo) } /** - Handles a conn_ping_info packet from the server. This packet contains - ping times for each connection. + * Handles a conn_ping_info packet from the server. This packet contains + * ping times for each connection. + * FIXME Only present for backward compatibility. */ void handle_conn_ping_info(int connections, const int *conn_id, const float *ping_time) { - int i; - - for (i = 0; i < connections; i++) { - struct connection *pconn = conn_by_number(conn_id[i]); - - if (!pconn) { - continue; - } - - pconn->ping_time = ping_time[i]; - log_debug("conn-id=%d, ping=%fs", pconn->id, pconn->ping_time); - } - // The old_ping_time data is ignored. - - players_dialog_update(); + Q_UNUSED(connections) + Q_UNUSED(conn_id) + Q_UNUSED(ping_time) } /** diff --git a/common/networking/packets.def b/common/networking/packets.def index c00ee34df7..5ae757b855 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -1264,6 +1264,10 @@ PACKET_CONN_INFO = 115; sc, lsend, is-info end # Information about the ping times of the connections. +# This packet is kept for backward compatibility only and is no longer sent by +# the server or used by the client. +# Can be removed once we are confident that all 3.0-alpha3 servers are gone +# (and the number can be reattributed once all 3.0-alpha3 clients are gone). PACKET_CONN_PING_INFO = 116; sc, lsend UINT8 connections; CONNECTION conn_id[MAX_NUM_CONNECTIONS:connections]; diff --git a/server/sernet.cpp b/server/sernet.cpp index e8d6e88df2..72ef5f110d 100644 --- a/server/sernet.cpp +++ b/server/sernet.cpp @@ -530,31 +530,6 @@ void handle_client_heartbeat(struct connection *pconn) log_debug("Received heartbeat"); } -/** - Send ping time info about all connections to all connections. - */ -void send_ping_times_to_all() -{ - struct packet_conn_ping_info packet; - int i; - - i = 0; - conn_list_iterate(game.est_connections, pconn) - { - if (!pconn->used) { - continue; - } - fc_assert(i < ARRAY_SIZE(packet.conn_id)); - packet.conn_id[i] = pconn->id; - packet.ping_time[i] = pconn->ping_time; - i++; - } - conn_list_iterate_end; - packet.connections = i; - - lsend_packet_conn_ping_info(game.est_connections, &packet); -} - /** Listen for UDP packets multicasted from clients requesting announcement of servers on the LAN. diff --git a/server/sernet.h b/server/sernet.h index 078247acf9..3eefc7d60a 100644 --- a/server/sernet.h +++ b/server/sernet.h @@ -33,5 +33,4 @@ int server_make_connection(QTcpSocket *new_sock, const QString &client_addr); void connection_ping(struct connection *pconn); void handle_conn_pong(struct connection *pconn); void handle_client_heartbeat(struct connection *pconn); -void send_ping_times_to_all(); void get_lanserver_announcement(); diff --git a/server/server.cpp b/server/server.cpp index bb8608a481..41b6b83f8e 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -429,9 +429,6 @@ void server::send_pings() { // Pinging around for statistics if (time(NULL) > (game.server.last_ping + game.server.pingtime)) { - // send data about the previous run - send_ping_times_to_all(); - conn_list_iterate(game.all_connections, pconn) { if ((!pconn->server.is_closing && 0 < pconn->server.ping_timers->size()