Pārlūkot izejas kodu

fix #791

tags/v2.0.0-rc1
Shivaram Lingamneni 4 gadus atpakaļ
vecāks
revīzija
41813cc15a
1 mainītis faili ar 19 papildinājumiem un 0 dzēšanām
  1. 19
    0
      irc/handlers.go

+ 19
- 0
irc/handlers.go Parādīt failu

@@ -804,6 +804,25 @@ func debugHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
804 804
 	case "STOPCPUPROFILE":
805 805
 		pprof.StopCPUProfile()
806 806
 		rb.Notice(fmt.Sprintf("CPU profiling stopped"))
807
+
808
+	case "CRASHSERVER":
809
+		if !client.HasRoleCapabs("oper:rehash") {
810
+			rb.Notice(client.t("You must have rehash permissions in order to execute DEBUG CRASHSERVER"))
811
+			return false
812
+		}
813
+		code := unregisterConfirmationCode(server.name, server.ctime)
814
+		if len(msg.Params) == 1 || msg.Params[1] != code {
815
+			rb.Notice(fmt.Sprintf(client.t("To crash the server, issue the following command: /DEBUG CRASHSERVER %s"), code))
816
+			return false
817
+		}
818
+		go func() {
819
+			// intentional nil dereference on a new goroutine, bypassing recover-from-errors
820
+			var i, j *int
821
+			*i = *j
822
+		}()
823
+
824
+	default:
825
+		rb.Notice(client.t("Unrecognized DEBUG subcommand"))
807 826
 	}
808 827
 	return false
809 828
 }

Notiek ielāde…
Atcelt
Saglabāt