merge
This commit is contained in:
20
cmd/cmd_gen_cert.go
Normal file
20
cmd/cmd_gen_cert.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/hiddify/libcore/utils"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
var commandGenerateCertification = &cobra.Command{
|
||||
Use: "gen-cert",
|
||||
Short: "Generate certification for web server",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
err := os.MkdirAll("cert", 600)
|
||||
if err != nil {
|
||||
panic("Error: " + err.Error())
|
||||
}
|
||||
utils.GenerateCertificate("cert/server-cert.pem", "cert/server-key.pem", true)
|
||||
utils.GenerateCertificate("cert/client-cert.pem", "cert/client-key.pem", false)
|
||||
},
|
||||
}
|
||||
10
cmd/cmd_service.go
Normal file
10
cmd/cmd_service.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var commandService = &cobra.Command{
|
||||
Use: "service",
|
||||
Short: "Sign box service",
|
||||
}
|
||||
12
cmd/cmd_service_install.go
Normal file
12
cmd/cmd_service_install.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/hiddify/libcore/service"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var commandServiceInstall = &cobra.Command{
|
||||
Use: "install",
|
||||
Short: "install the service",
|
||||
Run: service.InstallService,
|
||||
}
|
||||
12
cmd/cmd_service_start.go
Normal file
12
cmd/cmd_service_start.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/hiddify/libcore/service"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var commandServiceStart = &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Start a sign box instance",
|
||||
Run: service.StartService,
|
||||
}
|
||||
12
cmd/cmd_service_stop.go
Normal file
12
cmd/cmd_service_stop.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/hiddify/libcore/service"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var commandServiceStop = &cobra.Command{
|
||||
Use: "stop",
|
||||
Short: "stop sign box",
|
||||
Run: service.StopService,
|
||||
}
|
||||
10
cmd/main.go
10
cmd/main.go
@@ -22,8 +22,18 @@ var mainCommand = &cobra.Command{
|
||||
}
|
||||
|
||||
func init() {
|
||||
mainCommand.AddCommand(commandService)
|
||||
mainCommand.AddCommand(commandGenerateCertification)
|
||||
|
||||
commandService.AddCommand(commandServiceStart)
|
||||
commandService.AddCommand(commandServiceStop)
|
||||
commandService.AddCommand(commandServiceInstall)
|
||||
|
||||
commandServiceStart.Flags().Int("port", 8080, "Webserver port number")
|
||||
|
||||
mainCommand.PersistentFlags().StringVarP(&workingDir, "directory", "D", "", "set working directory")
|
||||
mainCommand.PersistentFlags().BoolVarP(&disableColor, "disable-color", "", false, "disable color output")
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
Reference in New Issue
Block a user