mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 13:14:04 +00:00
Custom relay server support (#13395)
* Custom relay server support Add support for custom user-ran relay servers. * snprintf NULL fix
This commit is contained in:
parent
f6291adf01
commit
c752f9b0de
@ -1457,6 +1457,7 @@ static struct config_path_setting *populate_settings_path(
|
||||
SETTING_PATH("core_updater_buildbot_assets_url", settings->paths.network_buildbot_assets_url, false, NULL, true);
|
||||
#ifdef HAVE_NETWORKING
|
||||
SETTING_PATH("netplay_ip_address", settings->paths.netplay_server, false, NULL, true);
|
||||
SETTING_PATH("netplay_custom_mitm_server", settings->paths.netplay_custom_mitm_server, false, NULL, true);
|
||||
SETTING_PATH("netplay_password", settings->paths.netplay_password, false, NULL, true);
|
||||
SETTING_PATH("netplay_spectate_password", settings->paths.netplay_spectate_password, false, NULL, true);
|
||||
#endif
|
||||
|
@ -455,6 +455,7 @@ typedef struct settings
|
||||
char netplay_spectate_password[128];
|
||||
|
||||
char netplay_server[255];
|
||||
char netplay_custom_mitm_server[255];
|
||||
char network_buildbot_url[255];
|
||||
char network_buildbot_assets_url[255];
|
||||
|
||||
|
@ -3930,6 +3930,10 @@ MSG_HASH(
|
||||
MENU_ENUM_LABEL_NETPLAY_MITM_SERVER,
|
||||
"netplay_mitm_server"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_NETPLAY_CUSTOM_MITM_SERVER,
|
||||
"netplay_custom_mitm_server"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_ADD_TO_MIXER,
|
||||
"audio_add_to_mixer"
|
||||
|
@ -5274,6 +5274,14 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_NETPLAY_MITM_SERVER,
|
||||
"Choose a specific relay server to use. Geographically closer locations tend to have lower latency."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_NETPLAY_CUSTOM_MITM_SERVER,
|
||||
"Custom Relay Server Address"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_NETPLAY_CUSTOM_MITM_SERVER,
|
||||
"Input the address of your custom relay server here. Format: address or address|port"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS,
|
||||
"Server Address"
|
||||
|
@ -926,6 +926,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_viewport_custom_x,
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_viewport_custom_y, MENU_ENUM_SUBLABEL_VIDEO_VIEWPORT_CUSTOM_Y)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_netplay_use_mitm_server, MENU_ENUM_SUBLABEL_NETPLAY_USE_MITM_SERVER)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_netplay_mitm_server, MENU_ENUM_SUBLABEL_NETPLAY_MITM_SERVER)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_netplay_custom_mitm_server, MENU_ENUM_SUBLABEL_NETPLAY_CUSTOM_MITM_SERVER)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_core_lock, MENU_ENUM_SUBLABEL_CORE_LOCK)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_core_delete, MENU_ENUM_SUBLABEL_CORE_DELETE)
|
||||
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_pause_hardcode_mode, MENU_ENUM_SUBLABEL_ACHIEVEMENT_PAUSE)
|
||||
@ -4284,6 +4285,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
case MENU_ENUM_LABEL_NETPLAY_MITM_SERVER:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_netplay_mitm_server);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_NETPLAY_CUSTOM_MITM_SERVER:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_netplay_custom_mitm_server);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_CORE_LOCK:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_core_lock);
|
||||
break;
|
||||
|
@ -7299,6 +7299,7 @@ unsigned menu_displaylist_build_list(
|
||||
{MENU_ENUM_LABEL_NETPLAY_PUBLIC_ANNOUNCE, PARSE_ONLY_BOOL, true },
|
||||
{MENU_ENUM_LABEL_NETPLAY_USE_MITM_SERVER, PARSE_ONLY_BOOL, true },
|
||||
{MENU_ENUM_LABEL_NETPLAY_MITM_SERVER, PARSE_ONLY_STRING, false},
|
||||
{MENU_ENUM_LABEL_NETPLAY_CUSTOM_MITM_SERVER, PARSE_ONLY_STRING, false},
|
||||
{MENU_ENUM_LABEL_NETPLAY_IP_ADDRESS, PARSE_ONLY_STRING, true},
|
||||
{MENU_ENUM_LABEL_NETPLAY_TCP_UDP_PORT, PARSE_ONLY_UINT, true},
|
||||
{MENU_ENUM_LABEL_NETPLAY_MAX_CONNECTIONS, PARSE_ONLY_UINT, true},
|
||||
@ -7331,6 +7332,10 @@ unsigned menu_displaylist_build_list(
|
||||
if (netplay_use_mitm_server)
|
||||
build_list[i].checked = true;
|
||||
break;
|
||||
case MENU_ENUM_LABEL_NETPLAY_CUSTOM_MITM_SERVER:
|
||||
if (netplay_use_mitm_server)
|
||||
build_list[i].checked = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -9948,6 +9953,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
{MENU_ENUM_LABEL_NETPLAY_PUBLIC_ANNOUNCE, PARSE_ONLY_BOOL, true },
|
||||
{MENU_ENUM_LABEL_NETPLAY_USE_MITM_SERVER, PARSE_ONLY_BOOL, true },
|
||||
{MENU_ENUM_LABEL_NETPLAY_MITM_SERVER, PARSE_ONLY_STRING, false},
|
||||
{MENU_ENUM_LABEL_NETPLAY_CUSTOM_MITM_SERVER, PARSE_ONLY_STRING, false},
|
||||
{MENU_ENUM_LABEL_NETPLAY_PASSWORD, PARSE_ONLY_STRING, true},
|
||||
{MENU_ENUM_LABEL_NETPLAY_SPECTATE_PASSWORD, PARSE_ONLY_STRING, true},
|
||||
};
|
||||
@ -9985,6 +9991,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
if (settings->bools.netplay_use_mitm_server)
|
||||
build_list[i].checked = true;
|
||||
break;
|
||||
case MENU_ENUM_LABEL_NETPLAY_CUSTOM_MITM_SERVER:
|
||||
if (settings->bools.netplay_use_mitm_server)
|
||||
build_list[i].checked = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -19176,6 +19176,22 @@ static bool setting_append_list(
|
||||
(*list)[list_info->index - 1].get_string_representation =
|
||||
&setting_get_string_representation_netplay_mitm_server;
|
||||
|
||||
CONFIG_STRING(
|
||||
list, list_info,
|
||||
settings->paths.netplay_custom_mitm_server,
|
||||
sizeof(settings->paths.netplay_custom_mitm_server),
|
||||
MENU_ENUM_LABEL_NETPLAY_CUSTOM_MITM_SERVER,
|
||||
MENU_ENUM_LABEL_VALUE_NETPLAY_CUSTOM_MITM_SERVER,
|
||||
"",
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ALLOW_INPUT);
|
||||
(*list)[list_info->index - 1].ui_type = ST_UI_TYPE_STRING_LINE_EDIT;
|
||||
(*list)[list_info->index - 1].action_start = setting_generic_action_start_default;
|
||||
|
||||
CONFIG_STRING(
|
||||
list, list_info,
|
||||
settings->paths.netplay_server,
|
||||
|
@ -2912,6 +2912,7 @@ enum msg_hash_enums
|
||||
|
||||
MENU_LABEL(NETPLAY_USE_MITM_SERVER),
|
||||
MENU_LABEL(NETPLAY_MITM_SERVER),
|
||||
MENU_LABEL(NETPLAY_CUSTOM_MITM_SERVER),
|
||||
MENU_LABEL(VIDEO_WINDOW_SHOW_DECORATIONS),
|
||||
MENU_LABEL(VIDEO_WINDOW_SAVE_POSITION),
|
||||
MENU_LABEL(VIDEO_WINDOW_CUSTOM_SIZE_ENABLE),
|
||||
|
@ -141,6 +141,7 @@ static const mitm_server_t netplay_mitm_server_list[] = {
|
||||
{ "madrid", "Madrid, Spain" },
|
||||
{ "saopaulo", "Sao Paulo, Brazil" },
|
||||
{ "singapore", "Singapore" },
|
||||
{ "custom", "Custom" },
|
||||
};
|
||||
|
||||
struct netplay_room
|
||||
|
@ -7854,7 +7854,10 @@ static void netplay_announce(netplay_t *netplay)
|
||||
char *gamename = NULL;
|
||||
char *subsystemname = NULL;
|
||||
char *frontend_ident = NULL;
|
||||
char *mitm_session = NULL;
|
||||
char *mitm_session = "";
|
||||
const char *mitm_custom_addr = "";
|
||||
int mitm_custom_port = 0;
|
||||
int is_mitm = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
net_driver_state_t *net_st = &networking_driver_st;
|
||||
struct netplay_room *host_room = &net_st->host_room;
|
||||
@ -7915,8 +7918,18 @@ static void netplay_announce(netplay_t *netplay)
|
||||
sizeof(frontend_architecture));
|
||||
net_http_urlencode(&frontend_ident, frontend_architecture);
|
||||
|
||||
if (!string_is_empty(host_room->mitm_session))
|
||||
{
|
||||
is_mitm = 1;
|
||||
net_http_urlencode(&mitm_session, host_room->mitm_session);
|
||||
|
||||
if (string_is_equal(host_room->mitm_handle, "custom"))
|
||||
{
|
||||
mitm_custom_addr = host_room->mitm_address;
|
||||
mitm_custom_port = host_room->mitm_port;
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf),
|
||||
"username=%s&"
|
||||
"core_name=%s&"
|
||||
@ -7931,7 +7944,9 @@ static void netplay_announce(netplay_t *netplay)
|
||||
"retroarch_version=%s&"
|
||||
"frontend=%s&"
|
||||
"subsystem_name=%s&"
|
||||
"mitm_session=%s",
|
||||
"mitm_session=%s&"
|
||||
"mitm_custom_addr=%s&"
|
||||
"mitm_custom_port=%d",
|
||||
username,
|
||||
corename,
|
||||
coreversion,
|
||||
@ -7941,11 +7956,13 @@ static void netplay_announce(netplay_t *netplay)
|
||||
host_room->mitm_handle,
|
||||
!string_is_empty(settings->paths.netplay_password) ? 1 : 0,
|
||||
!string_is_empty(settings->paths.netplay_spectate_password) ? 1 : 0,
|
||||
!string_is_empty(host_room->mitm_session) ? 1 : 0,
|
||||
is_mitm,
|
||||
PACKAGE_VERSION,
|
||||
frontend_ident,
|
||||
subsystemname,
|
||||
mitm_session);
|
||||
mitm_session,
|
||||
mitm_custom_addr,
|
||||
mitm_custom_port);
|
||||
|
||||
free(username);
|
||||
free(corename);
|
||||
@ -8019,18 +8036,43 @@ static void netplay_mitm_query_cb(retro_task_t *task, void *task_data,
|
||||
|
||||
static bool netplay_mitm_query(const char *mitm_name)
|
||||
{
|
||||
char query[512];
|
||||
net_driver_state_t *net_st = &networking_driver_st;
|
||||
struct netplay_room *host_room = &net_st->host_room;
|
||||
|
||||
if (string_is_empty(mitm_name))
|
||||
return false;
|
||||
|
||||
/* We don't need to query,
|
||||
if we are using a custom relay server. */
|
||||
if (string_is_equal(mitm_name, "custom"))
|
||||
{
|
||||
char addr[256];
|
||||
char sess[sizeof(addr)];
|
||||
unsigned port;
|
||||
settings_t *settings = config_get_ptr();
|
||||
const char *custom_server =
|
||||
settings->paths.netplay_custom_mitm_server;
|
||||
|
||||
addr[0] = '\0';
|
||||
sess[0] = '\0';
|
||||
port = 0;
|
||||
|
||||
netplay_decode_hostname(custom_server,
|
||||
addr, &port, sess, sizeof(addr));
|
||||
|
||||
strlcpy(host_room->mitm_address, addr,
|
||||
sizeof(host_room->mitm_address));
|
||||
host_room->mitm_port = port;
|
||||
}
|
||||
else
|
||||
{
|
||||
char query[512];
|
||||
#ifndef NETPLAY_TEST_BUILD
|
||||
const char *url = "http://lobby.libretro.com/tunnel";
|
||||
#else
|
||||
const char *url = "http://lobbytest.libretro.com/tunnel";
|
||||
#endif
|
||||
|
||||
if (string_is_empty(mitm_name))
|
||||
return false;
|
||||
|
||||
snprintf(query, sizeof(query), "%s?name=%s", url, mitm_name);
|
||||
|
||||
if (!task_push_http_transfer(query,
|
||||
@ -8039,6 +8081,7 @@ static bool netplay_mitm_query(const char *mitm_name)
|
||||
|
||||
/* Make sure we've the tunnel address before continuing. */
|
||||
task_queue_wait(NULL, NULL);
|
||||
}
|
||||
|
||||
return !string_is_empty(host_room->mitm_address) &&
|
||||
host_room->mitm_port;
|
||||
|
@ -498,6 +498,8 @@ QGroupBox *NetplayPage::createMitmServerGroup()
|
||||
groupBox->addRow(radioButton);
|
||||
}
|
||||
|
||||
groupBox->add(MENU_ENUM_LABEL_NETPLAY_CUSTOM_MITM_SERVER);
|
||||
|
||||
connect(buttonGroup, SIGNAL(buttonClicked(int)),
|
||||
this, SLOT(onRadioButtonClicked(int)));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user