From 34d0d94df0749850f7e3e77620a73c5692ad3b24 Mon Sep 17 00:00:00 2001 From: Aaron Roney Date: Wed, 19 Apr 2023 05:37:30 +0000 Subject: [PATCH 1/3] Allow passing `bind_address` to dedicated room. --- src/dedicated_room/yuzu_room.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/dedicated_room/yuzu_room.cpp b/src/dedicated_room/yuzu_room.cpp index 359891883..e1cf8a76d 100644 --- a/src/dedicated_room/yuzu_room.cpp +++ b/src/dedicated_room/yuzu_room.cpp @@ -49,6 +49,7 @@ static void PrintHelp(const char* argv0) { " [options] \n" "--room-name The name of the room\n" "--room-description The room description\n" + "--bind-address The bind address for the room\n" "--port The port used for the room\n" "--max_members The maximum number of players for this room\n" "--password The password for the room\n" @@ -195,6 +196,7 @@ int main(int argc, char** argv) { std::string web_api_url; std::string ban_list_file; std::string log_file = "yuzu-room.log"; + std::string bind_address; u64 preferred_game_id = 0; u32 port = Network::DefaultRoomPort; u32 max_members = 16; @@ -203,6 +205,7 @@ int main(int argc, char** argv) { static struct option long_options[] = { {"room-name", required_argument, 0, 'n'}, {"room-description", required_argument, 0, 'd'}, + {"bind-address", required_argument, 0, 's'}, {"port", required_argument, 0, 'p'}, {"max_members", required_argument, 0, 'm'}, {"password", required_argument, 0, 'w'}, @@ -222,7 +225,7 @@ int main(int argc, char** argv) { InitializeLogging(log_file); while (optind < argc) { - int arg = getopt_long(argc, argv, "n:d:p:m:w:g:u:t:a:i:l:hv", long_options, &option_index); + int arg = getopt_long(argc, argv, "n:d:s:p:m:w:g:u:t:a:i:l:hv", long_options, &option_index); if (arg != -1) { switch (static_cast(arg)) { case 'n': @@ -231,6 +234,9 @@ int main(int argc, char** argv) { case 'd': room_description.assign(optarg); break; + case 's': + bind_address.assign(optarg); + break; case 'p': port = strtoul(optarg, &endarg, 0); break; @@ -295,6 +301,9 @@ int main(int argc, char** argv) { PrintHelp(argv[0]); return -1; } + if (bind_address.empty()) { + LOG_INFO(Network, "Bind address is empty: defaulting to 0.0.0.0"); + } if (port > UINT16_MAX) { LOG_ERROR(Network, "Port needs to be in the range 0 - 65535!"); PrintHelp(argv[0]); @@ -358,7 +367,7 @@ int main(int argc, char** argv) { if (auto room = network.GetRoom().lock()) { AnnounceMultiplayerRoom::GameInfo preferred_game_info{.name = preferred_game, .id = preferred_game_id}; - if (!room->Create(room_name, room_description, "", port, password, max_members, username, + if (!room->Create(room_name, room_description, bind_address, port, password, max_members, username, preferred_game_info, std::move(verify_backend), ban_list, enable_yuzu_mods)) { LOG_INFO(Network, "Failed to create room: "); From 3e7af5fbd7ae5546b234e39d2ebed7ab47959e2c Mon Sep 17 00:00:00 2001 From: Aaron Roney Date: Wed, 19 Apr 2023 16:26:49 +0000 Subject: [PATCH 2/3] Fix formatting. --- src/dedicated_room/yuzu_room.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dedicated_room/yuzu_room.cpp b/src/dedicated_room/yuzu_room.cpp index e1cf8a76d..c1e5c8caf 100644 --- a/src/dedicated_room/yuzu_room.cpp +++ b/src/dedicated_room/yuzu_room.cpp @@ -367,8 +367,8 @@ int main(int argc, char** argv) { if (auto room = network.GetRoom().lock()) { AnnounceMultiplayerRoom::GameInfo preferred_game_info{.name = preferred_game, .id = preferred_game_id}; - if (!room->Create(room_name, room_description, bind_address, port, password, max_members, username, - preferred_game_info, std::move(verify_backend), ban_list, + if (!room->Create(room_name, room_description, bind_address, port, password, max_members, + username, preferred_game_info, std::move(verify_backend), ban_list, enable_yuzu_mods)) { LOG_INFO(Network, "Failed to create room: "); return -1; From 79e32127b3897424015b3f6842c87ea81e37efb1 Mon Sep 17 00:00:00 2001 From: Aaron Roney Date: Wed, 19 Apr 2023 17:52:09 +0000 Subject: [PATCH 3/3] Run clang-format to fix all. --- src/dedicated_room/yuzu_room.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dedicated_room/yuzu_room.cpp b/src/dedicated_room/yuzu_room.cpp index c1e5c8caf..d707dabe2 100644 --- a/src/dedicated_room/yuzu_room.cpp +++ b/src/dedicated_room/yuzu_room.cpp @@ -225,7 +225,8 @@ int main(int argc, char** argv) { InitializeLogging(log_file); while (optind < argc) { - int arg = getopt_long(argc, argv, "n:d:s:p:m:w:g:u:t:a:i:l:hv", long_options, &option_index); + int arg = + getopt_long(argc, argv, "n:d:s:p:m:w:g:u:t:a:i:l:hv", long_options, &option_index); if (arg != -1) { switch (static_cast(arg)) { case 'n':