From c8891848f1ecc06abc7819f8851a51da9df93026 Mon Sep 17 00:00:00 2001 From: "Qumolama.d" Date: Fri, 13 May 2022 15:28:13 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 37 +++++++++++++++++++++---------------- README.MD | 3 +++ src/index.js | 4 ++-- src/secure.js | 3 ++- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/.drone.yml b/.drone.yml index f82fe54..be33278 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,6 +7,8 @@ kind: pipeline name: test steps: + - name: setup-database + image: mongo:5 - name: test image: node:16 commands: @@ -25,20 +27,23 @@ steps: format: markdown message: > {{#success build.status}} - ✅ `{{repo.name}}` #{{build.number}} 号构建测试已通过\n - 📝 {{commit.author}} 在 `{{commit.branch}}` 的提交:\n - ``` - {{commit.message}} - ``` - \n🌐 {{ build.link }} - {{else}} - ❌ `{{repo.name}}` #{{build.number}} 号构建测试已失败\n - 📝 {{commit.author}} 在 `{{commit.branch}}` 的提交:\n - ``` - {{commit.message}} - ``` - \n🌐 {{ build.link }} - {{/success}} + ✅ `{{repo.name}}` #{{build.number}} 号构建测试已通过 - - + 📝 {{commit.author}} 在 `{{commit.branch}}` 的提交: + + ``` + {{commit.message}} + ``` + + 🌐 {{ build.link }} + {{else}} + ❌ `{{repo.name}}` #{{build.number}} 号构建测试已失败 + + 📝 {{commit.author}} 在 `{{commit.branch}}` 的提交: + + ``` + {{commit.message}} + ``` + + 🌐 {{ build.link }} + {{/success}} \ No newline at end of file diff --git a/README.MD b/README.MD index 54ff82f..7e7e12d 100644 --- a/README.MD +++ b/README.MD @@ -61,6 +61,9 @@ 4. 使用 `$ node build.js` 创建运行时构建 5. 使用 `$ node path/to/lsp-yggdrasil.full.cjs` 起飞 +> 注:对于开发者的首次运行,您可能需要创建一个测试账户,添加环境参数:`DEVEL_FIRST_RUN=1` 即可创建一个测试玩家 +> 测试玩家的账户为: `i@lama.icu` 密码为 `123456` 您可以到 `index.js` 中自由修改 + ## 常见问题 - Q:支持 `https` 嘛? diff --git a/src/index.js b/src/index.js index 4245afa..0008977 100644 --- a/src/index.js +++ b/src/index.js @@ -49,7 +49,7 @@ export const setup = async () => { config.custom.postRouting(server) - /* + if(process.env["UNIT_TEST"] || process.env["DEVEL_FIRST_RUN"]) { // Create a test player await new models.Player({ username: 'test', @@ -63,7 +63,7 @@ export const setup = async () => { registerDate: Date.now(), permissions: [{ node: 'login', allowed: true, duration: 0, eternal: true, startDate: Date.now(), highPriority: false }] }).save() - */ + } } const launch = async () => { diff --git a/src/secure.js b/src/secure.js index c5e1859..e99605c 100644 --- a/src/secure.js +++ b/src/secure.js @@ -2,6 +2,7 @@ import { PNG } from 'pngjs' import fs from 'fs' import { createHash, createPrivateKey, createSign } from 'crypto' import { config } from './config.js' +import { server } from './index.js' export const ImageSecurity = { createImageHash: async (path, isCape) => { @@ -70,7 +71,7 @@ export const ImageSecurity = { throw new Error('Invalid image size') }, sign: async (data) => { - return createSign('RSA-SHA1').update(data).sign(createPrivateKey(config.privateKey), 'hex') + return createSign('RSA-SHA1').update(data).sign({ key: createPrivateKey(server.keys.privateKey) }, 'hex') } }