Commit Graph

1682 Commits

Author SHA1 Message Date
Lion Kortlepel 66f5f2b8b6 fix error handling from SetErrorMessageFromResult 2026-04-19 18:17:54 +00:00
Lion Kortlepel e260de55af fix sol::error crash 2026-04-19 18:17:54 +00:00
Lion Kortlepel 7096fe058a fix PanicHandler crashing itself with another panic inside sol2
When sol2 does stack::get, it can panic, which causes the stack to
explode, corrupt it, and then any subsequent action crashes the server.
2026-04-19 18:17:54 +00:00
Lion Kortlepel 7089e5da9a fix race on disconnect
between the time we check for `is_open` and the actual disconnect, the
socket could already have been disconnected by another thread (TOCTOU).
Furthermore, the disconnects can race causing a segfault or similar
issue in the asio's internals.
2026-04-19 18:17:53 +00:00
Lion Kortlepel e9ce71d39a make send file accept a non-blocking socket 2026-04-19 18:17:53 +00:00
Lion Kortlepel d26e53a975 handle error cases early 2026-04-19 18:17:53 +00:00
Lion Kortlepel 4da5a7440a increase http curl pool to 128 2026-04-19 18:17:53 +00:00
Lion Kortlepel b1946ef1d9 use ReadWithTimeout until fully completed auth 2026-04-19 18:17:53 +00:00
Lion Kortlepel c08eefdf69 move TIoPollThread out and use it in TServer
the previous IoCtx was never being polled
2026-04-19 18:17:53 +00:00
Lion Kortlepel be0d8d5334 make connection reject msg a debug message, avoiding spam on ddos 2026-04-19 18:17:53 +00:00
Lion Kortlepel 1f55c35f2b fix ReadSocketWithTimeout to use dedicated io context polled on a new jthread
jthread so it's cancellable
2026-04-19 18:17:53 +00:00
Lion Kortlepel a3cfe47e78 fix http connections eating all fds
with this many http connnections, we were exhausting all available file
descriptors, leading to a dead server that keeps CLOSE_WAIT tcp sockets.
Because we want to retain the behavior that we keep connections open for
reuse, we instead make a pool of 8 curl instances now, shared between
all the different requests.
2026-04-19 18:17:53 +00:00
Lion Kortlepel 58e5317687 refactor ReadWithTimeout to not spawn a thread + use an fd each read
this was exhausting file descriptors with enough concurrent reads, from
what I can tell. Either way, spawning a new OS thread per read is not
the way.
Because this is so critical, I added unit-tests for that behavior.
2026-04-19 18:17:53 +00:00
Lion Kortlepel be6f3a2fd1 fix spammy logs on guard release 2026-04-19 18:17:53 +00:00
Lion Kortlepel 0ac5da2366 add connection limiter stats to status command 2026-04-19 18:17:53 +00:00
Lion Kortlepel b5642247a6 accept without EP, explicitly (and fallibly) get the endpoint 2026-04-19 18:17:53 +00:00
Lion Kortlepel a46f2d3204 set moved-from ip to explicitly obvious moved-from string 2026-04-19 18:17:53 +00:00
Lion Kortlepel a59f7296d0 avoid logging moved-from ip 2026-04-19 18:17:53 +00:00
Lion Kortlepel 6fca901aa2 implement connection limiter to replace manual limiting code 2026-04-08 12:31:35 +00:00
Lion Kortlepel 7925caf1a2 catch boost tcp's remote_endpoint() throwing and crashing the server
this happens when, somehow, the client disconnects before we get here.
I had this happen when breaking in the debugger and continuing, which
leads to clients timing out (client-side timeouts).
2026-04-07 21:19:33 +00:00
Lion Kortlepel 8cdee376c6 use jthread to join thread on scope exit 2026-04-07 20:25:17 +00:00
Tixx d56d9892c4 Bump version to 3.9.2 v3.9.2 2026-04-01 00:40:30 +02:00
SaltySnail 82102fcd4b Add ip limiting (#478)
By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
2026-04-01 00:13:45 +02:00
SaltySnail 66884920db Remove clients when shutting down the socket 2026-03-31 23:44:43 +02:00
SaltySnail 5c2a0db7ef Added timeout on read 2026-03-31 22:32:57 +02:00
Tixx b139a6aaad Fix skip invalid socket (#477)
Removes continue in socket accept flow

---

By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
2026-03-28 17:04:04 +01:00
SaltySnail 75e9c52ce8 Rewrite accept code to not use continue 2026-03-28 16:23:29 +01:00
SaltySnail b4b262196b Revert "Skip invalid socket when accept() fails"
This reverts commit 83afafc0c3.
2026-03-28 16:15:42 +01:00
Tixx 4af0e4ccac feature: BEAMMP_PROVIDER_DISABLE_MP_SET environment variable (#461)
This pull request adds BEAMMP_PROVIDER_DISABLE_MP_SET variable
(true/false/1/0) to disable MP::Set for providers.

---

By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
2026-03-21 20:11:51 +01:00
Tixx 5d2b198fb8 adding logchat boolean to MP.SendChatMessage (#471)
This PR adds a boolean parameter to the MP.SendChatMessage function that
allows logging the message or not (default true).

I took an example from the ``set_function("SendNotification" ...`` to
make the default value working.

It's my first time actually doing C++, I hope it's alright!

---

By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
2026-03-21 20:11:38 +01:00
Tixx 89392a67c2 Bump version to 3.9.1 v3.9.1 2026-03-08 18:16:10 +01:00
Tixx 86a1c50c8b Add dynamic export (#470)
Testing builds with -Wl,--export-dynamic

Closes #464 

---

By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
2026-03-08 18:09:42 +01:00
Tixx d97010c8ca Harden malformed vehicle packet parsing (#475)
## Summary
Reject malformed vehicle reset and paint packets before slicing
structured payloads, and catch parser exceptions in the TCP client loop.

## Problem
Or:<pid>-<vid>:null and similarly malformed Op packets could reach
substr(npos) in ParseVehicle, throwing std::out_of_range. On TCP, that
exception could escape the client loop and kill the thread.

## Changes
- Guard Or reset packets when no { payload exists
- Guard Op paint packets when no [ payload exists
- Add a small helper and unit test for structured payload extraction
- Catch std::exception around GlobalParser in the TCP client loop and
disconnect the offending client

## Verification
- git diff --check
- Full build/tests not run in this shell because cmake was not installed
2026-03-08 17:29:55 +01:00
Tixx 8a613e0b16 Prevent log spam and simplify code 2026-03-08 17:24:30 +01:00
alex 48d721f602 Harden malformed vehicle packet parsing 2026-03-07 21:23:00 -07:00
TechStreet f38797a9ab feature: BEAMMP_PROVIDER_DISABLE_MP_SET environment variable 2026-02-24 17:39:22 +00:00
0R3Z da0089fb2e add export-dynamic flag 2026-02-19 21:15:14 +01:00
Tixx 3befc84f00 Add build deb13 (#469)
add/test Debian 13 build to github actions

Closes #464 

---

By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
2026-02-19 20:07:28 +01:00
boubouleuh 595247d51d adding logchat boolean to MP.SendChatMessage 2026-02-02 22:33:58 +01:00
0R3Z 48a77e9ea6 add debian 13 to release workflow 2026-02-02 12:52:42 +01:00
0R3Z f9c85a1f35 fix release workflow formatting 2026-02-02 12:51:01 +01:00
0R3Z 168a410129 add build Debian 13 for ARM64 2026-01-25 18:11:33 +01:00
0R3Z 4926e1aebd add support for Debian 13 on github workflows 2026-01-25 17:59:02 +01:00
0R3Z 1e2d8688a8 add installation scripts for Debian 13 2026-01-25 17:58:26 +01:00
Tixx 6f196aca64 Decrease likelyhood of lua stack corruption (#462)
Decreases the likelyhood of lua stack corruption.

---

By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
2026-01-18 21:56:31 +01:00
Tixx 99476a2c77 Revert "Add stack trace to server lua engine (#350)" 2026-01-15 14:44:13 +01:00
Tixx 9fa9974159 Lua version change to 5.3.5 (#458)
Update Lua version to make plugin development easier across platforms
and simplify Windows builds by using vcpkg.

---

By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
2026-01-10 21:39:52 +01:00
boubouleuh 3ef816845d Lua version change to 5.3.5 2026-01-10 21:09:05 +01:00
Tixx 6ec4106ec7 refactor: optimize string operations and improve code clarity (#451)
- Avoid redundant substr() calls in packet parsing hot-path
(TServer.cpp)
  The previous code called substr(3) twice per packet, creating
  unnecessary temporary strings. Now stores the result once.

- Replace .size() == 0 with .empty() for idiomatic C++
  (TConsole.cpp, TLuaEngine.cpp)
2026-01-02 00:42:03 +01:00
Tixx b094e35f8c Skip invalid socket when accept() fails (#457)
When Acceptor.accept() returns an error (e.g., "Too many open files"),
the server was continuing to process an invalid socket, causing resource
leaks and potential infinite error loops.
Add continue statement to skip processing when accept() fails, allowing
the server to retry on the next iteration instead of crashing.
Fixes resource exhaustion DoS vulnerability where server would enter
error loop instead of handling gracefully.
<img width="1233" height="199" alt="image"
src="https://github.com/user-attachments/assets/bad8f559-6ef2-47ee-b1c1-3e6020cdfb77"
/>

---

By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
2025-12-29 17:38:53 +01:00