1
0
mirror of https://github.com/shiroikitsu8/Bayshore_6r_legacy.git synced 2025-01-19 16:58:41 +01:00

Add setuid/setgid

This commit is contained in:
Rin 2022-07-17 15:14:23 +01:00
parent 97d0fe7a4b
commit b9c756f442
2 changed files with 15 additions and 0 deletions

View File

@ -6,6 +6,12 @@ export interface ConfigFile {
regionName: string;
serverIp?: string;
gameOptions: GameOptions;
unix?: UnixOptions;
}
export interface UnixOptions {
setuid: number;
setgid: number;
}
export interface GameOptions {

View File

@ -9,6 +9,8 @@ import fs from 'fs';
import bodyParser from 'body-parser';
import AllnetModule from './allnet';
import MuchaModule from './mucha';
import { Config } from './config';
import process from 'process';
globalAgent.options.keepAlive = true;
// @ts-ignore
@ -70,6 +72,13 @@ let cert = fs.readFileSync('./server_wangan.crt');
http.createServer(allnetApp).listen(PORT_ALLNET, '0.0.0.0', 511, () => {
console.log(`ALL.net server listening on port ${PORT_ALLNET}!`);
let unix = Config.getConfig().unix;
if (unix && process.platform == 'linux') {
console.log('Downgrading permissions...');
process.setuid!(unix.setuid);
process.setgid!(unix.setgid);
console.log('Done!');
}
})
https.createServer({key, cert}, muchaApp).listen(PORT_MUCHA, '0.0.0.0', 511, () => {