diff options
Diffstat (limited to 'blabouncer.c')
-rw-r--r-- | blabouncer.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/blabouncer.c b/blabouncer.c index 1c61336..b57fb4a 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -805,6 +805,42 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) { continue; } + if (strncmp(outgoingmsg, "listclients", strlen("listclients")) == 0) { + debugprint(DEBUG_SOME, "dochat(): stdin: There are %d blabouncer client(s) connected:\n", numclients(clients)); + printf("There are %d blabouncer client(s) connected:\n", numclients(clients)); + + // Loop through each client in clients struct for connected and authenticated clients... + int clientcount = 0; + debugprint(DEBUG_SOME, "dochat(): stdin: Authenticated clients:\n"); + printf("Authenticated clients:\n"); + for (int i = 0; i < MAXCLIENTS; i++) { + if (clients[i].fd && clients[i].authed) { + // ...then tell the requesting client about them + clientcount++; + debugprint(DEBUG_SOME, "dochat(): stdin: #%d: File descriptor: %d, IP: %s.\n", clientcount, clients[i].fd, clients[i].remoteip); + printf("#%d: File descriptor: %d, IP: %s.\n", clientcount, clients[i].fd, clients[i].remoteip); + } + } + + // And now loop through each client in clients struct for connected but unauthenticated clients... + clientcount = 0; + debugprint(DEBUG_SOME, "dochat(): stdin: Unauthenticated clients:\n"); + printf("Unauthenticated clients:\n"); + for (int i = 0; i < MAXCLIENTS; i++) { + if (clients[i].fd && !clients[i].authed) { + // ...then tell the requesting client about them + clientcount++; + debugprint(DEBUG_SOME, "dochat(): stdin: #%d: File descriptor: %d, IP: %s.\n", clientcount, clients[i].fd, clients[i].remoteip); + printf("#%d: File descriptor: %d, IP: %s.\n", clientcount, clients[i].fd, clients[i].remoteip); + } + } + + debugprint(DEBUG_SOME, "dochat(): stdin: STDIN command complete: listclients\n"); + printf("STDIN command complete: listclients\n"); + + continue; + } + debugprint(DEBUG_FULL, "dochat(): stdin: '%s' not processed as a command, sending to server.\n", outgoingmsg); printf("'%s' not processed as a command, sending to server.\n", outgoingmsg); // sourcefd = 0 as this is a trusted message |