mirror of
https://github.com/Sithranduil/srcds_exporter.git
synced 2025-07-23 08:28:00 +02:00
feat: add support for source 2
This commit is contained in:
9
index.js
9
index.js
@@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { connect } from 'working-rcon';
|
||||
import module from './modules/index.js';
|
||||
import SourceRcon from '@hellz.fr/sourcecon';
|
||||
|
||||
const app = express();
|
||||
|
||||
@@ -30,16 +30,17 @@ app.get('/metrics', async (req, res) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!['csgo', 'cstrike', 'gmod'].includes(config.game)) {
|
||||
if (!['csgo', 'cstrike', 'gmod', 'cs2'].includes(config.game)) {
|
||||
res.send('Incorrect game value, currently supported games are : csgo, gmod, cstrike');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const client = await connect(config.ip, config.port, config.rconPassword, 5000);
|
||||
const client = new SourceRcon.default(config.ip, Number.parseInt(config.port));
|
||||
await client.connect();
|
||||
await client.auth(config.rconPassword);
|
||||
const response = await module.request(config, client);
|
||||
await module.send(config, response, res);
|
||||
await client.disconnect();
|
||||
} catch (e) {
|
||||
if (e.code === 'EHOSTUNREACH') {
|
||||
console.error(`Unreachable host : ${e.address}:${e.port}`);
|
||||
|
Reference in New Issue
Block a user