mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: fix support for node18
This commit is contained in:
1 parent
f1436a366c
commit
1397f91f1e
4 files changed
+12
-13
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import assert from 'assert';
|
||||
import crypto from 'crypto';
|
||||
import yaml from 'js-yaml';
|
||||
import * as bus from 'hydrooj/src/service/bus';
|
||||
@@ -28,7 +29,13 @@ class DataReportHandler extends Handler {
|
||||
@post('installId', Types.String)
|
||||
@post('payload', Types.String)
|
||||
async post(domainId: string, installId: string, _payload: string) {
|
||||
const payload: any = yaml.load(decrypt(_payload));
|
||||
let payload: any;
|
||||
try {
|
||||
payload = yaml.load(decrypt(_payload));
|
||||
} catch (e) {
|
||||
payload = yaml.load(_payload);
|
||||
}
|
||||
assert(payload.url);
|
||||
const old = await coll.findOne({ _id: installId });
|
||||
await coll.updateOne({ _id: installId }, {
|
||||
$set: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/center",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"main": "package.json",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.17.8",
|
||||
"version": "3.17.9",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import crypto from 'crypto';
|
||||
import { dump } from 'js-yaml';
|
||||
import superagent from 'superagent';
|
||||
import type { StatusUpdate } from '@hydrooj/utils/lib/sysinfo';
|
||||
@@ -10,13 +9,6 @@ import db from './db';
|
||||
const coll = db.collection('status');
|
||||
const logger = new Logger('monitor');
|
||||
|
||||
function crypt(str: string) {
|
||||
const cipher = crypto.createCipheriv('des-ecb', 'hydro-oj', ''); // lgtm [js/hardcoded-credentials]
|
||||
let encrypted = cipher.update(str, 'utf8', 'hex');
|
||||
encrypted += cipher.final('hex');
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
export async function feedback(): Promise<[string, StatusUpdate]> {
|
||||
const {
|
||||
system, domain, document, user, record,
|
||||
@@ -56,12 +48,12 @@ export async function feedback(): Promise<[string, StatusUpdate]> {
|
||||
const status = await db.db.admin().serverStatus();
|
||||
info.dbVersion = status.version;
|
||||
} catch (e) { }
|
||||
const payload = crypt(dump(info, {
|
||||
const payload = dump(info, {
|
||||
replacer: (key, value) => {
|
||||
if (typeof value === 'function') return '';
|
||||
return value;
|
||||
},
|
||||
}));
|
||||
});
|
||||
if (process.env.CI) return [mid, $update];
|
||||
superagent.post(`${system.get('server.center')}/report`)
|
||||
.send({ installId, payload })
|
||||
|
||||
Reference in new issue
Block a user