3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 11:59:40 +01:00

logger: Add notice on connection when server is logging all I/O

This commit is contained in:
Daniel Oaks 2017-03-08 21:57:31 +10:00
parent f1bf73c249
commit 25a373b7eb
2 changed files with 8 additions and 1 deletions

View File

@ -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 {

View File

@ -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.