@@ -58,14 +58,17 @@ NetworkClientInfo::~NetworkClientInfo()
58
58
59
59
NetworkServer::NetworkServer (std::vector<RGBController *>& control) : controllers(control)
60
60
{
61
- host = OPENRGB_SDK_HOST;
62
- port_num = OPENRGB_SDK_PORT;
63
- server_online = false ;
64
- server_listening = false ;
61
+ host = OPENRGB_SDK_HOST;
62
+ port_num = OPENRGB_SDK_PORT;
63
+ server_online = false ;
64
+ server_listening = false ;
65
+ legacy_workaround_enabled = false ;
66
+
65
67
for (int i = 0 ; i < MAXSOCK; i++)
66
68
{
67
69
ConnectionThread[i] = nullptr ;
68
70
}
71
+
69
72
profile_manager = nullptr ;
70
73
}
71
74
@@ -221,6 +224,11 @@ void NetworkServer::SetHost(std::string new_host)
221
224
}
222
225
}
223
226
227
+ void NetworkServer::SetLegacyWorkaroundEnable (bool enable)
228
+ {
229
+ legacy_workaround_enabled = enable;
230
+ }
231
+
224
232
void NetworkServer::SetPort (unsigned short new_port)
225
233
{
226
234
if (server_online == false )
@@ -689,14 +697,15 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
689
697
| Verify the color description size (first 4 bytes of data) |
690
698
| matches the packet size in the header |
691
699
| |
692
- | If protocol version is 4 or below, allow the description |
693
- | size to be zero. This allows backwards compatibility with|
694
- | versions of the OpenRGB.NET SDK implementation which had |
695
- | a bug where this field would always be zero. |
700
+ | If protocol version is 4 or below and the legacy SDK |
701
+ | compatibility workaround is enabled, ignore this check. |
702
+ | This allows backwards compatibility with old versions of |
703
+ | SDK applications that didn't properly implement the size |
704
+ | field. |
696
705
\*---------------------------------------------------------*/
697
706
if ((header.pkt_size == *((unsigned int *)data))
698
707
|| ((client_info->client_protocol_version <= 4 )
699
- && (*(( unsigned int *)data) == 0 )))
708
+ && (legacy_workaround_enabled )))
700
709
{
701
710
if (header.pkt_dev_idx < controllers.size ())
702
711
{
@@ -721,14 +730,15 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
721
730
| Verify the color description size (first 4 bytes of data) |
722
731
| matches the packet size in the header |
723
732
| |
724
- | If protocol version is 4 or below, allow the description |
725
- | size to be zero. This allows backwards compatibility with|
726
- | versions of the OpenRGB.NET SDK implementation which had |
727
- | a bug where this field would always be zero. |
733
+ | If protocol version is 4 or below and the legacy SDK |
734
+ | compatibility workaround is enabled, ignore this check. |
735
+ | This allows backwards compatibility with old versions of |
736
+ | SDK applications that didn't properly implement the size |
737
+ | field. |
728
738
\*---------------------------------------------------------*/
729
739
if ((header.pkt_size == *((unsigned int *)data))
730
740
|| ((client_info->client_protocol_version <= 4 )
731
- && (*(( unsigned int *)data) == 0 )))
741
+ && (legacy_workaround_enabled )))
732
742
{
733
743
if (header.pkt_dev_idx < controllers.size ())
734
744
{
@@ -793,14 +803,15 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
793
803
| Verify the mode description size (first 4 bytes of data) |
794
804
| matches the packet size in the header |
795
805
| |
796
- | If protocol version is 4 or below, allow the description |
797
- | size to be zero. This allows backwards compatibility with|
798
- | versions of the OpenRGB.NET SDK implementation which had |
799
- | a bug where this field would always be zero. |
806
+ | If protocol version is 4 or below and the legacy SDK |
807
+ | compatibility workaround is enabled, ignore this check. |
808
+ | This allows backwards compatibility with old versions of |
809
+ | SDK applications that didn't properly implement the size |
810
+ | field. |
800
811
\*---------------------------------------------------------*/
801
812
if ((header.pkt_size == *((unsigned int *)data))
802
813
|| ((client_info->client_protocol_version <= 4 )
803
- && (*(( unsigned int *)data) == 0 )))
814
+ && (legacy_workaround_enabled )))
804
815
{
805
816
if (header.pkt_dev_idx < controllers.size ())
806
817
{
@@ -825,14 +836,15 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
825
836
| Verify the mode description size (first 4 bytes of data) |
826
837
| matches the packet size in the header |
827
838
| |
828
- | If protocol version is 4 or below, allow the description |
829
- | size to be zero. This allows backwards compatibility with|
830
- | versions of the OpenRGB.NET SDK implementation which had |
831
- | a bug where this field would always be zero. |
839
+ | If protocol version is 4 or below and the legacy SDK |
840
+ | compatibility workaround is enabled, ignore this check. |
841
+ | This allows backwards compatibility with old versions of |
842
+ | SDK applications that didn't properly implement the size |
843
+ | field. |
832
844
\*---------------------------------------------------------*/
833
845
if ((header.pkt_size == *((unsigned int *)data))
834
846
|| ((client_info->client_protocol_version <= 4 )
835
- && (*(( unsigned int *)data) == 0 )))
847
+ && (legacy_workaround_enabled )))
836
848
{
837
849
if (header.pkt_dev_idx < controllers.size ())
838
850
{
0 commit comments