From aac890561985ddb703ce4c102f86c63ec0f5c6bb Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sat, 12 Aug 2023 15:43:30 +0800 Subject: [PATCH] =?UTF-8?q?api=20secret=E6=97=A0=E6=95=88=E6=97=B6?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E7=9B=B4=E6=8E=A5=E9=80=80=E5=87=BA=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 而是修改为随机字符串并持久化至配置文件 --- server/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/main.cpp b/server/main.cpp index b9d84249..f0d0ce1b 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -351,10 +351,13 @@ int start_main(int argc,char *argv[]) { #endif //defined(ENABLE_SRT) try { - auto secret = mINI::Instance()[API::kSecret]; + auto &secret = mINI::Instance()[API::kSecret]; if (secret == "035c73f7-bb6b-4889-a715-d9eb2d1925cc" || secret.empty()) { // 使用默认secret被禁止启动 - throw std::invalid_argument("please modify the configuration named " + API::kSecret + " in " + g_ini_file); + secret = makeRandStr(32, true); + mINI::Instance().dumpFile(g_ini_file); + WarnL << "The " << API::kSecret << " is invalid, modified it to: " << secret + << ", saved config file: " << g_ini_file; } //rtsp服务器,端口默认554 if (rtspPort) { rtspSrv->start(rtspPort); }