From 7e2f59eba84a38bb65d17d8ae2a0f0b613cbb59a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E9=BB=84=E6=9E=97?= Date: Mon, 11 Sep 2023 18:09:36 +0800 Subject: [PATCH] rename tls config --- cmd/frps-panel/cmd.go | 11 ++++++++--- config/frps-panel.ini | 10 ++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cmd/frps-panel/cmd.go b/cmd/frps-panel/cmd.go index 9533944..550044b 100644 --- a/cmd/frps-panel/cmd.go +++ b/cmd/frps-panel/cmd.go @@ -124,12 +124,17 @@ func ParseConfigFile(file string) (controller.HandleController, server.TLS, erro common.DashboardUser = commonSection.Key("dashboard_user").Value() common.DashboardPwd = commonSection.Key("dashboard_pwd").Value() - tls.Enable = commonSection.Key("dashboard_tls_mode").MustBool(false) - tls.Cert = commonSection.Key("dashboard_tls_cert_file").MustString("") - tls.Key = commonSection.Key("dashboard_tls_key_file").MustString("") + tls.Enable = commonSection.Key("tls_mode").MustBool(false) + tls.Cert = commonSection.Key("tls_cert_file").MustString("") + tls.Key = commonSection.Key("tls_key_file").MustString("") if tls.Enable { 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") if err != nil { diff --git a/config/frps-panel.ini b/config/frps-panel.ini index 2a881a2..483f422 100644 --- a/config/frps-panel.ini +++ b/config/frps-panel.ini @@ -5,15 +5,17 @@ plugin_addr = 127.0.0.1 plugin_port = 7200 admin_user = admin admin_pwd = admin + +; enable tls +tls_mode = false +; tls_cert_file = cert.crt +; tls_key_file = cert.key + ; frp dashboard info dashboard_addr = 127.0.0.1 dashboard_port = 7500 dashboard_user = admin dashboard_pwd = admin -; enable tls -dashboard_tls_mode = false -dashboard_tls_cert_file = cert.crt -dashboard_tls_key_file = cert.key ; user tokens [users]