forked from External/ergo
refactor logging to implement #142
This commit is contained in:
parent
23af746182
commit
aff1752d67
4 changed files with 96 additions and 71 deletions
|
|
@ -37,6 +37,10 @@ var (
|
|||
couldNotParseIPMsg, _ = (&[]ircmsg.IrcMessage{ircmsg.MakeMessage(nil, "", "ERROR", "Unable to parse your IP address")}[0]).Line()
|
||||
)
|
||||
|
||||
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."
|
||||
)
|
||||
|
||||
// Limits holds the maximum limits for various things such as topic lengths.
|
||||
type Limits struct {
|
||||
AwayLen int
|
||||
|
|
@ -425,8 +429,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("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.")
|
||||
if server.logger.DumpingRawInOut() {
|
||||
c.Notice(rawOutputNotice)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1408,23 +1412,22 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
|
|||
}
|
||||
|
||||
// set RPL_ISUPPORT
|
||||
var newISupportReplies [][]string
|
||||
oldISupportList := server.isupport
|
||||
server.setISupport()
|
||||
if oldISupportList != nil {
|
||||
newISupportReplies := oldISupportList.GetDifference(server.isupport)
|
||||
// push new info to all of our clients
|
||||
server.clients.ByNickMutex.RLock()
|
||||
for _, sClient := range server.clients.ByNick {
|
||||
for _, tokenline := range newISupportReplies {
|
||||
// ugly trickery ahead
|
||||
sClient.Send(nil, server.name, RPL_ISUPPORT, append([]string{sClient.nick}, tokenline...)...)
|
||||
}
|
||||
}
|
||||
server.clients.ByNickMutex.RUnlock()
|
||||
newISupportReplies = oldISupportList.GetDifference(server.isupport)
|
||||
}
|
||||
|
||||
server.loadMOTD(config.Server.MOTD)
|
||||
|
||||
// reload logging config
|
||||
err = server.logger.ApplyConfig(config.Logging)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dumpingRawInOut := server.logger.DumpingRawInOut()
|
||||
|
||||
if initial {
|
||||
if err := server.loadDatastore(config.Datastore.Path); err != nil {
|
||||
return err
|
||||
|
|
@ -1434,6 +1437,21 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
|
|||
// we are now open for business
|
||||
server.setupListeners(config)
|
||||
|
||||
if !initial {
|
||||
// push new info to all of our clients
|
||||
server.clients.ByNickMutex.RLock()
|
||||
for _, sClient := range server.clients.ByNick {
|
||||
for _, tokenline := range newISupportReplies {
|
||||
sClient.Send(nil, server.name, RPL_ISUPPORT, append([]string{sClient.nick}, tokenline...)...)
|
||||
}
|
||||
|
||||
if dumpingRawInOut {
|
||||
sClient.Notice(rawOutputNotice)
|
||||
}
|
||||
}
|
||||
server.clients.ByNickMutex.RUnlock()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue