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