From aa262d341d291c85f28c5494204ab0080cfdeabf Mon Sep 17 00:00:00 2001 From: kubistika Date: Sun, 26 May 2019 15:29:41 +0300 Subject: [PATCH] server/proxy: Use winpr library in proxy/filters --- server/proxy/CMakeLists.txt | 2 ++ server/proxy/config.ini | 2 +- server/proxy/filters/CMakeLists.txt | 3 +++ server/proxy/filters/filter_demo.c | 25 +++++++++++++++++++++++-- server/proxy/filters/filters_api.h | 16 +++++++--------- server/proxy/freerdp_proxy.c | 7 +++++-- 6 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 server/proxy/filters/CMakeLists.txt diff --git a/server/proxy/CMakeLists.txt b/server/proxy/CMakeLists.txt index 46dc120..a944f00 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 c528041..fe29861 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 0000000..43f7534 --- /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 c203c45..fd3a310 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 648aa84..644ebc9 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 fa4ba92..80fa85a 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)); } -- 2.7.4