summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-09-07 15:31:01 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-09-07 15:31:01 +0100
commit979b594b9a58059a5159f2a950e0a71c64f35e38 (patch)
treee395e679d08bb963d75a388fa723942b967cd1c3
parentc4e88bfe0c918604cb588ab8b3ce7d29b138cd0f (diff)
Avoid non-existent users appearing in channels after they change nicks by replay logging nick changes.
-rw-r--r--TODO4
-rw-r--r--logging.c12
-rw-r--r--logging.h6
-rw-r--r--message.c7
4 files changed, 18 insertions, 11 deletions
diff --git a/TODO b/TODO
index d707b2a..8a874af 100644
--- a/TODO
+++ b/TODO
@@ -4,8 +4,6 @@ Support arrays or similar in the configuration file (for nick(s), connectcommand
All the TODOs sprinkled throughout the code!
-(I think) replay log can cause non-existent user to appear in channel (e.g. ~19:00 on 12/08/2019 for me)
-
(I vaguely recall) some unwanted stuff (channel ban info?) was relayed to another client upon a client connecting.
PM replay chat in a channel (or perhaps a random channel?) e.g. replay on 06/09/2019 at 17:05 from 13:49 in #insomnia - maybe a client thing.
@@ -13,3 +11,5 @@ PM replay chat in a channel (or perhaps a random channel?) e.g. replay on 06/09/
Ensure replayed lines don't exceed IRC message maximum length due to inserted time/datestamp.
Log server messages to file.
+
+Is there a way to log nick changes to the normal log despite not tracking channels or nicks in each channel?
diff --git a/logging.c b/logging.c
index e7a20ea..d661a2b 100644
--- a/logging.c
+++ b/logging.c
@@ -37,8 +37,8 @@
// If LOG_TOPIC then it expects a string in the format:
// :nick!bar@baz TOPIC #channel :bla bla bla
//
-// With the ":foo!bar@baz "prefix being important for either
-// type.
+// With the ":foo!bar@baz "prefix being important for all
+// types.
//
// Returns 1 on success or 0 on failure.
int logline(char *str, char *ournick, char *basedir, int type) {
@@ -106,13 +106,13 @@ int logline(char *str, char *ournick, char *basedir, int type) {
// If the message was sent to us, then log it in the sender's log file
if (strncmp(tokens[2], ournick, strlen(tokens[0])) == 0) {
if (!snprintf(filename, MAXCHAR, "%s/logs/%s.log", basedir, from)) {
- debugprint(DEBUG_CRIT, "Error while log filename for from name, returning!\n");
+ debugprint(DEBUG_CRIT, "Error while preparing log filename for from name, returning!\n");
return 0;
}
} else {
// Otherwise log it in the "to" log file
if (!snprintf(filename, MAXCHAR, "%s/logs/%s.log", basedir, to)) {
- debugprint(DEBUG_CRIT, "Error while log filename for to name, returning!\n");
+ debugprint(DEBUG_CRIT, "Error while preparing log filename for to name, returning!\n");
return 0;
}
}
@@ -187,7 +187,7 @@ int logline(char *str, char *ournick, char *basedir, int type) {
stripprefix(str);
if (!snprintf(filename, MAXCHAR, "%s/logs/%s.log", basedir, to)) {
- debugprint(DEBUG_CRIT, "Error while log filename for topic, returning!\n");
+ debugprint(DEBUG_CRIT, "Error while preparing log filename for topic, returning!\n");
return 0;
}
@@ -199,7 +199,7 @@ int logline(char *str, char *ournick, char *basedir, int type) {
break;
default :
- printf("Unknown log type '%d', returning 0.\n", type);
+ debugprint(DEBUG_CRIT, "logline(): Unknown log type '%d', returning 0.\n", type);
return 0;
}
diff --git a/logging.h b/logging.h
index 479e2c8..441a500 100644
--- a/logging.h
+++ b/logging.h
@@ -59,9 +59,9 @@
//
// If LOG_TOPIC then it expects a string in the format:
// :nick!bar@baz TOPIC #channel :bla bla bla
-//
-// With the ":foo!bar@baz "prefix being important for either
-// type.
+
+// With the ":foo!bar@baz "prefix being important for all
+// types.
//
// Returns 1 on success or 0 on failure.
int logline(char *str, char *ournick, char *basedir, int type);
diff --git a/message.c b/message.c
index 5860219..1c511d2 100644
--- a/message.c
+++ b/message.c
@@ -411,6 +411,13 @@ int processservermessage(SSL *server_ssl, char *str, struct client *clients, int
// Relay to all clients
sendtoallclients(clients, str, sourcefd, settings);
+ // Write to replay log if replay logging enabled
+ if (settings->replaylogging) {
+ writereplayline(str, settings->basedir);
+ }
+
+ // TODO - Is there a way to log nick changes to the normal log despite not tracking channels or nicks in each channel?
+
free(svrprefixcopy);
return 1;
}