mirror of
https://github.com/smogon/pokemon-showdown-loginserver.git
synced 2026-03-21 17:34:38 -05:00
Supporting binding server to specific hosts (#32)
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled
This commit is contained in:
parent
15666f8711
commit
a50d5dd488
|
|
@ -133,6 +133,13 @@ exports.crashguardemail = null;
|
|||
*/
|
||||
exports.ssl = null;
|
||||
|
||||
/**
|
||||
* Address to bind to.
|
||||
* Leaving it as `undefined` will result in binding to `0.0.0.0`.
|
||||
* @type {undefined | string}
|
||||
*/
|
||||
exports.bindaddress = undefined;
|
||||
|
||||
/**
|
||||
* Port to listen on.
|
||||
* @type {number}
|
||||
|
|
|
|||
|
|
@ -324,15 +324,17 @@ export const SimServers = new class SimServersT {
|
|||
export class Server {
|
||||
server: http.Server;
|
||||
httpsServer: https.Server | null;
|
||||
host: string;
|
||||
port: number;
|
||||
awaitingEnd?: () => void;
|
||||
closing?: Promise<void>;
|
||||
activeRequests = 0;
|
||||
constructor(port = (Config.port || 8000)) {
|
||||
constructor(port = (Config.port || 8000), host = (Config.bindaddress || "0.0.0.0")) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
|
||||
this.server = http.createServer((req, res) => void this.handle(req, res));
|
||||
this.server.listen(port);
|
||||
this.server.listen(port, host);
|
||||
this.httpsServer = null;
|
||||
if (Config.ssl) {
|
||||
this.httpsServer = https.createServer(Config.ssl, (req, res) => void this.handle(req, res));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user