From bc04d87d2620cc6423b7b6bbeccb32a3d65981a5 Mon Sep 17 00:00:00 2001 From: leiyun Date: Mon, 19 May 2025 14:12:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/config/config.js | 3 ++- src/common/config/route.js | 3 +++ src/home/controller/index.js | 17 ++++++++++++++--- ssl/lechallenge/test-121212-0 | 1 + 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/common/config/route.js create mode 100644 ssl/lechallenge/test-121212-0 diff --git a/src/common/config/config.js b/src/common/config/config.js index c0ccd3e..7cf5f0b 100644 --- a/src/common/config/config.js +++ b/src/common/config/config.js @@ -4,5 +4,6 @@ */ export default { //key: value - port: 8361 + port: 8361, + route_on: true }; \ No newline at end of file diff --git a/src/common/config/route.js b/src/common/config/route.js new file mode 100644 index 0000000..0692fd2 --- /dev/null +++ b/src/common/config/route.js @@ -0,0 +1,3 @@ +export default [ + ['lechallenge/:file','/home/index/lechallenge'] +] \ No newline at end of file diff --git a/src/home/controller/index.js b/src/home/controller/index.js index 4aa7f3c..9ecbcd4 100644 --- a/src/home/controller/index.js +++ b/src/home/controller/index.js @@ -15,15 +15,17 @@ const dayjs = require('dayjs'); // 需安装dayjs库 // SSL根目录 const ROOT_PATH = path.join(think.ROOT_PATH, 'ssl'); const PEM_PATH = path.join(ROOT_PATH, 'cert'); +const LETSENCRYPT_PATH = path.join(ROOT_PATH, 'letsencrypt'); +const LECHALLENGE_PATH = path.join(ROOT_PATH, 'lechallenge'); // 创建存储对象 const leStore = GreenlockStoreFs.create({ - configDir: path.join(ROOT_PATH, 'letsencrypt'), - basePath: path.join(ROOT_PATH, 'letsencrypt'), + configDir: LETSENCRYPT_PATH, + basePath: LETSENCRYPT_PATH, env: think.env }); // 创建验证对象 const leHttpChallenge = LeChallengeFs.create({ - webrootPath: path.join(ROOT_PATH, 'lechallenge'), + webrootPath: LECHALLENGE_PATH, }); // 是否同意协议 function leAgree (opts, agreeCb) { @@ -242,4 +244,13 @@ export default class extends Base { console.error('部署失败:', error.message); } } + + /** + * 配置路由 + */ + async lechallengeAction () { + let params = this.param(); + let txt = fs.readFileSync(path.join(LECHALLENGE_PATH,params.file)) + this.json(txt); + } } \ No newline at end of file diff --git a/ssl/lechallenge/test-121212-0 b/ssl/lechallenge/test-121212-0 new file mode 100644 index 0000000..6f1cff6 --- /dev/null +++ b/ssl/lechallenge/test-121212-0 @@ -0,0 +1 @@ +dasdasdasdasdasds \ No newline at end of file