From 4733b6438fe267ec896526eb468fa9892e7752c3 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Wed, 8 May 2019 21:18:24 +0100 Subject: Add some STDIN based debugging commands. --- blabouncer.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'blabouncer.c') diff --git a/blabouncer.c b/blabouncer.c index 4127b6a..07461b8 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -7,6 +7,8 @@ // - Get CAP from server and relay to client // - Add blabouncer MOTD (375, 372, 376) // - "01:53:47 -!- ServerMode/#test [b] by irc.tghost.co.uk" on existing clients when new client connects +// - Other users PARTing causes us to PART +// - We might not track new users JOINing a channel (only users who were already in a channel when we joined) // // Example WHOIS reply: // BOUNCER-SERVER RECEIVED: :irc.tghost.co.uk 307 blabounce l_bratch :is identified for this nick @@ -925,6 +927,28 @@ void dochat(int *serversockfd, int *clientsockfd) { printf ("Error! Too long. Would have allowed up to: [%s]\n", outgoingmsg); } + // STDIN based commands for debugging + if (strncmp(outgoingmsg, "listchannels", strlen("listchannels")) == 0) { + printf("STDIN command starting: listchannels\n"); + + int channelcount = getchannelcount(channels); + + for (int i = 0; i < channelcount; i++) { + printf("Checking channel[%d] out of %d.\n", i, channelcount); + // Skip this one and increment channelcount if it's a blank channel + if (!channels[i].name[0]) { + printf("Skipping channel[%d], incrementing channelcount.\n", i); + channelcount++; + continue; + } + + printf("Found channel '%s'.\n", channels[i].name); + } + + printf("STDIN command complete: listchannels\n"); + continue; + } + sendtoserver(serversockfd, outgoingmsg, strlen(outgoingmsg)); } -- cgit v1.2.3