Skip to content

Commit ca42316

Browse files
committed
update Readme and some more error handling
1 parent fdd7110 commit ca42316

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

README.MD

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
# CS2 Server Control with a Nodejs-powered web-API (LINUX only)
22
this API is used to start/stop/update a CS2 linux dedicated server and control it via rcon.
3-
The backend accepts RESTful api calls authenticated either via steamID or a configurable user with hppt authentication for stateless API calls.
3+
The backend accepts RESTful api calls authenticated either via steamID or a configurable user with http authentication for stateless API calls.
44
A full featured example webinterface is provided to get a quick start on the application.
55

66
## Disclaimer
77
The use of this software is at your own risk.
88
It exposes control of your server and shell functions to the internet. Although I did everything to secure the API, any bugs may lead to security breaches on your server.
99
I strongly adivise to use secure connections to prevent possible man-in-the-middle attacks.
1010

11-
## CS2 Beta Info
12-
### New in Beta.3:
13-
- Reworked the code, to make the initial configuration much easier.
14-
- Example Webinterface is now served via the app, so you don't need to configure a seperate webserver.
15-
- Made using websockets for data-transfer to Webinterface the standard.
16-
17-
### This is a beta release for CS2. It has the following changes to previous functionality
11+
### This is the first release for CS2. It has the following changes to previous functionality
12+
- The Steam-Api calls for the map details now need an API-Token. See configuration section below for details.
1813
- Changed Log-reception to http logs, since UDP is not supported anymore in new server. Unnecessary library source-log-receiver removed.
19-
- Maplist loading is still bugged in CS2 Server - therefore working with a static Maplist.
20-
- Still working with the old CS_GO map-pictures, since the new ones are not yet available in the workshop
21-
- API calls are unchanged.
14+
- Maplist loading has changed to the worse, see [Maps TL;DR](https://github.com/Taraman17/nodejs-cs2-api/blob/master/MAPS.MD) for details how the API deals with it.
15+
- Changed API calls (non braking).
16+
- mapchange can now be done with map-filename (without extension), workshop-id or map-title as argument.
2217
- added API endpoints for pausing and resuming the match (/control/pause & /control/unpause). Status is tracked in serverInfo.pause (false/true).
2318

2419
## Prerequisites
@@ -71,9 +66,9 @@ Start the script with
7166
```console
7267
node serverControl.js
7368
```
74-
In your brower open http://\<yourIP>:8090/gameserver.htm
69+
In your browser open http://\<yourIP>:8090/gameserver.htm to see the example webinterface
7570

76-
The API will detect a running server and connect to it.
71+
If the server is already running in a screen, the API will detect a running server and connect to it.
7772

7873
To start the API on boot and have it running in the background, I recommend [PM2](https://pm2.keymetrics.io/)
7974

@@ -118,7 +113,7 @@ The /control message will return a JSON-String.
118113
If run without startmap, server will be started with de_dust2.
119114
- stop -> stop the server with RCON 'quit': { "success": true/false }
120115
- kill -> use 'kill' command to shutdown the server, if RCON connection is not working: { "success": true/false }
121-
- changemap -> additional argument "map" (action=changemap&map=mapname):
116+
- changemap -> additional argument "map" (action=changemap&map=mapfilename/workshopid/title):
122117
- reloadmaplist -> reload the available maps on the server (action=reloadmaplist): { "success": true/false }
123118

124119
If you do not use websockets, the answer will be sent after completion of the operation.
@@ -188,7 +183,7 @@ UpdateProgress looks as follows:
188183
{ "type": "updateProgress", "payload": { "step": <string>, "progress": <int> } }
189184
```
190185
## Api calls with http authentication
191-
For stateless API-Calls via command line or other automatic tools the http basic authentication can be activated in the config with
186+
For stateless API-Calls via command line or other automatic tools the http basic authentication can be activated in the config with:
192187
```
193188
"httpAuth": true,
194189
"httpUser": { "username": "", "password": "" },
@@ -202,12 +197,7 @@ The interface is:
202197
http://<your-servers-address>:<your-port>/csgoapi/http/v1.0/...
203198
```
204199
205-
## Example
206-
An example of a webinterface is available in the folder "example"
207-
It assumes, that you run it on the same domain as the API. If you want to change that, you can do so in js/gameserver.js (see comment in the file)
208-
To correctly load the maplist for server start, edit the respective line at the beginning of gameserver.js.
209-
The Webinterface works with and without websockets.
210-
211200
## Support
212201
If you have any questions, contact me.
202+
213203
If you find any bugs or have feature requests, don't hesitate to open an issue.

modules/apiV10.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* @requires child_process
33
* @requires node-pty
44
* @requires express
5+
* @requires express.Router
6+
* @requires ./logger.js
57
* @requires ./config.js
68
* @requires ./serverInfo.js
79
* @requires ./controlEmitter.js

modules/sharedFunctions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ async function reloadMaplist() {
117117
res.on('end', () => {
118118
if (res.statusCode != 200) {
119119
logger.warn(`getMapDetails api call failed. Status = ${res.statusCode}`);
120-
reject([]);
120+
reject('Api call was unsuccessful');
121121
} else {
122122
try {
123123
let resJson = JSON.parse(resData);
@@ -140,7 +140,7 @@ async function reloadMaplist() {
140140
resolve(returnDetails);
141141
} catch (e) {
142142
logger.warn(`Reading map details failed: ${e}`);
143-
reject([]);
143+
reject('Could not read map details from api response');
144144
}
145145
}
146146
});

0 commit comments

Comments
 (0)