Giter VIP home page Giter VIP logo

node-misrcon's Introduction

node-misrcon npm node-misrcon

package that contains functions to send rcon commands to miscreated game servers

Features

  • send RCON commands to miscreated game servers via nodejs
  • Parse responses from servers into js objects
  • Makes you pizza in the morning (Feature is WIP)
  • Won't kick your dog.

Getting Started

  • npm i -S node-misrcon
  • import the module
  • Instantiate the api object
  • Call the methods you want
    • getBanList
    • getStatus
    • getWhitelist
    • getPQM
    • getStats
    • send

Examples

import * as misrcon from '../src/node-misrcon';

// Create ApiObject
const server = new misrcon.NodeMisrcon({ip: '', port: '', password: ''});

// Run Commands
const banlist = await server.getBanList();
const status = await server.getStatus();
const whitelist = await server.getWhitelist();
const pqm = await server.getPQM();
const stats = await server.getStats();
const commandResponse = await server.send('status');

Changes from v1 -> 2

  • port in ICredentials now takes a number instead of a string
  • Many values now return numbers instead of strings if it makes sense

Changes from v0 > 1.0

  • New NodeMisrcon api object added to make requests a lot easier and only require a single authentication object and make parsing and sending requests easier

Contributing

Feel free to help in any way you'd like! PR's are always welcome!

node-misrcon's People

Contributors

csprance avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar

node-misrcon's Issues

Name and steamId parsing error

Hey there

I've just faced an issue in MisRCON. I traced the root cause to this library when parsing the status rcon response from the server.

image

We can see that my Steam id and name are between quotes. When I click on the Steam id it opens a steamrep url: https://steamrep.com/profiles/'76561197979700358'. As you can see the quotes remains in the url and as such it's not valid.

I believe it comes from the regexp parsing in src/parsers/parseStatus.ts#L106
The status response looks like

<?xml version="1.0"?>
<methodResponse>
    <params>
        <param>
            <value>
                <string>-----------------------------------------
                    Server Status:
                    name: Miscreated TDM Tournament
                    ip: DESKTOP-LMD8U3C
                    version: 1.0.0.1008
                    level: Multiplayer/islands
                    gamerules: Miscreated
                    time: 07:11
                    players: 24/50
                    round time remaining: 0:00
                    uptime: 01:13:06
                    next restart in: 23:39:33
                    weather: ClearSky
                    weatherpattern: 1
                    -----------------------------------------
                    Connection Status:
                    steam: '76561197979700358'  name: 'Outpox'  entID:'201703' id: '4'  ip: ''  ping: '55'  state: '3'  profile: '0'
                </string>
            </value>
        </param>
    </params>
</methodResponse

The regexp currently used for the steamid and name are valid, however they return the quotes as well.

const steamIdRE = new RegExp('steam: (.*)  name:');
const nameRE = new RegExp('name: (.*)  entID:');

So in my case steamidRE = "'76561197979700358'" and nameRE = "'Outpox'". Then these values are trimmed but trim() doesn't remove quotes :D

I'm not an expert with regexp but I think it would be possible to surround the capturing group with the quotes to exclude them from the returned value.

const steamIdRE = new RegExp("steam: '(.*)'  name:");
const nameRE = new RegExp("name: '(.*)' entID:");

But this might cause issue with names containing a quote '.

Let me know what you think.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.