From 38bd2b2761b7d0f556945ffad78f73536e12e157 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Fri, 6 Sep 2019 21:41:28 +0100 Subject: Send remote IP addresses instead of fd numbers in NOTICEs to clients and print both in related debugprint()s. --- message.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'message.c') diff --git a/message.c b/message.c index f360e99..0373ef3 100644 --- a/message.c +++ b/message.c @@ -731,7 +731,7 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int // PASS received? User is trying to log in, check their password. if (strncasecmp(tokens[0], "PASS", strlen(tokens[0])) == 0) { if (checkpassword(tokens[1], settings)) { - debugprint(DEBUG_FULL, "Password accepted! Setting fd %d to authenticated.\n", sourcefd); + debugprint(DEBUG_FULL, "Password accepted! Setting client %s with fd %d to authenticated.\n", clients[arrindex(clients, sourcefd)].remoteip, sourcefd); // Find the client in the clients array and set them as authenticated for (int i = 0; i < MAXCLIENTS; i++) { if (clients[i].fd == sourcefd) { @@ -740,7 +740,8 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int debugprint(DEBUG_FULL, "Found and authenticated fd in arr_authed.\n"); // Alert other clients about the successful authentication char alertmsg[MAXDATASIZE]; - if (!snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :blabouncer: new client with fd %d has successfully authenticated.", ircdstate->ircnick, sourcefd)) { + if (!snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :blabouncer: new client %s has successfully authenticated.", ircdstate->ircnick, + clients[arrindex(clients, sourcefd)].remoteip)) { fprintf(stderr, "Error while preparing authentication success NOTICE!\n"); debugprint(DEBUG_CRIT, "Error while preparing authentication success NOTICE!\n"); alertmsg[0] = '\0'; @@ -750,11 +751,12 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int } } } else { - debugprint(DEBUG_SOME, "Password rejected, disconnecting fd %d.\n", sourcefd); + debugprint(DEBUG_SOME, "Password rejected, disconnecting client %s with fd %d.\n", clients[arrindex(clients, sourcefd)].remoteip, sourcefd); disconnectclient(sourcefd, clients, ircdstate, settings, clientcodes); // Alert other clients about the failed authentication char alertmsg[MAXDATASIZE]; - if (!snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :blabouncer: new client with fd %d has failed to authenticate.", ircdstate->ircnick, sourcefd)) { + if (!snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :blabouncer: new client %s has failed to authenticate.", ircdstate->ircnick, + clients[arrindex(clients, sourcefd)].remoteip)) { fprintf(stderr, "Error while preparing authentication failure NOTICE!\n"); debugprint(DEBUG_CRIT, "Error while preparing authentication failure NOTICE!\n"); alertmsg[0] = '\0'; -- cgit v1.2.3