summaryrefslogtreecommitdiff
path: root/functions.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-09-06 21:41:28 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-09-06 21:41:28 +0100
commit38bd2b2761b7d0f556945ffad78f73536e12e157 (patch)
tree241402b5b883f77e3fb20608f173db5028484323 /functions.c
parentfb3963446890cbb966db2d463813d15701cd8fb1 (diff)
Send remote IP addresses instead of fd numbers in NOTICEs to clients and print both in related debugprint()s.
Diffstat (limited to 'functions.c')
-rw-r--r--functions.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/functions.c b/functions.c
index 8557f7a..b9f1080 100644
--- a/functions.c
+++ b/functions.c
@@ -557,11 +557,11 @@ int sendtoserver(SSL *server_ssl, char *strsrc, int str_len, int clientfd, struc
// Also set its authentication and registration statuses to 0.
// Also set the pending statuses to 0
int disconnectclient(int fd, struct client *clients, struct ircdstate *ircdstate, struct settings *settings, struct clientcodes *clientcodes) {
- debugprint(DEBUG_SOME, "disconnectclient(): disconnecting client fd '%d'\n", fd);
+ debugprint(DEBUG_SOME, "disconnectclient(): disconnecting client %s with fd '%d'\n", clients[arrindex(clients, fd)].remoteip, fd);
// Alert other clients about the disconnection (don't send yet, we haven't removed from the clients array yet)
char alertmsg[MAXDATASIZE];
- if (!snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :blabouncer: client with fd %d has disconnected.", ircdstate->ircnick, fd)) {
+ if (!snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :blabouncer: client %s has disconnected.", ircdstate->ircnick, clients[arrindex(clients, fd)].remoteip)) {
fprintf(stderr, "Error while preparing authentication failure NOTICE!\n");
debugprint(DEBUG_CRIT, "Error while preparing authentication failure NOTICE!\n");
alertmsg[0] = '\0';
@@ -591,6 +591,7 @@ int disconnectclient(int fd, struct client *clients, struct ircdstate *ircdstate
clients[i].pendingnames = 0;
clients[i].pendingcap = 0;
clients[i].clientcode[0] = '\0';
+ clients[i].remoteip[0] = '\0';
if (settings->clienttls) {
// Finish up with OpenSSL if using client TLS
SSL_free(clients[i].ssl);
@@ -1049,8 +1050,8 @@ void cleanexit(SSL *server_ssl, struct client *clients, int sourcefd, struct irc
// Tell clients and debug log
if (sourcefd) {
- snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Exiting on request from client with fd '%d', message '%s'.", ircdstate->ircnick, sourcefd, quitmsg);
- debugprint(DEBUG_CRIT, "Exiting on request from client with fd '%d', message '%s'.\n", sourcefd, quitmsg);
+ snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Exiting on request from client %s, message '%s'.", ircdstate->ircnick, clients[arrindex(clients, sourcefd)].remoteip, quitmsg);
+ debugprint(DEBUG_CRIT, "Exiting on request from client %s with fd '%d', message '%s'.\n", clients[arrindex(clients, sourcefd)].remoteip, sourcefd, quitmsg);
} else {
snprintf(outgoingmsg, MAXDATASIZE, "NOTICE %s :Exiting on request (not from a client), message '%s'.", ircdstate->ircnick, quitmsg);
debugprint(DEBUG_CRIT, "Exiting on request (not from a client), message '%s'.\n", quitmsg);