mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
telemetry: sandbox version
This commit is contained in:
1 parent
84c7815ef6
commit
5bc8882738
6 files changed
+20
-4
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
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 db from 'hydrooj/src/service/db';
|
import db from 'hydrooj/src/service/db';
|
||||||
import {
|
import {
|
||||||
Handler, post, Route, Types,
|
Handler, post, Route, Types,
|
||||||
@@ -28,6 +29,7 @@ class DataReportHandler extends Handler {
|
|||||||
@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));
|
const payload: any = yaml.load(decrypt(_payload));
|
||||||
|
const old = await coll.findOne({ _id: installId });
|
||||||
await coll.updateOne({ _id: installId }, {
|
await coll.updateOne({ _id: installId }, {
|
||||||
$set: {
|
$set: {
|
||||||
version: payload.version,
|
version: payload.version,
|
||||||
@@ -45,9 +47,11 @@ class DataReportHandler extends Handler {
|
|||||||
problemCount: payload.problemCount,
|
problemCount: payload.problemCount,
|
||||||
discussionCount: payload.discussionCount,
|
discussionCount: payload.discussionCount,
|
||||||
recordCount: payload.recordCount,
|
recordCount: payload.recordCount,
|
||||||
|
sandbox: payload.sandbox,
|
||||||
},
|
},
|
||||||
}, { upsert: true });
|
}, { upsert: true });
|
||||||
this.response.body = 'success';
|
bus.emit('center/report', this, installId, old, payload);
|
||||||
|
this.response.body = { code: 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/center",
|
"name": "@hydrooj/center",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"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.15.8",
|
"version": "3.15.9",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ SystemSetting(
|
|||||||
Setting('setting_smtp', 'smtp.from', null, 'text', 'smtp.from', 'Mail From'),
|
Setting('setting_smtp', 'smtp.from', null, 'text', 'smtp.from', 'Mail From'),
|
||||||
Setting('setting_smtp', 'smtp.secure', false, 'boolean', 'smtp.secure', 'SSL'),
|
Setting('setting_smtp', 'smtp.secure', false, 'boolean', 'smtp.secure', 'SSL'),
|
||||||
Setting('setting_smtp', 'smtp.verify', true, 'boolean', 'smtp.verify', 'Verify register email'),
|
Setting('setting_smtp', 'smtp.verify', true, 'boolean', 'smtp.verify', 'Verify register email'),
|
||||||
Setting('setting_server', 'server.center', 'https://hydro.undefined.moe:8443/center', 'text', 'server.center', '', FLAG_HIDDEN),
|
Setting('setting_server', 'server.center', 'https://hydro.ac/center', 'text', 'server.center', '', FLAG_HIDDEN),
|
||||||
Setting('setting_server', 'server.name', 'Hydro', 'text', 'server.name', 'Server Name'),
|
Setting('setting_server', 'server.name', 'Hydro', 'text', 'server.name', 'Server Name'),
|
||||||
Setting('setting_server', 'server.displayName', 'Hydro', 'text', 'server.name', 'Server Name (Global Display)', FLAG_PRO),
|
Setting('setting_server', 'server.displayName', 'Hydro', 'text', 'server.name', 'Server Name (Global Display)', FLAG_PRO),
|
||||||
Setting('setting_server', 'server.url', '/', 'text', 'server.url', 'Server BaseURL'),
|
Setting('setting_server', 'server.url', '/', 'text', 'server.url', 'Server BaseURL'),
|
||||||
|
|||||||
@@ -33,6 +33,13 @@ export async function feedback(): Promise<[string, StatusUpdate]> {
|
|||||||
document.coll.find({ docType: document.TYPE_DISCUSSION }).count(),
|
document.coll.find({ docType: document.TYPE_DISCUSSION }).count(),
|
||||||
record.coll.find().count(),
|
record.coll.find().count(),
|
||||||
]);
|
]);
|
||||||
|
let sandbox = '';
|
||||||
|
try {
|
||||||
|
let host = system.get('hydrojudge.sandbox_host') || 'http://localhost:5050/';
|
||||||
|
if (!host.endsWith('/')) host += '/';
|
||||||
|
const res = await superagent.get(`${host}version`);
|
||||||
|
sandbox = res.body;
|
||||||
|
} catch (e) { }
|
||||||
const payload = crypt(dump({
|
const payload = crypt(dump({
|
||||||
mid: mid.toString(),
|
mid: mid.toString(),
|
||||||
version,
|
version,
|
||||||
@@ -47,6 +54,7 @@ export async function feedback(): Promise<[string, StatusUpdate]> {
|
|||||||
memory: inf.memory,
|
memory: inf.memory,
|
||||||
osinfo: inf.osinfo,
|
osinfo: inf.osinfo,
|
||||||
cpu: inf.cpu,
|
cpu: inf.cpu,
|
||||||
|
sandbox,
|
||||||
}, {
|
}, {
|
||||||
replacer: (key, value) => {
|
replacer: (key, value) => {
|
||||||
if (typeof value === 'function') return '';
|
if (typeof value === 'function') return '';
|
||||||
|
|||||||
@@ -791,6 +791,10 @@ const scripts: UpgradeScript[] = [
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
async function _64_65() {
|
||||||
|
await system.set('server.center', 'https://hydro.ac/center');
|
||||||
|
return true;
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default scripts;
|
export default scripts;
|
||||||
Reference in new issue
Block a user