mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
server/proxy: Use winpr library in proxy/filters
This commit is contained in:
@@ -76,3 +76,5 @@ if (WITH_DEBUG_SYMBOLS AND MSVC)
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/proxy")
|
||||
|
||||
add_subdirectory("filters")
|
||||
|
||||
@@ -34,4 +34,4 @@ DeniedChannels = "Microsoft::Windows::RDS::Geometry"
|
||||
|
||||
[Filters]
|
||||
; FilterName = FilterPath
|
||||
DemoFilter = "server/proxy/demo.so"
|
||||
DemoFilter = "server/proxy/filters/libdemo_filter.so"
|
||||
|
||||
3
server/proxy/filters/CMakeLists.txt
Normal file
3
server/proxy/filters/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
add_library(demo_filter SHARED
|
||||
filter_demo.c
|
||||
)
|
||||
@@ -1,8 +1,29 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* FreeRDP Proxy Server
|
||||
*
|
||||
* Copyright 2019 Kobi Mizrachi <kmizrachi18@gmail.com>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
#ifndef FREERDP_SERVER_PROXY_FILTERS_API_H
|
||||
#define FREERDP_SERVER_PROXY_FILTERS_API_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
#include <winpr/winpr.h>
|
||||
|
||||
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 */
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user