Giter Site home page Giter Site logo

jaskowicz1 / rconpp Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 0.0 45 KB

A modern Source RCON library for C++

License: Apache License 2.0

CMake 15.82% C++ 82.69% C 1.49%
cpp rcon rcon-protocol source-rcon source-rcon-protocol steam valve rconpp rconplusplus

rconpp's Introduction

rcon++

Rcon++ is a modern Source RCON library for C++, allowing people to easily use RCON however they like!

Library Features

  • Support for Valve and non-Valve games.
  • Callbacks, allowing non-blocking calls.
  • Support for hosting an RCON server.

To-do

  • Support for multiple response packets.

Library Usage

This library is used in:

If you're using this library, feel free to message me and show me, you might just get your project shown here!

Supported Systems

Linux and Unix

This library was originally made and tested on Linux & UNIX (more specifically OSX) and will work perfectly on these!

Windows

Windows is fully supported and tested! We natively support MSVC and clang-cl, but not MinGW. We do not test support for MinGW, nor do we want to actively try and support it. You can try MinGW at your own risk.

Getting Started

rcon++ can be installed from the releases section!

We're aiming to start rolling out to package managers soon!

Quick Example

Client

#include <iostream>
#include <rconpp/rcon.h>

int main() {
        rconpp::rcon_client client("127.0.0.1", 27015, "changeme");
	
        client.on_log = [](const std::string_view& log) {
                std::cout << log << "\n";
        };

        client.start(true);
	
        client.send_data("Hello!", 3, rconpp::data_type::SERVERDATA_EXECCOMMAND, [](const rconpp::response& response) {
                std::cout << "response: " << response.data << "\n";
        });
        
        return 0;
}

Server

#include <iostream>
#include <rconpp/rcon.h>

int main() {
        rconpp::rcon_server server("0.0.0.0", 27015, "testing");

        server.on_log = [](const std::string_view log) {
            std::cout << log << "\n";
        };

        server.on_command = [](const rconpp::client_command& command) {
                if (command.command == "/test") {
                        return "This is a test!";
                } else {
                        return "Hello!";
                }
        };

        server.start(false);
        
        return 0;
}

Contributing

If you want to help out, simply make a fork and submit your PR! Once the PR has been reviewed and accepted, we will eventually merge it into the project!

Please note that PRs may take a few days to fully review/accept, so be patient!

Support us

If you like this project, be sure to give us a ⭐️! It really helps us out!

rconpp's People

Contributors

jaskowicz1 avatar kirkezz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

rconpp's Issues

`queue_runner` uses `this` after destruction

I am using your library as follows:

int getPlayersCount() {
    static int id = 2;
    int result = -1;

    rconpp::rcon_client client(rcon_credentials.ip, rcon_credentials.port, rcon_credentials.password);
    if (client.connected) {
        auto response = client.send_data_sync("list", ++id, rconpp::data_type::SERVERDATA_EXECCOMMAND);
        /* ... */
        std::cout << response.data << std::endl;
    }

    return result;
}

The program crashes with segfault:
crash
I think the problem is that queue_runner uses this after the rcon_client object is destroyed.
With the following changes, segfault no longer occurs:
changes

Responses are empty after 2nd command send

Windows app.
After using send_command_sync with a simple command "listplayers" in ARK, the response comes empty, crashing the app.

The code crashes at client.cpp, line 158 (packet_response.data is empty)

rconpp::response rconpp::rcon_client::receive_information(int32_t id, rconpp::data_type type) {
	// Whilst this loop is better than a while loop,
	// it should really just keep going for a certain amount of seconds.
	for (int i = 0; i < 500; i++) {
		packet packet_response = read_packet();

		int packet_type = bit32_to_int(packet_response.data);

I'm using the general_improvements branch.

Not handling multiple packets?

So im trying to use this to send RCON commands to a Minecraft Server. The connection is successful and the command is executed but the response seems... off. It should be something like "Made Player a server operator" but instead its just jibberish like ")/␦"

I thought maybe the server is sending back multiple packets containing the data but this library only handles one and then immediatly calls the callback.

Some more documentation on this would be nice!

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.