Add support for joining MITM servers over cmdline (#15762)

* Add support for MITM servers over cmdline

* Address https://github.com/libretro/RetroArch/pull/15762#pullrequestreview-1654378806
This commit is contained in:
XK 2023-10-06 10:02:50 +01:00 committed by GitHub
parent e7eb588fb6
commit 812c003a6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -299,6 +299,7 @@ extern const bluetooth_driver_t *bluetooth_drivers[];
struct rarch_state
{
char *connect_host; /* Netplay hostname passed from CLI */
char *connect_mitm_id; /* Netplay MITM address from CLI */
struct retro_perf_counter *perf_counters_rarch[MAX_COUNTERS];
@ -3780,10 +3781,20 @@ bool command_event(enum event_command cmd, void *data)
netplay_server = tmp_netplay_server;
netplay_session = tmp_netplay_session;
}
if (p_rarch->connect_host)
if (p_rarch->connect_mitm_id)
netplay_session = strdup(p_rarch->connect_mitm_id);
if (p_rarch->connect_host)
{
free(p_rarch->connect_host);
p_rarch->connect_host = NULL;
free(p_rarch->connect_host);
p_rarch->connect_host = NULL;
}
if (p_rarch->connect_mitm_id)
{
free(p_rarch->connect_mitm_id);
p_rarch->connect_mitm_id = NULL;
}
if (string_is_empty(netplay_server))
@ -5315,6 +5326,8 @@ static void retroarch_print_help(const char *arg0)
"Connect to netplay server as user 2.\n"
" --port=PORT "
"Port used to netplay. Default is 55435.\n"
" --mitm-session=ID "
"MITM (relay) session ID to join.\n"
" --nick=NICK "
"Picks a username (for use with netplay). Not mandatory.\n"
" --check-frames=NUMBER "
@ -5626,6 +5639,7 @@ static bool retroarch_parse_input_and_config(
#ifdef HAVE_NETWORKING
{ "host", 0, NULL, 'H' },
{ "connect", 1, NULL, 'C' },
{ "mitm-session", 1, NULL, 'T' },
{ "check-frames", 1, NULL, RA_OPT_CHECK_FRAMES },
{ "port", 1, NULL, RA_OPT_PORT },
#ifdef HAVE_NETWORK_CMD
@ -6054,6 +6068,10 @@ static bool retroarch_parse_input_and_config(
netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL);
p_rarch->connect_host = strdup(optarg);
break;
case 'T':
p_rarch->connect_mitm_id = strdup(optarg);
break;
case RA_OPT_CHECK_FRAMES:
retroarch_override_setting_set(