mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 03:32:12 -08:00
Use AthShield for mod verification
Implemented mod verification using AthShield when enabled. Added detailed mod identity extraction and validation logic for better integrity checks. Added logs for each verification step and fallback to hash-based identity if the manifest is missing. Grande ligne : quand tu actives ath shield alors il utilise le système Athena's Shield.
This commit is contained in:
parent
5f3e229360
commit
886b29e356
@ -66,6 +66,10 @@ async function dlAsync(login = true) {
|
||||
}
|
||||
|
||||
// --------- Mod Verification Logic ---------
|
||||
|
||||
if (athShield.status) {
|
||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.usingAthShield'))
|
||||
|
||||
const modsDir = path.join(ConfigManager.getDataDirectory(), 'instances', serv.rawServer.id, 'mods')
|
||||
|
||||
// Check if mods directory exists, if not, create it
|
||||
@ -81,7 +85,10 @@ async function dlAsync(login = true) {
|
||||
if (mdl.rawModule.name.endsWith('.jar')) {
|
||||
const modPath = path.join(modsDir, mdl.rawModule.name)
|
||||
const modIdentity = mdl.rawModule.identity || mdl.rawModule.MD5
|
||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.distributionIdentityError', {'moduleName': mdl.rawModule.name, 'moduleIdentity': modIdentity}))
|
||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.distributionIdentityError', {
|
||||
'moduleName': mdl.rawModule.name,
|
||||
'moduleIdentity': modIdentity
|
||||
}))
|
||||
distroMods[modPath] = modIdentity
|
||||
}
|
||||
})
|
||||
@ -97,7 +104,10 @@ async function dlAsync(login = true) {
|
||||
const lines = manifestContent.split('\n')
|
||||
const identityLine = lines.find(line => line.startsWith('Mod-Id:') || line.startsWith('Implementation-Title:'))
|
||||
if (identityLine) {
|
||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.manifestIdentityFound', {'filePath': filePath, 'identityLine': identityLine}))
|
||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.manifestIdentityFound', {
|
||||
'filePath': filePath,
|
||||
'identityLine': identityLine
|
||||
}))
|
||||
return identityLine.split(':')[1].trim()
|
||||
}
|
||||
}
|
||||
@ -107,7 +117,10 @@ async function dlAsync(login = true) {
|
||||
const hashSum = crypto.createHash('md5') // Use MD5 to match the distribution configuration
|
||||
hashSum.update(fileBuffer)
|
||||
const hash = hashSum.digest('hex')
|
||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.identityNotFoundInManifest', {'filePath': filePath, 'hash': hash}))
|
||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.identityNotFoundInManifest', {
|
||||
'filePath': filePath,
|
||||
'hash': hash
|
||||
}))
|
||||
return hash
|
||||
}
|
||||
|
||||
@ -131,10 +144,18 @@ async function dlAsync(login = true) {
|
||||
|
||||
if (expectedIdentity) {
|
||||
const modIdentity = extractModIdentity(modPath)
|
||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.expectedAndCalculatedIdentity', {'expectedIdentity': expectedIdentity, 'mod': mod, 'modIdentity': modIdentity}))
|
||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.expectedAndCalculatedIdentity', {
|
||||
'expectedIdentity': expectedIdentity,
|
||||
'mod': mod,
|
||||
'modIdentity': modIdentity
|
||||
}))
|
||||
|
||||
if (modIdentity !== expectedIdentity) {
|
||||
loggerLanding.error(Lang.queryJS('landing.dlAsync.AthShield.modIdentityMismatchError', {'mod': mod, 'expectedIdentity': expectedIdentity, 'modIdentity': modIdentity}))
|
||||
loggerLanding.error(Lang.queryJS('landing.dlAsync.AthShield.modIdentityMismatchError', {
|
||||
'mod': mod,
|
||||
'expectedIdentity': expectedIdentity,
|
||||
'modIdentity': modIdentity
|
||||
}))
|
||||
valid = false
|
||||
break
|
||||
}
|
||||
@ -156,6 +177,11 @@ async function dlAsync(login = true) {
|
||||
showLaunchFailure(errorMessage, null)
|
||||
return
|
||||
}
|
||||
|
||||
} else {
|
||||
loggerLanding.info(Lang.queryJS('landing.dlAsync.AthShield.notUsingAthShield'))
|
||||
}
|
||||
|
||||
// --------- End of Mod Verification Logic ---------
|
||||
|
||||
setLaunchDetails(Lang.queryJS('landing.dlAsync.pleaseWait'))
|
||||
|
Loading…
Reference in New Issue
Block a user