summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-27 11:09:36 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-27 11:09:36 +0100
commitab84512bc06ade328169d38ffb64f3820aa80dc4 (patch)
tree5b42b9ce5bebdb36965261b822bad7cdcb15c7f8 /blabouncer.c
parentff5b7166b8021e4562119852a9682cd09105601f (diff)
Only compare nick instead of full nick!user@host when processing server JOIN/PART/NICK. Also handle the "new" nick already being set in greeting strings during a server NICK if it's changing our nick.
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/blabouncer.c b/blabouncer.c
index 8f2e975..db0d384 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -768,11 +768,15 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
// If the user JOINing is us, then we must have joined a channel, so add to our local channel array.
// Copy to a temporary string so we still have the original in case we need it
char *prefixcopy = strdup(tokens[0]);
- if (strncmp(prefixcopy, ircdstrings->nickuserhost, strlen(tokens[0])) == 0) {
- printf("Server JOIN: nickuserhost is ours ('%s' vs '%s').\n", prefixcopy, ircdstrings->nickuserhost);
+ // Just get the nick for comparison
+ extractnickfromprefix(prefixcopy);
+ if (strncmp(prefixcopy, ircdstrings->ircnick, strlen(tokens[0])) == 0) {
+ printf("Server JOIN: nick is ours ('%s' vs '%s').\n", prefixcopy, ircdstrings->ircnick);
// TODO - Saner way to initialise this since we don't have the variables yet?
// TODO - Defaulting to type '=' which is "public" since I don't know what else to guess.
createchannel(channels, tokens[2], "TOPIC", "TOPICWHO", "0");
+ } else {
+ printf("Server JOIN: nick is NOT ours ('%s' vs '%s').\n", prefixcopy, ircdstrings->ircnick);
}
// And then send to all clients
@@ -795,15 +799,19 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
// Server PART received? Remove from our local channel list if it's us.
if (strncmp(tokens[1], "PART", strlen(tokens[1])) == 0) {
- printf("Server PART found and it is: %s with length %zd! Next token is '%s'. Adding to local channel list if it's us.\n", tokens[0], strlen(tokens[0]), tokens[2]);
+ printf("Server PART found and it is: %s with length %zd! Next token is '%s'. Removing from local channel list if it's us.\n", tokens[0], strlen(tokens[0]), tokens[2]);
// If the user PARTing is us, then we must have left a channel, so remove it from our local channel array.
// (If it's not us, then it's another user PARTing a channel, so just pass straight through to letting all our clients know.)
// Copy to a temporary string so we still have the original in case we need it
char *prefixcopy = strdup(tokens[0]);
- if (strncmp(prefixcopy, ircdstrings->nickuserhost, strlen(tokens[0])) == 0) {
- printf("Server PART: nickuserhost is ours ('%s' vs '%s').\n", prefixcopy, ircdstrings->nickuserhost);
+ // Just get the nick for comparison
+ extractnickfromprefix(prefixcopy);
+ if (strncmp(prefixcopy, ircdstrings->ircnick, strlen(tokens[0])) == 0) {
+ printf("Server PART: nick is ours ('%s' vs '%s').\n", prefixcopy, ircdstrings->ircnick);
removechannel(channels, tokens[2]);
+ } else {
+ printf("Server PART: nick is NOT ours ('%s' vs '%s').\n", prefixcopy, ircdstrings->ircnick);
}
// And then send to all clients
@@ -969,7 +977,12 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
printf("Server NICK found and it is: %s with length %zd! Next token is '%s'. Updating records and relaying to all clients.\n", tokens[0], strlen(tokens[0]), tokens[2]);
// Was it us?
- if (strncmp(ircdstrings->nickuserhost, tokens[0], strlen(ircdstrings->nickuserhost)) == 0) {
+ // Copy to a temporary string so we still have the original in case we need it
+ char *svrprefixcopy = strdup(tokens[0]);
+ // Just get the nick for comparison
+ extractnickfromprefix(svrprefixcopy);
+ if (strncmp(ircdstrings->ircnick, svrprefixcopy, strlen(ircdstrings->ircnick)) == 0) {
+ printf("Server NICK: nick is ours ('%s' vs '%s').\n", svrprefixcopy, ircdstrings->ircnick);
// Make a copy of the old nickuserhost for updategreetings() below
char *nickuserhostcpy = strdup(ircdstrings->nickuserhost);
// Update nickuserhost with the new :nick!user@host
@@ -992,6 +1005,7 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli
// Relay to all clients
sendtoallclients(clients, str, sourcefd, settings);
+ free(svrprefixcopy);
free(strcopyPtr);
return 1;
}