fix hwid generation
This commit is contained in:
parent
74e233ecc3
commit
6551f0b369
|
@ -16,17 +16,21 @@ const platforms = {
|
||||||
};
|
};
|
||||||
const crypto = require("crypto");
|
const crypto = require("crypto");
|
||||||
|
|
||||||
|
const defaultHWID = "recorderinthesandybridge";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns machine hardware id.
|
* Returns machine hardware id.
|
||||||
* Returns `undefined` if cannot determine.
|
* Returns `undefined` if cannot determine.
|
||||||
* @return {string?}
|
* @return {Promise<string>}
|
||||||
*/
|
*/
|
||||||
function getHwId() {
|
function getHwId() {
|
||||||
const getter = platforms[process.platform];
|
return new Promise((resolve) => {
|
||||||
if (!getter) return;
|
const getter = platforms[process.platform];
|
||||||
const result = getter[1].exec(child_process.execSync(getter[0], options));
|
if (getter) {
|
||||||
if (!result) return;
|
const result = getter[1].exec(child_process.execSync(getter[0], options));
|
||||||
return crypto.createHash("md5").update(result[1]).digest("hex") ||
|
if (result) resolve(crypto.createHash("md5").update(result[1]).digest("hex"));
|
||||||
undefined;
|
}
|
||||||
|
resolve(crypto.createHash("md5").update(defaultHWID).digest("hex"));
|
||||||
|
})
|
||||||
}
|
}
|
||||||
exports.getHwId = getHwId;
|
exports.getHwId = getHwId;
|
||||||
|
|
4
main.js
4
main.js
|
@ -248,7 +248,7 @@ function registerIPCPipes() {
|
||||||
ipcMain.handle("ezpplauncher:login", async (e, args) => {
|
ipcMain.handle("ezpplauncher:login", async (e, args) => {
|
||||||
let hwid = "";
|
let hwid = "";
|
||||||
try {
|
try {
|
||||||
hwid = getHwId();
|
hwid = await getHwId();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(`Failed to get HWID.`, err);
|
logger.error(`Failed to get HWID.`, err);
|
||||||
return {
|
return {
|
||||||
|
@ -315,7 +315,7 @@ function registerIPCPipes() {
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle("ezpplauncher:autologin", async (e) => {
|
ipcMain.handle("ezpplauncher:autologin", async (e) => {
|
||||||
const hwid = getHwId();
|
const hwid = await getHwId();
|
||||||
const username = config.get("username");
|
const username = config.get("username");
|
||||||
const guest = config.get("guest");
|
const guest = config.get("guest");
|
||||||
if (guest) return { code: 200, message: "Login as guest", guest: true };
|
if (guest) return { code: 200, message: "Login as guest", guest: true };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user