mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	network: check Console ID conflicts
As Console ID can be sensitive data sometimes, this implementation sent a SHA256 hash of it instead.
This commit is contained in:
		
							parent
							
								
									3c589f473f
								
							
						
					
					
						commit
						c396e3c6e5
					
				
					 14 changed files with 109 additions and 23 deletions
				
			
		|  | @ -15,6 +15,7 @@ | |||
| #include "citra_qt/multiplayer/state.h" | ||||
| #include "citra_qt/multiplayer/validation.h" | ||||
| #include "citra_qt/ui_settings.h" | ||||
| #include "core/hle/service/cfg/cfg.h" | ||||
| #include "core/settings.h" | ||||
| #include "network/network.h" | ||||
| #include "ui_direct_connect.h" | ||||
|  | @ -97,6 +98,7 @@ void DirectConnectWindow::Connect() { | |||
|         if (auto room_member = Network::GetRoomMember().lock()) { | ||||
|             auto port = UISettings::values.port.toUInt(); | ||||
|             room_member->Join(ui->nickname->text().toStdString(), | ||||
|                               Service::CFG::GetConsoleIdHash(Core::System::GetInstance()), | ||||
|                               ui->ip->text().toStdString().c_str(), port, 0, | ||||
|                               Network::NoPreferredMac, ui->password->text().toStdString().c_str()); | ||||
|         } | ||||
|  |  | |||
|  | @ -19,6 +19,7 @@ | |||
| #include "citra_qt/ui_settings.h" | ||||
| #include "common/logging/log.h" | ||||
| #include "core/announce_multiplayer_session.h" | ||||
| #include "core/hle/service/cfg/cfg.h" | ||||
| #include "core/settings.h" | ||||
| #include "ui_host_room.h" | ||||
| 
 | ||||
|  | @ -116,8 +117,9 @@ void HostRoomWindow::Host() { | |||
|                 return; | ||||
|             } | ||||
|         } | ||||
|         member->Join(ui->username->text().toStdString(), "127.0.0.1", port, 0, | ||||
|                      Network::NoPreferredMac, password); | ||||
|         member->Join(ui->username->text().toStdString(), | ||||
|                      Service::CFG::GetConsoleIdHash(Core::System::GetInstance()), "127.0.0.1", port, | ||||
|                      0, Network::NoPreferredMac, password); | ||||
| 
 | ||||
|         // Store settings
 | ||||
|         UISettings::values.room_nickname = ui->username->text(); | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ | |||
| #include "citra_qt/multiplayer/validation.h" | ||||
| #include "citra_qt/ui_settings.h" | ||||
| #include "common/logging/log.h" | ||||
| #include "core/hle/service/cfg/cfg.h" | ||||
| #include "core/settings.h" | ||||
| #include "network/network.h" | ||||
| 
 | ||||
|  | @ -139,7 +140,8 @@ void Lobby::OnJoinRoom(const QModelIndex& source) { | |||
|     // attempt to connect in a different thread
 | ||||
|     QFuture<void> f = QtConcurrent::run([nickname, ip, port, password] { | ||||
|         if (auto room_member = Network::GetRoomMember().lock()) { | ||||
|             room_member->Join(nickname, ip.c_str(), port, 0, Network::NoPreferredMac, password); | ||||
|             room_member->Join(nickname, Service::CFG::GetConsoleIdHash(Core::System::GetInstance()), | ||||
|                               ip.c_str(), port, 0, Network::NoPreferredMac, password); | ||||
|         } | ||||
|     }); | ||||
|     watcher->setFuture(f); | ||||
|  |  | |||
|  | @ -38,6 +38,9 @@ const ConnectionError GENERIC_ERROR( | |||
| const ConnectionError LOST_CONNECTION(QT_TR_NOOP("Connection to room lost. Try to reconnect.")); | ||||
| const ConnectionError MAC_COLLISION( | ||||
|     QT_TR_NOOP("MAC address is already in use. Please choose another.")); | ||||
| const ConnectionError CONSOLE_ID_COLLISION(QT_TR_NOOP( | ||||
|     "Your Console ID conflicted with someone else's in the room.\n\nPlease go to Emulation " | ||||
|     "> Configure > System to regenerate your Console ID.")); | ||||
| 
 | ||||
| static bool WarnMessage(const std::string& title, const std::string& text) { | ||||
|     return QMessageBox::Ok == QMessageBox::warning(nullptr, QObject::tr(title.c_str()), | ||||
|  |  | |||
|  | @ -37,6 +37,7 @@ extern const ConnectionError WRONG_PASSWORD; | |||
| extern const ConnectionError GENERIC_ERROR; | ||||
| extern const ConnectionError LOST_CONNECTION; | ||||
| extern const ConnectionError MAC_COLLISION; | ||||
| extern const ConnectionError CONSOLE_ID_COLLISION; | ||||
| 
 | ||||
| /**
 | ||||
|  *  Shows a standard QMessageBox with a error message | ||||
|  |  | |||
|  | @ -102,6 +102,9 @@ void MultiplayerState::OnNetworkStateChanged(const Network::RoomMember::State& s | |||
|     case Network::RoomMember::State::MacCollision: | ||||
|         NetworkMessage::ShowError(NetworkMessage::MAC_COLLISION); | ||||
|         break; | ||||
|     case Network::RoomMember::State::ConsoleIdCollision: | ||||
|         NetworkMessage::ShowError(NetworkMessage::CONSOLE_ID_COLLISION); | ||||
|         break; | ||||
|     case Network::RoomMember::State::RoomIsFull: | ||||
|         NetworkMessage::ShowError(NetworkMessage::ROOM_IS_FULL); | ||||
|         break; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue