From a25598f5eab21edfd6cfc59a6adf6b30954896e4 Mon Sep 17 00:00:00 2001 From: HolographicHat Date: Tue, 22 Mar 2022 11:28:50 +0800 Subject: [PATCH] fix --- app.js | 4 ++ proto/AllAchievement.proto | 22 ---------- .../{QueryCurRegion.proto => Messages.proto} | 43 +++++++++++++++++-- proto/QueryRegionList.proto | 15 ------- regionServer.js | 4 +- utils.js | 6 ++- 6 files changed, 50 insertions(+), 44 deletions(-) delete mode 100644 proto/AllAchievement.proto rename proto/{QueryCurRegion.proto => Messages.proto} (53%) delete mode 100644 proto/QueryRegionList.proto diff --git a/app.js b/app.js index bf5db58..c5adac8 100644 --- a/app.js +++ b/app.js @@ -134,10 +134,14 @@ const { exportData } = require("./export"); return server }).then(() => console.log("加载完毕")) } catch (e) { + console.log(e) if (e instanceof Error) { appcenter.uploadError(e, true) } else { appcenter.uploadError(Error(e), true) } + console.log("按任意键退出") + cp.execSync("pause > nul", { stdio: "inherit" }) + process.exit(0) } })() diff --git a/proto/AllAchievement.proto b/proto/AllAchievement.proto deleted file mode 100644 index 419b620..0000000 --- a/proto/AllAchievement.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; - -message AllAchievement { - repeated Achievement list = 1; -} - -message Achievement { - - enum Status { - INVALID = 0; - UNFINISHED = 1; - FINISHED = 2; - REWARD_TAKEN = 3; - } - - uint32 id = 1; - Status status = 2; - uint32 current = 3; - uint32 require = 4; - uint32 finish_timestamp = 5; - -} diff --git a/proto/QueryCurRegion.proto b/proto/Messages.proto similarity index 53% rename from proto/QueryCurRegion.proto rename to proto/Messages.proto index 4fb3fdc..0454201 100644 --- a/proto/QueryCurRegion.proto +++ b/proto/Messages.proto @@ -1,13 +1,34 @@ syntax = "proto3"; +message AllAchievement { + repeated Achievement list = 1; +} + +message Achievement { + + enum Status { + INVALID = 0; + UNFINISHED = 1; + FINISHED = 2; + REWARD_TAKEN = 3; + } + + uint32 id = 1; + Status status = 2; + uint32 current = 3; + uint32 require = 4; + uint32 finish_timestamp = 5; + +} + message QueryCurRegion { bytes field0 = 11; bytes field1 = 12; bytes field2 = 13; - RegionInfo info = 3; + msg0 info = 3; } -message RegionInfo { +message msg0 { string ip = 1; uint32 port = 2; string field0 = 3; @@ -29,13 +50,27 @@ message RegionInfo { string fieldG = 31; string fieldH = 32; string fieldI = 33; - ResVersionConfig fieldJ = 22; + msg1 fieldJ = 22; } -message ResVersionConfig { +message msg1 { uint32 field0 = 1; string field1 = 3; string field2 = 4; string field3 = 5; string field4 = 6; } + +message QueryRegionList { + bytes field0 = 5; + bytes field1 = 6; + bool field2 = 7; + repeated msg2 list = 2; +} + +message msg2 { + string field0 = 1; + string field1 = 2; + string field2 = 3; + string url = 4; +} diff --git a/proto/QueryRegionList.proto b/proto/QueryRegionList.proto deleted file mode 100644 index 1b341eb..0000000 --- a/proto/QueryRegionList.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; - -message QueryRegionList { - bytes field0 = 5; - bytes field1 = 6; - bool field2 = 7; - repeated RegionSimpleInfo list = 2; -} - -message RegionSimpleInfo { - string field0 = 1; - string field1 = 2; - string field2 = 3; - string url = 4; -} diff --git a/regionServer.js b/regionServer.js index 6a61b59..2eb747c 100644 --- a/regionServer.js +++ b/regionServer.js @@ -2,6 +2,8 @@ const fs = require("fs") const https = require("https") const axios = require("axios") const { decodeProto, encodeProto, debug } = require("./utils") +const path = require("path") +const cert = path.join(__dirname, "./cert/root.p12") const preparedRegions = {} let currentProxy = undefined @@ -64,7 +66,7 @@ const create = async (conf, regionListLoadedCallback, regionSelectCallback) => { const regions = await getModifiedRegionList(conf) regionListLoadedCallback() const hServer = https.createServer({ - pfx: fs.readFileSync("./cert/root.p12"), + pfx: fs.readFileSync(cert), passphrase: "" }, async (request, response) => { const url = request.url diff --git a/utils.js b/utils.js index e5cf647..b1f905f 100644 --- a/utils.js +++ b/utils.js @@ -8,6 +8,8 @@ const readline = require("readline") const protobuf = require("protobufjs") const { version } = require("./version") const { createHash } = require("crypto") +const path = require("path") +const messages = path.join(__dirname, "./proto/Messages.proto") let axios = require("axios") @@ -15,13 +17,13 @@ const sleep = ms => new Promise(resolve => { setTimeout(resolve, ms) }) -const encodeProto = (object, name) => protobuf.load(`proto/${name}.proto`).then(r => { +const encodeProto = (object, name) => protobuf.load(messages).then(r => { const msgType = r.lookupType(name) const msgInst = msgType.create(object) return msgType.encode(msgInst).finish() }) -const decodeProto = (buf, name) => protobuf.load(`proto/${name}.proto`).then(r => { +const decodeProto = (buf, name) => protobuf.load(messages).then(r => { return r.lookupType(name).decode(buf) })