增加"edge-admin security.reset"命令来使用命令行重置安全设置

This commit is contained in:
GoEdgeLab
2024-04-08 11:38:04 +08:00
parent 1efe256cbd
commit 900dbad528
3 changed files with 22 additions and 4 deletions

View File

@@ -41,7 +41,8 @@ func main() {
Option("dev", "switch to 'dev' mode").
Option("prod", "switch to 'prod' mode").
Option("upgrade [--url=URL]", "upgrade from official site or an url").
Option("install-local-node", "install a local node")
Option("install-local-node", "install a local node").
Option("security.reset", "reset security config")
app.On("daemon", func() {
nodes.NewAdminNode().Daemon()
@@ -179,6 +180,17 @@ func main() {
log.Println("restarting ...")
app.RunRestart()
})
app.On("security.reset", func() {
var sock = gosock.NewTmpSock(teaconst.ProcessName)
if !sock.IsListening() {
fmt.Println("[ERROR]the service not started yet, you should start the service first")
return
}
_, _ = sock.Send(&gosock.Command{
Code: "security.reset",
})
fmt.Println("ok")
})
app.Run(func() {
var adminNode = nodes.NewAdminNode()
adminNode.Run()