Skip to content

Commit

Permalink
Stop sending and showing ping times
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
lmoureaux and itvirta committed Jul 25, 2021
1 parent 5429701 commit eff5fd1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 46 deletions.
23 changes: 6 additions & 17 deletions client/packhand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand Down
4 changes: 4 additions & 0 deletions common/networking/packets.def
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
25 changes: 0 additions & 25 deletions server/sernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion server/sernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
3 changes: 0 additions & 3 deletions server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit eff5fd1

Please sign in to comment.