Compare commits

...
1 Commits
Author SHA1 Message Date
Lncvrt a433f57a58 Add authorization header to versions (not in use yet) 2026-10-02 10:47:59 -07:00
3 changed files with 22 additions and 16 deletions

No files matched your search

+5 -4
View File
@@ -179,11 +179,11 @@ setInterval(async () => {
app.ws('/ws', { app.ws('/ws', {
maxPayloadLength: 10 * 1024 * 1024, maxPayloadLength: 10 * 1024 * 1024,
open (ws) { open(ws) {
clients.add(ws) clients.add(ws)
// console.log(ws.id, 'connected') // console.log(ws.id, 'connected')
}, },
async message (ws, message: any) { async message(ws, message: any) {
console.log('received:', message, 'from', ws.id) console.log('received:', message, 'from', ws.id)
if (message == 'ping') ws.send('ping') if (message == 'ping') ws.send('ping')
if (message.type) { if (message.type) {
@@ -903,7 +903,7 @@ app.ws('/ws', {
} }
} }
}, },
async close (ws) { async close(ws) {
clients.forEach(client => { clients.forEach(client => {
if (client.id === ws.id) clients.delete(client) if (client.id === ws.id) clients.delete(client)
}) })
@@ -986,7 +986,8 @@ app.get('/launcher/versions', context => launcherVersionsHandler(context), {
hide: true hide: true
}) })
), ),
clientplatform: t.Optional(t.String()) clientplatform: t.Optional(t.String()),
authorization: t.Optional(t.String())
}) })
}) })
app.get('/launcher/latest', launcherLatestHandler, { app.get('/launcher/latest', launcherLatestHandler, {
+12 -12
View File
@@ -41,19 +41,19 @@ export const getDatabaseConnection = (type: number) => {
const env = const env =
type === 0 type === 0
? { ? {
host: process.env.DB_HOST ?? 'localhost', host: process.env.DB_HOST ?? 'localhost',
port: Number(process.env.DB_PORT) || 3306, port: Number(process.env.DB_PORT) || 3306,
user: process.env.GAMES_DB_USER ?? '', user: process.env.GAMES_DB_USER ?? '',
pass: process.env.GAMES_DB_PASS ?? '', pass: process.env.GAMES_DB_PASS ?? '',
name: process.env.GAMES_DB_NAME ?? '' name: process.env.GAMES_DB_NAME ?? ''
} }
: { : {
host: process.env.DB_HOST ?? 'localhost', host: process.env.DB_HOST ?? 'localhost',
port: Number(process.env.DB_PORT) || 3306, port: Number(process.env.DB_PORT) || 3306,
user: process.env.BERRYDASH_DB_USER ?? '', user: process.env.BERRYDASH_DB_USER ?? '',
pass: process.env.BERRYDASH_DB_PASS ?? '', pass: process.env.BERRYDASH_DB_PASS ?? '',
name: process.env.BERRYDASH_DB_NAME ?? '' name: process.env.BERRYDASH_DB_NAME ?? ''
} }
const connection = mysql.createConnection({ const connection = mysql.createConnection({
host: env.host, host: env.host,
+5
View File
@@ -9,6 +9,11 @@ export const handler = async (context: Context) => {
return jsonResponse({ error: 'Failed to connect to database' }, 500) return jsonResponse({ error: 'Failed to connect to database' }, 500)
const { connection, db } = dbResult const { connection, db } = dbResult
const authorization =
context.headers.authorization?.trim() == '' ||
context.headers.authorization == null
? null
: context.headers.authorization
const clientplatform = context.headers.clientplatform const clientplatform = context.headers.clientplatform
const platform = clientplatform?.split('-')[0] const platform = clientplatform?.split('-')[0]
const arch = clientplatform?.split('-')[1] const arch = clientplatform?.split('-')[1]