mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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 crypto from 'crypto';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import * as bus from 'hydrooj/src/service/bus';
|
import * as bus from 'hydrooj/src/service/bus';
|
||||||
@@ -28,7 +29,13 @@ class DataReportHandler extends Handler {
|
|||||||
@post('installId', Types.String)
|
@post('installId', Types.String)
|
||||||
@post('payload', Types.String)
|
@post('payload', Types.String)
|
||||||
async post(domainId: string, installId: string, _payload: 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 });
|
const old = await coll.findOne({ _id: installId });
|
||||||
await coll.updateOne({ _id: installId }, {
|
await coll.updateOne({ _id: installId }, {
|
||||||
$set: {
|
$set: {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/center",
|
"name": "@hydrooj/center",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.17.8",
|
"version": "3.17.9",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import crypto from 'crypto';
|
|
||||||
import { dump } from 'js-yaml';
|
import { dump } from 'js-yaml';
|
||||||
import superagent from 'superagent';
|
import superagent from 'superagent';
|
||||||
import type { StatusUpdate } from '@hydrooj/utils/lib/sysinfo';
|
import type { StatusUpdate } from '@hydrooj/utils/lib/sysinfo';
|
||||||
@@ -10,13 +9,6 @@ import db from './db';
|
|||||||
const coll = db.collection('status');
|
const coll = db.collection('status');
|
||||||
const logger = new Logger('monitor');
|
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]> {
|
export async function feedback(): Promise<[string, StatusUpdate]> {
|
||||||
const {
|
const {
|
||||||
system, domain, document, user, record,
|
system, domain, document, user, record,
|
||||||
@@ -56,12 +48,12 @@ export async function feedback(): Promise<[string, StatusUpdate]> {
|
|||||||
const status = await db.db.admin().serverStatus();
|
const status = await db.db.admin().serverStatus();
|
||||||
info.dbVersion = status.version;
|
info.dbVersion = status.version;
|
||||||
} catch (e) { }
|
} catch (e) { }
|
||||||
const payload = crypt(dump(info, {
|
const payload = dump(info, {
|
||||||
replacer: (key, value) => {
|
replacer: (key, value) => {
|
||||||
if (typeof value === 'function') return '';
|
if (typeof value === 'function') return '';
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
}));
|
});
|
||||||
if (process.env.CI) return [mid, $update];
|
if (process.env.CI) return [mid, $update];
|
||||||
superagent.post(`${system.get('server.center')}/report`)
|
superagent.post(`${system.get('server.center')}/report`)
|
||||||
.send({ installId, payload })
|
.send({ installId, payload })
|
||||||
|
|||||||
Reference in new issue
Block a user