mirror of
https://github.com/smogon/pokemon-showdown-loginserver.git
synced 2026-04-25 16:19:58 -05:00
Accept arguments in src/load-servers.php for path to load from
This commit is contained in:
parent
8a51a9fff3
commit
5dd3695003
|
|
@ -29,6 +29,9 @@ export function load(invalidate = false): Configuration {
|
|||
if (!config.mainserver) {
|
||||
config.mainserver = 'showdown';
|
||||
}
|
||||
if (!config.serverlist) {
|
||||
config.serverlist = '/var/www/html/play.pokemonshowdown.com/config/servers.inc.php';
|
||||
}
|
||||
const needsSet = ['autolockip', 'sysops', 'trustedproxies', 'compromisedkeys'] as const;
|
||||
for (const key of needsSet) {
|
||||
if (!config[key]) config[key] = [];
|
||||
|
|
|
|||
|
|
@ -164,7 +164,9 @@ export class Dispatcher {
|
|||
}
|
||||
static servers: {[k: string]: RegisteredServer} = (() => {
|
||||
try {
|
||||
const stdout = child.execSync(`php -f src/lib/load-servers.php`).toString();
|
||||
const stdout = child.execSync(
|
||||
`php -f src/lib/load-servers.php ${Config.serverlist}`
|
||||
).toString();
|
||||
return JSON.parse(stdout);
|
||||
} catch (e: any) {
|
||||
if (e.code !== 'ENOENT') throw e;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
// needs to be changed to the absolute path of your servers.php file
|
||||
include_once '/var/www/html/play.pokemonshowdown.com/config/servers.inc.php';
|
||||
include_once $argv[1];
|
||||
|
||||
$json = json_encode($PokemonServers, JSON_FORCE_OBJECT);
|
||||
if ($json === false) print("{}");
|
||||
|
|
|
|||
|
|
@ -416,9 +416,9 @@ export class Session {
|
|||
return;
|
||||
}
|
||||
const query = SQL`SELECT sid, timeout, \`ntbb_users\`.* `;
|
||||
query.append('FROM `ntbb_sessions\`, `ntbb_users` ');
|
||||
query.append('FROM `ntbb_sessions`, `ntbb_users` ');
|
||||
query.append(SQL`WHERE \`session\` = ${session} `);
|
||||
query.append('AND `ntbb_sessions`.`userid\` = `ntbb_users`.`userid` ');
|
||||
query.append('AND `ntbb_sessions`.`userid` = `ntbb_users`.`userid` ');
|
||||
query.append(' LIMIT 1');
|
||||
const res = await users.database.get<{sid: string; timeout: number}>(query);
|
||||
if (!res || !(await this.validateSid(sid, res.sid))) {
|
||||
|
|
@ -439,10 +439,11 @@ export class Session {
|
|||
this.sidhash = sid;
|
||||
this.session = session;
|
||||
}
|
||||
async validateSid(cachedSid: string, databaseSid: string): Promise<boolean> {
|
||||
validateSid(cachedSid: string, databaseSid: string): Promise<boolean> {
|
||||
if (Config.validateSid) {
|
||||
return Config.validateSid.call(this, cachedSid, databaseSid);
|
||||
// covers async functions
|
||||
return Promise.resolve(Config.validateSid.call(this, cachedSid, databaseSid));
|
||||
}
|
||||
return cachedSid === databaseSid;
|
||||
return Promise.resolve(cachedSid === databaseSid);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user