summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2025-08-08 23:11:31 +0100
committerLuke Bratch <luke@bratch.co.uk>2025-08-08 23:11:31 +0100
commitb2089e21606aed1a6aaa9644dbe0d2fe998ae1e0 (patch)
tree691e6edeeb7a040c8ae95cefe807346fd376f768 /blabouncer.c
parent0de8ed662321f25ab78cef094774593e1ce27677 (diff)
Improve output of LISTCLIENTS blabouncer command, add identical listclients command to STDIN commands, declare STDIN commands ("debug commands") in README.
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c36
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