Sync
This commit is contained in:
parent
5f9ae240bc
commit
468748fa60
1
.gitignore
vendored
1
.gitignore
vendored
@ -130,3 +130,4 @@ dist
|
|||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
|
data/gameFiles/*
|
||||||
@ -23,6 +23,12 @@ function initDB() {
|
|||||||
delivered_at TEXT DEFAULT CURRENT_TIMESTAMP
|
delivered_at TEXT DEFAULT CURRENT_TIMESTAMP
|
||||||
)
|
)
|
||||||
`)
|
`)
|
||||||
|
db.exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS launchers (
|
||||||
|
hardware_id TEXT NOT NULL,
|
||||||
|
last_minecraft_uuid TEXT NOT NULL
|
||||||
|
)
|
||||||
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function banLauncher(last_minecraft_uuid, hardware_id, banned_by, remote_ip, reason) {
|
function banLauncher(last_minecraft_uuid, hardware_id, banned_by, remote_ip, reason) {
|
||||||
@ -124,6 +130,22 @@ function regenerateToken(oldKey, newKey) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setLastUUIDForLauncher(hardware_id, last_minecraft_uuid) {
|
||||||
|
const query = `
|
||||||
|
INSERT INTO launchers (hardware_id, last_minecraft_uuid)
|
||||||
|
VALUES (?, ?)
|
||||||
|
`
|
||||||
|
try {
|
||||||
|
const stmt = db.prepare(query)
|
||||||
|
const result = stmt.run(hardware_id, last_minecraft_uuid)
|
||||||
|
return true
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("[DATABASE] <Telemetry:Error>")
|
||||||
|
logger.error(error)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
initDB,
|
initDB,
|
||||||
getBan,
|
getBan,
|
||||||
@ -132,5 +154,6 @@ module.exports = {
|
|||||||
isTokenValid,
|
isTokenValid,
|
||||||
createToken,
|
createToken,
|
||||||
revokeToken,
|
revokeToken,
|
||||||
regenerateToken
|
regenerateToken,
|
||||||
|
setLastUUIDForLauncher
|
||||||
}
|
}
|
||||||
BIN
data/main.db
BIN
data/main.db
Binary file not shown.
@ -12,7 +12,6 @@ router.post("/iam", (req, res) => {
|
|||||||
logger.log(`{Route:"/api/v1/ban/iam"} Strange request from ip<${ip}>`)
|
logger.log(`{Route:"/api/v1/ban/iam"} Strange request from ip<${ip}>`)
|
||||||
} else {
|
} else {
|
||||||
const potentialBan = controller.getBan(req.body.hwid)
|
const potentialBan = controller.getBan(req.body.hwid)
|
||||||
console.log(potentialBan)
|
|
||||||
if (potentialBan != undefined) {
|
if (potentialBan != undefined) {
|
||||||
delete potentialBan.remote_ip
|
delete potentialBan.remote_ip
|
||||||
delete potentialBan.hardware_id
|
delete potentialBan.hardware_id
|
||||||
|
|||||||
21
routes/api/v1/file/game.js
Normal file
21
routes/api/v1/file/game.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
const fs = require("node:fs")
|
||||||
|
const path = require("node:path")
|
||||||
|
const utils = require("../../../../modules/utils")
|
||||||
|
const express = require("express")
|
||||||
|
const router = express()
|
||||||
|
|
||||||
|
router.use("", (req, res) => {
|
||||||
|
const gameFiles = path.join(__dirname, "..", "..", "..", "..", "data", "gameFiles")
|
||||||
|
if (fs.existsSync(finalPath)) {
|
||||||
|
try {
|
||||||
|
res.status(200).json(fs.readdirSync(gameFiles, { recursive: true }))
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
utils.handleError(req, res, 500, "Erreur interne du serveur.")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
utils.handleError(req, res, 404, "Fichier introuvable.")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = router
|
||||||
12
routes/api/v1/telemetry.js
Normal file
12
routes/api/v1/telemetry.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
const utils = require("../../../modules/utils")
|
||||||
|
const logger = require("../../../modules/logger")
|
||||||
|
const controller = require("../../../controllers/db")
|
||||||
|
const express = require("express")
|
||||||
|
const router = express()
|
||||||
|
|
||||||
|
router.get("/:hwid/:uuid", (req, res) => {
|
||||||
|
const { hwid, uuid } = req.params
|
||||||
|
controller.setLastUUIDForLauncher(hwid, uuid)
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = router
|
||||||
Loading…
x
Reference in New Issue
Block a user