@@ -74,6 +74,17 @@ type ServerCommonConf struct {
74
74
// value is 0, the dashboard will not be started. By default, this value is
75
75
// 0.
76
76
DashboardPort int `ini:"dashboard_port" json:"dashboard_port" validate:"gte=0,lte=65535"`
77
+ // DashboardTLSCertFile specifies the path of the cert file that the server will
78
+ // load. If "dashboard_tls_cert_file", "dashboard_tls_key_file" are valid, the server will use this
79
+ // supplied tls configuration.
80
+ DashboardTLSCertFile string `ini:"dashboard_tls_cert_file" json:"dashboard_tls_cert_file"`
81
+ // DashboardTLSKeyFile specifies the path of the secret key that the server will
82
+ // load. If "dashboard_tls_cert_file", "dashboard_tls_key_file" are valid, the server will use this
83
+ // supplied tls configuration.
84
+ DashboardTLSKeyFile string `ini:"dashboard_tls_key_file" json:"dashboard_tls_key_file"`
85
+ // DashboardTLSMode specifies the mode of the dashboard between HTTP or HTTPS modes. By
86
+ // default, this value is false, which is HTTP mode.
87
+ DashboardTLSMode bool `ini:"dashboard_tls_mode" json:"dashboard_tls_mode"`
77
88
// DashboardUser specifies the username that the dashboard will use for
78
89
// login.
79
90
DashboardUser string `ini:"dashboard_user" json:"dashboard_user"`
@@ -297,6 +308,23 @@ func (cfg *ServerCommonConf) Complete() {
297
308
}
298
309
299
310
func (cfg * ServerCommonConf ) Validate () error {
311
+ if cfg .DashboardTLSMode == false {
312
+ if cfg .DashboardTLSCertFile != "" {
313
+ fmt .Println ("WARNING! dashboard_tls_cert_file is invalid when dashboard_tls_mode is false" )
314
+ }
315
+
316
+ if cfg .DashboardTLSKeyFile != "" {
317
+ fmt .Println ("WARNING! dashboard_tls_key_file is invalid when dashboard_tls_mode is false" )
318
+ }
319
+ } else {
320
+ if cfg .DashboardTLSCertFile == "" {
321
+ return fmt .Errorf ("ERROR! dashboard_tls_cert_file must be specified when dashboard_tls_mode is true" )
322
+ }
323
+
324
+ if cfg .DashboardTLSKeyFile == "" {
325
+ return fmt .Errorf ("ERROR! dashboard_tls_cert_file must be specified when dashboard_tls_mode is true" )
326
+ }
327
+ }
300
328
return validator .New ().Struct (cfg )
301
329
}
302
330
0 commit comments