diff --git a/cmd.go b/cmd.go index a477a8a..a54cff6 100644 --- a/cmd.go +++ b/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, + ), + ) + } + }, } diff --git a/config.go b/config.go index 01eecd5..c611e07 100644 --- a/config.go +++ b/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",