Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to allow adding/changing/removing rcon password #290

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

GooberRF
Copy link
Contributor

This PR adds the server_rcon_password command, which can be used to add an rcon password to a server without one, change the existing rcon password to something else, or remove the rcon password entirely.

Syntax is server_rcon_password <password>

@is-this-c
Copy link
Contributor

Like sv_pass I think sv_rcon_pass is way better. It is just simpler.

game_patch/rf/multi.h Outdated Show resolved Hide resolved

if (new_rcon_password) {
if (new_rcon_password->size() > 16) {
// game limits client requests to 16 characters
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is a bit wrong, the password is limited, not a "request" whatever that is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the term "request" because the command is rcon_request

But I can change the comment.

}

std::strncpy(rf::rcon_password, new_rcon_password->c_str(), sizeof(rf::rcon_password) - 1);
rf::rcon_password[sizeof(rf::rcon_password) - 1] = '\0'; // null terminator
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the point of using strncpy and setting the null character manually if you validated the length. Simple std::strcpy would do the job just fine

rf::console::print("Server rcon password set to: {}", rf::rcon_password);
}
else {
*rf::rcon_password = '\0';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer rf::rcon_password[0] syntax - it's an array, not a generic pointer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants