feature: ajouter cfg.Server.UI.Host et implémenter UI TLS
This commit is contained in:
parent
61c4ef80f5
commit
f5aa25a12a
2 changed files with 36 additions and 2 deletions
24
cmd.go
24
cmd.go
|
@ -251,7 +251,27 @@ Programme: [%s] %s
|
|||
})
|
||||
|
||||
// Execution
|
||||
e.Logger.Fatal(e.Start(
|
||||
fmt.Sprintf(":%d", cfg.Server.UI.Port)))
|
||||
switch cfg.Server.UI.TLS.Enabled {
|
||||
case false:
|
||||
e.Logger.Fatal(e.Start(
|
||||
fmt.Sprintf("%s:%d", cfg.Server.UI.Host, cfg.Server.UI.Port)))
|
||||
case true:
|
||||
if cfg.Server.UI.TLS.Certfile == "" {
|
||||
log.Fatal("TLS enabled for UI but no certificate file provided")
|
||||
}
|
||||
|
||||
if cfg.Server.UI.TLS.Keyfile == "" {
|
||||
log.Fatal("TLS enabled for UI but no private key file provided")
|
||||
}
|
||||
|
||||
e.Logger.Fatal(
|
||||
e.StartTLS(
|
||||
fmt.Sprintf("%s:%d", cfg.Server.UI.Host, cfg.Server.UI.Port),
|
||||
cfg.Server.UI.TLS.Certfile,
|
||||
cfg.Server.UI.TLS.Keyfile,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
|
|
14
config.go
14
config.go
|
@ -46,6 +46,7 @@ type Config struct {
|
|||
Port int `yaml:"port"`
|
||||
Protocol string `yaml:"protocol"`
|
||||
} `yaml:"api"`
|
||||
Host string `yaml:"host"`
|
||||
Password string `yaml:"password"`
|
||||
Port int `yaml:"port"`
|
||||
TLS struct {
|
||||
|
@ -366,6 +367,19 @@ func init() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// server.ui.host
|
||||
uiCmd.PersistentFlags().String(
|
||||
"server-ui-host",
|
||||
"",
|
||||
"Web UI host",
|
||||
)
|
||||
if err := viper.BindPFlag(
|
||||
"server.ui.host",
|
||||
uiCmd.PersistentFlags().Lookup("server-ui-host"),
|
||||
); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// server.ui.password
|
||||
uiCmd.PersistentFlags().String(
|
||||
"server-ui-password",
|
||||
|
|
Loading…
Reference in a new issue