78 Commits

Author SHA1 Message Date
Egor Vorontsov
56b75aaffc Set SO_REUSEADDR on network sockets. 2025-12-16 06:24:30 +03:00
Adam Honse
a6b890a48d Use ResourceManager::RescanDevices() to initiate a rescan in places where ResourceManager::DetectDevices() was still being used 2025-11-14 20:31:10 -06:00
Adam Honse
c71cc4f18a Change SPDX license identifier from GPL 2.0 only to GPL 2.0 or later, as the original LICENSE file includes an or later clause at the end so the file headers were incorrect 2025-09-28 00:47:08 -05:00
Adam Honse
df73d0263a Add send_in_progress locks around send groups in NetworkServer.cpp 2025-07-04 23:37:23 -05:00
Adam Honse
0cfe5ae0bb Add SDK command to rescan devices 2025-07-04 04:24:37 -05:00
Adam Honse
85625a37b2 SDK cleanup, update SDK documentation 2025-02-06 20:00:27 -06:00
Adam Honse
1967ec9526 Save sizes file when server processes segment changes 2025-02-06 20:00:27 -06:00
Adam Honse
012cb5e62d Fix segment creation and modification over the network protocol 2025-02-06 20:00:27 -06:00
Adam Honse
ff2188ba45 Update SDK Documentation, fix plugin protocol version type in NetworkServer 2025-01-10 11:59:53 -06:00
morg
59e303c882 Add missing tags in logs 2025-01-10 08:53:31 +01:00
Adam Honse
471f9d3e2e Add server option to disable the size check called legacy workaround, which can be enabled to allow some old SDK apps that didn't properly implement the size to still be used 2025-01-08 20:44:20 -06:00
Adam Honse
39c968ff2a Fix some warnings in NetworkServer.cpp 2024-11-26 01:55:35 -06:00
Adam Honse
c1149da754 Fix possible loss of data warnings in NetworkServer.cpp 2024-08-17 00:24:18 -05:00
Adam Honse
fdd04a1511 Allow data size of zero for data length checks if protocol version is 4 or lower, this is to fix backwards compatibility with a bug in older versions OpenRGB.NET that has since been fixed. 2024-07-28 18:05:47 -05:00
Adam Honse
e7240ecca0 Improve logging in NetworkServer.cpp and close listener if any packet with an invalid size is received 2024-07-27 16:38:41 -05:00
Adam Honse
64a0d2c061 Add some size checks on the server to ensure received data matches the size from the packet header 2024-07-26 00:19:19 -05:00
Adam Honse
a7c400bc65 Update yet more file header comments to standardized new format 2024-05-03 21:56:32 -05:00
Adam Honse
89983dcdd1 Process received magic using a loop in client and server 2024-03-25 19:56:33 -05:00
Adam Honse
cf4fd16b09 Define SDK magic string value as a shared constant in NetworkProtocol.cpp, use InitNetPacketHeader function to set up packets 2024-03-25 19:45:06 -05:00
Adam Honse
9215ae0514 Clean up comment formatting in NetworkServer.cpp 2024-03-25 17:50:37 -05:00
Adam Honse
d7ed55b264 Use size when parsing received buffers into strings in NetworkServer 2023-10-01 22:43:32 -05:00
Jack
e15b299684 SDK Plugins Fix 2023-01-25 20:28:50 +00:00
Jack
4baf19f13a SDK plugin control 2023-01-25 17:50:28 +00:00
B Horn
a54f03e199 Fixing MacOS / Clang builds 2022-07-18 02:32:28 +00:00
B Horn
640eb7905c SDK Listening Options 2022-07-17 20:30:15 +00:00
Chris
f3eac499d4 Allow for server side controller resizing
* Save sizes profile on the server
* Update RGBController_Network size on the client
2022-07-04 20:16:39 +00:00
Alex
4af8614fce Add formated loging for device detection
Commits merged and amended for code style by Adam Honse <calcprogrammer1@gmail.com>
2021-07-05 03:23:34 -05:00
Adam Honse
5130f07e21 Add saving support to network protocol 2021-07-04 21:17:55 -05:00
Chris
a46eccef3c Added brightness to profile loading and saving
* Bumped profile version to 3
* Loading a v1/v2 profile onto a device with brightness will work
* Loading a v3 profile onto a device without brightness also works
* Add profile version parameter to Get/SetModeDescription

Commit amended for code style and to update versioning by Adam Honse <calcprogrammer1@gmail.com>
2021-07-04 21:16:56 -05:00
k1-801
65623d3978 Autoclose updated
Commit amended for code style by Adam Honse <calcprogrammer1@gmail.com>
2021-05-24 22:45:24 -05:00
k1-801
abfb6ea22d Tiny fixups (server conn info leak closed, log va leak closed, config dir optimized)
Commit amended for code style by Adam Honse <calcprogrammer1@gmail.com>
2021-05-24 22:41:12 -05:00
k1-801
02ba8a799e Server freed from ResourceManager
Commit amended to revert OpenRGBInterfaces.h header (may reconsider in the future) by Adam Honse
<calcprogrammer1@gmail.com>
2021-05-13 22:10:41 -05:00
Gabriel Marcano
30f88d5fcf Fix mismatched new[] / delete
- The device description buffer was allocated using new[] in
   RGBController. Make sure to free it using delete[].
2021-05-05 02:07:19 -07:00
morg
8ef9f622f1 Fix memory leak (RGBController::GetDeviceDescription) 2021-03-27 22:15:24 +01:00
morg
79dacbaeb0 Fix crash on server stop
Commit amended to initialize listening variable by Adam Honse <calcprogrammer1@gmail.com>
2021-02-09 16:34:25 -06:00
morg
e2bc1003e6 Add profile management to SDK
Commit amended for code style by Adam Honse <calcprogrammer1@gmail.com>
2021-02-05 19:13:50 -06:00
Adam Honse
72da8f362c SDK protocol versioning implemented. Protocol updated to version 1 which adds vendor string to controller request. 2020-12-01 21:02:32 -06:00
k1-801
dde857dfb4 Tiny threads fixes & a little bit of safety 2020-11-15 13:28:29 -06:00
Adam Honse
c3b4489fd3 Fix Windows build 2020-09-27 23:19:59 -05:00
Adam Honse
60fd721586 Server sends a request to the client when the device list is updated 2020-09-27 22:12:34 +00:00
Adam Honse
f568253c51 Clean up more warnings 2020-09-02 18:25:58 -05:00
k1-801
8b8451017e Non-important warnings removed
Commit amended by Adam Honse <calcprogrammer1@gmail.com> due to merging from a different branch.
2020-09-01 23:29:00 -05:00
B Horn
f02223d6ba Checks to avoid null dereferences in NetworkServer
Various commands in NetworkServer require extra data. However, if the
packet size is set to 0 for these, the code will skip over reading the
data in and allocating memory. This results in null dereferences.

This patch adds checks to the relevant commands to make sure they don't
continue reading a null pointer.
2020-07-19 13:16:19 -05:00
Adam Honse
0ccf2d0c33 Remove some debugging printouts in Network Client and Server code 2020-07-17 22:10:53 -05:00
B Horn
47baeb6b6b Improving NetworkServer's memory management (#373)
This patch resolves several bugs:

* NetworkServer would allocate various instances of `NetworkClientInfo`.
  This is patched by deallocating the NetworkClientInfo when it's
  listening thread ends in the `listen_done` section.

* Memory would be allocated for threads that wouldn't be freed. This
  is resolved by detaching from the threads, so they no longer need to
  be joined to be freed, and then freeing the memory as they finish.

* Thread-Safety issues involving `ServerClients` would result in stray
  `NetworkClientInfo`'s not being removed from the list in certain
  situations. This is resolved by used a mutex to lock access to this
  from different threads.
2020-07-09 21:56:42 -05:00
Adam Honse
96af869d79 Check for local server before detecting devices from hardware and tweak timeouts to make network connections faster 2020-06-28 21:08:59 -05:00
Térence Clastres
1db412e970 Fix high CPU usage when running the SDK server
It was coming from `recv_select()` and `accept_select()`
The timeval struct members for select() is reset after each call to select() for
whatever reason so like FD_ZERO and FD_SET it needs to be placed inside
the loop.

Source: https://stackoverflow.com/questions/3324078/why-select-always-return-0-after-the-first-timeout
2020-06-24 10:08:40 -05:00
Térence Clastres
b94f701db8 Fix high CPU usage when running the SDK server
It was coming from `recv_select()` `nd accept_select()`
The timeout for select() is only when waiting for the file descriptor to
be ready for reading/writing so when the FD is ready AND there is
nothing to read, it will not return and instead keep executing the while loop with no timeout.
Fix this by adding a 100ms timeout when there is nothing to read.
2020-06-24 09:35:31 -05:00
Térence Clastres
b79ff124e6 Replace Sleep() by std::thread::sleep_for() 2020-06-24 09:28:11 -05:00
Adam Honse
0464fbcbe2 Make default SDK port a defined constant 2020-06-22 11:32:32 -05:00