From 25a373b7eb6530a64eec56b124778e6faa484580 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Wed, 8 Mar 2017 21:57:31 +1000 Subject: [PATCH] logger: Add notice on connection when server is logging all I/O --- irc/logger.go | 6 +++++- irc/server.go | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/irc/logger.go b/irc/logger.go index 84d8e393..54067957 100644 --- a/irc/logger.go +++ b/irc/logger.go @@ -48,7 +48,8 @@ var ( // Logger is the main interface used to log debug/info/error messages. type Logger struct { - loggers []SingleLogger + loggers []SingleLogger + DumpingRawInOut bool } // NewLogger returns a new Logger. @@ -66,6 +67,9 @@ func NewLogger(config []LoggingConfig) (*Logger, error) { Types: logConfig.Types, ExcludedTypes: logConfig.ExcludedTypes, } + if logConfig.Types["userinput"] || logConfig.Types["useroutput"] || (logConfig.Types["*"] && !(logConfig.ExcludedTypes["userinput"] && logConfig.ExcludedTypes["useroutput"])) { + logger.DumpingRawInOut = true + } if sLogger.MethodFile.Enabled { file, err := os.OpenFile(sLogger.MethodFile.Filename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666) if err != nil { diff --git a/irc/server.go b/irc/server.go index 9d2b70fd..6bea3209 100644 --- a/irc/server.go +++ b/irc/server.go @@ -658,6 +658,9 @@ 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("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.") + } } // MOTD serves the Message of the Day.