FreeRDP
Loading...
Searching...
No Matches
pf_config.c
1
23#include <stdio.h>
24#include <string.h>
25#include <winpr/crt.h>
26#include <winpr/path.h>
27#include <winpr/collections.h>
28#include <winpr/cmdline.h>
29
30#include "pf_server.h"
31#include <freerdp/server/proxy/proxy_config.h>
32
33#include <freerdp/server/proxy/proxy_log.h>
34
35#include <freerdp/crypto/crypto.h>
36#include <freerdp/channels/cliprdr.h>
37#include <freerdp/channels/rdpsnd.h>
38#include <freerdp/channels/audin.h>
39#include <freerdp/channels/rdpdr.h>
40#include <freerdp/channels/disp.h>
41#include <freerdp/channels/rail.h>
42#include <freerdp/channels/rdpei.h>
43#include <freerdp/channels/tsmf.h>
44#include <freerdp/channels/video.h>
45#include <freerdp/channels/rdpecam.h>
46
47#include "pf_utils.h"
48
49#define TAG PROXY_TAG("config")
50
51#define CONFIG_PRINT_SECTION(section) WLog_INFO(TAG, "\t%s:", section)
52#define CONFIG_PRINT_SECTION_KEY(section, key) WLog_INFO(TAG, "\t%s/%s:", section, key)
53#define CONFIG_PRINT_STR(config, key) WLog_INFO(TAG, "\t\t%s: %s", #key, (config)->key)
54#define CONFIG_PRINT_STR_CONTENT(config, key) \
55 WLog_INFO(TAG, "\t\t%s: %s", #key, (config)->key ? "set" : NULL)
56#define CONFIG_PRINT_BOOL(config, key) WLog_INFO(TAG, "\t\t%s: %s", #key, boolstr((config)->key))
57#define CONFIG_PRINT_UINT16(config, key) WLog_INFO(TAG, "\t\t%s: %" PRIu16 "", #key, (config)->key)
58#define CONFIG_PRINT_UINT32(config, key) WLog_INFO(TAG, "\t\t%s: %" PRIu32 "", #key, (config)->key)
59
60static const char* bool_str_true = "true";
61static const char* bool_str_false = "false";
62static const char* boolstr(BOOL rc)
63{
64 return rc ? bool_str_true : bool_str_false;
65}
66
67static const char* section_server = "Server";
68static const char* key_host = "Host";
69static const char* key_port = "Port";
70
71static const char* section_target = "Target";
72static const char* key_target_fixed = "FixedTarget";
73static const char* key_target_user = "User";
74static const char* key_target_pwd = "Password";
75static const char* key_target_domain = "Domain";
76static const char* key_target_tls_seclevel = "TlsSecLevel";
77
78static const char* section_plugins = "Plugins";
79static const char* key_plugins_modules = "Modules";
80static const char* key_plugins_required = "Required";
81
82static const char* section_channels = "Channels";
83static const char* key_channels_gfx = "GFX";
84static const char* key_channels_disp = "DisplayControl";
85static const char* key_channels_clip = "Clipboard";
86static const char* key_channels_mic = "AudioInput";
87static const char* key_channels_sound = "AudioOutput";
88static const char* key_channels_rdpdr = "DeviceRedirection";
89static const char* key_channels_video = "VideoRedirection";
90static const char* key_channels_camera = "CameraRedirection";
91static const char* key_channels_rails = "RemoteApp";
92static const char* key_channels_blacklist = "PassthroughIsBlacklist";
93static const char* key_channels_pass = "Passthrough";
94static const char* key_channels_intercept = "Intercept";
95
96static const char* section_input = "Input";
97static const char* key_input_kbd = "Keyboard";
98static const char* key_input_mouse = "Mouse";
99static const char* key_input_multitouch = "Multitouch";
100
101static const char* section_security = "Security";
102static const char* key_security_server_nla = "ServerNlaSecurity";
103static const char* key_security_server_tls = "ServerTlsSecurity";
104static const char* key_security_server_rdp = "ServerRdpSecurity";
105static const char* key_security_client_nla = "ClientNlaSecurity";
106static const char* key_security_client_tls = "ClientTlsSecurity";
107static const char* key_security_client_rdp = "ClientRdpSecurity";
108static const char* key_security_client_fallback = "ClientAllowFallbackToTls";
109
110static const char* section_certificates = "Certificates";
111static const char* key_private_key_file = "PrivateKeyFile";
112static const char* key_private_key_content = "PrivateKeyContent";
113static const char* key_cert_file = "CertificateFile";
114static const char* key_cert_content = "CertificateContent";
115
116WINPR_ATTR_MALLOC(CommandLineParserFree, 1)
117WINPR_ATTR_NODISCARD
118static char** pf_config_parse_comma_separated_list(const char* list, size_t* count)
119{
120 if (!list || !count)
121 return NULL;
122
123 if (strlen(list) == 0)
124 {
125 *count = 0;
126 return NULL;
127 }
128
129 return CommandLineParseCommaSeparatedValues(list, count);
130}
131
132static BOOL pf_config_get_uint16(wIniFile* ini, const char* section, const char* key,
133 UINT16* result, BOOL required)
134{
135 int val = 0;
136 const char* strval = NULL;
137
138 WINPR_ASSERT(result);
139
140 strval = IniFile_GetKeyValueString(ini, section, key);
141 if (!strval && required)
142 {
143 WLog_ERR(TAG, "key '%s.%s' does not exist.", section, key);
144 return FALSE;
145 }
146 val = IniFile_GetKeyValueInt(ini, section, key);
147 if ((val <= 0) || (val > UINT16_MAX))
148 {
149 WLog_ERR(TAG, "invalid value %d for key '%s.%s'.", val, section, key);
150 return FALSE;
151 }
152
153 *result = (UINT16)val;
154 return TRUE;
155}
156
157static BOOL pf_config_get_uint32(wIniFile* ini, const char* section, const char* key,
158 UINT32* result, BOOL required)
159{
160 WINPR_ASSERT(result);
161
162 const char* strval = IniFile_GetKeyValueString(ini, section, key);
163 if (!strval)
164 {
165 if (required)
166 WLog_ERR(TAG, "key '%s.%s' does not exist.", section, key);
167 return !required;
168 }
169
170 const int val = IniFile_GetKeyValueInt(ini, section, key);
171 if (val < 0)
172 {
173 WLog_ERR(TAG, "invalid value %d for key '%s.%s'.", val, section, key);
174 return FALSE;
175 }
176
177 *result = (UINT32)val;
178 return TRUE;
179}
180
181static BOOL pf_config_get_bool(wIniFile* ini, const char* section, const char* key, BOOL fallback)
182{
183 int num_value = 0;
184 const char* str_value = NULL;
185
186 str_value = IniFile_GetKeyValueString(ini, section, key);
187 if (!str_value)
188 {
189 WLog_WARN(TAG, "key '%s.%s' not found, value defaults to %s.", section, key,
190 fallback ? bool_str_true : bool_str_false);
191 return fallback;
192 }
193
194 if (_stricmp(str_value, bool_str_true) == 0)
195 return TRUE;
196 if (_stricmp(str_value, bool_str_false) == 0)
197 return FALSE;
198
199 num_value = IniFile_GetKeyValueInt(ini, section, key);
200
201 if (num_value != 0)
202 return TRUE;
203
204 return FALSE;
205}
206
207static const char* pf_config_get_str(wIniFile* ini, const char* section, const char* key,
208 BOOL required)
209{
210 const char* value = NULL;
211
212 value = IniFile_GetKeyValueString(ini, section, key);
213
214 if (!value)
215 {
216 if (required)
217 WLog_ERR(TAG, "key '%s.%s' not found.", section, key);
218 return NULL;
219 }
220
221 return value;
222}
223
224static BOOL pf_config_load_server(wIniFile* ini, proxyConfig* config)
225{
226 WINPR_ASSERT(config);
227 const char* host = pf_config_get_str(ini, section_server, key_host, FALSE);
228
229 if (!host)
230 return TRUE;
231
232 free(config->Host);
233 config->Host = _strdup(host);
234
235 if (!config->Host)
236 return FALSE;
237
238 if (!pf_config_get_uint16(ini, section_server, key_port, &config->Port, TRUE))
239 return FALSE;
240
241 return TRUE;
242}
243
244static BOOL pf_config_load_target(wIniFile* ini, proxyConfig* config)
245{
246 const char* target_value = NULL;
247
248 WINPR_ASSERT(config);
249 config->FixedTarget = pf_config_get_bool(ini, section_target, key_target_fixed, FALSE);
250
251 if (!pf_config_get_uint16(ini, section_target, key_port, &config->TargetPort,
252 config->FixedTarget))
253 return FALSE;
254
255 if (!pf_config_get_uint32(ini, section_target, key_target_tls_seclevel,
256 &config->TargetTlsSecLevel, FALSE))
257 return FALSE;
258
259 if (config->FixedTarget)
260 {
261 target_value = pf_config_get_str(ini, section_target, key_host, TRUE);
262 if (!target_value)
263 return FALSE;
264
265 free(config->TargetHost);
266 config->TargetHost = _strdup(target_value);
267 if (!config->TargetHost)
268 return FALSE;
269 }
270
271 target_value = pf_config_get_str(ini, section_target, key_target_user, FALSE);
272 if (target_value)
273 {
274 free(config->TargetUser);
275 config->TargetUser = _strdup(target_value);
276 if (!config->TargetUser)
277 return FALSE;
278 }
279
280 target_value = pf_config_get_str(ini, section_target, key_target_pwd, FALSE);
281 if (target_value)
282 {
283 free(config->TargetPassword);
284 config->TargetPassword = _strdup(target_value);
285 if (!config->TargetPassword)
286 return FALSE;
287 }
288
289 target_value = pf_config_get_str(ini, section_target, key_target_domain, FALSE);
290 if (target_value)
291 {
292 free(config->TargetDomain);
293 config->TargetDomain = _strdup(target_value);
294 if (!config->TargetDomain)
295 return FALSE;
296 }
297
298 return TRUE;
299}
300
301static BOOL pf_config_load_channels(wIniFile* ini, proxyConfig* config)
302{
303 WINPR_ASSERT(config);
304 config->GFX = pf_config_get_bool(ini, section_channels, key_channels_gfx, TRUE);
305 config->DisplayControl = pf_config_get_bool(ini, section_channels, key_channels_disp, TRUE);
306 config->Clipboard = pf_config_get_bool(ini, section_channels, key_channels_clip, FALSE);
307 config->AudioOutput = pf_config_get_bool(ini, section_channels, key_channels_mic, TRUE);
308 config->AudioInput = pf_config_get_bool(ini, section_channels, key_channels_sound, TRUE);
309 config->DeviceRedirection = pf_config_get_bool(ini, section_channels, key_channels_rdpdr, TRUE);
310 config->VideoRedirection = pf_config_get_bool(ini, section_channels, key_channels_video, TRUE);
311 config->CameraRedirection =
312 pf_config_get_bool(ini, section_channels, key_channels_camera, TRUE);
313 config->RemoteApp = pf_config_get_bool(ini, section_channels, key_channels_rails, FALSE);
314 config->PassthroughIsBlacklist =
315 pf_config_get_bool(ini, section_channels, key_channels_blacklist, FALSE);
316 config->Passthrough = pf_config_parse_comma_separated_list(
317 pf_config_get_str(ini, section_channels, key_channels_pass, FALSE),
318 &config->PassthroughCount);
319 config->Intercept = pf_config_parse_comma_separated_list(
320 pf_config_get_str(ini, section_channels, key_channels_intercept, FALSE),
321 &config->InterceptCount);
322
323 return TRUE;
324}
325
326static BOOL pf_config_load_input(wIniFile* ini, proxyConfig* config)
327{
328 WINPR_ASSERT(config);
329 config->Keyboard = pf_config_get_bool(ini, section_input, key_input_kbd, TRUE);
330 config->Mouse = pf_config_get_bool(ini, section_input, key_input_mouse, TRUE);
331 config->Multitouch = pf_config_get_bool(ini, section_input, key_input_multitouch, TRUE);
332 return TRUE;
333}
334
335static BOOL pf_config_load_security(wIniFile* ini, proxyConfig* config)
336{
337 WINPR_ASSERT(config);
338 config->ServerTlsSecurity =
339 pf_config_get_bool(ini, section_security, key_security_server_tls, TRUE);
340 config->ServerNlaSecurity =
341 pf_config_get_bool(ini, section_security, key_security_server_nla, FALSE);
342 config->ServerRdpSecurity =
343 pf_config_get_bool(ini, section_security, key_security_server_rdp, TRUE);
344
345 config->ClientTlsSecurity =
346 pf_config_get_bool(ini, section_security, key_security_client_tls, TRUE);
347 config->ClientNlaSecurity =
348 pf_config_get_bool(ini, section_security, key_security_client_nla, TRUE);
349 config->ClientRdpSecurity =
350 pf_config_get_bool(ini, section_security, key_security_client_rdp, TRUE);
351 config->ClientAllowFallbackToTls =
352 pf_config_get_bool(ini, section_security, key_security_client_fallback, TRUE);
353 return TRUE;
354}
355
356static BOOL pf_config_load_modules(wIniFile* ini, proxyConfig* config)
357{
358 const char* modules_to_load = NULL;
359 const char* required_modules = NULL;
360
361 modules_to_load = pf_config_get_str(ini, section_plugins, key_plugins_modules, FALSE);
362 required_modules = pf_config_get_str(ini, section_plugins, key_plugins_required, FALSE);
363
364 WINPR_ASSERT(config);
365 config->Modules = pf_config_parse_comma_separated_list(modules_to_load, &config->ModulesCount);
366
367 config->RequiredPlugins =
368 pf_config_parse_comma_separated_list(required_modules, &config->RequiredPluginsCount);
369 return TRUE;
370}
371
372static char* pf_config_decode_base64(const char* data, const char* name, size_t* pLength)
373{
374 const char* headers[] = { "-----BEGIN PUBLIC KEY-----", "-----BEGIN RSA PUBLIC KEY-----",
375 "-----BEGIN CERTIFICATE-----", "-----BEGIN PRIVATE KEY-----",
376 "-----BEGIN RSA PRIVATE KEY-----" };
377
378 size_t decoded_length = 0;
379 char* decoded = NULL;
380 if (!data)
381 {
382 WLog_ERR(TAG, "Invalid base64 data [NULL] for %s", name);
383 return NULL;
384 }
385
386 WINPR_ASSERT(name);
387 WINPR_ASSERT(pLength);
388
389 const size_t length = strlen(data);
390
391 if (strncmp(data, "-----", 5) == 0)
392 {
393 BOOL expected = FALSE;
394 for (size_t x = 0; x < ARRAYSIZE(headers); x++)
395 {
396 const char* header = headers[x];
397
398 if (strncmp(data, header, strlen(header)) == 0)
399 expected = TRUE;
400 }
401
402 if (!expected)
403 {
404 /* Extract header for log message
405 * expected format is '----- SOMETEXT -----'
406 */
407 char hdr[128] = { 0 };
408 const char* end = strchr(&data[5], '-');
409 if (end)
410 {
411 while (*end == '-')
412 end++;
413
414 const size_t s = MIN(ARRAYSIZE(hdr) - 1ULL, (size_t)(end - data));
415 memcpy(hdr, data, s);
416 }
417
418 WLog_WARN(TAG, "PEM has unexpected header '%s'. Known supported headers are:", hdr);
419 for (size_t x = 0; x < ARRAYSIZE(headers); x++)
420 {
421 const char* header = headers[x];
422 WLog_WARN(TAG, "%s", header);
423 }
424 }
425
426 *pLength = length + 1;
427 return _strdup(data);
428 }
429
430 crypto_base64_decode(data, length, (BYTE**)&decoded, &decoded_length);
431 if (!decoded || decoded_length == 0)
432 {
433 WLog_ERR(TAG, "Failed to decode base64 data of length %" PRIuz " for %s", length, name);
434 free(decoded);
435 return NULL;
436 }
437
438 *pLength = strnlen(decoded, decoded_length) + 1;
439 return decoded;
440}
441
442static BOOL pf_config_load_certificates(wIniFile* ini, proxyConfig* config)
443{
444 const char* tmp1 = NULL;
445 const char* tmp2 = NULL;
446
447 WINPR_ASSERT(ini);
448 WINPR_ASSERT(config);
449
450 tmp1 = pf_config_get_str(ini, section_certificates, key_cert_file, FALSE);
451 if (tmp1)
452 {
453 if (!winpr_PathFileExists(tmp1))
454 {
455 WLog_ERR(TAG, "%s/%s file %s does not exist", section_certificates, key_cert_file,
456 tmp1);
457 return FALSE;
458 }
459 config->CertificateFile = _strdup(tmp1);
460 config->CertificatePEM =
461 crypto_read_pem(config->CertificateFile, &config->CertificatePEMLength);
462 if (!config->CertificatePEM)
463 return FALSE;
464 config->CertificatePEMLength += 1;
465 }
466 tmp2 = pf_config_get_str(ini, section_certificates, key_cert_content, FALSE);
467 if (tmp2)
468 {
469 if (strlen(tmp2) < 1)
470 {
471 WLog_ERR(TAG, "%s/%s has invalid empty value", section_certificates, key_cert_content);
472 return FALSE;
473 }
474 config->CertificateContent = _strdup(tmp2);
475 config->CertificatePEM = pf_config_decode_base64(
476 config->CertificateContent, "CertificateContent", &config->CertificatePEMLength);
477 if (!config->CertificatePEM)
478 return FALSE;
479 }
480 if (tmp1 && tmp2)
481 {
482 WLog_ERR(TAG,
483 "%s/%s and %s/%s are "
484 "mutually exclusive options",
485 section_certificates, key_cert_file, section_certificates, key_cert_content);
486 return FALSE;
487 }
488 else if (!tmp1 && !tmp2)
489 {
490 WLog_ERR(TAG,
491 "%s/%s or %s/%s are "
492 "required settings",
493 section_certificates, key_cert_file, section_certificates, key_cert_content);
494 return FALSE;
495 }
496
497 tmp1 = pf_config_get_str(ini, section_certificates, key_private_key_file, FALSE);
498 if (tmp1)
499 {
500 if (!winpr_PathFileExists(tmp1))
501 {
502 WLog_ERR(TAG, "%s/%s file %s does not exist", section_certificates,
503 key_private_key_file, tmp1);
504 return FALSE;
505 }
506 config->PrivateKeyFile = _strdup(tmp1);
507 config->PrivateKeyPEM =
508 crypto_read_pem(config->PrivateKeyFile, &config->PrivateKeyPEMLength);
509 if (!config->PrivateKeyPEM)
510 return FALSE;
511 config->PrivateKeyPEMLength += 1;
512 }
513 tmp2 = pf_config_get_str(ini, section_certificates, key_private_key_content, FALSE);
514 if (tmp2)
515 {
516 if (strlen(tmp2) < 1)
517 {
518 WLog_ERR(TAG, "%s/%s has invalid empty value", section_certificates,
519 key_private_key_content);
520 return FALSE;
521 }
522 config->PrivateKeyContent = _strdup(tmp2);
523 config->PrivateKeyPEM = pf_config_decode_base64(
524 config->PrivateKeyContent, "PrivateKeyContent", &config->PrivateKeyPEMLength);
525 if (!config->PrivateKeyPEM)
526 return FALSE;
527 }
528
529 if (tmp1 && tmp2)
530 {
531 WLog_ERR(TAG,
532 "%s/%s and %s/%s are "
533 "mutually exclusive options",
534 section_certificates, key_private_key_file, section_certificates,
535 key_private_key_content);
536 return FALSE;
537 }
538 else if (!tmp1 && !tmp2)
539 {
540 WLog_ERR(TAG,
541 "%s/%s or %s/%s are "
542 "are required settings",
543 section_certificates, key_private_key_file, section_certificates,
544 key_private_key_content);
545 return FALSE;
546 }
547
548 return TRUE;
549}
550
551proxyConfig* server_config_load_ini(wIniFile* ini)
552{
553 proxyConfig* config = NULL;
554
555 WINPR_ASSERT(ini);
556
557 config = calloc(1, sizeof(proxyConfig));
558 if (config)
559 {
560 /* Set default values != 0 */
561 config->TargetTlsSecLevel = 1;
562
563 /* Load from ini */
564 if (!pf_config_load_server(ini, config))
565 goto out;
566
567 if (!pf_config_load_target(ini, config))
568 goto out;
569
570 if (!pf_config_load_channels(ini, config))
571 goto out;
572
573 if (!pf_config_load_input(ini, config))
574 goto out;
575
576 if (!pf_config_load_security(ini, config))
577 goto out;
578
579 if (!pf_config_load_modules(ini, config))
580 goto out;
581
582 if (!pf_config_load_certificates(ini, config))
583 goto out;
584 config->ini = IniFile_Clone(ini);
585 if (!config->ini)
586 goto out;
587 }
588 return config;
589out:
590 WINPR_PRAGMA_DIAG_PUSH
591 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
592 pf_server_config_free(config);
593 WINPR_PRAGMA_DIAG_POP
594
595 return NULL;
596}
597
598BOOL pf_server_config_dump(const char* file)
599{
600 BOOL rc = FALSE;
601 wIniFile* ini = IniFile_New();
602 if (!ini)
603 return FALSE;
604
605 /* Proxy server configuration */
606 if (IniFile_SetKeyValueString(ini, section_server, key_host, "0.0.0.0") < 0)
607 goto fail;
608 if (IniFile_SetKeyValueInt(ini, section_server, key_port, 3389) < 0)
609 goto fail;
610
611 /* Target configuration */
612 if (IniFile_SetKeyValueString(ini, section_target, key_host, "somehost.example.com") < 0)
613 goto fail;
614 if (IniFile_SetKeyValueInt(ini, section_target, key_port, 3389) < 0)
615 goto fail;
616 if (IniFile_SetKeyValueString(ini, section_target, key_target_fixed, bool_str_true) < 0)
617 goto fail;
618 if (IniFile_SetKeyValueInt(ini, section_target, key_target_tls_seclevel, 1) < 0)
619 goto fail;
620
621 /* Channel configuration */
622 if (IniFile_SetKeyValueString(ini, section_channels, key_channels_gfx, bool_str_true) < 0)
623 goto fail;
624 if (IniFile_SetKeyValueString(ini, section_channels, key_channels_disp, bool_str_true) < 0)
625 goto fail;
626 if (IniFile_SetKeyValueString(ini, section_channels, key_channels_clip, bool_str_true) < 0)
627 goto fail;
628 if (IniFile_SetKeyValueString(ini, section_channels, key_channels_mic, bool_str_true) < 0)
629 goto fail;
630 if (IniFile_SetKeyValueString(ini, section_channels, key_channels_sound, bool_str_true) < 0)
631 goto fail;
632 if (IniFile_SetKeyValueString(ini, section_channels, key_channels_rdpdr, bool_str_true) < 0)
633 goto fail;
634 if (IniFile_SetKeyValueString(ini, section_channels, key_channels_video, bool_str_true) < 0)
635 goto fail;
636 if (IniFile_SetKeyValueString(ini, section_channels, key_channels_camera, bool_str_true) < 0)
637 goto fail;
638 if (IniFile_SetKeyValueString(ini, section_channels, key_channels_rails, bool_str_false) < 0)
639 goto fail;
640
641 if (IniFile_SetKeyValueString(ini, section_channels, key_channels_blacklist, bool_str_true) < 0)
642 goto fail;
643 if (IniFile_SetKeyValueString(ini, section_channels, key_channels_pass, "") < 0)
644 goto fail;
645 if (IniFile_SetKeyValueString(ini, section_channels, key_channels_intercept, "") < 0)
646 goto fail;
647
648 /* Input configuration */
649 if (IniFile_SetKeyValueString(ini, section_input, key_input_kbd, bool_str_true) < 0)
650 goto fail;
651 if (IniFile_SetKeyValueString(ini, section_input, key_input_mouse, bool_str_true) < 0)
652 goto fail;
653 if (IniFile_SetKeyValueString(ini, section_input, key_input_multitouch, bool_str_true) < 0)
654 goto fail;
655
656 /* Security settings */
657 if (IniFile_SetKeyValueString(ini, section_security, key_security_server_tls, bool_str_true) <
658 0)
659 goto fail;
660 if (IniFile_SetKeyValueString(ini, section_security, key_security_server_nla, bool_str_false) <
661 0)
662 goto fail;
663 if (IniFile_SetKeyValueString(ini, section_security, key_security_server_rdp, bool_str_true) <
664 0)
665 goto fail;
666
667 if (IniFile_SetKeyValueString(ini, section_security, key_security_client_tls, bool_str_true) <
668 0)
669 goto fail;
670 if (IniFile_SetKeyValueString(ini, section_security, key_security_client_nla, bool_str_true) <
671 0)
672 goto fail;
673 if (IniFile_SetKeyValueString(ini, section_security, key_security_client_rdp, bool_str_true) <
674 0)
675 goto fail;
676 if (IniFile_SetKeyValueString(ini, section_security, key_security_client_fallback,
677 bool_str_true) < 0)
678 goto fail;
679
680 /* Module configuration */
681 if (IniFile_SetKeyValueString(ini, section_plugins, key_plugins_modules,
682 "module1,module2,...") < 0)
683 goto fail;
684 if (IniFile_SetKeyValueString(ini, section_plugins, key_plugins_required,
685 "module1,module2,...") < 0)
686 goto fail;
687
688 /* Certificate configuration */
689 if (IniFile_SetKeyValueString(ini, section_certificates, key_cert_file,
690 "<absolute path to some certificate file> OR") < 0)
691 goto fail;
692 if (IniFile_SetKeyValueString(ini, section_certificates, key_cert_content,
693 "<Contents of some certificate file in PEM format>") < 0)
694 goto fail;
695
696 if (IniFile_SetKeyValueString(ini, section_certificates, key_private_key_file,
697 "<absolute path to some private key file> OR") < 0)
698 goto fail;
699 if (IniFile_SetKeyValueString(ini, section_certificates, key_private_key_content,
700 "<Contents of some private key file in PEM format>") < 0)
701 goto fail;
702
703 /* store configuration */
704 if (IniFile_WriteFile(ini, file) < 0)
705 goto fail;
706
707 rc = TRUE;
708
709fail:
710 IniFile_Free(ini);
711 return rc;
712}
713
714proxyConfig* pf_server_config_load_buffer(const char* buffer)
715{
716 proxyConfig* config = NULL;
717 wIniFile* ini = NULL;
718
719 ini = IniFile_New();
720
721 if (!ini)
722 {
723 WLog_ERR(TAG, "IniFile_New() failed!");
724 return NULL;
725 }
726
727 if (IniFile_ReadBuffer(ini, buffer) < 0)
728 {
729 WLog_ERR(TAG, "failed to parse ini: '%s'", buffer);
730 goto out;
731 }
732
733 config = server_config_load_ini(ini);
734out:
735 IniFile_Free(ini);
736 return config;
737}
738
739proxyConfig* pf_server_config_load_file(const char* path)
740{
741 proxyConfig* config = NULL;
742 wIniFile* ini = IniFile_New();
743
744 if (!ini)
745 {
746 WLog_ERR(TAG, "IniFile_New() failed!");
747 return NULL;
748 }
749
750 if (IniFile_ReadFile(ini, path) < 0)
751 {
752 WLog_ERR(TAG, "failed to parse ini file: '%s'", path);
753 goto out;
754 }
755
756 config = server_config_load_ini(ini);
757out:
758 IniFile_Free(ini);
759 return config;
760}
761
762static void pf_server_config_print_list(char** list, size_t count)
763{
764 WINPR_ASSERT(list);
765 for (size_t i = 0; i < count; i++)
766 WLog_INFO(TAG, "\t\t- %s", list[i]);
767}
768
769void pf_server_config_print(const proxyConfig* config)
770{
771 WINPR_ASSERT(config);
772 WLog_INFO(TAG, "Proxy configuration:");
773
774 CONFIG_PRINT_SECTION(section_server);
775 CONFIG_PRINT_STR(config, Host);
776 CONFIG_PRINT_UINT16(config, Port);
777
778 if (config->FixedTarget)
779 {
780 CONFIG_PRINT_SECTION(section_target);
781 CONFIG_PRINT_STR(config, TargetHost);
782 CONFIG_PRINT_UINT16(config, TargetPort);
783 CONFIG_PRINT_UINT32(config, TargetTlsSecLevel);
784
785 if (config->TargetUser)
786 CONFIG_PRINT_STR(config, TargetUser);
787 if (config->TargetDomain)
788 CONFIG_PRINT_STR(config, TargetDomain);
789 }
790
791 CONFIG_PRINT_SECTION(section_input);
792 CONFIG_PRINT_BOOL(config, Keyboard);
793 CONFIG_PRINT_BOOL(config, Mouse);
794 CONFIG_PRINT_BOOL(config, Multitouch);
795
796 CONFIG_PRINT_SECTION(section_security);
797 CONFIG_PRINT_BOOL(config, ServerNlaSecurity);
798 CONFIG_PRINT_BOOL(config, ServerTlsSecurity);
799 CONFIG_PRINT_BOOL(config, ServerRdpSecurity);
800 CONFIG_PRINT_BOOL(config, ClientNlaSecurity);
801 CONFIG_PRINT_BOOL(config, ClientTlsSecurity);
802 CONFIG_PRINT_BOOL(config, ClientRdpSecurity);
803 CONFIG_PRINT_BOOL(config, ClientAllowFallbackToTls);
804
805 CONFIG_PRINT_SECTION(section_channels);
806 CONFIG_PRINT_BOOL(config, GFX);
807 CONFIG_PRINT_BOOL(config, DisplayControl);
808 CONFIG_PRINT_BOOL(config, Clipboard);
809 CONFIG_PRINT_BOOL(config, AudioOutput);
810 CONFIG_PRINT_BOOL(config, AudioInput);
811 CONFIG_PRINT_BOOL(config, DeviceRedirection);
812 CONFIG_PRINT_BOOL(config, VideoRedirection);
813 CONFIG_PRINT_BOOL(config, CameraRedirection);
814 CONFIG_PRINT_BOOL(config, RemoteApp);
815 CONFIG_PRINT_BOOL(config, PassthroughIsBlacklist);
816
817 if (config->PassthroughCount)
818 {
819 WLog_INFO(TAG, "\tStatic Channels Proxy:");
820 pf_server_config_print_list(config->Passthrough, config->PassthroughCount);
821 }
822
823 if (config->InterceptCount)
824 {
825 WLog_INFO(TAG, "\tStatic Channels Proxy-Intercept:");
826 pf_server_config_print_list(config->Intercept, config->InterceptCount);
827 }
828
829 /* modules */
830 CONFIG_PRINT_SECTION_KEY(section_plugins, key_plugins_modules);
831 for (size_t x = 0; x < config->ModulesCount; x++)
832 CONFIG_PRINT_STR(config, Modules[x]);
833
834 /* Required plugins */
835 CONFIG_PRINT_SECTION_KEY(section_plugins, key_plugins_required);
836 for (size_t x = 0; x < config->RequiredPluginsCount; x++)
837 CONFIG_PRINT_STR(config, RequiredPlugins[x]);
838
839 CONFIG_PRINT_SECTION(section_certificates);
840 CONFIG_PRINT_STR(config, CertificateFile);
841 CONFIG_PRINT_STR_CONTENT(config, CertificateContent);
842 CONFIG_PRINT_STR(config, PrivateKeyFile);
843 CONFIG_PRINT_STR_CONTENT(config, PrivateKeyContent);
844}
845
846static void zfree(char* str)
847{
848 if (!str)
849 return;
850 const size_t len = strlen(str);
851 memset(str, 0, len);
852 free(str);
853}
854
855static void znfree(char* str, size_t len)
856{
857 if (!str)
858 return;
859 memset(str, 0, len);
860 free(str);
861}
862
863void pf_server_config_free(proxyConfig* config)
864{
865 if (config == NULL)
866 return;
867
868 free(config->Host);
869 free(config->TargetHost);
870 free(config->TargetUser);
871 free(config->TargetDomain);
872 free(config->TargetPassword);
873
874 CommandLineParserFree(config->Passthrough);
875 CommandLineParserFree(config->Intercept);
876 CommandLineParserFree(config->Modules);
877 CommandLineParserFree(config->RequiredPlugins);
878
879 free(config->CertificateFile);
880 zfree(config->CertificateContent);
881 znfree(config->CertificatePEM, config->CertificatePEMLength);
882 free(config->PrivateKeyFile);
883 zfree(config->PrivateKeyContent);
884 znfree(config->PrivateKeyPEM, config->PrivateKeyPEMLength);
885 IniFile_Free(config->ini);
886 free(config);
887}
888
889size_t pf_config_required_plugins_count(const proxyConfig* config)
890{
891 WINPR_ASSERT(config);
892 return config->RequiredPluginsCount;
893}
894
895const char* pf_config_required_plugin(const proxyConfig* config, size_t index)
896{
897 WINPR_ASSERT(config);
898 if (index >= config->RequiredPluginsCount)
899 return NULL;
900
901 return config->RequiredPlugins[index];
902}
903
904size_t pf_config_modules_count(const proxyConfig* config)
905{
906 WINPR_ASSERT(config);
907 return config->ModulesCount;
908}
909
910const char** pf_config_modules(const proxyConfig* config)
911{
912 union
913 {
914 char** ppc;
915 const char** cppc;
916 } cnv;
917
918 WINPR_ASSERT(config);
919
920 cnv.ppc = config->Modules;
921 return cnv.cppc;
922}
923
924static BOOL pf_config_copy_string(char** dst, const char* src)
925{
926 *dst = NULL;
927 if (src)
928 *dst = _strdup(src);
929 return TRUE;
930}
931
932static BOOL pf_config_copy_string_n(char** dst, const char* src, size_t size)
933{
934 *dst = NULL;
935
936 if (src && (size > 0))
937 {
938 WINPR_ASSERT(strnlen(src, size) == size - 1);
939 *dst = calloc(size, sizeof(char));
940 if (!*dst)
941 return FALSE;
942 memcpy(*dst, src, size);
943 }
944
945 return TRUE;
946}
947
948static BOOL pf_config_copy_string_list(char*** dst, size_t* size, char** src, size_t srcSize)
949{
950 WINPR_ASSERT(dst);
951 WINPR_ASSERT(size);
952 WINPR_ASSERT(src || (srcSize == 0));
953
954 *dst = NULL;
955 *size = 0;
956 if (srcSize > INT32_MAX)
957 return FALSE;
958
959 if (srcSize != 0)
960 {
961 char* csv = CommandLineToCommaSeparatedValues((INT32)srcSize, src);
962 *dst = CommandLineParseCommaSeparatedValues(csv, size);
963 free(csv);
964 }
965
966 return TRUE;
967}
968
969BOOL pf_config_clone(proxyConfig** dst, const proxyConfig* config)
970{
971 proxyConfig* tmp = calloc(1, sizeof(proxyConfig));
972
973 WINPR_ASSERT(dst);
974 WINPR_ASSERT(config);
975
976 if (!tmp)
977 return FALSE;
978
979 *tmp = *config;
980
981 if (!pf_config_copy_string(&tmp->Host, config->Host))
982 goto fail;
983 if (!pf_config_copy_string(&tmp->TargetHost, config->TargetHost))
984 goto fail;
985
986 if (!pf_config_copy_string_list(&tmp->Passthrough, &tmp->PassthroughCount, config->Passthrough,
987 config->PassthroughCount))
988 goto fail;
989 if (!pf_config_copy_string_list(&tmp->Intercept, &tmp->InterceptCount, config->Intercept,
990 config->InterceptCount))
991 goto fail;
992 if (!pf_config_copy_string_list(&tmp->Modules, &tmp->ModulesCount, config->Modules,
993 config->ModulesCount))
994 goto fail;
995 if (!pf_config_copy_string_list(&tmp->RequiredPlugins, &tmp->RequiredPluginsCount,
996 config->RequiredPlugins, config->RequiredPluginsCount))
997 goto fail;
998 if (!pf_config_copy_string(&tmp->CertificateFile, config->CertificateFile))
999 goto fail;
1000 if (!pf_config_copy_string(&tmp->CertificateContent, config->CertificateContent))
1001 goto fail;
1002 if (!pf_config_copy_string_n(&tmp->CertificatePEM, config->CertificatePEM,
1003 config->CertificatePEMLength))
1004 goto fail;
1005 if (!pf_config_copy_string(&tmp->PrivateKeyFile, config->PrivateKeyFile))
1006 goto fail;
1007 if (!pf_config_copy_string(&tmp->PrivateKeyContent, config->PrivateKeyContent))
1008 goto fail;
1009 if (!pf_config_copy_string_n(&tmp->PrivateKeyPEM, config->PrivateKeyPEM,
1010 config->PrivateKeyPEMLength))
1011 goto fail;
1012
1013 tmp->ini = IniFile_Clone(config->ini);
1014 if (!tmp->ini)
1015 goto fail;
1016
1017 *dst = tmp;
1018 return TRUE;
1019
1020fail:
1021 WINPR_PRAGMA_DIAG_PUSH
1022 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
1024 WINPR_PRAGMA_DIAG_POP
1025 return FALSE;
1026}
1027
1028struct config_plugin_data
1029{
1030 proxyPluginsManager* mgr;
1031 const proxyConfig* config;
1032};
1033
1034static const char config_plugin_name[] = "config";
1035static const char config_plugin_desc[] =
1036 "A plugin filtering according to proxy configuration file rules";
1037
1038static BOOL config_plugin_unload(proxyPlugin* plugin)
1039{
1040 WINPR_ASSERT(plugin);
1041
1042 /* Here we have to free up our custom data storage. */
1043 if (plugin)
1044 {
1045 free(plugin->custom);
1046 plugin->custom = NULL;
1047 }
1048
1049 return TRUE;
1050}
1051
1052static BOOL config_plugin_keyboard_event(proxyPlugin* plugin, WINPR_ATTR_UNUSED proxyData* pdata,
1053 void* param)
1054{
1055 BOOL rc = 0;
1056 const struct config_plugin_data* custom = NULL;
1057 const proxyConfig* cfg = NULL;
1058 const proxyKeyboardEventInfo* event_data = (const proxyKeyboardEventInfo*)(param);
1059
1060 WINPR_ASSERT(plugin);
1061 WINPR_ASSERT(pdata);
1062 WINPR_ASSERT(event_data);
1063
1064 WINPR_UNUSED(event_data);
1065
1066 custom = plugin->custom;
1067 WINPR_ASSERT(custom);
1068
1069 cfg = custom->config;
1070 WINPR_ASSERT(cfg);
1071
1072 rc = cfg->Keyboard;
1073 WLog_DBG(TAG, "%s", boolstr(rc));
1074 return rc;
1075}
1076
1077static BOOL config_plugin_unicode_event(proxyPlugin* plugin, WINPR_ATTR_UNUSED proxyData* pdata,
1078 void* param)
1079{
1080 BOOL rc = 0;
1081 const struct config_plugin_data* custom = NULL;
1082 const proxyConfig* cfg = NULL;
1083 const proxyUnicodeEventInfo* event_data = (const proxyUnicodeEventInfo*)(param);
1084
1085 WINPR_ASSERT(plugin);
1086 WINPR_ASSERT(pdata);
1087 WINPR_ASSERT(event_data);
1088
1089 WINPR_UNUSED(event_data);
1090
1091 custom = plugin->custom;
1092 WINPR_ASSERT(custom);
1093
1094 cfg = custom->config;
1095 WINPR_ASSERT(cfg);
1096
1097 rc = cfg->Keyboard;
1098 WLog_DBG(TAG, "%s", boolstr(rc));
1099 return rc;
1100}
1101
1102static BOOL config_plugin_mouse_event(proxyPlugin* plugin, WINPR_ATTR_UNUSED proxyData* pdata,
1103 void* param)
1104{
1105 BOOL rc = 0;
1106 const struct config_plugin_data* custom = NULL;
1107 const proxyConfig* cfg = NULL;
1108 const proxyMouseEventInfo* event_data = (const proxyMouseEventInfo*)(param);
1109
1110 WINPR_ASSERT(plugin);
1111 WINPR_ASSERT(pdata);
1112 WINPR_ASSERT(event_data);
1113
1114 WINPR_UNUSED(event_data);
1115
1116 custom = plugin->custom;
1117 WINPR_ASSERT(custom);
1118
1119 cfg = custom->config;
1120 WINPR_ASSERT(cfg);
1121
1122 rc = cfg->Mouse;
1123 return rc;
1124}
1125
1126static BOOL config_plugin_mouse_ex_event(proxyPlugin* plugin, WINPR_ATTR_UNUSED proxyData* pdata,
1127 void* param)
1128{
1129 BOOL rc = 0;
1130 const struct config_plugin_data* custom = NULL;
1131 const proxyConfig* cfg = NULL;
1132 const proxyMouseExEventInfo* event_data = (const proxyMouseExEventInfo*)(param);
1133
1134 WINPR_ASSERT(plugin);
1135 WINPR_ASSERT(pdata);
1136 WINPR_ASSERT(event_data);
1137
1138 WINPR_UNUSED(event_data);
1139
1140 custom = plugin->custom;
1141 WINPR_ASSERT(custom);
1142
1143 cfg = custom->config;
1144 WINPR_ASSERT(cfg);
1145
1146 rc = cfg->Mouse;
1147 return rc;
1148}
1149
1150static BOOL config_plugin_client_channel_data(WINPR_ATTR_UNUSED proxyPlugin* plugin,
1151 WINPR_ATTR_UNUSED proxyData* pdata, void* param)
1152{
1153 const proxyChannelDataEventInfo* channel = (const proxyChannelDataEventInfo*)(param);
1154
1155 WINPR_ASSERT(plugin);
1156 WINPR_ASSERT(pdata);
1157 WINPR_ASSERT(channel);
1158
1159 WLog_DBG(TAG, "%s [0x%04" PRIx16 "] got %" PRIuz, channel->channel_name, channel->channel_id,
1160 channel->data_len);
1161 return TRUE;
1162}
1163
1164static BOOL config_plugin_server_channel_data(WINPR_ATTR_UNUSED proxyPlugin* plugin,
1165 WINPR_ATTR_UNUSED proxyData* pdata, void* param)
1166{
1167 const proxyChannelDataEventInfo* channel = (const proxyChannelDataEventInfo*)(param);
1168
1169 WINPR_ASSERT(plugin);
1170 WINPR_ASSERT(pdata);
1171 WINPR_ASSERT(channel);
1172
1173 WLog_DBG(TAG, "%s [0x%04" PRIx16 "] got %" PRIuz, channel->channel_name, channel->channel_id,
1174 channel->data_len);
1175 return TRUE;
1176}
1177
1178static BOOL config_plugin_dynamic_channel_create(proxyPlugin* plugin,
1179 WINPR_ATTR_UNUSED proxyData* pdata, void* param)
1180{
1181 BOOL accept = 0;
1182 const proxyChannelDataEventInfo* channel = (const proxyChannelDataEventInfo*)(param);
1183
1184 WINPR_ASSERT(plugin);
1185 WINPR_ASSERT(pdata);
1186 WINPR_ASSERT(channel);
1187
1188 const struct config_plugin_data* custom = plugin->custom;
1189 WINPR_ASSERT(custom);
1190
1191 const proxyConfig* cfg = custom->config;
1192 WINPR_ASSERT(cfg);
1193
1194 pf_utils_channel_mode rc = pf_utils_get_channel_mode(cfg, channel->channel_name);
1195 switch (rc)
1196 {
1197
1198 case PF_UTILS_CHANNEL_INTERCEPT:
1199 case PF_UTILS_CHANNEL_PASSTHROUGH:
1200 accept = TRUE;
1201 break;
1202 case PF_UTILS_CHANNEL_BLOCK:
1203 default:
1204 accept = FALSE;
1205 break;
1206 }
1207
1208 if (accept)
1209 {
1210 if (strncmp(RDPGFX_DVC_CHANNEL_NAME, channel->channel_name,
1211 sizeof(RDPGFX_DVC_CHANNEL_NAME)) == 0)
1212 accept = cfg->GFX;
1213 else if (strncmp(RDPSND_DVC_CHANNEL_NAME, channel->channel_name,
1214 sizeof(RDPSND_DVC_CHANNEL_NAME)) == 0)
1215 accept = cfg->AudioOutput;
1216 else if (strncmp(RDPSND_LOSSY_DVC_CHANNEL_NAME, channel->channel_name,
1217 sizeof(RDPSND_LOSSY_DVC_CHANNEL_NAME)) == 0)
1218 accept = cfg->AudioOutput;
1219 else if (strncmp(AUDIN_DVC_CHANNEL_NAME, channel->channel_name,
1220 sizeof(AUDIN_DVC_CHANNEL_NAME)) == 0)
1221 accept = cfg->AudioInput;
1222 else if (strncmp(RDPEI_DVC_CHANNEL_NAME, channel->channel_name,
1223 sizeof(RDPEI_DVC_CHANNEL_NAME)) == 0)
1224 accept = cfg->Multitouch;
1225 else if (strncmp(TSMF_DVC_CHANNEL_NAME, channel->channel_name,
1226 sizeof(TSMF_DVC_CHANNEL_NAME)) == 0)
1227 accept = cfg->VideoRedirection;
1228 else if (strncmp(VIDEO_CONTROL_DVC_CHANNEL_NAME, channel->channel_name,
1229 sizeof(VIDEO_CONTROL_DVC_CHANNEL_NAME)) == 0)
1230 accept = cfg->VideoRedirection;
1231 else if (strncmp(VIDEO_DATA_DVC_CHANNEL_NAME, channel->channel_name,
1232 sizeof(VIDEO_DATA_DVC_CHANNEL_NAME)) == 0)
1233 accept = cfg->VideoRedirection;
1234 else if (strncmp(RDPECAM_DVC_CHANNEL_NAME, channel->channel_name,
1235 sizeof(RDPECAM_DVC_CHANNEL_NAME)) == 0)
1236 accept = cfg->CameraRedirection;
1237 }
1238
1239 WLog_DBG(TAG, "%s [0x%04" PRIx16 "]: %s", channel->channel_name, channel->channel_id,
1240 boolstr(accept));
1241 return accept;
1242}
1243
1244static BOOL config_plugin_channel_create(proxyPlugin* plugin, WINPR_ATTR_UNUSED proxyData* pdata,
1245 void* param)
1246{
1247 BOOL accept = 0;
1248 const proxyChannelDataEventInfo* channel = (const proxyChannelDataEventInfo*)(param);
1249
1250 WINPR_ASSERT(plugin);
1251 WINPR_ASSERT(pdata);
1252 WINPR_ASSERT(channel);
1253
1254 const struct config_plugin_data* custom = plugin->custom;
1255 WINPR_ASSERT(custom);
1256
1257 const proxyConfig* cfg = custom->config;
1258 WINPR_ASSERT(cfg);
1259
1260 pf_utils_channel_mode rc = pf_utils_get_channel_mode(cfg, channel->channel_name);
1261 switch (rc)
1262 {
1263 case PF_UTILS_CHANNEL_INTERCEPT:
1264 case PF_UTILS_CHANNEL_PASSTHROUGH:
1265 accept = TRUE;
1266 break;
1267 case PF_UTILS_CHANNEL_BLOCK:
1268 default:
1269 accept = FALSE;
1270 break;
1271 }
1272 if (accept)
1273 {
1274 if (strncmp(CLIPRDR_SVC_CHANNEL_NAME, channel->channel_name,
1275 sizeof(CLIPRDR_SVC_CHANNEL_NAME)) == 0)
1276 accept = cfg->Clipboard;
1277 else if (strncmp(RDPSND_CHANNEL_NAME, channel->channel_name, sizeof(RDPSND_CHANNEL_NAME)) ==
1278 0)
1279 accept = cfg->AudioOutput;
1280 else if (strncmp(RDPDR_SVC_CHANNEL_NAME, channel->channel_name,
1281 sizeof(RDPDR_SVC_CHANNEL_NAME)) == 0)
1282 accept = cfg->DeviceRedirection;
1283 else if (strncmp(DISP_DVC_CHANNEL_NAME, channel->channel_name,
1284 sizeof(DISP_DVC_CHANNEL_NAME)) == 0)
1285 accept = cfg->DisplayControl;
1286 else if (strncmp(RAIL_SVC_CHANNEL_NAME, channel->channel_name,
1287 sizeof(RAIL_SVC_CHANNEL_NAME)) == 0)
1288 accept = cfg->RemoteApp;
1289 }
1290
1291 WLog_DBG(TAG, "%s [static]: %s", channel->channel_name, boolstr(accept));
1292 return accept;
1293}
1294
1295BOOL pf_config_plugin(proxyPluginsManager* plugins_manager, void* userdata)
1296{
1297 struct config_plugin_data* custom = NULL;
1298 proxyPlugin plugin = { 0 };
1299
1300 plugin.name = config_plugin_name;
1301 plugin.description = config_plugin_desc;
1302 plugin.PluginUnload = config_plugin_unload;
1303
1304 plugin.KeyboardEvent = config_plugin_keyboard_event;
1305 plugin.UnicodeEvent = config_plugin_unicode_event;
1306 plugin.MouseEvent = config_plugin_mouse_event;
1307 plugin.MouseExEvent = config_plugin_mouse_ex_event;
1308 plugin.ClientChannelData = config_plugin_client_channel_data;
1309 plugin.ServerChannelData = config_plugin_server_channel_data;
1310 plugin.ChannelCreate = config_plugin_channel_create;
1311 plugin.DynamicChannelCreate = config_plugin_dynamic_channel_create;
1312 plugin.userdata = userdata;
1313
1314 custom = calloc(1, sizeof(struct config_plugin_data));
1315 if (!custom)
1316 return FALSE;
1317
1318 custom->mgr = plugins_manager;
1319 custom->config = userdata;
1320
1321 plugin.custom = custom;
1322 plugin.userdata = userdata;
1323
1324 return plugins_manager->RegisterPlugin(plugins_manager, &plugin);
1325}
1326
1327const char* pf_config_get(const proxyConfig* config, const char* section, const char* key)
1328{
1329 WINPR_ASSERT(config);
1330 WINPR_ASSERT(config->ini);
1331 WINPR_ASSERT(section);
1332 WINPR_ASSERT(key);
1333
1334 return IniFile_GetKeyValueString(config->ini, section, key);
1335}
void pf_server_config_free(proxyConfig *config)
pf_server_config_free Releases all resources associated with proxyConfig
Definition pf_config.c:863
proxyConfig * pf_server_config_load_file(const char *path)
pf_server_config_load_file Create a proxyConfig from a INI file found at path.
Definition pf_config.c:739
void pf_server_config_print(const proxyConfig *config)
pf_server_config_print Print the configuration to stdout
Definition pf_config.c:769
proxyConfig * pf_server_config_load_buffer(const char *buffer)
pf_server_config_load_buffer Create a proxyConfig from a memory string buffer in INI file format
Definition pf_config.c:714
BOOL pf_config_clone(proxyConfig **dst, const proxyConfig *config)
pf_config_clone Create a copy of the configuration
Definition pf_config.c:969
BOOL pf_server_config_dump(const char *file)
pf_server_config_dump Dumps a default INI configuration file
Definition pf_config.c:598
const char * pf_config_get(const proxyConfig *config, const char *section, const char *key)
pf_config_get get a value for a section/key
Definition pf_config.c:1327
proxyConfig * server_config_load_ini(wIniFile *ini)
server_config_load_ini Create a proxyConfig from a already loaded INI file.
Definition pf_config.c:551
size_t pf_config_required_plugins_count(const proxyConfig *config)
pf_config_required_plugins_count
Definition pf_config.c:889
const char ** pf_config_modules(const proxyConfig *config)
pf_config_modules
Definition pf_config.c:910
BOOL pf_config_plugin(proxyPluginsManager *plugins_manager, void *userdata)
pf_config_plugin Register a proxy plugin handling event filtering defined in the configuration.
Definition pf_config.c:1295
const char * pf_config_required_plugin(const proxyConfig *config, size_t index)
pf_config_required_plugin
Definition pf_config.c:895
size_t pf_config_modules_count(const proxyConfig *config)
pf_config_modules_count
Definition pf_config.c:904