/
serve.go
47 lines (39 loc) · 1.35 KB
/
serve.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cli
import (
"log"
"github.com/archimoebius/fishler/app"
rootConfig "github.com/archimoebius/fishler/cli/config/root"
config "github.com/archimoebius/fishler/cli/config/serve"
"github.com/archimoebius/fishler/util"
"github.com/leebenson/conform"
"github.com/spf13/cobra"
)
var ServeCmd = &cobra.Command{
Use: "serve",
Short: "Start an SSH server on --port configured to as desired; serving a docker container on authentication success.",
Long: `Leveraging the goodness of Golang, Docker, and SSH - create a container for any user that authenticates with success to the SSH server - recording the session and credentials used.`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
CallPersistentPreRun(cmd, args)
config.Load()
if rootConfig.Setting.Debug {
util.Logger.SetReportCaller(true)
config.Setting.Print()
}
config.Setting.SetupAuthentication()
},
Run: func(cmd *cobra.Command, args []string) {
err := app.NewApplication().Start()
if err != nil {
util.Logger.Error(err)
}
},
}
// init is called before main
func init() {
// A custom sanitizer to redact sensitive data by defining a struct tag= named "redact".
conform.AddSanitizer("redact", func(_ string) string { return "*****" })
// Initialize the config and panic on failure
if err := config.CommandInit(ServeCmd); err != nil {
log.Fatal(err)
}
}