19#include <freerdp/config.h>
23#include <winpr/path.h>
24#include <winpr/cmdline.h>
25#include <winpr/winsock.h>
27#include <winpr/tools/makecert.h>
29#include <freerdp/server/shadow.h>
30#include <freerdp/settings.h>
32#include <freerdp/log.h>
33#define TAG SERVER_TAG("shadow")
36static const char* boolstr(BOOL val)
38 return val ?
"TRUE" :
"FALSE";
41static void dump_security_settings(
const rdpSettings* settings)
43 WINPR_ASSERT(settings);
51 WLog_INFO(TAG,
"security: RDP:%s, TLS:%s, NLA:%s, EXT:%s, AAD:%s, RDSTLS:%s", boolstr(rdp),
52 boolstr(tls), boolstr(nla), boolstr(ext), boolstr(aad), boolstr(rdstls));
55int main(
int argc,
char** argv)
60 {
"log-filters", COMMAND_LINE_VALUE_REQUIRED,
"<tag>:<level>[,<tag>:<level>[,...]]",
61 nullptr,
nullptr, -1,
nullptr,
"Set logger filters, see wLog(7) for details" },
62 {
"log-level", COMMAND_LINE_VALUE_REQUIRED,
"[OFF|FATAL|ERROR|WARN|INFO|DEBUG|TRACE]",
63 nullptr,
nullptr, -1,
nullptr,
"Set the default log level, see wLog(7) for details" },
64 {
"port", COMMAND_LINE_VALUE_REQUIRED,
"<number>",
nullptr,
nullptr, -1,
nullptr,
66 {
"ipc-socket", COMMAND_LINE_VALUE_REQUIRED,
"<ipc-socket>",
nullptr,
nullptr, -1,
nullptr,
67 "Server IPC socket" },
68 {
"bind-address", COMMAND_LINE_VALUE_REQUIRED,
"<bind-address>[,<another address>, ...]",
69 nullptr,
nullptr, -1,
nullptr,
70 "An address to bind to. Use '[<ipv6>]' for IPv6 addresses, e.g. '[::1]' for "
72 {
"server-side-cursor", COMMAND_LINE_VALUE_BOOL,
nullptr,
nullptr,
nullptr, -1,
nullptr,
73 "hide mouse cursor in RDP client." },
74 {
"monitors", COMMAND_LINE_VALUE_OPTIONAL,
"<0,1,2...>",
nullptr,
nullptr, -1,
nullptr,
75 "Select or list monitors" },
76 {
"subsystem", COMMAND_LINE_VALUE_OPTIONAL,
"<name>[,<name>...]",
nullptr,
nullptr, -1,
77 nullptr,
"Subsystems to try, in this order, or list them" },
78 {
"max-connections", COMMAND_LINE_VALUE_REQUIRED,
"<number>",
nullptr,
nullptr, -1,
nullptr,
79 "maximum connections allowed to server, 0 to deactivate" },
80 {
"mouse-relative", COMMAND_LINE_VALUE_BOOL,
nullptr,
nullptr,
nullptr, -1,
nullptr,
81 "enable support for relative mouse events" },
82 {
"rect", COMMAND_LINE_VALUE_REQUIRED,
"<x,y,w,h>",
nullptr,
nullptr, -1,
nullptr,
83 "Select rectangle within monitor to share" },
84 {
"auth", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
85 "Clients must authenticate" },
86 {
"remote-guard", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueFalse,
nullptr, -1,
nullptr,
87 "Remote credential guard" },
88 {
"restricted-admin", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
90 {
"vmconnect", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueFalse,
91 nullptr, -1,
nullptr,
"Hyper-V console server (bind on vsock://1)" },
92 {
"may-view", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
93 "Clients may view without prompt" },
94 {
"may-interact", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
95 "Clients may interact without prompt" },
96 {
"sec", COMMAND_LINE_VALUE_REQUIRED,
"<rdp|tls|nla|ext>",
nullptr,
nullptr, -1,
nullptr,
97 "force specific protocol security" },
98 {
"sec-rdp", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
99 "rdp protocol security" },
100 {
"sec-tls", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
101 "tls protocol security" },
102 {
"sec-nla", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
103 "nla protocol security" },
104 {
"sec-ext", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
105 "nla extended protocol security" },
106 {
"sam-file", COMMAND_LINE_VALUE_REQUIRED,
"<file>",
nullptr,
nullptr, -1,
nullptr,
107 "NTLM SAM file for NLA authentication" },
108 {
"keytab", COMMAND_LINE_VALUE_REQUIRED,
"<file>",
nullptr,
nullptr, -1,
nullptr,
109 "Kerberos keytab file for NLA authentication" },
110 {
"ccache", COMMAND_LINE_VALUE_REQUIRED,
"<file>",
nullptr,
nullptr, -1,
nullptr,
111 "Kerberos host ccache file for NLA authentication" },
112 {
"tls-secrets-file", COMMAND_LINE_VALUE_REQUIRED,
"<file>",
nullptr,
nullptr, -1,
nullptr,
113 "file where tls secrets shall be stored" },
114 {
"nsc", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
116 {
"rfx", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
117 "Allow RFX surface bits" },
118 {
"gfx", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
119 "Allow GFX pipeline" },
120#if defined(WITH_RDPEUDP_SERVER)
121 {
"multitransport", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueFalse,
nullptr, -1,
nullptr,
122 "[experimental] Offer clients the UDP multitransport tunnel" },
124#if defined(WITH_GFX_AV1)
125 {
"gfx-av1", COMMAND_LINE_VALUE_OPTIONAL,
"[:profile:[low|high|0|1]|off]", BoolValueTrue,
126 nullptr, -1,
nullptr,
"Allow GFX pipeline AV1 codec extension" },
128#if defined(WITH_GFX_AV2)
129 {
"gfx-av2", COMMAND_LINE_VALUE_OPTIONAL,
"[:profile:[low|high|0|1]|off]", BoolValueTrue,
130 nullptr, -1,
nullptr,
"Allow GFX pipeline AV2 codec extension" },
132 {
"gfx-progressive", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
133 "Allow GFX progressive codec" },
134 {
"gfx-rfx", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
135 "Allow GFX RFX codec" },
136 {
"gfx-planar", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
137 "Allow GFX planar codec" },
138 {
"gfx-avc420", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
139 "Allow GFX AVC420 codec" },
140 {
"gfx-avc444", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueTrue,
nullptr, -1,
nullptr,
141 "Allow GFX AVC444 codec" },
142 {
"codec", COMMAND_LINE_VALUE_REQUIRED,
"<codec>:<key>:<value>[,<codec>:<key>:<value>...]",
143 nullptr,
nullptr, -1,
nullptr,
144 "Encoder settings, bit rates in kbit/s: h264:rate-control:vbr|cqp, h264:bitrate, "
145 "h264:qp:<0-51>; av1 and av2: rate-control:vbr|cbr|cq|q, bitrate; hevc: "
146 "rate-control:vbr, bitrate (a codec not built in is refused)" },
147#if defined(WITH_GFX_AZURE)
148 {
"gfx-hevc", COMMAND_LINE_VALUE_OPTIONAL,
"[on|off|i420|i444]", BoolValueTrue,
nullptr, -1,
149 nullptr,
"Allow GFX pipeline HEVC codec extension" },
151 {
"bitmap-compat", COMMAND_LINE_VALUE_BOOL,
nullptr, BoolValueFalse,
nullptr, -1,
nullptr,
152 "Limit BitmapUpdate to 1 rectangle (fixes broken windows 11 24H2 clients)" },
153 {
"version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION,
nullptr,
nullptr,
154 nullptr, -1,
nullptr,
"Print version" },
155 {
"buildconfig", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_BUILDCONFIG,
nullptr,
nullptr,
156 nullptr, -1,
nullptr,
"Print the build configuration" },
157 {
"help", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP,
nullptr,
nullptr,
nullptr, -1,
159 {
nullptr, 0,
nullptr,
nullptr,
nullptr, -1,
nullptr,
nullptr }
162 shadow_subsystem_set_entry_builtin(
nullptr);
164 rdpShadowServer* server = shadow_server_new();
169 WLog_ERR(TAG,
"Server new failed");
174 rdpSettings* settings = server->settings;
175 WINPR_ASSERT(settings);
203 if ((status = shadow_server_parse_command_line(server, argc, argv, shadow_args)) < 0)
205 status = shadow_server_command_line_status_print(server, argc, argv, status, shadow_args);
209 if (server->authentication)
210 dump_security_settings(server->settings);
212 WLog_INFO(TAG,
"authentication: disabled");
214 if ((status = shadow_server_init(server)) < 0)
216 WLog_ERR(TAG,
"Server initialization failed.");
220 if ((status = shadow_server_start(server)) < 0)
222 WLog_ERR(TAG,
"Failed to start server.");
228 MSG msg = WINPR_C_ARRAY_INIT;
229 while (GetMessage(&msg, 0, 0, 0))
231 TranslateMessage(&msg);
232 DispatchMessage(&msg);
237 (void)WaitForSingleObject(server->thread, INFINITE);
239 if (!GetExitCodeThread(server->thread, &dwExitCode))
242 status = (int)dwExitCode;
245 shadow_server_uninit(server);
246 shadow_server_free(server);
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_set_bool(rdpSettings *settings, FreeRDP_Settings_Keys_Bool id, BOOL val)
Sets a BOOL settings value.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_set_uint32(rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id, UINT32 val)
Sets a UINT32 settings value.
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.