87 Commits

Author SHA1 Message Date
Kawe Mazidjatari
6a86ae2606 Cleanup CMakeLists files
Light cleanup in CMakeLists files. Split protocols and improve filter names.
2023-05-14 17:36:08 +02:00
Kawe Mazidjatari
8dbc2024c6 CMake code improvements
Use the 'add_module' macro to add modules without creating duplicate code. This macro also takes a reuse PCH as parameter, so modules that need a precompiled header, could reuse those from different targets that compile them. This commit also restructures the group order of the generated solution files for easier code navigation.
2023-05-13 00:14:53 +02:00
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
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
2748c61fe2 Put json value getters in try catch
Put 'nlohmann::json::value' operations in try catch, as these could raise an exception.
2023-04-29 14:58:46 +02:00
Kawe Mazidjatari
145bc3797f Only check token field if the server is hidden 2023-04-29 13:15:18 +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
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
fcc4b410f3 Improve formatting in pylon code 2023-04-26 23:31:16 +02:00
Kawe Mazidjatari
9872b4042a Improve pylon error logging
Improve error formatting.
2023-04-25 22:57:06 +02:00
Kawe Mazidjatari
73fe590f99 Fix small bug
Fixed bug caused by const char* to const string& conversion, resulting in the request message not always getting sent properly.
2023-04-25 22:51:06 +02:00
Kawe Mazidjatari
000f7c7f82 CPylon parsing/logging code deduplication
Deduplicated parsing and logging code. Results are a lot more consistent and comprehensive.
2023-04-25 00:45:39 +02:00
Kawe Mazidjatari
f0a561552b CPylon server query code deduplication
Created another dedicated wrapper for handling API requests; significantly reduced duplicate code.
2023-04-24 01:55:37 +02:00
Kawe Mazidjatari
aff4b6125e CPylon error handling code deduplication
Deduplicate code.
2023-04-24 00:32:27 +02:00
Kawe Mazidjatari
02bef4c2dd Light cleanup in CPylon
Force consistency.
2023-04-22 22:00:20 +02:00
Kawe Mazidjatari
94d30b759d Fix potential security flaws caused by uncontrolled format strings
Make sure format strings are string literals to avoid an uncontrolled format string situation.
2023-04-08 20:13:06 +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
53c693f6e1 Avoid creating a unnecessary copy
Avoid copying the string out of the vector.
2023-04-03 11:21:31 +02:00
Kawe Mazidjatari
e1f0e72af4 /W4: Fix type demotion warnings
Explicitly demote to 'int' to suppress pesky compiler warnings.
2023-04-02 16:03:01 +02:00
Kawe Mazidjatari
7c8fc3a67d CPylon: explicitly cast status in string format to int
Newer versions of the 'fmt::format' library require these to be casted as such.
2023-03-18 13:29:40 +01:00
Kawe Mazidjatari
bd9cc31599 Remove useless print
This print is useless; either gets logged in CURL code or in browser panel.
2023-02-26 19:40:36 +01:00
Kawe Mazidjatari
03bc4e71c4 Ban system improvements
* Refactored code; kick & ban now share the same function.
* Kick & ban will now log a confirmation to the console.
* Players in refused list will no longer get banned, this was initially performed to keep load off the master server, but this turned out to be excessive. It also caused the side effect of having players banned even if their bans have been removed from the master server.
2023-02-23 23:55:55 +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
8b227c90d8 Master server query code improvements
* Improved error messages.
* Fixed bug where status was not checked to determine what error message to return.
2023-01-28 01:57:42 +01:00
Kawe Mazidjatari
3cd7f4331d Add debug logging for 'CPylon::CheckForBan' 2023-01-26 21:11:32 +01:00
Kawe Mazidjatari
500a7c1925 Finish libcurl implementation
Master server queries now use SSL.
2023-01-26 20:06:48 +01:00
Kawe Mazidjatari
59a917a2bc Light cleanup 2023-01-26 03:00:23 +01:00
rexx
9d2ffa6e26
bansystem: fix incorrect allocation size causing OOB memory write 2023-01-14 15:35:46 +00:00
Michael Poutre
0077320bb7
Add server response to pylon debug info for GetServer and PostServer (#85) 2022-12-21 00:55:31 +01:00
Kawe Mazidjatari
277e05b2b8 Improve logging throughout SDK
Used proper enum for context. The low level tier1 stuff should print in COMMON.
Also added newlines where missing, the logging system will undergo a change where a newline will only be appended if we are logging in the same context without a newline.
2022-11-25 23:03:56 +01:00
Kawe Mazidjatari
793c2e8e50 Rename 'Reputation_t' enumerant 2022-09-20 02:04:25 +02:00
Kawe Mazidjatari
58cadb529b 'Bad behaving player' systems improvement
* Use 'CClient::Disconnect(..)' for all kicks and bans (this automatically clears the entire CClient slot, and removes the net channel).
* Only force disconnect when 'CNetChan::m_nSignonState' has a value that is not NULL.
* Clear the ServerPlayer slot on 'CClient::Disconnect(..)' and 'CClient::Connect(..)'.
* Only kick player for NetChannel overflow when value exceeds processing budget (not equals).
2022-09-19 01:28:43 +02:00
Kawe Mazidjatari
fdd74aa622 Implement net message processing budget
Implement net message process budget (channel gets removed if value is exceeded).
Use 'net_processLimit' to enable the implementation on the server. It will get enabled by default after testing and some cleanup. This helps against people trying to slow the server down by spamming net messages with a higher rate, e.g. using 'bind "mousewheel_up" "status"'.
2022-09-18 23:19:50 +02:00
Kawe Mazidjatari
a68f55dac0 Move unban logic to CBanSystem and expose to Squirrel
New unban function in SERVER context 'UnbanPlayer(string criteria)'.
2022-09-16 00:51:35 +02:00
Kawe Mazidjatari
9c9843a0fc Centralize kick/ban wrappers to CBanSystem and add new server functions for kicking/banning players 2022-09-15 23:13:37 +02: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
3b237a827f Function must return a value 2022-09-09 21:05:10 +02:00
Kawe Mazidjatari
34a06147d7 Fix spelling errors
Overall spelling improvements and cleanup..
2022-09-09 19:47:31 +02:00
Kawe Mazidjatari
dea5f166db Use internal file system to load/save banned list.
'banlist.json' is now read from all searchpaths.
'banned.json' is only written to "PLATFORM".
2022-09-01 01:07:16 +02:00
Kawe Mazidjatari
d9709cfb1e Flip order of assignment 2022-08-31 18:20:11 +02:00
Kawe Mazidjatari
e0b45cce9b Fix pylon debug info
* Fixed bug where we dumped the json object again for the post, while this is already stored in a nearly unused string.
* Better debug messages.
2022-08-31 17:18:26 +02:00
Kawe Mazidjatari
1285d15623 Ban system and authentication improvements
* Fixed bug where multiple of the same entries get added to the global ban/refuse list.
* Fixed bug where we still use the client instance after deleting it in 'CBanSystem::BanListCheck()'.
* Load banlist at a later state (not at construction of class), this is needed for a future change of adapting the 'business' code to feature the game's FileSystem.
* CServer cleanup.
* More detailed ban messages (banned, added to refused list, removed from slot, etc..).
* Use localization key for banned message ("#Valve_Reject_Banned").
* Add const qualifiers to all CPylon methods.

Note:
* This commit requires changes on the master server, these changes are already performed, however the new master server isn't live yet until we publish the new release.
2022-08-30 12:07:09 +02:00
Kawe Mazidjatari
71c5ff2416 Clear banlist if valid if we attempt to load it
When we 'reload' the banlist, and have a valid file, none of the current bans in the vector will get overwritten. We clear the entire vector if valid, and rebuild it if the file is valid. if no file is found, or if access to file is denied, we assume the server operator wants all bans dropped.
2022-08-29 17:03:14 +02:00
Kawe Mazidjatari
afad5b92ec Rename 'OriginID' to 'NucleusID'
Nucleus ID is the official internal term for the platform user id used by the OriginSDK.
2022-08-29 15:59:12 +02:00
Kawe Mazidjatari
1a3f17a422 Update pylon time-out message 2022-08-29 00:29:32 +02:00
Kawe Mazidjatari
0b49ea1f29 Use 'g_pServer->IsActive()' over 'g_pHostState->m_bActiveGame' 2022-08-28 17:40:03 +02:00
Kawe Mazidjatari
48e708e498 CPylon: Exception handling for all 'json::parse' calls 2022-08-28 17:12:58 +02:00
Kawe Mazidjatari
38c94eda27 Banlist writing optimizations
* Only write if there is something to write.
* Don't write each iteration, write after the loops are finished.
2022-08-28 00:11:33 +02:00