FreeRDP
pf_server.c File Reference
#include <winpr/crt.h>
#include <winpr/ssl.h>
#include <winpr/path.h>
#include <winpr/synch.h>
#include <winpr/string.h>
#include <winpr/winsock.h>
#include <winpr/thread.h>
#include <errno.h>
#include <freerdp/freerdp.h>
#include <freerdp/streamdump.h>
#include <freerdp/channels/wtsvc.h>
#include <freerdp/channels/channels.h>
#include <freerdp/build-config.h>
#include <freerdp/server/proxy/proxy_server.h>
#include <freerdp/server/proxy/proxy_log.h>
#include "pf_server.h"
#include <freerdp/server/proxy/proxy_config.h>
#include "pf_client.h"
#include <freerdp/server/proxy/proxy_context.h>
#include "pf_update.h"
#include "proxy_modules.h"
#include "pf_utils.h"

Macros

#define TAG   PROXY_TAG("server")
 
#define TARGET_MAX   (100)
 
#define ROUTING_TOKEN_PREFIX   "Cookie: msts="
 

Functions

static BOOL pf_server_parse_target_from_routing_token (rdpContext *context, char **target, DWORD *port)
 
static BOOL pf_server_get_target_info (rdpContext *context, rdpSettings *settings, const proxyConfig *config)
 
static BOOL pf_server_post_connect (freerdp_peer *peer)
 
static BOOL pf_server_activate (freerdp_peer *peer)
 
static BOOL pf_server_logon (freerdp_peer *peer, const SEC_WINNT_AUTH_IDENTITY *identity, BOOL automatic)
 
static BOOL pf_server_adjust_monitor_layout (freerdp_peer *peer)
 
static BOOL pf_server_receive_channel_data_hook (freerdp_peer *peer, UINT16 channelId, const BYTE *data, size_t size, UINT32 flags, size_t totalSize)
 
static BOOL pf_server_initialize_peer_connection (freerdp_peer *peer)
 
static DWORD WINAPI pf_server_handle_peer (LPVOID arg)
 
static BOOL pf_server_start_peer (freerdp_peer *client)
 
static BOOL pf_server_peer_accepted (freerdp_listener *listener, freerdp_peer *client)
 
BOOL pf_server_start (proxyServer *server)
 pf_server_start Starts the proxy, binding the configured port. More...
 
BOOL pf_server_start_from_socket (proxyServer *server, int socket)
 pf_server_start_from_socket Starts the proxy using an existing bound socket More...
 
BOOL pf_server_start_with_peer_socket (proxyServer *server, int peer_fd)
 pf_server_start_with_peer_socket Use existing peer socket More...
 
static BOOL are_all_required_modules_loaded (proxyModule *module, const proxyConfig *config)
 
static void peer_free (void *obj)
 
proxyServer * pf_server_new (const proxyConfig *config)
 pf_server_new Creates a new proxy server instance More...
 
BOOL pf_server_run (proxyServer *server)
 pf_server_run This (blocking) function runs the main loop of the proxy. More...
 
void pf_server_stop (proxyServer *server)
 pf_server_stop Stops a server instance asynchronously. Can be called from any thread to stop a running server instance. More...
 
void pf_server_free (proxyServer *server)
 pf_server_free Cleans up a (stopped) proxy server instance. More...
 
BOOL pf_server_add_module (proxyServer *server, proxyModuleEntryPoint ep, void *userdata)
 pf_server_add_module Allows registering proxy modules that are build-in instead of shipped as separate module loaded at runtime. More...
 

Macro Definition Documentation

◆ ROUTING_TOKEN_PREFIX

#define ROUTING_TOKEN_PREFIX   "Cookie: msts="

◆ TAG

#define TAG   PROXY_TAG("server")

FreeRDP: A Remote Desktop Protocol Implementation FreeRDP Proxy Server

Copyright 2019 Mati Shabtay matis.nosp@m.habt.nosp@m.ay@gm.nosp@m.ail..nosp@m.com Copyright 2019 Kobi Mizrachi kmizr.nosp@m.achi.nosp@m.18@gm.nosp@m.ail..nosp@m.com Copyright 2019 Idan Freiberg speid.nosp@m.y@gm.nosp@m.ail.c.nosp@m.om Copyright 2021 Armin Novak anova.nosp@m.k@th.nosp@m.incas.nosp@m.t.co.nosp@m.m Copyright 2021 Thincast Technologies GmbH

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.

◆ TARGET_MAX

#define TARGET_MAX   (100)

Function Documentation

◆ are_all_required_modules_loaded()

static BOOL are_all_required_modules_loaded ( proxyModule *  module,
const proxyConfig *  config 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ peer_free()

static void peer_free ( void *  obj)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_activate()

static BOOL pf_server_activate ( freerdp_peer *  peer)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_add_module()

BOOL pf_server_add_module ( proxyServer *  server,
proxyModuleEntryPoint  ep,
void *  userdata 
)

pf_server_add_module Allows registering proxy modules that are build-in instead of shipped as separate module loaded at runtime.

Parameters
serverA proxy instance to add the module to. Must NOT be NULL
epThe proxy entry function to add. Must NOT be NULL
userdataCustom data for the module. May be NULL
Returns
TRUE for success, FALSE otherwise.
Here is the call graph for this function:

◆ pf_server_adjust_monitor_layout()

static BOOL pf_server_adjust_monitor_layout ( freerdp_peer *  peer)
static
Here is the caller graph for this function:

◆ pf_server_free()

void pf_server_free ( proxyServer *  server)

pf_server_free Cleans up a (stopped) proxy server instance.

Parameters
serverThe proxy server to clean up. Might be NULL.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_get_target_info()

static BOOL pf_server_get_target_info ( rdpContext *  context,
rdpSettings *  settings,
const proxyConfig *  config 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_handle_peer()

static DWORD WINAPI pf_server_handle_peer ( LPVOID  arg)
static

Handles an incoming client connection, to be run in it's own thread.

arg is a pointer to a freerdp_peer representing the client.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_initialize_peer_connection()

static BOOL pf_server_initialize_peer_connection ( freerdp_peer *  peer)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_logon()

static BOOL pf_server_logon ( freerdp_peer *  peer,
const SEC_WINNT_AUTH_IDENTITY *  identity,
BOOL  automatic 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_new()

proxyServer* pf_server_new ( const proxyConfig *  config)

pf_server_new Creates a new proxy server instance

Parameters
configThe proxy server configuration to use. Must NOT be NULL.
Returns
A new proxy server instance or NULL on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_parse_target_from_routing_token()

static BOOL pf_server_parse_target_from_routing_token ( rdpContext *  context,
char **  target,
DWORD *  port 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_peer_accepted()

static BOOL pf_server_peer_accepted ( freerdp_listener *  listener,
freerdp_peer *  client 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_post_connect()

static BOOL pf_server_post_connect ( freerdp_peer *  peer)
static

This callback is called when the entire connection sequence is done (as described in MS-RDPBCGR section 1.3)

The server may start sending graphics output and receiving keyboard/mouse input after this callback returns.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_receive_channel_data_hook()

static BOOL pf_server_receive_channel_data_hook ( freerdp_peer *  peer,
UINT16  channelId,
const BYTE data,
size_t  size,
UINT32  flags,
size_t  totalSize 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_run()

BOOL pf_server_run ( proxyServer *  server)

pf_server_run This (blocking) function runs the main loop of the proxy.

Parameters
serverThe server instance. Must NOT be NULL.
Returns
TRUE for successful termination, FALSE otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_start()

BOOL pf_server_start ( proxyServer *  server)

pf_server_start Starts the proxy, binding the configured port.

Parameters
serverThe server instance. Must NOT be NULL.
Returns
TRUE for success, FALSE on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_start_from_socket()

BOOL pf_server_start_from_socket ( proxyServer *  server,
int  socket 
)

pf_server_start_from_socket Starts the proxy using an existing bound socket

Parameters
serverThe server instance. Must NOT be NULL.
socketThe bound socket to wait for events on.
Returns
TRUE for success, FALSE on error
Here is the call graph for this function:

◆ pf_server_start_peer()

static BOOL pf_server_start_peer ( freerdp_peer *  client)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pf_server_start_with_peer_socket()

BOOL pf_server_start_with_peer_socket ( proxyServer *  server,
int  socket 
)

pf_server_start_with_peer_socket Use existing peer socket

Parameters
serverThe server instance. Must NOT be NULL.
socketReady to use peer socket
Returns
TRUE for success, FALSE on error
Here is the call graph for this function:

◆ pf_server_stop()

void pf_server_stop ( proxyServer *  server)

pf_server_stop Stops a server instance asynchronously. Can be called from any thread to stop a running server instance.

Parameters
serverA pointer to the server instance to stop. May be NULL.
Here is the call graph for this function:
Here is the caller graph for this function: