32 lines
617 B
Go
32 lines
617 B
Go
|
package command
|
||
|
|
||
|
import (
|
||
|
"kon/auth"
|
||
|
"kon/config"
|
||
|
"kon/utils"
|
||
|
"os/exec"
|
||
|
|
||
|
"github.com/gofiber/fiber/v2"
|
||
|
)
|
||
|
|
||
|
func HandleFunc(c *fiber.Ctx) error {
|
||
|
queryValue := c.Query("token")
|
||
|
command := c.Query("command")
|
||
|
if auth.VerifyToken(queryValue) {
|
||
|
val, ok := config.Config.Commands[command]
|
||
|
if !ok {
|
||
|
return c.SendString("Command not found.")
|
||
|
} else {
|
||
|
cmd := exec.Command(val[0])
|
||
|
if len(val) > 1 {
|
||
|
cmd = exec.Command(val[0], val[1:]...)
|
||
|
}
|
||
|
err := cmd.Run()
|
||
|
utils.CheckError(err)
|
||
|
return c.SendString("Command was run successfully!")
|
||
|
}
|
||
|
} else {
|
||
|
return c.SendString("Auth failed!")
|
||
|
}
|
||
|
}
|