Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabricio-191/valve-server-query
An implementation of valve protocols (server, master servers and RCON)
https://github.com/fabricio-191/valve-server-query
game-server-query master-server-query ping protocol query steam valve
Last synced: about 1 month ago
JSON representation
An implementation of valve protocols (server, master servers and RCON)
- Host: GitHub
- URL: https://github.com/fabricio-191/valve-server-query
- Owner: Fabricio-191
- License: apache-2.0
- Created: 2020-09-14T02:28:06.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-01-10T03:14:20.000Z (12 months ago)
- Last Synced: 2024-10-31T18:23:28.316Z (about 2 months ago)
- Topics: game-server-query, master-server-query, ping, protocol, query, steam, valve
- Language: TypeScript
- Homepage:
- Size: 3.1 MB
- Stars: 37
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This module allows you to:
* Easily make queries to servers running valve games
* Make queries to valve master servers
* Use a remote console to control your server remotely## Links
* [Full Docs](https://fabricio-191.github.io/docs/valve-server-query/)
* [GitHub](https://github.com/Fabricio-191/valve-server-query)
* [Discord](https://discord.gg/zrESMn6)## An implementation of valve protocols
```js
const { Server, RCON, MasterServer } = require('@fabricio-191/valve-server-query');
```**Some** of the games where it works with are:
* Counter-Strike
* Counter-Strike: Global Offensive
* Garry's Mod
* Half-Life
* Team Fortress 2
* Day of Defeat
* The ship## Examples
#### Server
```js
const server = new Server({
ip: '0.0.0.0',
port: 27015,
timeout: 3000,
});const info = await server.getInfo();
console.log(info);const players = await server.getPlayers();
console.log(players);const rules = await server.getRules();
console.log(rules);console.log(server.lastPing);
```#### Master Server
```js
const servers = await MasterServer({
quantity: 1000,
region: 'US_EAST',
timeout: 3000,
});//servers is an array if 'ip:port' strings, see the docs
console.log(servers);
```#### RCON
```js
const rcon = await RCON({
ip: '0.0.0.0',
port: 27015, //RCON port
password: 'your RCON password'
});rcon.on('disconnect', async (reason) => {
console.log('disconnected', reason);
try{
await rcon.reconnect();
}catch(e){
console.log('reconnect failed', e.message);
}
});rcon.on('passwordChanged', async () => {
const password = await getNewPasswordSomehow();
try{
await rcon.authenticate(password);
}catch(e){
console.error('Failed to authenticate with new password', e.message);
}
});const response = await rcon.exec('sv_gravity 1000');
```#### [Full docs](https://fabricio-191.github.io/docs/valve-server-query/)