This commit is contained in:
HolographicHat
2022-03-22 11:28:50 +08:00
parent bcebaf979a
commit a25598f5ea
6 changed files with 50 additions and 44 deletions

4
app.js
View File

@@ -134,10 +134,14 @@ const { exportData } = require("./export");
return server return server
}).then(() => console.log("加载完毕")) }).then(() => console.log("加载完毕"))
} catch (e) { } catch (e) {
console.log(e)
if (e instanceof Error) { if (e instanceof Error) {
appcenter.uploadError(e, true) appcenter.uploadError(e, true)
} else { } else {
appcenter.uploadError(Error(e), true) appcenter.uploadError(Error(e), true)
} }
console.log("按任意键退出")
cp.execSync("pause > nul", { stdio: "inherit" })
process.exit(0)
} }
})() })()

View File

@@ -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;
}

View File

@@ -1,13 +1,34 @@
syntax = "proto3"; 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 { message QueryCurRegion {
bytes field0 = 11; bytes field0 = 11;
bytes field1 = 12; bytes field1 = 12;
bytes field2 = 13; bytes field2 = 13;
RegionInfo info = 3; msg0 info = 3;
} }
message RegionInfo { message msg0 {
string ip = 1; string ip = 1;
uint32 port = 2; uint32 port = 2;
string field0 = 3; string field0 = 3;
@@ -29,13 +50,27 @@ message RegionInfo {
string fieldG = 31; string fieldG = 31;
string fieldH = 32; string fieldH = 32;
string fieldI = 33; string fieldI = 33;
ResVersionConfig fieldJ = 22; msg1 fieldJ = 22;
} }
message ResVersionConfig { message msg1 {
uint32 field0 = 1; uint32 field0 = 1;
string field1 = 3; string field1 = 3;
string field2 = 4; string field2 = 4;
string field3 = 5; string field3 = 5;
string field4 = 6; 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;
}

View File

@@ -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;
}

View File

@@ -2,6 +2,8 @@ const fs = require("fs")
const https = require("https") const https = require("https")
const axios = require("axios") const axios = require("axios")
const { decodeProto, encodeProto, debug } = require("./utils") const { decodeProto, encodeProto, debug } = require("./utils")
const path = require("path")
const cert = path.join(__dirname, "./cert/root.p12")
const preparedRegions = {} const preparedRegions = {}
let currentProxy = undefined let currentProxy = undefined
@@ -64,7 +66,7 @@ const create = async (conf, regionListLoadedCallback, regionSelectCallback) => {
const regions = await getModifiedRegionList(conf) const regions = await getModifiedRegionList(conf)
regionListLoadedCallback() regionListLoadedCallback()
const hServer = https.createServer({ const hServer = https.createServer({
pfx: fs.readFileSync("./cert/root.p12"), pfx: fs.readFileSync(cert),
passphrase: "" passphrase: ""
}, async (request, response) => { }, async (request, response) => {
const url = request.url const url = request.url

View File

@@ -8,6 +8,8 @@ const readline = require("readline")
const protobuf = require("protobufjs") const protobuf = require("protobufjs")
const { version } = require("./version") const { version } = require("./version")
const { createHash } = require("crypto") const { createHash } = require("crypto")
const path = require("path")
const messages = path.join(__dirname, "./proto/Messages.proto")
let axios = require("axios") let axios = require("axios")
@@ -15,13 +17,13 @@ const sleep = ms => new Promise(resolve => {
setTimeout(resolve, ms) 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 msgType = r.lookupType(name)
const msgInst = msgType.create(object) const msgInst = msgType.create(object)
return msgType.encode(msgInst).finish() 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) return r.lookupType(name).decode(buf)
}) })