2019-05-17 15:32:54 +03:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* FreeRDP Proxy Server
|
|
|
|
*
|
|
|
|
* Copyright 2019 Mati Shabtay <matishabtay@gmail.com>
|
|
|
|
* Copyright 2019 Kobi Mizrachi <kmizrachi18@gmail.com>
|
|
|
|
* Copyright 2019 Idan Freiberg <speidy@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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FREERDP_SERVER_PROXY_PFCONTEXT_H
|
|
|
|
#define FREERDP_SERVER_PROXY_PFCONTEXT_H
|
|
|
|
|
|
|
|
#include <freerdp/freerdp.h>
|
|
|
|
#include <freerdp/channels/wtsvc.h>
|
|
|
|
#include <freerdp/client/rdpei.h>
|
2019-08-06 16:46:18 +03:00
|
|
|
#include <freerdp/client/rail.h>
|
|
|
|
#include <freerdp/server/rail.h>
|
2019-05-17 15:32:54 +03:00
|
|
|
#include <freerdp/client/rdpgfx.h>
|
|
|
|
#include <freerdp/server/rdpgfx.h>
|
2019-06-11 17:13:42 +03:00
|
|
|
#include <freerdp/client/disp.h>
|
|
|
|
#include <freerdp/server/disp.h>
|
2019-08-04 17:41:43 +03:00
|
|
|
#include <freerdp/server/cliprdr.h>
|
2019-08-13 13:53:36 +03:00
|
|
|
#include <freerdp/server/rdpsnd.h>
|
2019-06-11 17:13:42 +03:00
|
|
|
|
2019-05-17 15:32:54 +03:00
|
|
|
#include "pf_config.h"
|
|
|
|
#include "pf_server.h"
|
|
|
|
|
2020-06-10 10:16:59 +03:00
|
|
|
#define PROXY_SESSION_ID_LENGTH 32
|
|
|
|
|
2019-05-17 15:32:54 +03:00
|
|
|
typedef struct proxy_data proxyData;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wraps rdpContext and holds the state for the proxy's server.
|
|
|
|
*/
|
|
|
|
struct p_server_context
|
|
|
|
{
|
2019-09-08 18:10:50 +03:00
|
|
|
rdpContext context;
|
2019-05-17 15:32:54 +03:00
|
|
|
|
|
|
|
proxyData* pdata;
|
|
|
|
|
|
|
|
HANDLE vcm;
|
|
|
|
HANDLE dynvcReady;
|
|
|
|
|
2019-08-06 16:46:18 +03:00
|
|
|
RailServerContext* rail;
|
2019-05-17 15:32:54 +03:00
|
|
|
RdpgfxServerContext* gfx;
|
2019-06-11 17:13:42 +03:00
|
|
|
DispServerContext* disp;
|
2019-08-04 17:41:43 +03:00
|
|
|
CliprdrServerContext* cliprdr;
|
2019-08-13 13:53:36 +03:00
|
|
|
RdpsndServerContext* rdpsnd;
|
2020-02-02 16:15:28 +03:00
|
|
|
|
|
|
|
HANDLE* vc_handles; /* static virtual channels open handles */
|
|
|
|
wHashTable* vc_ids; /* channel_name -> channel_id map */
|
2019-05-17 15:32:54 +03:00
|
|
|
};
|
|
|
|
typedef struct p_server_context pServerContext;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wraps rdpContext and holds the state for the proxy's client.
|
|
|
|
*/
|
|
|
|
struct p_client_context
|
|
|
|
{
|
2019-09-08 18:10:50 +03:00
|
|
|
rdpContext context;
|
2019-05-17 15:32:54 +03:00
|
|
|
|
|
|
|
proxyData* pdata;
|
|
|
|
|
|
|
|
RdpeiClientContext* rdpei;
|
2019-10-22 16:06:05 +03:00
|
|
|
RdpgfxClientContext* gfx_proxy;
|
|
|
|
RdpgfxClientContext* gfx_decoder;
|
2019-06-11 17:13:42 +03:00
|
|
|
DispClientContext* disp;
|
2019-08-04 17:41:43 +03:00
|
|
|
CliprdrClientContext* cliprdr;
|
2019-08-06 16:46:18 +03:00
|
|
|
RailClientContext* rail;
|
2019-07-15 10:55:57 +03:00
|
|
|
|
|
|
|
/*
|
2019-07-16 13:28:14 +03:00
|
|
|
* In a case when freerdp_connect fails,
|
2019-07-15 10:55:57 +03:00
|
|
|
* Used for NLA fallback feature, to check if the server should close the connection.
|
2020-02-02 16:15:28 +03:00
|
|
|
* When it is set to TRUE, proxy's client knows it shouldn't signal the server thread to
|
|
|
|
* closed the connection when pf_client_post_disconnect is called, because it is trying to
|
|
|
|
* connect reconnect without NLA. It must be set to TRUE before the first try, and to FALSE
|
|
|
|
* after the connection fully established, to ensure graceful shutdown of the connection
|
|
|
|
* when it will be closed.
|
2019-07-15 10:55:57 +03:00
|
|
|
*/
|
2019-09-10 10:11:00 +03:00
|
|
|
BOOL allow_next_conn_failure;
|
2019-10-22 16:06:05 +03:00
|
|
|
|
2020-02-02 16:15:28 +03:00
|
|
|
wHashTable* vc_ids; /* channel_name -> channel_id map */
|
2019-05-17 15:32:54 +03:00
|
|
|
};
|
|
|
|
typedef struct p_client_context pClientContext;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds data common to both sides of a proxy's session.
|
|
|
|
*/
|
|
|
|
struct proxy_data
|
|
|
|
{
|
|
|
|
proxyConfig* config;
|
|
|
|
|
|
|
|
pServerContext* ps;
|
|
|
|
pClientContext* pc;
|
|
|
|
|
2019-07-16 16:13:12 +03:00
|
|
|
HANDLE abort_event;
|
|
|
|
HANDLE client_thread;
|
2019-11-12 11:42:28 +03:00
|
|
|
HANDLE gfx_server_ready;
|
2019-12-26 11:25:13 +03:00
|
|
|
|
2020-06-10 10:16:59 +03:00
|
|
|
char session_id[PROXY_SESSION_ID_LENGTH + 1];
|
2019-12-31 12:16:12 +03:00
|
|
|
|
|
|
|
/* used to external modules to store per-session info */
|
|
|
|
wHashTable* modules_info;
|
2019-05-17 15:32:54 +03:00
|
|
|
};
|
|
|
|
|
2019-09-08 18:10:50 +03:00
|
|
|
BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src);
|
|
|
|
BOOL pf_context_init_server_context(freerdp_peer* client);
|
2019-09-25 16:09:36 +03:00
|
|
|
pClientContext* pf_context_create_client_context(rdpSettings* clientSettings);
|
2019-07-16 16:13:12 +03:00
|
|
|
|
2019-08-19 16:05:59 +03:00
|
|
|
proxyData* proxy_data_new(void);
|
2019-12-26 11:25:13 +03:00
|
|
|
void proxy_data_set_client_context(proxyData* pdata, pClientContext* context);
|
|
|
|
void proxy_data_set_server_context(proxyData* pdata, pServerContext* context);
|
2019-05-26 15:33:28 +03:00
|
|
|
void proxy_data_free(proxyData* pdata);
|
2019-08-19 16:05:59 +03:00
|
|
|
|
2019-07-16 16:13:12 +03:00
|
|
|
BOOL proxy_data_shall_disconnect(proxyData* pdata);
|
2019-09-08 15:18:45 +03:00
|
|
|
void proxy_data_abort_connect(proxyData* pdata);
|
2019-07-16 16:13:12 +03:00
|
|
|
|
2019-05-17 15:32:54 +03:00
|
|
|
#endif /* FREERDP_SERVER_PROXY_PFCONTEXT_H */
|