1
0
mirror of synced 2024-09-24 03:08:26 +02:00

Add ping method yes I am committing this change from a hotel room

This commit is contained in:
Rin 2022-07-11 15:19:36 +01:00
parent 4a2f9de102
commit 4cf03efa0b
2 changed files with 18 additions and 1 deletions

View File

@ -31,7 +31,7 @@ for (let i of dirs) {
}
app.all('*', (req, res) => {
console.log(`CATCH-ALL: ${req.method} ${req.originalUrl}`);
res.status(200).end();
})
https.createServer({

View File

@ -48,5 +48,22 @@ export default class StartupModule extends Module {
.status(200);
r.send(Buffer.from(end));
})
app.post('/method/ping', (req, res) => {
console.log('ping');
let body = wm.wm.protobuf.PingRequest.decode(req.body);
let ping = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
pong: body.ping || 1
};
let resp = wm.wm.protobuf.PingResponse.encode(ping);
let end = resp.finish();
let r = res
.header('Server', 'v388 wangan')
.header('Content-Type', 'application/x-protobuf; revision=8053')
.header('Content-Length', end.length.toString())
.status(200);
r.send(Buffer.from(end));
})
}
}