FreeRDP
Proxy Configuration

Data Structures

struct  proxyConfig
 

Functions

FREERDP_API BOOL pf_server_config_dump (const char *file)
 pf_server_config_dump Dumps a default INI configuration file More...
 
FREERDP_API void pf_server_config_free (proxyConfig *config)
 pf_server_config_free Releases all resources associated with proxyConfig More...
 
FREERDP_API proxyConfig * server_config_load_ini (wIniFile *ini)
 server_config_load_ini Create a proxyConfig from a already loaded INI file. More...
 
FREERDP_API proxyConfig * pf_server_config_load_file (const char *path)
 pf_server_config_load_file Create a proxyConfig from a INI file found at path. More...
 
FREERDP_API 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 More...
 
FREERDP_API void pf_server_config_print (const proxyConfig *config)
 pf_server_config_print Print the configuration to stdout More...
 
FREERDP_API size_t pf_config_required_plugins_count (const proxyConfig *config)
 pf_config_required_plugins_count More...
 
FREERDP_API const char * pf_config_required_plugin (const proxyConfig *config, size_t index)
 pf_config_required_plugin More...
 
FREERDP_API size_t pf_config_modules_count (const proxyConfig *config)
 pf_config_modules_count More...
 
FREERDP_API const char ** pf_config_modules (const proxyConfig *config)
 pf_config_modules More...
 
FREERDP_API BOOL pf_config_clone (proxyConfig **dst, const proxyConfig *config)
 pf_config_clone Create a copy of the configuration More...
 
FREERDP_API BOOL pf_config_plugin (proxyPluginsManager *plugins_manager, void *userdata)
 pf_config_plugin Register a proxy plugin handling event filtering defined in the configuration. More...
 
FREERDP_API const char * pf_config_get (const proxyConfig *config, const char *section, const char *key)
 pf_config_get get a value for a section/key More...
 

Detailed Description

FreeRDP: A Remote Desktop Protocol Implementation FreeRDP Proxy Server

Copyright 2021-2023 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m Copyright 2021-2023 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.

Function Documentation

◆ pf_config_clone()

FREERDP_API BOOL pf_config_clone ( proxyConfig **  dst,
const proxyConfig *  config 
)

pf_config_clone Create a copy of the configuration

Parameters
dstA pointer that receives the newly allocated copy
configThe source configuration to copy
Returns
TRUE for success, FALSE otherwise

Definition at line 947 of file pf_config.c.

948 {
949  proxyConfig* tmp = calloc(1, sizeof(proxyConfig));
950 
951  WINPR_ASSERT(dst);
952  WINPR_ASSERT(config);
953 
954  if (!tmp)
955  return FALSE;
956 
957  *tmp = *config;
958 
959  if (!pf_config_copy_string(&tmp->Host, config->Host))
960  goto fail;
961  if (!pf_config_copy_string(&tmp->TargetHost, config->TargetHost))
962  goto fail;
963 
964  if (!pf_config_copy_string_list(&tmp->Passthrough, &tmp->PassthroughCount, config->Passthrough,
965  config->PassthroughCount))
966  goto fail;
967  if (!pf_config_copy_string_list(&tmp->Intercept, &tmp->InterceptCount, config->Intercept,
968  config->InterceptCount))
969  goto fail;
970  if (!pf_config_copy_string_list(&tmp->Modules, &tmp->ModulesCount, config->Modules,
971  config->ModulesCount))
972  goto fail;
973  if (!pf_config_copy_string_list(&tmp->RequiredPlugins, &tmp->RequiredPluginsCount,
974  config->RequiredPlugins, config->RequiredPluginsCount))
975  goto fail;
976  if (!pf_config_copy_string(&tmp->CertificateFile, config->CertificateFile))
977  goto fail;
978  if (!pf_config_copy_string(&tmp->CertificateContent, config->CertificateContent))
979  goto fail;
980  if (!pf_config_copy_string_n(&tmp->CertificatePEM, config->CertificatePEM,
981  config->CertificatePEMLength))
982  goto fail;
983  if (!pf_config_copy_string(&tmp->PrivateKeyFile, config->PrivateKeyFile))
984  goto fail;
985  if (!pf_config_copy_string(&tmp->PrivateKeyContent, config->PrivateKeyContent))
986  goto fail;
987  if (!pf_config_copy_string_n(&tmp->PrivateKeyPEM, config->PrivateKeyPEM,
988  config->PrivateKeyPEMLength))
989  goto fail;
990 
991  tmp->ini = IniFile_Clone(config->ini);
992  if (!tmp->ini)
993  goto fail;
994 
995  *dst = tmp;
996  return TRUE;
997 
998 fail:
999  WINPR_PRAGMA_DIAG_PUSH
1000  WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
1001  pf_server_config_free(tmp);
1002  WINPR_PRAGMA_DIAG_POP
1003  return FALSE;
1004 }
void pf_server_config_free(proxyConfig *config)
pf_server_config_free Releases all resources associated with proxyConfig
Definition: pf_config.c:842

References pf_server_config_free().

Here is the call graph for this function:

◆ pf_config_get()

FREERDP_API const char* pf_config_get ( const proxyConfig *  config,
const char *  section,
const char *  key 
)

pf_config_get get a value for a section/key

Parameters
configA pointer to the proxyConfig. Must NOT be NULL.
sectionThe name of the section the key is in, must not be NULL
keyThe name of the key to look for. Must not be NULL
Returns
A pointer to the value for section/key or NULL if not found

Definition at line 1297 of file pf_config.c.

1298 {
1299  WINPR_ASSERT(config);
1300  WINPR_ASSERT(config->ini);
1301  WINPR_ASSERT(section);
1302  WINPR_ASSERT(key);
1303 
1304  return IniFile_GetKeyValueString(config->ini, section, key);
1305 }

◆ pf_config_modules()

FREERDP_API const char** pf_config_modules ( const proxyConfig *  config)

pf_config_modules

Parameters
configA pointer to the proxyConfig. Must NOT be NULL.
Returns
An array of strings of size pf_config_modules_count with the module names.

Definition at line 888 of file pf_config.c.

889 {
890  union
891  {
892  char** ppc;
893  const char** cppc;
894  } cnv;
895 
896  WINPR_ASSERT(config);
897 
898  cnv.ppc = config->Modules;
899  return cnv.cppc;
900 }

◆ pf_config_modules_count()

FREERDP_API size_t pf_config_modules_count ( const proxyConfig *  config)

pf_config_modules_count

Parameters
configA pointer to the proxyConfig. Must NOT be NULL.
Returns
The number of proxy modules configured.

Definition at line 882 of file pf_config.c.

883 {
884  WINPR_ASSERT(config);
885  return config->ModulesCount;
886 }

◆ pf_config_plugin()

FREERDP_API BOOL pf_config_plugin ( proxyPluginsManager *  plugins_manager,
void *  userdata 
)

pf_config_plugin Register a proxy plugin handling event filtering defined in the configuration.

Parameters
plugins_managerThe plugin manager
userdataA proxyConfig* to use as reference
Returns
TRUE for success, FALSE for failure

Definition at line 1265 of file pf_config.c.

1266 {
1267  struct config_plugin_data* custom = NULL;
1268  proxyPlugin plugin = { 0 };
1269 
1270  plugin.name = config_plugin_name;
1271  plugin.description = config_plugin_desc;
1272  plugin.PluginUnload = config_plugin_unload;
1273 
1274  plugin.KeyboardEvent = config_plugin_keyboard_event;
1275  plugin.UnicodeEvent = config_plugin_unicode_event;
1276  plugin.MouseEvent = config_plugin_mouse_event;
1277  plugin.MouseExEvent = config_plugin_mouse_ex_event;
1278  plugin.ClientChannelData = config_plugin_client_channel_data;
1279  plugin.ServerChannelData = config_plugin_server_channel_data;
1280  plugin.ChannelCreate = config_plugin_channel_create;
1281  plugin.DynamicChannelCreate = config_plugin_dynamic_channel_create;
1282  plugin.userdata = userdata;
1283 
1284  custom = calloc(1, sizeof(struct config_plugin_data));
1285  if (!custom)
1286  return FALSE;
1287 
1288  custom->mgr = plugins_manager;
1289  custom->config = userdata;
1290 
1291  plugin.custom = custom;
1292  plugin.userdata = userdata;
1293 
1294  return plugins_manager->RegisterPlugin(plugins_manager, &plugin);
1295 }

◆ pf_config_required_plugin()

FREERDP_API const char* pf_config_required_plugin ( const proxyConfig *  config,
size_t  index 
)

pf_config_required_plugin

Parameters
configA pointer to the proxyConfig. Must NOT be NULL.
indexThe index of the plugin to return
Returns
The name of the plugin or NULL.

Definition at line 873 of file pf_config.c.

874 {
875  WINPR_ASSERT(config);
876  if (index >= config->RequiredPluginsCount)
877  return NULL;
878 
879  return config->RequiredPlugins[index];
880 }

◆ pf_config_required_plugins_count()

FREERDP_API size_t pf_config_required_plugins_count ( const proxyConfig *  config)

pf_config_required_plugins_count

Parameters
configA pointer to the proxyConfig. Must NOT be NULL.
Returns
The number of required plugins configured.

Definition at line 867 of file pf_config.c.

868 {
869  WINPR_ASSERT(config);
870  return config->RequiredPluginsCount;
871 }

◆ pf_server_config_dump()

FREERDP_API BOOL pf_server_config_dump ( const char *  file)

pf_server_config_dump Dumps a default INI configuration file

Parameters
fileThe file to write to. Existing files are truncated.
Returns
TRUE for success, FALSE if the file could not be written.

Definition at line 594 of file pf_config.c.

595 {
596  BOOL rc = FALSE;
597  wIniFile* ini = IniFile_New();
598  if (!ini)
599  return FALSE;
600 
601  /* Proxy server configuration */
602  if (IniFile_SetKeyValueString(ini, section_server, key_host, "0.0.0.0") < 0)
603  goto fail;
604  if (IniFile_SetKeyValueInt(ini, section_server, key_port, 3389) < 0)
605  goto fail;
606 
607  /* Target configuration */
608  if (IniFile_SetKeyValueString(ini, section_target, key_host, "somehost.example.com") < 0)
609  goto fail;
610  if (IniFile_SetKeyValueInt(ini, section_target, key_port, 3389) < 0)
611  goto fail;
612  if (IniFile_SetKeyValueString(ini, section_target, key_target_fixed, bool_str_true) < 0)
613  goto fail;
614  if (IniFile_SetKeyValueInt(ini, section_target, key_target_tls_seclevel, 1) < 0)
615  goto fail;
616 
617  /* Channel configuration */
618  if (IniFile_SetKeyValueString(ini, section_channels, key_channels_gfx, bool_str_true) < 0)
619  goto fail;
620  if (IniFile_SetKeyValueString(ini, section_channels, key_channels_disp, bool_str_true) < 0)
621  goto fail;
622  if (IniFile_SetKeyValueString(ini, section_channels, key_channels_clip, bool_str_true) < 0)
623  goto fail;
624  if (IniFile_SetKeyValueString(ini, section_channels, key_channels_mic, bool_str_true) < 0)
625  goto fail;
626  if (IniFile_SetKeyValueString(ini, section_channels, key_channels_sound, bool_str_true) < 0)
627  goto fail;
628  if (IniFile_SetKeyValueString(ini, section_channels, key_channels_rdpdr, bool_str_true) < 0)
629  goto fail;
630  if (IniFile_SetKeyValueString(ini, section_channels, key_channels_video, bool_str_true) < 0)
631  goto fail;
632  if (IniFile_SetKeyValueString(ini, section_channels, key_channels_camera, bool_str_true) < 0)
633  goto fail;
634  if (IniFile_SetKeyValueString(ini, section_channels, key_channels_rails, bool_str_false) < 0)
635  goto fail;
636 
637  if (IniFile_SetKeyValueString(ini, section_channels, key_channels_blacklist, bool_str_true) < 0)
638  goto fail;
639  if (IniFile_SetKeyValueString(ini, section_channels, key_channels_pass, "") < 0)
640  goto fail;
641  if (IniFile_SetKeyValueString(ini, section_channels, key_channels_intercept, "") < 0)
642  goto fail;
643 
644  /* Input configuration */
645  if (IniFile_SetKeyValueString(ini, section_input, key_input_kbd, bool_str_true) < 0)
646  goto fail;
647  if (IniFile_SetKeyValueString(ini, section_input, key_input_mouse, bool_str_true) < 0)
648  goto fail;
649  if (IniFile_SetKeyValueString(ini, section_input, key_input_multitouch, bool_str_true) < 0)
650  goto fail;
651 
652  /* Security settings */
653  if (IniFile_SetKeyValueString(ini, section_security, key_security_server_tls, bool_str_true) <
654  0)
655  goto fail;
656  if (IniFile_SetKeyValueString(ini, section_security, key_security_server_nla, bool_str_false) <
657  0)
658  goto fail;
659  if (IniFile_SetKeyValueString(ini, section_security, key_security_server_rdp, bool_str_true) <
660  0)
661  goto fail;
662 
663  if (IniFile_SetKeyValueString(ini, section_security, key_security_client_tls, bool_str_true) <
664  0)
665  goto fail;
666  if (IniFile_SetKeyValueString(ini, section_security, key_security_client_nla, bool_str_true) <
667  0)
668  goto fail;
669  if (IniFile_SetKeyValueString(ini, section_security, key_security_client_rdp, bool_str_true) <
670  0)
671  goto fail;
672  if (IniFile_SetKeyValueString(ini, section_security, key_security_client_fallback,
673  bool_str_true) < 0)
674  goto fail;
675 
676  /* Module configuration */
677  if (IniFile_SetKeyValueString(ini, section_plugins, key_plugins_modules,
678  "module1,module2,...") < 0)
679  goto fail;
680  if (IniFile_SetKeyValueString(ini, section_plugins, key_plugins_required,
681  "module1,module2,...") < 0)
682  goto fail;
683 
684  /* Certificate configuration */
685  if (IniFile_SetKeyValueString(ini, section_certificates, key_cert_file,
686  "<absolute path to some certificate file> OR") < 0)
687  goto fail;
688  if (IniFile_SetKeyValueString(ini, section_certificates, key_cert_content,
689  "<Contents of some certificate file in PEM format>") < 0)
690  goto fail;
691 
692  if (IniFile_SetKeyValueString(ini, section_certificates, key_private_key_file,
693  "<absolute path to some private key file> OR") < 0)
694  goto fail;
695  if (IniFile_SetKeyValueString(ini, section_certificates, key_private_key_content,
696  "<Contents of some private key file in PEM format>") < 0)
697  goto fail;
698 
699  /* store configuration */
700  if (IniFile_WriteFile(ini, file) < 0)
701  goto fail;
702 
703  rc = TRUE;
704 
705 fail:
706  IniFile_Free(ini);
707  return rc;
708 }

◆ pf_server_config_free()

FREERDP_API void pf_server_config_free ( proxyConfig *  config)

pf_server_config_free Releases all resources associated with proxyConfig

Parameters
configA pointer to the proxyConfig to clean up. Might be NULL.

Definition at line 842 of file pf_config.c.

843 {
844  if (config == NULL)
845  return;
846 
847  CommandLineParserFree(config->Passthrough);
848  CommandLineParserFree(config->Intercept);
849  CommandLineParserFree(config->RequiredPlugins);
850  CommandLineParserFree(config->Modules);
851  free(config->TargetHost);
852  free(config->Host);
853  free(config->CertificateFile);
854  free(config->CertificateContent);
855  if (config->CertificatePEM)
856  memset(config->CertificatePEM, 0, config->CertificatePEMLength);
857  free(config->CertificatePEM);
858  free(config->PrivateKeyFile);
859  free(config->PrivateKeyContent);
860  if (config->PrivateKeyPEM)
861  memset(config->PrivateKeyPEM, 0, config->PrivateKeyPEMLength);
862  free(config->PrivateKeyPEM);
863  IniFile_Free(config->ini);
864  free(config);
865 }

Referenced by pf_config_clone(), and server_config_load_ini().

Here is the caller graph for this function:

◆ pf_server_config_load_buffer()

FREERDP_API 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

Parameters
bufferA pointer to the '\0' terminated INI string.
Returns
A proxyConfig or NULL in case of failure.

Definition at line 710 of file pf_config.c.

711 {
712  proxyConfig* config = NULL;
713  wIniFile* ini = NULL;
714 
715  ini = IniFile_New();
716 
717  if (!ini)
718  {
719  WLog_ERR(TAG, "IniFile_New() failed!");
720  return NULL;
721  }
722 
723  if (IniFile_ReadBuffer(ini, buffer) < 0)
724  {
725  WLog_ERR(TAG, "failed to parse ini: '%s'", buffer);
726  goto out;
727  }
728 
729  config = server_config_load_ini(ini);
730 out:
731  IniFile_Free(ini);
732  return config;
733 }
proxyConfig * server_config_load_ini(wIniFile *ini)
server_config_load_ini Create a proxyConfig from a already loaded INI file.
Definition: pf_config.c:547

References server_config_load_ini().

Here is the call graph for this function:

◆ pf_server_config_load_file()

FREERDP_API proxyConfig* pf_server_config_load_file ( const char *  path)

pf_server_config_load_file Create a proxyConfig from a INI file found at path.

Parameters
pathThe path of the INI file
Returns
A proxyConfig or NULL in case of failure.

Definition at line 735 of file pf_config.c.

736 {
737  proxyConfig* config = NULL;
738  wIniFile* ini = IniFile_New();
739 
740  if (!ini)
741  {
742  WLog_ERR(TAG, "IniFile_New() failed!");
743  return NULL;
744  }
745 
746  if (IniFile_ReadFile(ini, path) < 0)
747  {
748  WLog_ERR(TAG, "failed to parse ini file: '%s'", path);
749  goto out;
750  }
751 
752  config = server_config_load_ini(ini);
753 out:
754  IniFile_Free(ini);
755  return config;
756 }

References server_config_load_ini().

Here is the call graph for this function:

◆ pf_server_config_print()

FREERDP_API void pf_server_config_print ( const proxyConfig *  config)

pf_server_config_print Print the configuration to stdout

Parameters
configA pointer to the configuration to print. Must NOT be NULL.

Definition at line 765 of file pf_config.c.

766 {
767  WINPR_ASSERT(config);
768  WLog_INFO(TAG, "Proxy configuration:");
769 
770  CONFIG_PRINT_SECTION(section_server);
771  CONFIG_PRINT_STR(config, Host);
772  CONFIG_PRINT_UINT16(config, Port);
773 
774  if (config->FixedTarget)
775  {
776  CONFIG_PRINT_SECTION(section_target);
777  CONFIG_PRINT_STR(config, TargetHost);
778  CONFIG_PRINT_UINT16(config, TargetPort);
779  CONFIG_PRINT_UINT32(config, TargetTlsSecLevel);
780 
781  if (config->TargetUser)
782  CONFIG_PRINT_STR(config, TargetUser);
783  if (config->TargetDomain)
784  CONFIG_PRINT_STR(config, TargetDomain);
785  }
786 
787  CONFIG_PRINT_SECTION(section_input);
788  CONFIG_PRINT_BOOL(config, Keyboard);
789  CONFIG_PRINT_BOOL(config, Mouse);
790  CONFIG_PRINT_BOOL(config, Multitouch);
791 
792  CONFIG_PRINT_SECTION(section_security);
793  CONFIG_PRINT_BOOL(config, ServerNlaSecurity);
794  CONFIG_PRINT_BOOL(config, ServerTlsSecurity);
795  CONFIG_PRINT_BOOL(config, ServerRdpSecurity);
796  CONFIG_PRINT_BOOL(config, ClientNlaSecurity);
797  CONFIG_PRINT_BOOL(config, ClientTlsSecurity);
798  CONFIG_PRINT_BOOL(config, ClientRdpSecurity);
799  CONFIG_PRINT_BOOL(config, ClientAllowFallbackToTls);
800 
801  CONFIG_PRINT_SECTION(section_channels);
802  CONFIG_PRINT_BOOL(config, GFX);
803  CONFIG_PRINT_BOOL(config, DisplayControl);
804  CONFIG_PRINT_BOOL(config, Clipboard);
805  CONFIG_PRINT_BOOL(config, AudioOutput);
806  CONFIG_PRINT_BOOL(config, AudioInput);
807  CONFIG_PRINT_BOOL(config, DeviceRedirection);
808  CONFIG_PRINT_BOOL(config, VideoRedirection);
809  CONFIG_PRINT_BOOL(config, CameraRedirection);
810  CONFIG_PRINT_BOOL(config, RemoteApp);
811  CONFIG_PRINT_BOOL(config, PassthroughIsBlacklist);
812 
813  if (config->PassthroughCount)
814  {
815  WLog_INFO(TAG, "\tStatic Channels Proxy:");
816  pf_server_config_print_list(config->Passthrough, config->PassthroughCount);
817  }
818 
819  if (config->InterceptCount)
820  {
821  WLog_INFO(TAG, "\tStatic Channels Proxy-Intercept:");
822  pf_server_config_print_list(config->Intercept, config->InterceptCount);
823  }
824 
825  /* modules */
826  CONFIG_PRINT_SECTION_KEY(section_plugins, key_plugins_modules);
827  for (size_t x = 0; x < config->ModulesCount; x++)
828  CONFIG_PRINT_STR(config, Modules[x]);
829 
830  /* Required plugins */
831  CONFIG_PRINT_SECTION_KEY(section_plugins, key_plugins_required);
832  for (size_t x = 0; x < config->RequiredPluginsCount; x++)
833  CONFIG_PRINT_STR(config, RequiredPlugins[x]);
834 
835  CONFIG_PRINT_SECTION(section_certificates);
836  CONFIG_PRINT_STR(config, CertificateFile);
837  CONFIG_PRINT_STR_CONTENT(config, CertificateContent);
838  CONFIG_PRINT_STR(config, PrivateKeyFile);
839  CONFIG_PRINT_STR_CONTENT(config, PrivateKeyContent);
840 }

◆ server_config_load_ini()

FREERDP_API proxyConfig* server_config_load_ini ( wIniFile *  ini)

server_config_load_ini Create a proxyConfig from a already loaded INI file.

Parameters
iniA pointer to the parsed INI file. Must NOT be NULL.
Returns
A proxyConfig or NULL in case of failure.

Definition at line 547 of file pf_config.c.

548 {
549  proxyConfig* config = NULL;
550 
551  WINPR_ASSERT(ini);
552 
553  config = calloc(1, sizeof(proxyConfig));
554  if (config)
555  {
556  /* Set default values != 0 */
557  config->TargetTlsSecLevel = 1;
558 
559  /* Load from ini */
560  if (!pf_config_load_server(ini, config))
561  goto out;
562 
563  if (!pf_config_load_target(ini, config))
564  goto out;
565 
566  if (!pf_config_load_channels(ini, config))
567  goto out;
568 
569  if (!pf_config_load_input(ini, config))
570  goto out;
571 
572  if (!pf_config_load_security(ini, config))
573  goto out;
574 
575  if (!pf_config_load_modules(ini, config))
576  goto out;
577 
578  if (!pf_config_load_certificates(ini, config))
579  goto out;
580  config->ini = IniFile_Clone(ini);
581  if (!config->ini)
582  goto out;
583  }
584  return config;
585 out:
586  WINPR_PRAGMA_DIAG_PUSH
587  WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
588  pf_server_config_free(config);
589  WINPR_PRAGMA_DIAG_POP
590 
591  return NULL;
592 }

References pf_server_config_free().

Referenced by pf_server_config_load_buffer(), and pf_server_config_load_file().

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