diff --git a/server/proxy/CMakeLists.txt b/server/proxy/CMakeLists.txt index 46dc1208b..a944f005e 100644 --- a/server/proxy/CMakeLists.txt +++ b/server/proxy/CMakeLists.txt @@ -76,3 +76,5 @@ if (WITH_DEBUG_SYMBOLS AND MSVC) endif() set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/proxy") + +add_subdirectory("filters") diff --git a/server/proxy/config.ini b/server/proxy/config.ini index c52804141..fe29861e4 100644 --- a/server/proxy/config.ini +++ b/server/proxy/config.ini @@ -34,4 +34,4 @@ DeniedChannels = "Microsoft::Windows::RDS::Geometry" [Filters] ; FilterName = FilterPath -DemoFilter = "server/proxy/demo.so" +DemoFilter = "server/proxy/filters/libdemo_filter.so" diff --git a/server/proxy/filters/CMakeLists.txt b/server/proxy/filters/CMakeLists.txt new file mode 100644 index 000000000..43f753469 --- /dev/null +++ b/server/proxy/filters/CMakeLists.txt @@ -0,0 +1,3 @@ +add_library(demo_filter SHARED + filter_demo.c +) diff --git a/server/proxy/filters/filter_demo.c b/server/proxy/filters/filter_demo.c index c203c451a..fd3a31079 100644 --- a/server/proxy/filters/filter_demo.c +++ b/server/proxy/filters/filter_demo.c @@ -1,8 +1,29 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * FreeRDP Proxy Server + * + * Copyright 2019 Kobi Mizrachi + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "filters_api.h" static PF_FILTER_RESULT demo_filter_keyboard_event(connectionInfo* info, void* param) { proxyKeyboardEventInfo* event_data = (proxyKeyboardEventInfo*) param; + WINPR_UNUSED(event_data); + return FILTER_PASS; } @@ -18,10 +39,10 @@ static PF_FILTER_RESULT demo_filter_mouse_event(connectionInfo* info, void* para return FILTER_PASS; } -bool filter_init(proxyEvents* events) +BOOL filter_init(proxyEvents* events) { events->KeyboardEvent = demo_filter_keyboard_event; events->MouseEvent = demo_filter_mouse_event; - return true; + return TRUE; } diff --git a/server/proxy/filters/filters_api.h b/server/proxy/filters/filters_api.h index 648aa8485..644ebc962 100644 --- a/server/proxy/filters/filters_api.h +++ b/server/proxy/filters/filters_api.h @@ -22,8 +22,7 @@ #ifndef FREERDP_SERVER_PROXY_FILTERS_API_H #define FREERDP_SERVER_PROXY_FILTERS_API_H -#include -#include +#include enum pf_filter_result { FILTER_PASS = 0, @@ -51,21 +50,20 @@ struct proxy_events { #pragma pack(push, 1) struct proxy_keyboard_event_info { - uint16_t flags; - uint16_t rdp_scan_code; + UINT16 flags; + UINT16 rdp_scan_code; }; struct proxy_mouse_event_info { - uint16_t flags; - uint16_t x; - uint16_t y; + UINT16 flags; + UINT16 x; + UINT16 y; }; #pragma pack(pop) - /* implement this method and register callbacks for proxy events * return TRUE if initialization succeeded, otherwise FALSE. **/ -bool filter_init(proxyEvents* events); +BOOL filter_init(proxyEvents* events); #endif /* FREERDP_SERVER_PROXY_FILTERS_API_H */ diff --git a/server/proxy/freerdp_proxy.c b/server/proxy/freerdp_proxy.c index fa4ba92b1..80fa85adf 100644 --- a/server/proxy/freerdp_proxy.c +++ b/server/proxy/freerdp_proxy.c @@ -34,6 +34,7 @@ int main(int argc, char* argv[]) int status = 0; DWORD ld; UINT32 i; + UINT32 count; proxyConfig* config = calloc(1, sizeof(proxyConfig)); if (!config) @@ -61,15 +62,17 @@ int main(int argc, char* argv[]) if (config->WhitelistMode) { WLog_INFO(TAG, "Channels mode: WHITELIST"); + count = ArrayList_Count(config->AllowedChannels); - for (i = 0; i < ArrayList_Count(config->AllowedChannels); i++) + for (i = 0; i < count; i++) WLog_INFO(TAG, "Allowing %s", (char*) ArrayList_GetItem(config->AllowedChannels, i)); } else { WLog_INFO(TAG, "Channels mode: BLACKLIST"); + count = ArrayList_Count(config->BlockedChannels); - for (i = 0; i < ArrayList_Count(config->BlockedChannels); i++) + for (i = 0; i < count; i++) WLog_INFO(TAG, "Blocking %s", (char*) ArrayList_GetItem(config->BlockedChannels, i)); }