feat(accounts): implement local login
Route login and character requests by their original host names on one loopback port. Add local accounts, saves, and credential redaction.
This commit is contained in:
1 parent
c3914ec0d6
commit
7f482ae530
55 files changed
+1559
-58
No files matched your search
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Development entry point of the local service.
|
||||
*
|
||||
* node packages/local-service/src/cli.ts --game <game folder> --data <data folder> --port <n>
|
||||
*
|
||||
* The port must match the one the game copy was built with (packages/build). The launcher
|
||||
* will start the service the same way. Stops on Ctrl+C.
|
||||
*/
|
||||
import { parseArgs } from 'node:util';
|
||||
import { LOOPBACK, startLocalService } from './local-service.ts';
|
||||
|
||||
async function main(): Promise<number> {
|
||||
const { values } = parseArgs({
|
||||
options: {
|
||||
game: { type: 'string' },
|
||||
data: { type: 'string' },
|
||||
port: { type: 'string' },
|
||||
},
|
||||
});
|
||||
const port = Number(values.port);
|
||||
if (!values.game || !values.data || !Number.isInteger(port) || port < 1 || port > 65535) {
|
||||
console.error('usage: cli.ts --game <game folder> --data <data folder> --port <n>');
|
||||
return 2;
|
||||
}
|
||||
let service;
|
||||
try {
|
||||
service = await startLocalService({ gameFolder: values.game, dataFolder: values.data, port });
|
||||
} catch (error) {
|
||||
const code = (error as NodeJS.ErrnoException).code;
|
||||
console.error(code === 'EADDRINUSE' ? `port ${port} is already in use; choose another port` : String(error));
|
||||
return 1;
|
||||
}
|
||||
console.log(`local service listening on ${LOOPBACK}:${port}`);
|
||||
console.log(`traffic log: ${service.logFolder}`);
|
||||
const running = service;
|
||||
await new Promise<void>((resolve) => process.once('SIGINT', resolve));
|
||||
await running.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
process.exitCode = await main();
|
||||
Reference in new issue
Block a user