40 Commits

Author SHA1 Message Date
Kawe Mazidjatari
179bd31ee6 Initial large refactor of the RCON implementation
* Decoding and encoding is done into a single buffer, from raw buffers to avoid extraneous copies.
* Added base class holding all core logic for encoding, decoding, receiving and processing of the RCON protocol. This code was initially identical between all implementations of RCON, deduplicating this avoids bugs.
* Added more sophisticated error handling, stop right away when decoding for example fails.
* Added ability to have more than one active authenticated net console on the server. Controlled by cvar 'sv_rcon_maxconnections' (default 1).
* Max packet size for accepted, but not authenticated sockets is now controled by cvar 'sv_rcon_maxpacketsize' (default 1024).
2023-04-19 01:35:31 +02:00
Kawe Mazidjatari
2caede5099 Add asserts in CSocketCreator 2023-04-16 15:51:16 +02:00
Kawe Mazidjatari
3882b64b91 Fixed several bugs in socket creator class
* Fixed 'connect' socket bug preventing connection to IPv4 addresses, by making the method used by the listen socket and connect socket configurator shared (dual stack was disabled on connect, but not on listen).
* Removed extraneous member from the 'CSocketCreator' class, this member was a copy of the 'netadr_t' input, but nothing ever was done with it.
2023-04-16 00:28:33 +02:00
Kawe Mazidjatari
53e2ddb122 Fix compiler warning caused by signed/unsigned mismatch 2023-04-10 23:45:51 +02:00
Kawe Mazidjatari
1d04f837f8 Fix many high level compiler warnings
* Put initializer values inside brackets.
* Put logical AND conditions within parentheses.
* Put assignments within conditional statements within parentheses.
* Mark unused variables as such to suppress compiler warnings.
* Fix vftable shadow warnings caused by ConVar::CreateInternal (does not implement, only interface. Renamed to yield desired behavior).
* Fix 'never' initialized class members for 'CCVarIteratorInternal'.
* Return values in interface vftables that cannot be pure virtual.
2023-04-08 19:00:28 +02:00
Kawe Mazidjatari
16910aa45c Use custom string formatter
Enforce consistency through code base by using the same format specifiers.
2023-04-08 10:50:32 +02:00
Kawe Mazidjatari
9f428f1567 Move tier0 lib headers to public
This commit does not change any logic or behavior of the code.
2023-04-06 23:50:48 +02:00
Kawe Mazidjatari
a1f7cc9a0d Make code compatible with older C++ versions
Made compatible with earlier C++ versions without having verbose compiler warnings.
2023-04-03 01:41:46 +02:00
Kawe Mazidjatari
0c5a24152e /W4: Fix name shadowing warnings
Parameter 'hostname' shadows global cvar 'hostname'.
2023-04-02 17:40:15 +02:00
Kawe Mazidjatari
bae2e0a99c /W4: Fix implicit type conversion warnings
Explicitly convert them to avoid any warnings or potential bugs.
2023-04-02 17:23:53 +02:00
Kawe Mazidjatari
7de717d47c /W4: Use 'constexpr' to evaluate branch at compile time
Fixes many compiler warnings.
2023-04-02 11:19:23 +02:00
Kawe Mazidjatari
b3621ba53a Add cvar 'curl_timeout'
New cvar for setting the curl timeout determined in function 'CURLInitRequest'.
2023-03-15 21:33:16 +01:00
Kawe Mazidjatari
c58d8f646a CSocketCreator: add getter for authorized sockets
Add method for obtaining the amount of authorized sockets.
2023-03-13 20:39:49 +01:00
Kawe Mazidjatari
dcf6d12ae1 Fix memory leak in Curl util code
'curl_slist' pointer should be passed in as reference, as its destroyed elsewhere.
2023-02-09 22:56:13 +01:00
Kawe Mazidjatari
66f31916d1 Pylon logic imporvements
* Removed duplicate json parsing that was part of a PR that required a small refactor.
* Only check if response buffer is empty when we are going to parse the error message (this helps finding bugs in master server, since failure to parse has an exception handler).
* Log private server token and error messages to dedicated server console.
2023-02-04 19:18:18 +01:00
Kawe Mazidjatari
ca9143dde9 Add curl cvars for debugging 2023-01-30 00:04:11 +01:00
Kawe Mazidjatari
b98eee0268 RCON system refactor and improvements
* Use game's CNetAdr RCON and socket creator.
* Add support for constructing host from [ip]:port format in the netconsole client.
* Pass 'netadr_t' parameter by reference to 'CSocketCreator::OnSocketAccepted'.
2023-01-29 15:24:24 +01:00
Kawe Mazidjatari
6c21fc5b7a Create libcurl wrappers
Created wrappers which are currently focused on master server queries. This avoids boiler plating and manual deleting.
2023-01-26 19:54:38 +01:00
Kawe Mazidjatari
4ba88963ff Fix bugs and many compiler warnings
* Promoted size types in CUtlBuffer to int64.
* Fixed bug where CUtlBuffer::GetPtr returns a 64bit pointer that was promoted from a 32bit integral type.
* Use int64/size_t for anything strlen, pointer subtraction, etc..
* Removed invalid structure alignment declarations.
2022-11-24 15:41:52 +01:00
Kawe Mazidjatari
4b1c5dd5a3 RCON system light refactor
* Used 'htonl'/'ntohl' for constructing the length prefix.
* Used static socket/address members instead of pointers.
* Used const qualifier where possible.
* Changed length prefix field type to 'u_long'.
* Removed extraneous include.
* Properly escaped percentage characters on the RCON game client for the ImGui console.
2022-11-14 21:00:41 +01:00
Kawe Mazidjatari
729475c74c Light cleanup
Use NO_ERROR instead of NULL for error code parameter passed to Error(..).
2022-09-14 01:14:51 +02:00
Kawe Mazidjatari
3d6d6644bd Logging bug fix and error handling improvements
* Replaced the boolean 'fatal' parameter with a error code parameter, anything non-null will prompt a message (fatal) and terminate the process with given error code.
* Fixed bug where the global ostreamsink for spdlog did NOT get cleared in 'SQVM_PrintFunc' when cvar 'sq_showvmoutput' was < 3. Moved to global scope.
* Added error message for when detouring the process has failed, with the error code.
* Only call 'Plat_GetProcessUpTime()' once per log, (improves performance and fixes bug where the error message box would show a different time stamp than what is logged into the console or file).
* All TIER0 loggers only log to notify and console when the SDK engine has fully initialized and detoured all functions.
2022-09-14 00:39:38 +02:00
Kawe Mazidjatari
2010e11310 Add 'fatal' functionality to Error()
When fatal is set, the function will show a error dialogue, which will halt the process and close when the message is dismissed. Else we will end up in a crash.
2022-08-22 12:42:41 +02:00
Kawe Mazidjatari
9775fc4bba RCON system overhaul
* 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.
2022-08-02 23:58:43 +02:00
Kawe Mazidjatari
f4ea846284 RenderUtils cleanup. 2022-07-12 21:02:10 +02:00
Kawe Mazidjatari
c9c002d27a Improve readability for DebugDrawHemiSphere angle math 2022-07-12 15:06:44 +02:00
Kawe Mazidjatari
0496d5d66b Improve DebugDrawSphere 2022-07-12 14:52:12 +02:00
Kawe Mazidjatari
d47eaf98a0 Improve segmentation math for DebugDrawHemiSphere
Use actual number of segments per semi.
2022-07-11 21:43:57 +02:00
Kawe Mazidjatari
2ffb1da730 Default bZBuffer for all shapes to true; 2022-07-11 21:31:54 +02:00
Kawe Mazidjatari
27ff727949 Use Vector3D for capsule and hemisphere radius. 2022-07-11 20:45:14 +02:00
Kawe Mazidjatari
ffa9f12e2b New DebugDraw shapes in SDK
DebugDrawCapsule and DebugDrawHemiSphere.
Hooked up to DrawOverlay (OverlayType_t::OVERLAY_CAPSULE).
2022-07-11 20:35:20 +02:00
Kawe Mazidjatari
856b386945 Debug overlay improvements and new render utilities.
Fixed internal RenderBox transforms (origin and angles are packed in xmm registers).
Added new render utilities in the SDK similar to the script ones.
2022-07-10 14:30:28 +02:00
Kawe Mazidjatari
6b7a1f62e6 Fix declaration
Add missing optimizations belonging to previous commit.
2022-07-08 20:18:40 +02:00
Kawe Mazidjatari
bbf7896218 Move GetBoxCorners to mathlib
Renamed to 'PointsFromAngledBox' (no longer adds origin by default).
2022-07-08 20:17:30 +02:00
Kawe Mazidjatari
d8a45ae563 Overlay improvements
* Move render utils to dedicated file.
* Implement more render/mesh utils.
* Added structure for OverlayTriangle_t, OverlaySweptBox_t and OverlayCapsule_t.
OverlayCapsule_t has been modified to accommodate the size in r5 (2 new vectors).
2022-07-07 21:31:00 +02:00
Kawe Mazidjatari
59f43d0157 Slight cleanup/improvements for CSocketCreator 2022-06-30 20:21:15 +02:00
Amos
2fee28ae96 Adapt to new loggers 2022-03-04 15:59:33 +01:00
Amos
1058a6fa10 Use unicode character set instead and light cleanup/bug fixes 2022-03-04 12:22:17 +01:00
Amos
a5da2e81bf RCON improvements (see description)
** SERVER **
* Close redundant connections if max sockets have been reached.
* Ban if client keeps spamming without authing first (ignoring message).
* Check for whitelisted address before issuing bans (whitelisted address in ConVar 'sv_rcon_whitelist_address' will never get banned or get its connection terminated.
* Transmit SQVM and DevMsg logs over the wire to the net console.

** NETCON **
* IPv6 support.
* Close connection properly after FIN request.
* Prompt user to reconnect after connection has been terminated instead of closing the application.
* Add proper quit command.

** SDKLAUNCHER **
* Rename to 'launcher.exe' to describe its purpose better. Our logo gets printed nice and large on the console during startup.

** SDK **
* Cleanup.
2022-02-08 16:32:00 +01:00
Amos
c187bed4c5 RCON implementation (see description)
* Fully rewritten protocol agnostic CNetAdr class
* Fully rebuilded legacy CNetAdr class
* Fully rebuilded dual-stack CSocketCreator class
* New project "netconsole" added (lightweight netconsole for RCON)

RCON is still work in progress
2022-02-06 16:48:52 +01:00