From 95e5671dfd9a2a19992be6c9d3c174113ea475d0 Mon Sep 17 00:00:00 2001 From: Rin Date: Mon, 11 Jul 2022 13:43:39 +0100 Subject: [PATCH] Final commit on the JS branch.. this doesnt work. --- .gitignore | 4 ++- package.json | 2 ++ src/index.ts | 11 ++++++-- src/modules/startup.ts | 53 ++++++++++++++++++++--------------- src/proto/wm.ts | 26 +++-------------- yarn.lock | 63 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 110 insertions(+), 49 deletions(-) diff --git a/.gitignore b/.gitignore index 74cf2f0..822e154 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ proto/ !src/proto/proto/ .env dist/ -server_wangan.key \ No newline at end of file +server_wangan.key +cert.pfx +key.pem \ No newline at end of file diff --git a/package.json b/package.json index 7834525..8f2d38b 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,10 @@ }, "dependencies": { "@prisma/client": "^4.0.0", + "@types/pem": "^1.9.6", "body-parser": "^1.20.0", "express": "^4.18.1", + "pem": "^1.14.6", "protobufjs": "^7.0.0", "ts-proto": "^1.117.0" } diff --git a/src/index.ts b/src/index.ts index 4968944..4cbe9e8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,6 +16,11 @@ app.use(bodyParser.raw({ type: '*/*' })); +app.use((req, res, next) => { + console.log(`${req.method} ${req.url}`); + next() +}); + let dirs = fs.readdirSync('dist/modules'); for (let i of dirs) { if (i.endsWith('.js')) { @@ -30,8 +35,8 @@ app.all('*', (req, res) => { }) https.createServer({ - key: fs.readFileSync('server_wangan.key'), - cert: fs.readFileSync('server_wangan.crt') + key: fs.readFileSync('./server_wangan.key'), + cert: fs.readFileSync('./server_wangan.crt') }, app).listen(9002, () => { console.log('Server listening on port 9002!'); -}) \ No newline at end of file +}) diff --git a/src/modules/startup.ts b/src/modules/startup.ts index 94f7f59..948205e 100644 --- a/src/modules/startup.ts +++ b/src/modules/startup.ts @@ -1,46 +1,53 @@ import { Application } from "express"; import {Module} from "module"; -import {ClientLogType, ErrorCode, RegisterSystemInfoRequest, RegisterSystemInfoResponse} from "../proto/wm"; +import {ClientLogType, ErrorCode, Place, PlaceList, RegisterSystemInfoRequest, RegisterSystemInfoResponse} from "../proto/wm"; export default class StartupModule extends Module { register(app: Application): void { app.post('/method/register_system_info', (req, res) => { - for (let i of req.rawHeaders) { - console.log(i); - } - - let b = RegisterSystemInfoRequest.decode(req.body); - console.log(b); let msg = { error: ErrorCode.ERR_SUCCESS, - regionId: b.allnetRegion0, - placeId: b.allnetPlaceId.toString(), - allowedClientLogTypes: [ - ClientLogType.LOG_ERROR - ], - ghostSelectionMinRedoWait: 1, - ghostSelectionMaxRedoWait: 3, + regionId: 1, + placeId: "123", + allowedClientLogTypes: [], + ghostSelectionMinRedoWait: 30, + ghostSelectionMaxRedoWait: 4000, inviteFriendCampaignSchedule: undefined, featureVersion: { - version: 304, + version: 9, year: 2022, month: 7, - pluses: 1, - releaseAt: 1657438767 // idk what this is + pluses: 0, + releaseAt: 0 // idk what this is }, latestCompetitionId: 0, competitionSchedule: undefined, - scratchNotes: "test" // null + scratchNotes: "" // null } let resp = RegisterSystemInfoResponse.encode(msg); let end = resp.finish(); let r = res - .header('User-Agent', 'v388 wangan') - .header('Content-Type', 'application/x-protobuf; revision=8053'); - r.write(Buffer.from(end)); - r.writeContinue(() => { - console.log('writeContinue') + .header('Server', 'v388 wangan') + .header('Content-Type', 'application/x-protobuf; revision=8053') + .status(200); + r.send(Buffer.from(end)); + }) + + app.get('/resource/place_list', (req, res) => { + console.log('place list'); + let places: Place[] = []; + places.push({ + placeId: "123", + regionId: 1, + shopName: "WMMT6", + country: "JPN" }); + let resp = PlaceList.encode({places}); + let r = res + .header('Server', 'v388 wangan') + .header('Content-Type', 'application/x-protobuf; revision=8053') + .status(200); + r.send(resp); }) } } \ No newline at end of file diff --git a/src/proto/wm.ts b/src/proto/wm.ts index 53878c5..d31b083 100644 --- a/src/proto/wm.ts +++ b/src/proto/wm.ts @@ -2974,15 +2974,9 @@ export const RegisterSystemInfoResponse = { message: RegisterSystemInfoResponse, writer: _m0.Writer = _m0.Writer.create() ): _m0.Writer { - if (message.error !== 0) { writer.uint32(8).int32(message.error); - } - if (message.regionId !== 0) { writer.uint32(16).uint32(message.regionId); - } - if (message.placeId !== "") { writer.uint32(26).string(message.placeId); - } writer.uint32(34).fork(); for (const v of message.allowedClientLogTypes) { writer.int32(v); @@ -3012,12 +3006,8 @@ export const RegisterSystemInfoResponse = { writer.uint32(218).fork() ).ldelim(); } - if (message.ghostSelectionMinRedoWait !== 0) { writer.uint32(224).uint32(message.ghostSelectionMinRedoWait); - } - if (message.ghostSelectionMaxRedoWait !== 0) { writer.uint32(232).uint32(message.ghostSelectionMaxRedoWait); - } return writer; }, @@ -17713,18 +17703,10 @@ function createBasePlace(): Place { export const Place = { encode(message: Place, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.placeId !== "") { - writer.uint32(10).string(message.placeId); - } - if (message.shopName !== "") { - writer.uint32(18).string(message.shopName); - } - if (message.regionId !== 0) { - writer.uint32(24).uint32(message.regionId); - } - if (message.country !== "") { - writer.uint32(34).string(message.country); - } + writer.uint32(10).string(message.placeId); + writer.uint32(18).string(message.shopName); + writer.uint32(24).uint32(message.regionId); + writer.uint32(34).string(message.country); return writer; }, diff --git a/yarn.lock b/yarn.lock index fbd9ba5..1943669 100644 --- a/yarn.lock +++ b/yarn.lock @@ -194,6 +194,13 @@ resolved "https://registry.yarnpkg.com/@types/object-hash/-/object-hash-1.3.4.tgz#079ba142be65833293673254831b5e3e847fe58b" integrity sha512-xFdpkAkikBgqBdG9vIlsqffDV8GpvnPEzs0IUtr1v3BEB97ijsFQ4RXVbUZwjFThhB4MDSTUfvmxUD5PGx0wXA== +"@types/pem@^1.9.6": + version "1.9.6" + resolved "https://registry.yarnpkg.com/@types/pem/-/pem-1.9.6.tgz#c3686832e935947fdd9d848dec3b8fe830068de7" + integrity sha512-IC67SxacM9fxEi/w7hf98dTun83OwUMeLMo1NS2gE0wdM9MHeg73iH/Pp9nB02OUCQ7Zb2UuKE/IpFCmQw9jxw== + dependencies: + "@types/node" "*" + "@types/qs@*": version "6.9.7" resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" @@ -328,6 +335,11 @@ chalk@^4.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" +charenc@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" + integrity sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA== + color-convert@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" @@ -372,6 +384,11 @@ create-require@^1.1.0: resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== +crypt@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" + integrity sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow== + dataloader@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/dataloader/-/dataloader-1.4.0.tgz#bca11d867f5d3f1b9ed9f737bd15970c65dff5c8" @@ -419,6 +436,11 @@ entities@~2.1.0: resolved "https://registry.yarnpkg.com/entities/-/entities-2.1.0.tgz#992d3129cf7df6870b96c57858c249a120f8b8b5" integrity sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w== +es6-promisify@^6.0.0: + version "6.1.1" + resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-6.1.1.tgz#46837651b7b06bf6fff893d03f29393668d01621" + integrity sha512-HBL8I3mIki5C1Cc9QjKUenHtnG0A5/xA8Q/AllRcfiwl2CZFXGK7ddBiCoRwAix4i2KxcQfjtIVcrVbB3vbmwg== + escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" @@ -640,6 +662,16 @@ ipaddr.js@1.9.1: resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== +is-buffer@~1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + js2xmlparser@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/js2xmlparser/-/js2xmlparser-4.0.2.tgz#2a1fdf01e90585ef2ae872a01bc169c6a8d5e60a" @@ -736,6 +768,15 @@ marked@^4.0.10: resolved "https://registry.yarnpkg.com/marked/-/marked-4.0.17.tgz#1186193d85bb7882159cdcfc57d1dfccaffb3fe9" integrity sha512-Wfk0ATOK5iPxM4ptrORkFemqroz0ZDxp5MWfYA7H/F+wO17NRWV5Ypxi6p3g2Xmw2bKeiYOl6oVnLHKxBA0VhA== +md5@^2.2.1: + version "2.3.0" + resolved "https://registry.yarnpkg.com/md5/-/md5-2.3.0.tgz#c3da9a6aae3a30b46b7b0c349b87b110dc3bda4f" + integrity sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g== + dependencies: + charenc "0.0.2" + crypt "0.0.2" + is-buffer "~1.1.6" + mdurl@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" @@ -848,6 +889,11 @@ optionator@^0.8.1: type-check "~0.3.2" word-wrap "~1.2.3" +os-tmpdir@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== + parseurl@~1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" @@ -863,6 +909,16 @@ path-to-regexp@0.1.7: resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" integrity sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ== +pem@^1.14.6: + version "1.14.6" + resolved "https://registry.yarnpkg.com/pem/-/pem-1.14.6.tgz#89babca3a73466fb844df70666dbf1b25eb0dc56" + integrity sha512-I5GKUer2PPv5qzUfxaZ6IGRkhp+357Kyv2t1JJg9vP8hGGI13qU34N2QupmggbpIZGPuudH0jn8KU5hjFpPk3g== + dependencies: + es6-promisify "^6.0.0" + md5 "^2.2.1" + os-tmpdir "^1.0.1" + which "^2.0.2" + prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -1179,6 +1235,13 @@ vary@~1.1.2: resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== +which@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + word-wrap@~1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"