mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 11:42:14 -08:00
Refactor mod verification logic and improve debug capabilities
This commit is contained in:
parent
040ca971e8
commit
aef5e02f19
@ -437,35 +437,7 @@ async function downloadJava(effectiveJavaOptions, launchAfter = true) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Name dlAsync Function
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*
|
|
||||||
* @author Sandro642
|
|
||||||
* @Cheating Athena's Shield
|
|
||||||
*
|
|
||||||
* @Added whitelist for mods
|
|
||||||
* @Added support for the new HeliosLauncher version
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Reviewed on 10.26.2024 expires on XX.XX.2025
|
|
||||||
* @Bugs discovereds: 0
|
|
||||||
* @Athena's Shield
|
|
||||||
* @Sandro642
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// ▄▄▄ ▄▄▄█████▓ ██░ ██ ▓█████ ███▄ █ ▄▄▄ ██████ ██████ ██░ ██ ██▓▓█████ ██▓ ▓█████▄
|
|
||||||
// ▒████▄ ▓ ██▒ ▓▒▓██░ ██▒▓█ ▀ ██ ▀█ █ ▒████▄ ▒██ ▒ ▒██ ▒ ▓██░ ██▒▓██▒▓█ ▀ ▓██▒ ▒██▀ ██▌
|
|
||||||
// ▒██ ▀█▄ ▒ ▓██░ ▒░▒██▀▀██░▒███ ▓██ ▀█ ██▒▒██ ▀█▄ ░ ▓██▄ ░ ▓██▄ ▒██▀▀██░▒██▒▒███ ▒██░ ░██ █▌
|
|
||||||
// ░██▄▄▄▄██░ ▓██▓ ░ ░▓█ ░██ ▒▓█ ▄ ▓██▒ ▐▌██▒░██▄▄▄▄██ ▒ ██▒ ▒ ██▒░▓█ ░██ ░██░▒▓█ ▄ ▒██░ ░▓█▄ ▌
|
|
||||||
// ▓█ ▓██▒ ▒██▒ ░ ░▓█▒░██▓░▒████▒▒██░ ▓██░ ▓█ ▓██▒▒██████▒▒ ▒██████▒▒░▓█▒░██▓░██░░▒████▒░██████▒░▒████▓
|
|
||||||
// ▒▒ ▓▒█░ ▒ ░░ ▒ ░░▒░▒░░ ▒░ ░░ ▒░ ▒ ▒ ▒▒ ▓▒█░▒ ▒▓▒ ▒ ░ ▒ ▒▓▒ ▒ ░ ▒ ░░▒░▒░▓ ░░ ▒░ ░░ ▒░▓ ░ ▒▒▓ ▒
|
|
||||||
// ▒ ▒▒ ░ ░ ▒ ░▒░ ░ ░ ░ ░░ ░░ ░ ▒░ ▒ ▒▒ ░░ ░▒ ░ ░ ░ ░▒ ░ ░ ▒ ░▒░ ░ ▒ ░ ░ ░ ░░ ░ ▒ ░ ░ ▒ ▒
|
|
||||||
// ░ ▒ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░░ ░ ▒ ░ ░ ░ ░ ░ ░ ░
|
|
||||||
// ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
|
|
||||||
// ░
|
|
||||||
|
|
||||||
// Keep reference to Minecraft Process
|
// Keep reference to Minecraft Process
|
||||||
let proc
|
let proc
|
||||||
@ -512,8 +484,8 @@ async function dlAsync(login = true) {
|
|||||||
|
|
||||||
// --------- Mod Verification Logic ---------
|
// --------- Mod Verification Logic ---------
|
||||||
|
|
||||||
if (athShield.status) {
|
if (extraFileVerif.status) {
|
||||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.usingAthShield'))
|
loggerLanding.info(Lang.queryJS('landing.dlAsync.extraFileVerif.usingExtraFileVerif'))
|
||||||
|
|
||||||
const modsDir = path.join(ConfigManager.getDataDirectory(), 'instances', serv.rawServer.id, 'mods')
|
const modsDir = path.join(ConfigManager.getDataDirectory(), 'instances', serv.rawServer.id, 'mods')
|
||||||
|
|
||||||
@ -529,9 +501,9 @@ async function dlAsync(login = true) {
|
|||||||
mdls.forEach(mdl => {
|
mdls.forEach(mdl => {
|
||||||
if (mdl.rawModule.name.endsWith('.jar')) {
|
if (mdl.rawModule.name.endsWith('.jar')) {
|
||||||
const modPath = path.join(modsDir, mdl.rawModule.name)
|
const modPath = path.join(modsDir, mdl.rawModule.name)
|
||||||
const modIdentity = mdl.rawModule.identity || mdl.rawModule.artifact.MD5
|
const modIdentity = mdl.rawModule || mdl.rawModule.artifact.MD5
|
||||||
if (athShield.debug) {
|
if (extraFileVerif.debug) {
|
||||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.distributionIdentityError', {
|
loggerLanding.info(Lang.queryJS('landing.dlAsync.extraFileVerif.distributionIdentityError', {
|
||||||
'moduleName': mdl.rawModule.name,
|
'moduleName': mdl.rawModule.name,
|
||||||
'moduleIdentity': modIdentity
|
'moduleIdentity': modIdentity
|
||||||
}))
|
}))
|
||||||
@ -543,17 +515,16 @@ async function dlAsync(login = true) {
|
|||||||
|
|
||||||
// Function to extract mod identity from the jar file
|
// Function to extract mod identity from the jar file
|
||||||
const extractModIdentity = (filePath) => {
|
const extractModIdentity = (filePath) => {
|
||||||
if (athShield.debug) {
|
if (extraFileVerif.debug) {
|
||||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.modIdentityExtraction', {'filePath': filePath}))
|
loggerLanding.info(Lang.queryJS('landing.dlAsync.extraFileVerif.modIdentityExtraction', {'filePath': filePath}))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fall back to a hash if no identity is found
|
|
||||||
const fileBuffer = fs.readFileSync(filePath)
|
const fileBuffer = fs.readFileSync(filePath)
|
||||||
const hashSum = crypto.createHash('md5') // Use MD5 to match the distribution configuration
|
const hashSum = crypto.createHash('md5') // Use MD5 to match the distribution configuration
|
||||||
hashSum.update(fileBuffer)
|
hashSum.update(fileBuffer)
|
||||||
const hash = hashSum.digest('hex')
|
const hash = hashSum.digest('hex')
|
||||||
if (athShield.debug) {
|
if (extraFileVerif.debug) {
|
||||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.identityNotFoundUsingHash', {
|
loggerLanding.info(Lang.queryJS('landing.dlAsync.extraFileVerif.identityNotFoundUsingHash', {
|
||||||
'filePath': filePath,
|
'filePath': filePath,
|
||||||
'hash': hash
|
'hash': hash
|
||||||
}))
|
}))
|
||||||
@ -564,7 +535,7 @@ async function dlAsync(login = true) {
|
|||||||
|
|
||||||
// Validate mods function
|
// Validate mods function
|
||||||
const validateMods = () => {
|
const validateMods = () => {
|
||||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.startingModValidation'))
|
loggerLanding.info(Lang.queryJS('landing.dlAsync.extraFileVerif.startingModValidation'))
|
||||||
const installedMods = fs.readdirSync(modsDir)
|
const installedMods = fs.readdirSync(modsDir)
|
||||||
let valid = true
|
let valid = true
|
||||||
|
|
||||||
@ -573,17 +544,17 @@ async function dlAsync(login = true) {
|
|||||||
|
|
||||||
// Skip validation for mods in the excluded list
|
// Skip validation for mods in the excluded list
|
||||||
if (EXCLUDED_MODS.includes(mod)) {
|
if (EXCLUDED_MODS.includes(mod)) {
|
||||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.modValidationBypassed', {'mod': mod}))
|
loggerLanding.info(Lang.queryJS('landing.dlAsync.extraFileVerif.modValidationBypassed', {'mod': mod}))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const expectedIdentity = distroMods[modPath]
|
const expectedIdentity = distroMods[modPath]
|
||||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.validatingMod', {'mod': mod}))
|
loggerLanding.info(Lang.queryJS('landing.dlAsync.extraFileVerif.validatingMod', {'mod': mod}))
|
||||||
|
|
||||||
if (expectedIdentity) {
|
if (expectedIdentity) {
|
||||||
const modIdentity = extractModIdentity(modPath)
|
const modIdentity = extractModIdentity(modPath)
|
||||||
if (athShield.debug) {
|
if (extraFileVerif.debug) {
|
||||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.expectedAndCalculatedIdentity', {
|
loggerLanding.info(Lang.queryJS('landing.dlAsync.extraFileVerif.expectedAndCalculatedIdentity', {
|
||||||
'expectedIdentity': expectedIdentity,
|
'expectedIdentity': expectedIdentity,
|
||||||
'mod': mod,
|
'mod': mod,
|
||||||
'modIdentity': modIdentity
|
'modIdentity': modIdentity
|
||||||
@ -591,8 +562,8 @@ async function dlAsync(login = true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (modIdentity !== expectedIdentity) {
|
if (modIdentity !== expectedIdentity) {
|
||||||
if (athShield.debug) {
|
if (extraFileVerif.debug) {
|
||||||
loggerLanding.error(Lang.queryJS('landing.dlAsync.AthShield.modIdentityMismatchError', {
|
loggerLanding.error(Lang.queryJS('landing.dlAsync.extraFileVerif.modIdentityMismatchError', {
|
||||||
'mod': mod,
|
'mod': mod,
|
||||||
'expectedIdentity': expectedIdentity,
|
'expectedIdentity': expectedIdentity,
|
||||||
'modIdentity': modIdentity
|
'modIdentity': modIdentity
|
||||||
@ -603,26 +574,26 @@ async function dlAsync(login = true) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
loggerLanding.warn(Lang.queryJS('landing.dlAsync.AthShield.expectedIdentityNotFound', {'mod': mod}))
|
loggerLanding.warn(Lang.queryJS('landing.dlAsync.extraFileVerif.expectedIdentityNotFound', {'mod': mod}))
|
||||||
valid = false
|
valid = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.modValidationCompleted'))
|
loggerLanding.info(Lang.queryJS('landing.dlAsync.extraFileVerif.modValidationCompleted'))
|
||||||
return valid
|
return valid
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform mod validation before proceeding
|
// Perform mod validation before proceeding
|
||||||
if (!validateMods()) {
|
if (!validateMods()) {
|
||||||
const errorMessage = Lang.queryJS('landing.dlAsync.AthShield.invalidModsDetectedMessage', {'folder': ConfigManager.getNameDataPath()})
|
const errorMessage = Lang.queryJS('landing.dlAsync.extraFileVerif.invalidModsDetectedMessage', {'folder': ConfigManager.getNameDataPath()})
|
||||||
loggerLanding.error(errorMessage)
|
loggerLanding.error(errorMessage)
|
||||||
showLaunchFailure(errorMessage, null)
|
showLaunchFailure(errorMessage, null)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.notUsingAthShield'))
|
loggerLanding.info(Lang.queryJS('landing.dlAsync.extraFileVerif.notUsingExtraFileVerif'))
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------- End of Mod Verification Logic ---------
|
// --------- End of Mod Verification Logic ---------
|
||||||
@ -681,7 +652,7 @@ async function dlAsync(login = true) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
loggerLaunchSuite.info(Lang.queryJS('landing.dlAsync.AthShield.downloadingFiles'))
|
loggerLaunchSuite.info(Lang.queryJS('landing.dlAsync.notUsingExtraFileVerif.downloadingFiles'))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove download bar.
|
// Remove download bar.
|
||||||
|
@ -3,7 +3,7 @@ const os = require('os')
|
|||||||
const semver = require('semver')
|
const semver = require('semver')
|
||||||
|
|
||||||
const DropinModUtil = require('./assets/js/dropinmodutil')
|
const DropinModUtil = require('./assets/js/dropinmodutil')
|
||||||
const athShield = require('./assets/athshield/parserAthShield')
|
const extraFileVerif = require('./assets/extraverif/parserExtraverif')
|
||||||
const { MSFT_OPCODE, MSFT_REPLY_TYPE, MSFT_ERROR } = require('./assets/js/ipcconstants')
|
const { MSFT_OPCODE, MSFT_REPLY_TYPE, MSFT_ERROR } = require('./assets/js/ipcconstants')
|
||||||
|
|
||||||
const settingsState = {
|
const settingsState = {
|
||||||
@ -722,10 +722,10 @@ function manageModCategory() {
|
|||||||
const modsButton = document.querySelector('button[rSc="settingsTabMods"]')
|
const modsButton = document.querySelector('button[rSc="settingsTabMods"]')
|
||||||
const dropInMods = document.getElementById('settingsDropinModsContainer')
|
const dropInMods = document.getElementById('settingsDropinModsContainer')
|
||||||
|
|
||||||
if (athShield.type === 'hidden') {
|
if (extraFileVerif.type === 'hidden') {
|
||||||
// Hide the Mods navigation button
|
// Hide the Mods navigation button
|
||||||
modsButton.style.display = 'none'
|
modsButton.style.display = 'none'
|
||||||
} else if (athShield.type === 'blocked') {
|
} else if (extraFileVerif.type === 'blocked') {
|
||||||
// Hide the drop-in mods elements
|
// Hide the drop-in mods elements
|
||||||
dropInMods.style.display = 'none'
|
dropInMods.style.display = 'none'
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user