Skip to content

Commit

Permalink
Don't send out player IP adresses on disconnect
Browse files Browse the repository at this point in the history
Closes #1069.
  • Loading branch information
lmoureaux committed Jul 15, 2022
1 parent 6768d9c commit 9f2d41d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 7 additions & 3 deletions common/networking/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void default_conn_close_callback(struct connection *pconn)
{
fc_assert_msg(conn_close_callback != default_conn_close_callback,
"Closing a socket (%s) before calling "
"close_socket_set_callback().",
"connections_set_close_callback().",
conn_description(pconn));
}

Expand Down Expand Up @@ -428,8 +428,12 @@ const char *conn_description(const struct connection *pconn, bool is_private)
buffer[0] = '\0';

if (*pconn->username != '\0') {
fc_snprintf(buffer, sizeof(buffer), _("%s from %s"), pconn->username,
qUtf8Printable(addr));
if (is_private) {
fc_snprintf(buffer, sizeof(buffer), _("%s from %s"), pconn->username,
qUtf8Printable(addr));
} else {
fc_snprintf(buffer, sizeof(buffer), "%s", pconn->username);
}
} else {
sz_strlcpy(buffer, "server");
}
Expand Down
6 changes: 2 additions & 4 deletions server/connecthand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,16 +477,14 @@ bool handle_login_request(struct connection *pconn,
*/
void lost_connection_to_client(struct connection *pconn)
{
const char *desc = conn_description(pconn);

fc_assert_ret(true == pconn->server.is_closing);

qInfo(_("Lost connection: %s."), desc);
qInfo(_("Lost connection: %s."), conn_description(pconn, true));

// Special color (white on black) for player loss
notify_conn(game.est_connections, nullptr, E_CONNECTION,
conn_controls_player(pconn) ? ftc_player_lost : ftc_server,
_("Lost connection: %s."), desc);
_("Lost connection: %s."), conn_description(pconn, false));

connection_detach(pconn, true);
send_conn_info_remove(pconn->self, game.est_connections);
Expand Down

0 comments on commit 9f2d41d

Please sign in to comment.