diff --git a/irc/logger/logger.go b/irc/logger/logger.go index 5e05608e..cebb5904 100644 --- a/irc/logger/logger.go +++ b/irc/logger/logger.go @@ -57,7 +57,7 @@ type Manager struct { loggers []singleLogger stdoutWriteLock sync.Mutex // use one lock for both stdout and stderr fileWriteLock sync.Mutex - dumpingRawInOut bool + loggingRawIO bool } // Config represents the configuration of a single logger. @@ -94,7 +94,7 @@ func (logger *Manager) ApplyConfig(config []LoggingConfig) error { } logger.loggers = nil - logger.dumpingRawInOut = false + logger.loggingRawIO = false // for safety, this deep-copies all mutable data in `config` // XXX let's keep it that way @@ -123,7 +123,7 @@ func (logger *Manager) ApplyConfig(config []LoggingConfig) error { fileWriteLock: &logger.fileWriteLock, } if typeMap["userinput"] || typeMap["useroutput"] || (typeMap["*"] && !(excludedTypeMap["userinput"] && excludedTypeMap["useroutput"])) { - logger.dumpingRawInOut = true + logger.loggingRawIO = true } if sLogger.MethodFile.Enabled { file, err := os.OpenFile(sLogger.MethodFile.Filename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666) @@ -140,10 +140,10 @@ func (logger *Manager) ApplyConfig(config []LoggingConfig) error { return lastErr } -func (logger *Manager) DumpingRawInOut() bool { +func (logger *Manager) IsLoggingRawIO() bool { logger.configMutex.RLock() defer logger.configMutex.RUnlock() - return logger.dumpingRawInOut + return logger.loggingRawIO } // Log logs the given message with the given details. diff --git a/irc/server.go b/irc/server.go index 087e34d0..f6ba641f 100644 --- a/irc/server.go +++ b/irc/server.go @@ -38,7 +38,7 @@ var ( ) const ( - rawOutputNotice = "This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect." + rawIONotice = "This server is in debug mode and is logging all user I/O. If you do not wish for everything you send to be readable by the server owner(s), please disconnect." ) // Limits holds the maximum limits for various things such as topic lengths. @@ -90,6 +90,7 @@ type Server struct { ctime time.Time defaultChannelModes Modes dlines *DLineManager + loggingRawIO bool isupport *ISupportList klines *KLineManager limits Limits @@ -429,8 +430,8 @@ func (server *Server) tryRegister(c *Client) { c.RplISupport() server.MOTD(c) c.Send(nil, c.nickMaskString, RPL_UMODEIS, c.nick, c.ModeString()) - if server.logger.DumpingRawInOut() { - c.Notice(rawOutputNotice) + if server.logger.IsLoggingRawIO() { + c.Notice(rawIONotice) } } @@ -1426,7 +1427,10 @@ func (server *Server) applyConfig(config *Config, initial bool) error { if err != nil { return err } - dumpingRawInOut := server.logger.DumpingRawInOut() + nowLoggingRawIO := server.logger.IsLoggingRawIO() + // notify clients if raw i/o logging was enabled by a rehash + sendRawOutputNotice := !initial && !server.loggingRawIO && nowLoggingRawIO + server.loggingRawIO = nowLoggingRawIO if initial { if err := server.loadDatastore(config.Datastore.Path); err != nil { @@ -1445,8 +1449,8 @@ func (server *Server) applyConfig(config *Config, initial bool) error { sClient.Send(nil, server.name, RPL_ISUPPORT, append([]string{sClient.nick}, tokenline...)...) } - if dumpingRawInOut { - sClient.Notice(rawOutputNotice) + if sendRawOutputNotice { + sClient.Notice(rawIONotice) } } server.clients.ByNickMutex.RUnlock()