rename tls config

This commit is contained in:
杨黄林
2023-09-11 18:09:36 +08:00
parent ef8b65cbf2
commit 7e2f59eba8
2 changed files with 14 additions and 7 deletions

View File

@@ -124,12 +124,17 @@ func ParseConfigFile(file string) (controller.HandleController, server.TLS, erro
common.DashboardUser = commonSection.Key("dashboard_user").Value() common.DashboardUser = commonSection.Key("dashboard_user").Value()
common.DashboardPwd = commonSection.Key("dashboard_pwd").Value() common.DashboardPwd = commonSection.Key("dashboard_pwd").Value()
tls.Enable = commonSection.Key("dashboard_tls_mode").MustBool(false) tls.Enable = commonSection.Key("tls_mode").MustBool(false)
tls.Cert = commonSection.Key("dashboard_tls_cert_file").MustString("") tls.Cert = commonSection.Key("tls_cert_file").MustString("")
tls.Key = commonSection.Key("dashboard_tls_key_file").MustString("") tls.Key = commonSection.Key("tls_key_file").MustString("")
if tls.Enable { if tls.Enable {
tls.Protocol = "HTTPS" tls.Protocol = "HTTPS"
} }
if tls.Enable && (strings.TrimSpace(tls.Cert) == "" || strings.TrimSpace(tls.Key) == "") {
tls.Enable = false
tls.Protocol = "HTTP"
log.Printf("fail to enable tls: tls cert or key not exist, use http as default.")
}
portsSection, err := iniFile.GetSection("ports") portsSection, err := iniFile.GetSection("ports")
if err != nil { if err != nil {

View File

@@ -5,15 +5,17 @@ plugin_addr = 127.0.0.1
plugin_port = 7200 plugin_port = 7200
admin_user = admin admin_user = admin
admin_pwd = admin admin_pwd = admin
; enable tls
tls_mode = false
; tls_cert_file = cert.crt
; tls_key_file = cert.key
; frp dashboard info ; frp dashboard info
dashboard_addr = 127.0.0.1 dashboard_addr = 127.0.0.1
dashboard_port = 7500 dashboard_port = 7500
dashboard_user = admin dashboard_user = admin
dashboard_pwd = admin dashboard_pwd = admin
; enable tls
dashboard_tls_mode = false
dashboard_tls_cert_file = cert.crt
dashboard_tls_key_file = cert.key
; user tokens ; user tokens
[users] [users]