FreeRDP
pf_utils.c
1 
21 #include <winpr/assert.h>
22 #include <winpr/string.h>
23 #include <winpr/wtsapi.h>
24 
25 #include <freerdp/server/proxy/proxy_log.h>
26 #include "pf_utils.h"
27 
28 #define TAG PROXY_TAG("utils")
29 
30 pf_utils_channel_mode pf_utils_get_channel_mode(const proxyConfig* config, const char* name)
31 {
32  pf_utils_channel_mode rc = PF_UTILS_CHANNEL_NOT_HANDLED;
33  BOOL found = FALSE;
34 
35  WINPR_ASSERT(config);
36  WINPR_ASSERT(name);
37 
38  for (size_t i = 0; i < config->InterceptCount; i++)
39  {
40  const char* channel_name = config->Intercept[i];
41  if (strcmp(name, channel_name) == 0)
42  {
43  rc = PF_UTILS_CHANNEL_INTERCEPT;
44  goto end;
45  }
46  }
47 
48  for (size_t i = 0; i < config->PassthroughCount; i++)
49  {
50  const char* channel_name = config->Passthrough[i];
51  if (strcmp(name, channel_name) == 0)
52  {
53  found = TRUE;
54  break;
55  }
56  }
57 
58  if (found)
59  {
60  if (config->PassthroughIsBlacklist)
61  rc = PF_UTILS_CHANNEL_BLOCK;
62  else
63  rc = PF_UTILS_CHANNEL_PASSTHROUGH;
64  }
65  else if (config->PassthroughIsBlacklist)
66  rc = PF_UTILS_CHANNEL_PASSTHROUGH;
67 
68 end:
69  WLog_DBG(TAG, "%s -> %s", name, pf_utils_channel_mode_string(rc));
70  return rc;
71 }
72 
73 BOOL pf_utils_is_passthrough(const proxyConfig* config)
74 {
75  WINPR_ASSERT(config);
76 
77  /* TODO: For the time being only passthrough mode is supported. */
78  return TRUE;
79 }
80 
81 const char* pf_utils_channel_mode_string(pf_utils_channel_mode mode)
82 {
83  switch (mode)
84  {
85  case PF_UTILS_CHANNEL_BLOCK:
86  return "blocked";
87  case PF_UTILS_CHANNEL_PASSTHROUGH:
88  return "passthrough";
89  case PF_UTILS_CHANNEL_INTERCEPT:
90  return "intercepted";
91  case PF_UTILS_CHANNEL_NOT_HANDLED:
92  default:
93  return "ignored";
94  }
95 }