mirror of https://github.com/FreeRDP/FreeRDP
Merge pull request #10198 from akallabeth/dump-replay-fix
Dump replay fix
This commit is contained in:
commit
9c687650a2
|
@ -2050,13 +2050,12 @@ static int parse_tls_enforce(rdpSettings* settings, const char* Value)
|
|||
const char* name;
|
||||
UINT16 version;
|
||||
};
|
||||
const struct map_t map[] = {
|
||||
{ "1.0", TLS1_VERSION },
|
||||
{ "1.1", TLS1_1_VERSION },
|
||||
{ "1.2", TLS1_2_VERSION }
|
||||
const struct map_t map[] = { { "1.0", TLS1_VERSION },
|
||||
{ "1.1", TLS1_1_VERSION },
|
||||
{ "1.2", TLS1_2_VERSION }
|
||||
#if defined(TLS1_3_VERSION)
|
||||
,
|
||||
{ "1.3", TLS1_3_VERSION }
|
||||
,
|
||||
{ "1.3", TLS1_3_VERSION }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -2891,30 +2890,62 @@ static int parse_dump_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT
|
|||
BOOL failed = FALSE;
|
||||
size_t count = 0;
|
||||
char** args = CommandLineParseCommaSeparatedValues(arg->Value, &count);
|
||||
if (!args || (count != 2))
|
||||
if (!args)
|
||||
failed = TRUE;
|
||||
else
|
||||
{
|
||||
if (!freerdp_settings_set_string(settings, FreeRDP_TransportDumpFile, args[1]))
|
||||
BOOL modernsyntax = FALSE;
|
||||
BOOL oldsyntax = FALSE;
|
||||
for (size_t x = 0; (x < count) && !failed; x++)
|
||||
{
|
||||
const char* carg = args[x];
|
||||
if (option_starts_with("file:", carg))
|
||||
{
|
||||
const char* val = &carg[5];
|
||||
if (oldsyntax)
|
||||
failed = TRUE;
|
||||
else if (!freerdp_settings_set_string(settings, FreeRDP_TransportDumpFile, val))
|
||||
failed = TRUE;
|
||||
modernsyntax = TRUE;
|
||||
}
|
||||
else if (option_equals("replay", carg))
|
||||
{
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDump, FALSE))
|
||||
failed = TRUE;
|
||||
else if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDumpReplay, TRUE))
|
||||
failed = TRUE;
|
||||
}
|
||||
else if (option_equals("record", carg))
|
||||
{
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDump, TRUE))
|
||||
failed = TRUE;
|
||||
else if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDumpReplay, FALSE))
|
||||
failed = TRUE;
|
||||
}
|
||||
else if (option_equals("nodelay", carg))
|
||||
{
|
||||
if (oldsyntax)
|
||||
failed = TRUE;
|
||||
else if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDumpReplayNodelay,
|
||||
TRUE))
|
||||
failed = TRUE;
|
||||
modernsyntax = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* compat:
|
||||
* support syntax record,<filename> and replay,<filename>
|
||||
*/
|
||||
if (modernsyntax)
|
||||
failed = TRUE;
|
||||
else if (!freerdp_settings_set_string(settings, FreeRDP_TransportDumpFile, carg))
|
||||
failed = TRUE;
|
||||
oldsyntax = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (oldsyntax && (count != 2))
|
||||
failed = TRUE;
|
||||
else if (option_equals(args[0], "replay"))
|
||||
{
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDump, FALSE))
|
||||
failed = TRUE;
|
||||
else if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDumpReplay, TRUE))
|
||||
failed = TRUE;
|
||||
}
|
||||
else if (option_equals(args[0], "record"))
|
||||
{
|
||||
if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDump, TRUE))
|
||||
failed = TRUE;
|
||||
else if (!freerdp_settings_set_bool(settings, FreeRDP_TransportDumpReplay, FALSE))
|
||||
failed = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
failed = TRUE;
|
||||
}
|
||||
}
|
||||
free(args);
|
||||
if (failed)
|
||||
|
|
|
@ -147,8 +147,8 @@ static const COMMAND_LINE_ARGUMENT_A global_cmd_args[] = {
|
|||
"later\" option in MSTSC." },
|
||||
{ "drives", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL,
|
||||
"Redirect all mount points as shares" },
|
||||
{ "dump", COMMAND_LINE_VALUE_REQUIRED, "<record|replay>,<file>", NULL, NULL, -1, NULL,
|
||||
"record or replay dump" },
|
||||
{ "dump", COMMAND_LINE_VALUE_REQUIRED, "<record|replay>,file:<file>[,nodelay]", NULL, NULL, -1,
|
||||
NULL, "record or replay dump" },
|
||||
{ "dvc", COMMAND_LINE_VALUE_REQUIRED, "<channel>[,<options>]", NULL, NULL, -1, NULL,
|
||||
"Dynamic virtual channel" },
|
||||
{ "dynamic-resolution", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL,
|
||||
|
|
|
@ -432,7 +432,8 @@ struct rdp_settings
|
|||
SETTINGS_DEPRECATED(ALIGN64 char* TransportDumpFile); /* 1861 */
|
||||
SETTINGS_DEPRECATED(ALIGN64 BOOL TransportDumpReplay); /* 1862 */
|
||||
SETTINGS_DEPRECATED(ALIGN64 BOOL DeactivateClientDecoding); /* 1863 */
|
||||
UINT64 padding1920[1920 - 1864]; /* 1864 */
|
||||
SETTINGS_DEPRECATED(ALIGN64 BOOL TransportDumpReplayNodelay); /* 1864 */
|
||||
UINT64 padding1920[1920 - 1865]; /* 1865 */
|
||||
UINT64 padding1984[1984 - 1920]; /* 1920 */
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,7 +59,7 @@ extern "C"
|
|||
};
|
||||
typedef struct rdp_transport_io rdpTransportIo;
|
||||
|
||||
FREERDP_API BOOL freerdp_io_callback_set_event(rdpContext* context, BOOL reset);
|
||||
FREERDP_API BOOL freerdp_io_callback_set_event(rdpContext* context, BOOL set);
|
||||
|
||||
FREERDP_API const rdpTransportIo* freerdp_get_io_callbacks(rdpContext* context);
|
||||
FREERDP_API BOOL freerdp_set_io_callbacks(rdpContext* context,
|
||||
|
|
|
@ -600,6 +600,9 @@ BOOL freerdp_settings_get_bool(const rdpSettings* settings, FreeRDP_Settings_Key
|
|||
case FreeRDP_TransportDumpReplay:
|
||||
return settings->TransportDumpReplay;
|
||||
|
||||
case FreeRDP_TransportDumpReplayNodelay:
|
||||
return settings->TransportDumpReplayNodelay;
|
||||
|
||||
case FreeRDP_UnicodeInput:
|
||||
return settings->UnicodeInput;
|
||||
|
||||
|
@ -1378,6 +1381,10 @@ BOOL freerdp_settings_set_bool(rdpSettings* settings, FreeRDP_Settings_Keys_Bool
|
|||
settings->TransportDumpReplay = cnv.c;
|
||||
break;
|
||||
|
||||
case FreeRDP_TransportDumpReplayNodelay:
|
||||
settings->TransportDumpReplayNodelay = cnv.c;
|
||||
break;
|
||||
|
||||
case FreeRDP_UnicodeInput:
|
||||
settings->UnicodeInput = cnv.c;
|
||||
break;
|
||||
|
|
|
@ -254,6 +254,8 @@ static const struct settings_str_entry settings_map[] = {
|
|||
{ FreeRDP_ToggleFullscreen, FREERDP_SETTINGS_TYPE_BOOL, "FreeRDP_ToggleFullscreen" },
|
||||
{ FreeRDP_TransportDump, FREERDP_SETTINGS_TYPE_BOOL, "FreeRDP_TransportDump" },
|
||||
{ FreeRDP_TransportDumpReplay, FREERDP_SETTINGS_TYPE_BOOL, "FreeRDP_TransportDumpReplay" },
|
||||
{ FreeRDP_TransportDumpReplayNodelay, FREERDP_SETTINGS_TYPE_BOOL,
|
||||
"FreeRDP_TransportDumpReplayNodelay" },
|
||||
{ FreeRDP_UnicodeInput, FREERDP_SETTINGS_TYPE_BOOL, "FreeRDP_UnicodeInput" },
|
||||
{ FreeRDP_UnmapButtons, FREERDP_SETTINGS_TYPE_BOOL, "FreeRDP_UnmapButtons" },
|
||||
{ FreeRDP_UseCommonStdioCallbacks, FREERDP_SETTINGS_TYPE_BOOL,
|
||||
|
|
|
@ -40,6 +40,7 @@ struct stream_dump_context
|
|||
UINT64 replayTime;
|
||||
CONNECTION_STATE state;
|
||||
BOOL isServer;
|
||||
BOOL nodelay;
|
||||
};
|
||||
|
||||
static UINT32 crc32b(const BYTE* data, size_t length)
|
||||
|
@ -339,14 +340,19 @@ static int stream_dump_replay_transport_read(rdpTransport* transport, wStream* s
|
|||
WINPR_ASSERT(ctx->dump);
|
||||
WINPR_ASSERT(s);
|
||||
|
||||
const size_t start = Stream_GetPosition(s);
|
||||
do
|
||||
{
|
||||
Stream_SetPosition(s, start);
|
||||
if (stream_dump_get(ctx, &flags, s, &ctx->dump->replayOffset, &ts) < 0)
|
||||
return -1;
|
||||
} while (flags & STREAM_MSG_SRV_RX);
|
||||
|
||||
if ((ctx->dump->replayTime > 0) && (ts > ctx->dump->replayTime))
|
||||
slp = ts - ctx->dump->replayTime;
|
||||
if (!ctx->dump->nodelay)
|
||||
{
|
||||
if ((ctx->dump->replayTime > 0) && (ts > ctx->dump->replayTime))
|
||||
slp = ts - ctx->dump->replayTime;
|
||||
}
|
||||
ctx->dump->replayTime = ts;
|
||||
|
||||
size = Stream_Length(s);
|
||||
|
@ -391,17 +397,18 @@ static BOOL stream_dump_replay_transport_accept(rdpTransport* transport)
|
|||
|
||||
static BOOL stream_dump_register_read_handlers(rdpContext* context)
|
||||
{
|
||||
rdpTransportIo dump;
|
||||
const rdpTransportIo* dfl = freerdp_get_io_callbacks(context);
|
||||
|
||||
if (!freerdp_settings_get_bool(context->settings, FreeRDP_TransportDumpReplay))
|
||||
return TRUE;
|
||||
|
||||
WINPR_ASSERT(dfl);
|
||||
dump = *dfl;
|
||||
rdpTransportIo dump = *dfl;
|
||||
|
||||
/* Remember original callbacks for later */
|
||||
WINPR_ASSERT(context->dump);
|
||||
context->dump->nodelay =
|
||||
freerdp_settings_get_bool(context->settings, FreeRDP_TransportDumpReplayNodelay);
|
||||
context->dump->io.ReadPdu = dfl->ReadPdu;
|
||||
context->dump->io.WritePdu = dfl->WritePdu;
|
||||
|
||||
|
@ -415,7 +422,9 @@ static BOOL stream_dump_register_read_handlers(rdpContext* context)
|
|||
dump.TCPConnect = stream_dump_replay_transport_tcp_connect;
|
||||
dump.TLSAccept = stream_dump_replay_transport_accept;
|
||||
dump.TLSConnect = stream_dump_replay_transport_tls_connect;
|
||||
return freerdp_set_io_callbacks(context, &dump);
|
||||
if (!freerdp_set_io_callbacks(context, &dump))
|
||||
return FALSE;
|
||||
return freerdp_io_callback_set_event(context, TRUE);
|
||||
}
|
||||
|
||||
BOOL stream_dump_register_handlers(rdpContext* context, CONNECTION_STATE state, BOOL isServer)
|
||||
|
|
|
@ -184,6 +184,7 @@ static const size_t bool_list_indices[] = {
|
|||
FreeRDP_ToggleFullscreen,
|
||||
FreeRDP_TransportDump,
|
||||
FreeRDP_TransportDumpReplay,
|
||||
FreeRDP_TransportDumpReplayNodelay,
|
||||
FreeRDP_UnicodeInput,
|
||||
FreeRDP_UnmapButtons,
|
||||
FreeRDP_UseCommonStdioCallbacks,
|
||||
|
|
Loading…
Reference in New Issue