mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-23 03:02:48 +01:00
review fixes for raw i/o notification
This commit is contained in:
parent
aff1752d67
commit
456174ed53
@ -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.
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user