1
0
Fork 0
forked from External/ergo

Merge pull request #800 from slingamn/issue791_crashserver

fix #791
This commit is contained in:
Shivaram Lingamneni 2020-02-22 20:08:42 -08:00 committed by GitHub
commit c445b45f31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 85 additions and 16 deletions

View file

@ -804,6 +804,26 @@ func debugHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
case "STOPCPUPROFILE":
pprof.StopCPUProfile()
rb.Notice(fmt.Sprintf("CPU profiling stopped"))
case "CRASHSERVER":
if !client.HasRoleCapabs("oper:rehash") {
rb.Notice(client.t("You must have rehash permissions in order to execute DEBUG CRASHSERVER"))
return false
}
code := utils.ConfirmationCode(server.name, server.ctime)
if len(msg.Params) == 1 || msg.Params[1] != code {
rb.Notice(fmt.Sprintf(client.t("To crash the server, issue the following command: /DEBUG CRASHSERVER %s"), code))
return false
}
server.logger.Error("server", fmt.Sprintf("DEBUG CRASHSERVER executed by operator %s", client.Oper().Name))
go func() {
// intentional nil dereference on a new goroutine, bypassing recover-from-errors
var i, j *int
*i = *j
}()
default:
rb.Notice(client.t("Unrecognized DEBUG subcommand"))
}
return false
}