94 Commits

Author SHA1 Message Date
Kawe Mazidjatari
f120354e96 Initial port to CMake
* All libraries have been isolated from each other, and build into separate artifacts.
* Project has been restructured to support isolating libraries.
* CCrashHandler now calls a callback on crash (setup from core/dllmain.cpp, this can be setup in any way for any project. This callback is getting called when the apllication crashes. Useful for flushing buffers before closing handles to logging files for example).
* Tier0 'CoreMsgV' function now calls a callback sink, which could be set by the user (currently setup to the SDK's internal logger in core/dllmain.cpp).

TODO:
* Add a batch file to autogenerate all projects.
* Add support for dedicated server.
* Add support for client dll.

Bugs:
* Game crashes on the title screen after the UI script compiler has finished (root cause unknown).
* Curl error messages are getting logged twice for the dedicated server due to the removal of all "DEDICATED" preprocessor directives to support isolating projects. This has to be fixed properly!
2023-05-10 00:05:38 +02:00
Kawe Mazidjatari
f97cf6c249 RCON socket bind improvement
Check 'net_usesocketsforloopback' before binding sockets; allows binding to loopback as well.
2023-04-30 11:32:51 +02:00
Kawe Mazidjatari
90cf742fb5 Don't check for ban if client is a loopback address 2023-04-30 11:31:05 +02:00
Kawe Mazidjatari
f319fc0846 Use server global variables for client loops
Use server global variables for determining the num clients to loop over. This is cheaper and better than always looping over MAX_PLAYERS.
2023-04-30 01:50:38 +02:00
Kawe Mazidjatari
6b23570beb Ban system bug fix and improvements
* Format the ip as '[ip]:port' in all logging calls for consistency.
* Fixed a bug causing the IP to be send up as full instead of base only to master server (should always be base only).
* Temporarily uncommented the plugin callback logic.
2023-04-30 01:29:54 +02:00
Kawe Mazidjatari
78a86fed6a Log address of 'SV_BroadcastVoiceData' 2023-04-29 21:07:45 +02:00
Kawe Mazidjatari
55aa254e6b Merge branch 'bulk_check' into indev 2023-04-29 21:01:59 +02:00
Kawe Mazidjatari
a5bc2f77cb Fix broken 'SV_IsClientBanned' implementation
SV_IsClientBanned is now checked after the creating of CClient, and thus 'CServer::AuthClient' has been inlined into 'CServer::ConnectClient'. Since we have to request the master server to check whether or not this particular client is globally banned, we have to detach it into a separate thread, and process the results back into the main thread once finished. This takes too much time, so we connect the client anyways and if the master server marked it as 'banned', we disconnect it right away.
2023-04-29 20:36:29 +02:00
Kawe Mazidjatari
3ea49766c6 Light banning code improvements
* Removed extraneous std::string constructors (everything using the bansystem used raw char pointers).
* Improved logging and function comments.
2023-04-29 12:15:51 +02:00
rexx
dca27475ec (re)implement sv_alltalk
Rebuilds SV_BroadcastVoiceData with an additional check of "sv_alltalk" cvar to disable team checking, allowing for servers to enable global voice chat
2023-04-29 11:11:10 +01:00
Kawe Mazidjatari
ab9d36e0d8 Send client's persona name to the master server
Will be used on the master server for additional checking.
2023-04-29 00:05:47 +02:00
Kawe Mazidjatari
48bc69b028 Initial implementation of bulk ban checking
Initial implementation of the bulk ban check system. This implementation takes a snapshot of the currently connected clients, sends it up to the master server, and the master server returns anything within this list that is marked 'banned'. The server would then kick the player from the server. This commit also removes the global banned list cache, as the bulk checking system offers a lot more freedom regarding banning specific players and have it sync across all available servers.
2023-04-28 23:47:58 +02:00
Kawe Mazidjatari
a1c97e1b39 Fix assignment bug
Sigscan results returned to the wrong var.
2023-04-26 23:31:03 +02:00
Kawe Mazidjatari
d9fa611418 Add new callbacks to server functions
A few new callback hooks which are perhaps useful in the future.
2023-04-25 00:46:45 +02:00
rexx
3eb660c9f7 enable pluginsystem 2023-04-23 22:28:16 +01:00
Kawe Mazidjatari
615de70b1f Fix shutdown crash
Fixed crash due to destructor of CSocketCreator being called during shutdown. If the socket fails to close, an error is logged. But at this point, all sockets have been closed already and the logger system has already been destroyed. Allocated as dynamic memory to avoid destructor being called at this stage.
2023-04-23 18:01:30 +02:00
Kawe Mazidjatari
1eef4aacb4 Improve signatures
Better signatures, and fix signature/compile errors for s1 and s2.
2023-04-23 17:05:00 +02:00
Kawe Mazidjatari
df81d52398 Improve assert
Fix assert condition where iSocket and GetAcceptedSocketCount are both 0.
2023-04-22 21:46:05 +02:00
Kawe Mazidjatari
13fcdaa442 Fix bug in 'CServer::AuthClient'
The IP that is sent to the server should be in base format only (no brackets or port). The buffer size was also too small to contain the entire length of the full IP address with port and brackets.
2023-04-22 20:30:53 +02:00
Kawe Mazidjatari
50b3273101 Add change callback for 'sv_rcon_maxconnections'
If 'sv_rcon_maxconnections' is set higher than current auth socket count, reopen listen socket. If its set lower, close all sockets until auth socket count matches 'sv_rcon_maxconnections'. Sockets are getting closed in reverse order, so the netcon that connected last will be disconnected first.
2023-04-22 16:51:18 +02:00
Kawe Mazidjatari
be61c93c85 RCON system improvements
* Added more error handling throughout code.
* Marked function parameters 'const' where possible.
* Updated comments.
2023-04-22 16:02:54 +02:00
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
85f586bd2e RCON server improvements
* Prevent attacker from being able to abuse and overflow the banned list vector.
* Improved IPv6 comparison performance.
* Change size fields of payload frame from unsigned to signed.
* Close all accepted sockets on RCON server shutdown.
2023-04-16 17:51:48 +02:00
Kawe Mazidjatari
bd1bec3cfe Several RCON bug fixes and improvements
* Fixed uncontrolled format specifier in 'NetMsg' call on the RCON client.
* Removed extraneous call to 'PrintPercentageEscape'.
* Compare, and disable RCON logs if user attempts to connect to listen server's RCON.
2023-04-16 12:05:39 +02:00
Kawe Mazidjatari
2d3f2ba507 Fixed bug causing RCON server socket to only listen on IPv6
Ip address must be unspecified (::) to bind sockets properly.
2023-04-16 00:24:06 +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
b15d848c66 Cleanup 'user_creds_s'
Light cleanup.
2023-04-01 01:51:39 +02:00
Kawe Mazidjatari
67180e51ff Validate client's origin name on connect
Recently, there has been a sudden influx of players playing with a name that isn't valid. Names such as "    " or "@something $very !crazy". This patch fixes this problem by enforcing checks during connect by default.
2023-03-31 22:37:53 +02:00
Kawe Mazidjatari
47aabf244b Remove redundant tier1 files
These files are no longer necessary.
2023-03-28 01:30:09 +02:00
Kawe Mazidjatari
5aea2f4261 RCON system upgrade
RCON upgrade with additional logging system improvements:
* Netconsole's can now log received messages in color, even when the RCON server has ANSI colors disabled; logs are fully composed locally.
* RCON server now also sends the log type over the wire, along with the (already existing) context.
* SDK logging code is now shared with the standalone netconsole application.
* Improved logging readability for the standalone netconsole application.
2023-03-27 02:01:48 +02:00
Kawe Mazidjatari
793fcd62f2 End of logger refactor
Changed all loggers to use the internal 'CoreMsg/CoreMsgV' functions. Significantly reduced duplicate code and CPU time. Code is also much more robust.

* Code now only acquires mutex lock when the actual logging part takes place.
* Code now only checks and strip ANSI rows if its enabled to begin with.
* Code now supports setting log levels, which ultimately could be tweaked with a cvar.
* Changed logger and file names to be more readable.

TODO:
* The RCON protocol has to be modified to accommodate these changes.
2023-03-26 16:09:05 +02:00
Kawe Mazidjatari
371e15db41 Fix many verbose compiler warnings
Many compiler warnings regarding implicit conversions.
2023-03-18 16:45:43 +01:00
Kawe Mazidjatari
031eee80a1 RCONServer: send/serialize optimizations
Check if we are initialized, have at least one socket, and in case of a console log, if we have at least 1 authorized netconsole before serializing the message and sending the result.
2023-03-13 21:20:20 +01:00
Kawe Mazidjatari
cae5037324 Initial fix for older game builds
SDK compiles and works for the S1 game now, still needs to be debugged further.
2023-03-01 00:09:38 +01:00
Kawe Mazidjatari
3e246a9d27 CServer improvements
* Added new member 'm_nSpawnCount'.
* Added hook for 'CServer::RunFrame'.
* Abstract class 'IServer' no longer exists in this engine, inherit from 'IConnectionlessPacketHandler' instead (see RTTI in engine executable).
2023-02-18 11:42:36 +01:00
Kawe Mazidjatari
2ed56d7317 More mapped out fields for server and client class 2023-02-17 23:59:37 +01:00
Kawe Mazidjatari
decf3552ea Add 'GetNumClients'
Gets the total amount of clients on the server (both fake and real clients).
2023-02-12 15:20:11 +01:00
Kawe Mazidjatari
0dace8eea3 Fix crash during init
If an error occurs during init, and 'Error' is called, the program will segfault. Fixed by only running the 'send' code from RCON after it has been initialized.
2023-02-04 01:34:08 +01:00
Kawe Mazidjatari
e50601ed29 Rename 'g_bDedicated' to 'm_bIsDedicated' 2023-01-31 22:40:15 +01:00
Kawe Mazidjatari
6e32464519 Rename 's_bDedicated' to 's_bIsDedicated'
's_bIsDedicated' is the original name (see TRACEINIT in game executable).
2023-01-31 22:30:45 +01:00
Kawe Mazidjatari
462439b1dc Improve string formatting
Flip bracket.
2023-01-31 17:10:17 +01:00
Kawe Mazidjatari
5f56c23af2 Compile CRConServer for gamesdk
RCON can now be used on the host game as well (previously dedicated exclusive).
2023-01-29 16:07:02 +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
6df498e5c8 Rename 'v_netadr_t' to 'netadr_t'
Name was used for compatibility reasons. No longer necessary.
2023-01-29 15:12:27 +01:00
Kawe Mazidjatari
61684ddf87 Create cvar for global banned list queries
This was planned to be changed a long time ago. This change allows dedicated server users to disable the logic as well.
2023-01-26 21:20:11 +01:00
Kawe Mazidjatari
59a917a2bc Light cleanup 2023-01-26 03:00:23 +01:00
Kawe Mazidjatari
a618990937 Detour code refactor
This change was planned for a long time. This moves all REGISTER calls to a single translation unit, this is required as we currently added a very dirty workaround for not registering duplicates by checking if VFTable pointer was already present in the vector... Registering from single translation unit prevents duplicate instances that gets created if header is included by more cpp files.
Reworking this reduced 100kb+ of compiled code. This commit also reworked the way functions/variables/constant gets logged with their addresses; the new code formats them on the fly, and allows for resize at any time. Formatting is no longer required by programmer.

TODO: currently there are some compile errors for dedicated and client dll's. These will be resolved very soon as they need to be properly worked out still (server & client only stuff needs to be properly split). Use the 'main' (stable) branch for the time being if you need to compile these dll's.
2023-01-25 02:26:52 +01:00
Kawe Mazidjatari
2501c37044 Globally convert all byte patterns to strings
These get reconverted to masked byte patterns at runtime. With the signature map cache system, this will only happen when building the cache.
2022-12-01 22:44:55 +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
0c13ca4e3f Only run threaded bone setup when we don't run the listen server
The Season 3 versions of the executable deadlock when threaded bone setup has been enabled on the client while the listen server has ran at least once during the process lifetime.
2022-11-10 11:47:02 +01:00