summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2023-04-21 23:13:51 -0700
committerGravatar GitHub2023-04-21 23:13:51 -0700
commitd0e6eafe23418f94dc88a0c3f8f221394d6d4d0a (patch)
tree5db236607039ba183c5cb8a6f89a843deea634c9 /src
parentMerge pull request #10060 from german77/no_dead (diff)
parentRun clang-format to fix all. (diff)
downloadyuzu-d0e6eafe23418f94dc88a0c3f8f221394d6d4d0a.tar.gz
yuzu-d0e6eafe23418f94dc88a0c3f8f221394d6d4d0a.tar.xz
yuzu-d0e6eafe23418f94dc88a0c3f8f221394d6d4d0a.zip
Merge pull request #10068 from twitchax/twitchax/dr_bind_address
Allow passing `--bind-address` to dedicated room.
Diffstat (limited to '')
-rw-r--r--src/dedicated_room/yuzu_room.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/dedicated_room/yuzu_room.cpp b/src/dedicated_room/yuzu_room.cpp
index 359891883..d707dabe2 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) {
49 " [options] <filename>\n" 49 " [options] <filename>\n"
50 "--room-name The name of the room\n" 50 "--room-name The name of the room\n"
51 "--room-description The room description\n" 51 "--room-description The room description\n"
52 "--bind-address The bind address for the room\n"
52 "--port The port used for the room\n" 53 "--port The port used for the room\n"
53 "--max_members The maximum number of players for this room\n" 54 "--max_members The maximum number of players for this room\n"
54 "--password The password for the room\n" 55 "--password The password for the room\n"
@@ -195,6 +196,7 @@ int main(int argc, char** argv) {
195 std::string web_api_url; 196 std::string web_api_url;
196 std::string ban_list_file; 197 std::string ban_list_file;
197 std::string log_file = "yuzu-room.log"; 198 std::string log_file = "yuzu-room.log";
199 std::string bind_address;
198 u64 preferred_game_id = 0; 200 u64 preferred_game_id = 0;
199 u32 port = Network::DefaultRoomPort; 201 u32 port = Network::DefaultRoomPort;
200 u32 max_members = 16; 202 u32 max_members = 16;
@@ -203,6 +205,7 @@ int main(int argc, char** argv) {
203 static struct option long_options[] = { 205 static struct option long_options[] = {
204 {"room-name", required_argument, 0, 'n'}, 206 {"room-name", required_argument, 0, 'n'},
205 {"room-description", required_argument, 0, 'd'}, 207 {"room-description", required_argument, 0, 'd'},
208 {"bind-address", required_argument, 0, 's'},
206 {"port", required_argument, 0, 'p'}, 209 {"port", required_argument, 0, 'p'},
207 {"max_members", required_argument, 0, 'm'}, 210 {"max_members", required_argument, 0, 'm'},
208 {"password", required_argument, 0, 'w'}, 211 {"password", required_argument, 0, 'w'},
@@ -222,7 +225,8 @@ int main(int argc, char** argv) {
222 InitializeLogging(log_file); 225 InitializeLogging(log_file);
223 226
224 while (optind < argc) { 227 while (optind < argc) {
225 int arg = getopt_long(argc, argv, "n:d:p:m:w:g:u:t:a:i:l:hv", long_options, &option_index); 228 int arg =
229 getopt_long(argc, argv, "n:d:s:p:m:w:g:u:t:a:i:l:hv", long_options, &option_index);
226 if (arg != -1) { 230 if (arg != -1) {
227 switch (static_cast<char>(arg)) { 231 switch (static_cast<char>(arg)) {
228 case 'n': 232 case 'n':
@@ -231,6 +235,9 @@ int main(int argc, char** argv) {
231 case 'd': 235 case 'd':
232 room_description.assign(optarg); 236 room_description.assign(optarg);
233 break; 237 break;
238 case 's':
239 bind_address.assign(optarg);
240 break;
234 case 'p': 241 case 'p':
235 port = strtoul(optarg, &endarg, 0); 242 port = strtoul(optarg, &endarg, 0);
236 break; 243 break;
@@ -295,6 +302,9 @@ int main(int argc, char** argv) {
295 PrintHelp(argv[0]); 302 PrintHelp(argv[0]);
296 return -1; 303 return -1;
297 } 304 }
305 if (bind_address.empty()) {
306 LOG_INFO(Network, "Bind address is empty: defaulting to 0.0.0.0");
307 }
298 if (port > UINT16_MAX) { 308 if (port > UINT16_MAX) {
299 LOG_ERROR(Network, "Port needs to be in the range 0 - 65535!"); 309 LOG_ERROR(Network, "Port needs to be in the range 0 - 65535!");
300 PrintHelp(argv[0]); 310 PrintHelp(argv[0]);
@@ -358,8 +368,8 @@ int main(int argc, char** argv) {
358 if (auto room = network.GetRoom().lock()) { 368 if (auto room = network.GetRoom().lock()) {
359 AnnounceMultiplayerRoom::GameInfo preferred_game_info{.name = preferred_game, 369 AnnounceMultiplayerRoom::GameInfo preferred_game_info{.name = preferred_game,
360 .id = preferred_game_id}; 370 .id = preferred_game_id};
361 if (!room->Create(room_name, room_description, "", port, password, max_members, username, 371 if (!room->Create(room_name, room_description, bind_address, port, password, max_members,
362 preferred_game_info, std::move(verify_backend), ban_list, 372 username, preferred_game_info, std::move(verify_backend), ban_list,
363 enable_yuzu_mods)) { 373 enable_yuzu_mods)) {
364 LOG_INFO(Network, "Failed to create room: "); 374 LOG_INFO(Network, "Failed to create room: ");
365 return -1; 375 return -1;