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

RCON (Server & Client) #100

Closed
wants to merge 54 commits into from
Closed

RCON (Server & Client) #100

wants to merge 54 commits into from

Conversation

Mauler125
Copy link
Contributor

@Mauler125 Mauler125 commented Mar 4, 2022

This pull request contains:

  • Full CNetAdr class rewrite in modern C++ (protocol agnostic)
  • Full CSocketCreator rebuild (based on Valve's implementation, but protocol agnostic)
  • RCON for server (dedicated only)
  • RCON for client
  • Non-game net console client to connect to dedicated server without needing any files of the game itself (just the netcon, link MFC static to the netconsole if maximum portability is desired, since then user doesn't need to install vc runtime)

Information regarding using RCON:
SERVER:

  • The password must be at least 8 characters long (ConVar: rcon_password)
  • To disable RCON, simply keep rcon_password empty.
  • To send logs to connected net consoles, set sv_rcon_sendlogs to 1, or send a SERVERDATA_REQUEST_SEND_CONSOLE_LOG message
  • The RCON server will bind to the same port as the hostport ConVar used by the game for UDP sockets, both IPv4 and IPv6 (dual stack)
  • The server will automatically ban IP's of spammers or hackers. It will not kick them out of game, just remove access to server remote access. Game kicking/banning could be implemented if desired.
  • It is recommended that the user sets a sv_rcon_whitelist_address, this will never get banned for failed attempts, or get 'cleaned' when max sockets (defined by sv_rcon_maxsockets) gets reached.
  • The server will automatically close the listen socket once a net console has successfully authenticated with the server
  • The listen socket gets reopened if connection to net console gets closed in any way (for example, when your game crashes or when you issued a disconnect)
  • Auto executes rcon_server.cfg on launch. You can put your configs in here.

CLIENT:

  • To connect to server, in the console set 'rcon_address' to the address of the RCON server you wish to connect to (default: [127.0.0.1]:37015)
  • Then enter command rcon. This will try to establish a connection to address stored in rcon_address ConVar.
  • To authenticate with the server: rcon PASS yourRCONpassword321.
  • To send commands to server: rcon "your commands here".
  • To disconnect from RCON server: rcon_disconnect.
    • Auto executes rcon_client.cfg on launch. You can put your configs in here.

NETCONSOLE:

  • Same as CLIENT, but in this case you do not need to use the rcon command prefix to send queries to RCON server.
  • Follow instructions in the terminal.

Additional information:

  • Port forwarding is required for this to work. Its the same range as the UDP protocol (37015-37020), but it has to be opened for TCP as well (RCON ports are equal to the UDP port of the game, which you could retrieve with the 'status' command or various tools available for Windows).

Library is configured to compile as 'lite'.
* Full CNetAdr rewrite (protocol agnostic)
* Full CSocketCreator class rebuild (based on Valve's implementation)
* RCON implementation on server and client
* Misc cleanup
Fixed several small bugs
Allows users to connect to their dedicated servers without having the game installed. Its also a base for example for anyone that wants to create their own RCON client.
@wolf109909
Copy link
Contributor

I love this. Thank you Amos :D

@Vexbane
Copy link

Vexbane commented Mar 4, 2022

Thanks for all your hard work Amos!

@abarichello abarichello added this to To do in Northstar via automation Mar 11, 2022
@abarichello abarichello moved this from To do to Todo for next release in Northstar Mar 11, 2022
@abarichello abarichello moved this from Todo for future releases to Next Release in Northstar Mar 31, 2022
@abarichello abarichello moved this from Next Release to Reviewing in Northstar Apr 5, 2022
@abarichello
Copy link
Contributor

Had some problems while testing this, changing convars worked fine but running server scripts gave me this error:
image
Left: dedicated server output | Right: NetConsole

@abarichello
Copy link
Contributor

Inviting others to test/review since there's a lot of code to cover

@GeckoEidechse GeckoEidechse added needs testing Changes from the PR still need to be tested waiting on changes by author Waiting on PR author to implement the suggested changes labels Jul 27, 2022
@GeckoEidechse
Copy link
Member

So on a new attempt I using the newest CI build at the time I now get:

image

Checking dedi console a (long enough) password is set:

image

Trying to connect on in-game client it says: image

And, yes I verified I properly added the files from CI as logs say version is dev (I was running stock v1.9.1 launcher before).

Okay for some reason I cannot reproduce that issue anymore so I guess consider it solved ig :P

* Implemented robust length-prefix framing logic for non-blocking sockets (previously used character sequences to determine length, but you cannot use character sequences on protocol buffers as its binary data. This logic should fix all problems regarding some commands not getting networked properly to the server and stuff not getting printed on the client).
* Increased buffer size to std::vector::max_size when netconsole is authenticated (MAX_NETCONSOLE_INPUT_LEN still remains enforced on accepted but not authenticated connections to prevent attackers from crashing the server).
* Process max 1024 bytes each recv buffer iteration.
* Additional optimizations and cleanup.
@Mauler125
Copy link
Contributor Author

So on a new attempt I using the newest CI build at the time I now get:
image
Checking dedi console a (long enough) password is set:
image
Trying to connect on in-game client it says: image
And, yes I verified I properly added the files from CI as logs say version is dev (I was running stock v1.9.1 launcher before).

Okay for some reason I cannot reproduce that issue anymore so I guess consider it solved ig :P

This most likely happened because the hostport of the dedi isn't 37015. By default (when no args are passed to netconsole or the rcon command in-game), the netconsole will attempt to connect to localhost::37015. If your server happens to have port 37016 or anything non 37015, which happens if you have multiple servers running, or started a game client before the dedi, or could also happen if something else uses that socket, then you need to specify the correct ip and port manually.

Copy link
Contributor

@cpdt cpdt left a comment

Choose a reason for hiding this comment

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

I ran into a couple of assertion failures when running a debug build of this:

NorthstarDedicatedTest/sha256.cpp Outdated Show resolved Hide resolved
NorthstarDedicatedTest/sv_rcon.cpp Show resolved Hide resolved
@DxsSucuk
Copy link

DxsSucuk commented Aug 8, 2022

What exactly happends on a wrong password try?
Cause while playing around (I was using https://github.com/cpdt/northstar-rcon-client/blob/main/northstar-rcon-cli/src/main.rs) I found out that the Server does not tell me that I entered the wrong password and just continues keeping the connection normally open.

The external rcon client that I used has a check for authentication Issues unsure if that one is wrong or if Northstar even sends a rcon auth error?

@cpdt
Copy link
Contributor

cpdt commented Aug 8, 2022

@DxsSucuk If you try the included netcon.exe client, it works correctly:

Northstar TCP net console [Version 2.0.0.1]
Enter <IP> <PORT>:
[22:06:26] [info] Connected to: [127.0.0.1]:37015
sv_cheats 1
[22:06:29] [info] This server is password protected for console access. Authenticate with 'PASS <password>' command.
PASS test
[22:06:31] [info] Admin password incorrect.

So that's a bug in my RCON client, presumably the auth response strings that it was checking against have changed. I've tracked that in cpdt/northstar-rcon-client#1.

@DxsSucuk
Copy link

DxsSucuk commented Aug 8, 2022

Thanks for the response @cpdt!

@DxsSucuk
Copy link

DxsSucuk commented Aug 8, 2022

I noticed that the server does not log that someone connected over RCON?
Is that wanted or?

Addressed:
* 'Expression: vector subscript out of range' (we only ever ensured capacity upon construction).
* 'Run-Time Check Failure #2 - Stack around the variable 'buf' was corrupted.' (caused because of 'misuse' of sprintf_s, which was initially used to suppress microsoft compiler warnings, reverted to sprintf).
The solution compiles on all systems, but CI. The cause happens to be the "net.h" include in cl_rcon.cpp. Perhaps moving it up higher fixes the problem (hopefully).
Hopefully this fixes CI.
@Mauler125 Mauler125 requested review from GeckoEidechse and removed request for pg9182 August 24, 2022 01:02
Copy link
Member

@GeckoEidechse GeckoEidechse left a comment

Choose a reason for hiding this comment

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

Before someone pings me again on Discord about RCON, the reason it's not getting merged currently is due to being flat-out broken in the sense that it causes host timescale issues.

More info can be found in this comment I left a while back that GitHub "helpfully" hides due to the amount of comments left on this PR: #100 (review)
(Just retested on latest RCON commit and it still exists)

Obviously as long as only having RCON active (no RCON clients connected) already causes timescale issues making the game unplayable there's no point in merging until fixed.

The other issue is merge conflicts but those can always be resolved once we have a working RCON implementation. ^^

@Mauler125 Mauler125 closed this Jan 15, 2023
@Mauler125
Copy link
Contributor Author

Pull request has been closed due to lack of interest. The amount of work required for merging the local fixes for the time scale issue into the new code base outweighs the interest for RCON. The contributors of Northstar had also requested me to move this into a plug-in instead; this is a big task which I unfortunately no longer have time for.

@GeckoEidechse
Copy link
Member

Pull request has been closed due to lack of interest. The amount of work required for merging the local fixes for the time scale issue into the new code base outweighs the interest for RCON.

Do note that interest for RCON support (or any protocol that allows for remotely interacting with server) is still very high. It wasn't tackled by core Northstar contributors at the time, due to higher priority tasks like codebase refactors and adding needed functionality to release new gamemodes, or lower hanging fruits that are easier to implement. There was also the assumption that this pull request was still being worked on to resolve the issues it had.

You're of course free to share your unpushed local fixes so that we can hopefully resolve the timescale issues together and push this PR over the finish line. ^^

 

As for

The contributors of Northstar had also requested me to move this into a plug-in instead; this is a big task which I unfortunately no longer have time for.

Despite the discussion, I'm not sure there was ever a definitive conclusion whether to do plugin or merge directly. The main issue was lack of a working implementation that didn't cause clients to desync due to server timescale slowing down as soon as RCON is active. An actually working version would have probably guided the way of how to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs testing Changes from the PR still need to be tested waiting on changes by author Waiting on PR author to implement the suggested changes
Projects
Archived in project
Northstar
  
Reviewing
Development

Successfully merging this pull request may close these issues.

None yet