From 5ede882715fdb19c55865c228ae892351c2eee9e Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Thu, 25 Aug 2022 22:24:44 -0700 Subject: [PATCH] add ability to handle V2 and V3 clients on the same port --- src/CommandFormats.hh | 12 ++-- src/PSOEncryption.cc | 93 ++++++++++++++++++++++++ src/PSOEncryption.hh | 51 ++++++++++++++ src/ProxyServer.cc | 6 +- src/ReceiveCommands.cc | 94 ++++++++++++++----------- src/SendCommands.cc | 77 ++++++++++++-------- src/SendCommands.hh | 30 +++++--- src/Version.cc | 33 ++++----- src/Version.hh | 4 +- system/config.example.json | 57 ++++++++------- tests/BB-CreateCharGame.test.txt | 8 +-- tests/GC-Episode3GameSmokeTest.test.txt | 24 ++++++- tests/GC-ForestGame.test.txt | 12 ++-- tests/GC-LoginSmokeTest.test.txt | 6 +- tests/PC-BasicGame.test.txt | 24 +++++-- tests/config.json | 57 ++++++++------- 16 files changed, 401 insertions(+), 187 deletions(-) diff --git a/src/CommandFormats.hh b/src/CommandFormats.hh index 0d4d8695..bd2fc509 100644 --- a/src/CommandFormats.hh +++ b/src/CommandFormats.hh @@ -1291,15 +1291,19 @@ struct C_Login_DC_PC_V3_9A { struct C_Register_DC_PC_V3_9C { le_uint64_t unused; le_uint32_t sub_version; - le_uint32_t unused2; + uint8_t unused1; + uint8_t language; + uint8_t unused2[2]; ptext serial_number; // On XB, this is the XBL gamertag ptext access_key; // On XB, this is the XBL user ID - ptext password; // On XB, this is unused + ptext password; // On XB, this contains "xbox-pso" }; struct C_Register_BB_9C { le_uint32_t sub_version; - le_uint32_t unknown_a1; // Only the second byte (0x0000??00) is used, but is 0 + uint8_t unused1; + uint8_t language; + uint8_t unused2[2]; ptext username; ptext password; ptext game_tag; // "psopc2" on BB @@ -1999,7 +2003,7 @@ struct C_VerifyLicense_V3_DB { le_uint32_t sub_version; ptext serial_number2; // On XB, this is the XBL gamertag ptext access_key2; // On XB, this is the XBL user ID - ptext password; // On XB, this is unused + ptext password; // On XB, this contains "xbox-pso" }; // Note: This login pathway generally isn't used on BB (and isn't supported at diff --git a/src/PSOEncryption.cc b/src/PSOEncryption.cc index f7db03e6..9f90ee79 100644 --- a/src/PSOEncryption.cc +++ b/src/PSOEncryption.cc @@ -105,6 +105,10 @@ void PSOV2Encryption::encrypt_big_endian(void* vdata, size_t size, bool advance) this->encrypt_t(vdata, size, advance); } +PSOEncryption::Type PSOV2Encryption::type() const { + return Type::V2; +} + void PSOV3Encryption::update_stream() { @@ -191,6 +195,83 @@ void PSOV3Encryption::encrypt_big_endian(void* vdata, size_t size, bool advance) this->encrypt_t(vdata, size, advance); } +PSOEncryption::Type PSOV3Encryption::type() const { + return Type::V3; +} + + + +PSOV2OrV3DetectorEncryption::PSOV2OrV3DetectorEncryption( + uint32_t key, + const std::unordered_set& v2_matches, + const std::unordered_set& v3_matches) + : key(key), v2_matches(v2_matches), v3_matches(v3_matches) { } + +PSOEncryption::Type PSOV2OrV3DetectorEncryption::type() const { + if (!this->active_crypt) { + throw logic_error("detector encryption state is indeterminate"); + } + return this->active_crypt->type(); +} + +void PSOV2OrV3DetectorEncryption::encrypt(void* data, size_t size, bool advance) { + if (!this->active_crypt) { + if (size != 4) { + throw logic_error("initial detector decrypt size must be 4"); + } + + le_uint32_t encrypted = *reinterpret_cast(data); + + le_uint32_t decrypted_v2 = encrypted; + unique_ptr v2_crypt(new PSOV2Encryption(this->key)); + v2_crypt->decrypt(&decrypted_v2, sizeof(decrypted_v2), false); + + le_uint32_t decrypted_v3 = encrypted; + unique_ptr v3_crypt(new PSOV3Encryption(this->key)); + v3_crypt->decrypt(&decrypted_v3, sizeof(decrypted_v3), false); + + bool v2_match = this->v2_matches.count(decrypted_v2); + bool v3_match = this->v3_matches.count(decrypted_v3); + if (!v2_match && !v3_match) { + throw runtime_error("unable to determine crypt version"); + } else if (v2_match && v3_match) { + throw runtime_error("ambiguous crypt version"); + } else if (v2_match) { + this->active_crypt = move(v2_crypt); + } else { + this->active_crypt = move(v3_crypt); + } + } + this->active_crypt->encrypt(data, size, advance); +} + + + +PSOV2OrV3ImitatorEncryption::PSOV2OrV3ImitatorEncryption( + uint32_t key, std::shared_ptr detector_crypt) + : key(key), detector_crypt(detector_crypt) { } + +void PSOV2OrV3ImitatorEncryption::encrypt(void* data, size_t size, bool advance) { + if (!this->active_crypt) { + auto t = this->detector_crypt->type(); + if (t == Type::V2) { + this->active_crypt.reset(new PSOV2Encryption(this->key)); + } else if (t == Type::V3) { + this->active_crypt.reset(new PSOV3Encryption(this->key)); + } else { + throw logic_error("detector crypt is not V2 or V3"); + } + } + this->active_crypt->encrypt(data, size, advance); +} + +PSOEncryption::Type PSOV2OrV3ImitatorEncryption::type() const { + if (!this->active_crypt) { + return this->detector_crypt->type(); + } + return this->active_crypt->type(); +} + void PSOBBEncryption::decrypt(void* vdata, size_t size, bool advance) { @@ -663,6 +744,10 @@ void PSOBBEncryption::apply_seed(const void* original_seed, size_t seed_size) { } } +PSOEncryption::Type PSOBBEncryption::type() const { + return Type::BB; +} + PSOBBMultiKeyDetectorEncryption::PSOBBMultiKeyDetectorEncryption( @@ -706,6 +791,10 @@ void PSOBBMultiKeyDetectorEncryption::decrypt(void* data, size_t size, bool adva this->active_crypt->decrypt(data, size, advance); } +PSOEncryption::Type PSOBBMultiKeyDetectorEncryption::type() const { + return Type::BB; +} + PSOBBMultiKeyImitatorEncryption::PSOBBMultiKeyImitatorEncryption( @@ -745,3 +834,7 @@ shared_ptr PSOBBMultiKeyImitatorEncryption::ensure_crypt() { } return this->active_crypt; } + +PSOEncryption::Type PSOBBMultiKeyImitatorEncryption::type() const { + return Type::BB; +} diff --git a/src/PSOEncryption.hh b/src/PSOEncryption.hh index 2fc4b3d8..f60c9bcb 100644 --- a/src/PSOEncryption.hh +++ b/src/PSOEncryption.hh @@ -18,6 +18,12 @@ class PSOEncryption { public: + enum class Type { + V2 = 0, + V3, + BB, + }; + virtual ~PSOEncryption() = default; virtual void encrypt(void* data, size_t size, bool advance = true) = 0; @@ -30,6 +36,8 @@ public: this->decrypt(data.data(), data.size(), advance); } + virtual Type type() const = 0; + protected: PSOEncryption() = default; }; @@ -43,6 +51,8 @@ public: uint32_t next(bool advance = true); + virtual Type type() const; + protected: template void encrypt_t(void* data, size_t size, bool advance); @@ -62,6 +72,8 @@ public: uint32_t next(bool advance = true); + virtual Type type() const; + protected: template void encrypt_t(void* data, size_t size, bool advance); @@ -72,6 +84,39 @@ protected: uint16_t offset; }; +class PSOV2OrV3DetectorEncryption : public PSOEncryption { +public: + PSOV2OrV3DetectorEncryption( + uint32_t key, + const std::unordered_set& v2_matches, + const std::unordered_set& v3_matches); + + virtual void encrypt(void* data, size_t size, bool advance = true); + + virtual Type type() const; + +protected: + uint32_t key; + const std::unordered_set& v2_matches; + const std::unordered_set& v3_matches; + std::unique_ptr active_crypt; +}; + +class PSOV2OrV3ImitatorEncryption : public PSOEncryption { +public: + PSOV2OrV3ImitatorEncryption( + uint32_t key, std::shared_ptr client_crypt); + + virtual void encrypt(void* data, size_t size, bool advance = true); + + virtual Type type() const; + +protected: + uint32_t key; + std::shared_ptr detector_crypt; + std::shared_ptr active_crypt; +}; + class PSOBBEncryption : public PSOEncryption { public: enum Subtype : uint8_t { @@ -107,6 +152,8 @@ public: virtual void encrypt(void* data, size_t size, bool advance = true); virtual void decrypt(void* data, size_t size, bool advance = true); + virtual Type type() const; + protected: KeyFile state; @@ -136,6 +183,8 @@ public: return this->seed; } + virtual Type type() const; + protected: std::vector> possible_keys; std::shared_ptr active_key; @@ -155,6 +204,8 @@ public: virtual void encrypt(void* data, size_t size, bool advance = true); virtual void decrypt(void* data, size_t size, bool advance = true); + virtual Type type() const; + protected: std::shared_ptr ensure_crypt(); diff --git a/src/ProxyServer.cc b/src/ProxyServer.cc index db721310..86183951 100644 --- a/src/ProxyServer.cc +++ b/src/ProxyServer.cc @@ -191,8 +191,8 @@ void ProxyServer::on_client_connect( case GameVersion::XB: { uint32_t server_key = random_object(); uint32_t client_key = random_object(); - auto cmd = prepare_server_init_contents_dc_pc_v3( - false, server_key, client_key); + auto cmd = prepare_server_init_contents_console( + server_key, client_key, 0); session->channel.send(0x02, 0x00, &cmd, sizeof(cmd)); // TODO: Is this actually needed? // bufferevent_flush(session->channel.bev.get(), EV_READ | EV_WRITE, BEV_FLUSH); @@ -210,7 +210,7 @@ void ProxyServer::on_client_connect( parray client_key; random_data(server_key.data(), server_key.bytes()); random_data(client_key.data(), client_key.bytes()); - auto cmd = prepare_server_init_contents_bb(server_key, client_key, false); + auto cmd = prepare_server_init_contents_bb(server_key, client_key, 0); session->channel.send(0x03, 0x00, &cmd, sizeof(cmd)); // TODO: Is this actually needed? // bufferevent_flush(session->bev.get(), EV_READ | EV_WRITE, BEV_FLUSH); diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 2cd709b7..02308d6f 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -68,36 +68,27 @@ vector quest_download_menu({ void process_connect(std::shared_ptr s, std::shared_ptr c) { switch (c->server_behavior) { - case ServerBehavior::SPLIT_RECONNECT: { + case ServerBehavior::PC_CONSOLE_DETECT: { uint16_t pc_port = s->name_to_port_config.at("pc-login")->port; - uint16_t gc_port = s->name_to_port_config.at("gc-jp10")->port; - send_pc_gc_split_reconnect(c, s->connect_address_for_client(c), pc_port, gc_port); + uint16_t console_port = s->name_to_port_config.at("console-login")->port; + send_pc_console_split_reconnect(c, s->connect_address_for_client(c), pc_port, console_port); c->should_disconnect = true; break; } - case ServerBehavior::LOGIN_SERVER_GC_TRIAL_EDITION: - c->flags |= Client::Flag::GC_TRIAL_EDITION; - [[fallthrough]]; case ServerBehavior::LOGIN_SERVER: - send_server_init(s, c, true, false); - if (s->pre_lobby_event) { - send_change_event(c, s->pre_lobby_event); - } + send_server_init(s, c, SendServerInitFlag::IS_INITIAL_CONNECTION); break; case ServerBehavior::PATCH_SERVER_BB: c->flags |= Client::Flag::BB_PATCH; - send_server_init(s, c, false, false); + send_server_init(s, c, 0); break; - case ServerBehavior::LOBBY_SERVER_GC_TRIAL_EDITION: - c->flags |= Client::Flag::GC_TRIAL_EDITION; - [[fallthrough]]; case ServerBehavior::PATCH_SERVER_PC: case ServerBehavior::DATA_SERVER_BB: case ServerBehavior::LOBBY_SERVER: - send_server_init(s, c, false, false); + send_server_init(s, c, 0); break; default: @@ -111,21 +102,19 @@ void process_login_complete(shared_ptr s, shared_ptr c) { // (when we should send ths ship select menu). if ((c->server_behavior == ServerBehavior::LOGIN_SERVER) || (c->server_behavior == ServerBehavior::DATA_SERVER_BB)) { - // On the login server, send the ep3 updates and the main menu or welcome - // message + // On the login server, send the events/songs, ep3 updates, and the main + // menu or welcome message + if (s->pre_lobby_event) { + send_change_event(c, s->pre_lobby_event); + } if (c->flags & Client::Flag::EPISODE_3) { + if (s->ep3_menu_song >= 0) { + send_ep3_change_music(c, s->ep3_menu_song); + } send_ep3_card_list_update(s, c); send_ep3_rank_update(c); } - // On BB, send the pre-lobby event, if set. This normally happens on the - // login server immediately after the encryption init command, but on BB we - // don't know the client's state until after we receive the login command, - // so we do it here instead. - if ((c->version == GameVersion::BB) && s->pre_lobby_event) { - send_change_event(c, s->pre_lobby_event); - } - if (s->welcome_message.empty() || (c->flags & Client::Flag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION) || !(c->flags & Client::Flag::AT_WELCOME_MESSAGE)) { @@ -168,10 +157,28 @@ void process_disconnect(shared_ptr s, shared_ptr c) { //////////////////////////////////////////////////////////////////////////////// +static void set_console_client_flags( + shared_ptr c, uint32_t sub_version) { + if (c->channel.crypt_in->type() == PSOEncryption::Type::V2) { + if (sub_version < 0x28) { + c->version = GameVersion::DC; + c->log.info("Game version changed to DC"); + } else if (c->version == GameVersion::GC) { + c->flags |= Client::Flag::GC_TRIAL_EDITION; + c->log.info("Trial edition flag set"); + } + } + c->flags |= flags_for_version(c->version, sub_version); +} + void process_verify_license_v3(shared_ptr s, shared_ptr c, uint16_t, uint32_t, const string& data) { // DB const auto& cmd = check_size_t(data); - c->flags |= flags_for_version(c->version, cmd.sub_version); + + if (c->channel.crypt_in->type() == PSOEncryption::Type::V2) { + throw runtime_error("GC trial edition client sent V3 verify license command"); + } + set_console_client_flags(c, cmd.sub_version); uint32_t serial_number = stoul(cmd.serial_number, nullptr, 16); try { @@ -208,8 +215,7 @@ void process_verify_license_v3(shared_ptr s, shared_ptr c, void process_login_a_dc_pc_v3(shared_ptr s, shared_ptr c, uint16_t, uint32_t, const string& data) { // 9A const auto& cmd = check_size_t(data); - - c->flags |= flags_for_version(c->version, cmd.sub_version); + set_console_client_flags(c, cmd.sub_version); uint32_t serial_number = stoul(cmd.serial_number, nullptr, 16); try { @@ -323,10 +329,6 @@ void process_login_c_dc_pc_v3(shared_ptr s, shared_ptr c, void process_login_d_e_pc_v3(shared_ptr s, shared_ptr c, uint16_t command, uint32_t, const string& data) { // 9D 9E - - // The client sends extra unused data the first time it sends these commands, - // hence the odd check_size calls here - const C_Login_PC_GC_9D* base_cmd; if (command == 0x9D) { base_cmd = &check_size_t(data, @@ -339,8 +341,22 @@ void process_login_d_e_pc_v3(shared_ptr s, shared_ptr c, } } else if (command == 0x9E) { + // GC and XB send different amounts of data in this command. This is how + // newserv determines if a V3 client is GC or XB. const auto& cmd = check_size_t(data, - sizeof(C_Login_GC_9E), sizeof(C_LoginExtended_GC_9E)); + sizeof(C_Login_GC_9E), sizeof(C_LoginExtended_XB_9E)); + switch (data.size()) { + case sizeof(C_Login_GC_9E): + case sizeof(C_LoginExtended_GC_9E): + break; + case sizeof(C_Login_XB_9E): + case sizeof(C_LoginExtended_XB_9E): + c->version = GameVersion::XB; + c->log.info("Game version set to XB"); + break; + default: + throw runtime_error("invalid size for 9E command"); + } base_cmd = &cmd; if (cmd.is_extended) { const auto& cmd = check_size_t(data); @@ -363,7 +379,7 @@ void process_login_d_e_pc_v3(shared_ptr s, shared_ptr c, throw logic_error("9D/9E handler called for incorrect command"); } - c->flags |= flags_for_version(c->version, base_cmd->sub_version); + set_console_client_flags(c, base_cmd->sub_version); uint32_t serial_number = stoul(base_cmd->serial_number, nullptr, 16); try { @@ -412,10 +428,6 @@ void process_login_d_e_pc_v3(shared_ptr s, shared_ptr c, } } - if ((c->flags & Client::Flag::EPISODE_3) && (s->ep3_menu_song >= 0)) { - send_ep3_change_music(c, s->ep3_menu_song); - } - send_update_client_config(c); process_login_complete(s, c); @@ -539,7 +551,7 @@ void process_server_time_request(shared_ptr s, shared_ptr c // responds after saving. if (c->should_send_to_lobby_server) { static const vector version_to_port_name({ - "dc-lobby", "pc-lobby", "bb-lobby", "gc-lobby", "xb-lobby", "bb-lobby"}); + "console-lobby", "pc-lobby", "bb-lobby", "console-lobby", "console-lobby", "bb-lobby"}); const auto& port_name = version_to_port_name.at(static_cast(c->version)); send_reconnect(c, s->connect_address_for_client(c), s->name_to_port_config.at(port_name)->port); @@ -881,7 +893,7 @@ void process_menu_selection(shared_ptr s, shared_ptr c, send_update_client_config(c); } else { static const vector version_to_port_name({ - "dc-lobby", "pc-lobby", "bb-lobby", "gc-lobby", "xb-lobby", "bb-lobby"}); + "console-lobby", "pc-lobby", "bb-lobby", "console-lobby", "console-lobby", "bb-lobby"}); const auto& port_name = version_to_port_name.at(static_cast(c->version)); send_reconnect(c, s->connect_address_for_client(c), s->name_to_port_config.at(port_name)->port); @@ -978,7 +990,7 @@ void process_menu_selection(shared_ptr s, shared_ptr c, // license/char name/etc. for remote auth) static const vector version_to_port_name({ - "dc-proxy", "pc-proxy", "", "gc-proxy", "xb-proxy", "bb-proxy"}); + "console-proxy", "pc-proxy", "", "console-proxy", "console-proxy", "bb-proxy"}); const auto& port_name = version_to_port_name.at(static_cast(c->version)); uint16_t local_port = s->name_to_port_config.at(port_name)->port; diff --git a/src/SendCommands.cc b/src/SendCommands.cc index e5d5b648..bc8a5c8c 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -26,6 +26,27 @@ extern FileContentsCache file_cache; +const unordered_set v2_crypt_initial_client_commands({ + 0x00290090, // (17) DCv1 license check + 0x00B00093, // (02) DCv1 login + 0x01140093, // (02) DCv1 extended login + 0x00E0009A, // (17) DCv2 license check + 0x00CC009D, // (02) DCv2 login + 0x0130009D, // (02) DCv2 extended login + // Note: PSO PC initial commands are not listed here because we don't use a + // detector encryption for PSO PC (instead, we use the split reconnect command + // to send PC to a different port). +}); +const unordered_set v3_crypt_initial_client_commands({ + 0x00E000DB, // (17) GC/XB license check + 0x00EC019E, // (02) GC login + 0x0150019E, // (02) GC extended login + 0x0130019E, // (02) XB login + 0x0194019E, // (02) XB extended login +}); + + + void send_command(shared_ptr c, uint16_t command, uint32_t flag, const void* data, size_t size) { c->channel.send(command, flag, data, size); @@ -91,10 +112,9 @@ static const char* bb_game_server_copyright = "Phantasy Star Online Blue Burst G static const char* bb_pm_server_copyright = "PSO NEW PM Server. Copyright 1999-2002 SONICTEAM."; static const char* patch_server_copyright = "Patch Server. Copyright SonicTeam, LTD. 2001"; -S_ServerInit_DC_PC_V3_02_17_91_9B prepare_server_init_contents_dc_pc_v3( - bool initial_connection, - uint32_t server_key, - uint32_t client_key) { +S_ServerInit_DC_PC_V3_02_17_91_9B prepare_server_init_contents_console( + uint32_t server_key, uint32_t client_key, uint8_t flags) { + bool initial_connection = (flags & SendServerInitFlag::IS_INITIAL_CONNECTION); S_ServerInit_DC_PC_V3_02_17_91_9B cmd; cmd.copyright = initial_connection ? dc_port_map_copyright : dc_lobby_server_copyright; @@ -104,31 +124,30 @@ S_ServerInit_DC_PC_V3_02_17_91_9B prepare_server_init_contents_dc_pc_v3( return cmd; } -void send_server_init_dc_pc_v3(shared_ptr c, bool initial_connection) { +void send_server_init_dc_pc_v3(shared_ptr c, uint8_t flags) { + bool initial_connection = (flags & SendServerInitFlag::IS_INITIAL_CONNECTION); uint8_t command = initial_connection ? 0x17 : 0x02; uint32_t server_key = random_object(); uint32_t client_key = random_object(); - auto cmd = prepare_server_init_contents_dc_pc_v3( - initial_connection, server_key, client_key); + auto cmd = prepare_server_init_contents_console( + server_key, client_key, initial_connection); send_command_t(c, command, 0x00, cmd); switch (c->version) { - case GameVersion::DC: case GameVersion::PC: - c->channel.crypt_out.reset(new PSOV2Encryption(server_key)); c->channel.crypt_in.reset(new PSOV2Encryption(client_key)); + c->channel.crypt_out.reset(new PSOV2Encryption(server_key)); break; + case GameVersion::DC: case GameVersion::GC: - case GameVersion::XB: - if (c->flags & Client::Flag::GC_TRIAL_EDITION) { - c->channel.crypt_out.reset(new PSOV2Encryption(server_key)); - c->channel.crypt_in.reset(new PSOV2Encryption(client_key)); - } else { - c->channel.crypt_out.reset(new PSOV3Encryption(server_key)); - c->channel.crypt_in.reset(new PSOV3Encryption(client_key)); - } + case GameVersion::XB: { + shared_ptr det_crypt(new PSOV2OrV3DetectorEncryption( + client_key, v2_crypt_initial_client_commands, v3_crypt_initial_client_commands)); + c->channel.crypt_in = det_crypt; + c->channel.crypt_out.reset(new PSOV2OrV3ImitatorEncryption(server_key, det_crypt)); break; + } default: throw invalid_argument("incorrect client version"); } @@ -137,7 +156,8 @@ void send_server_init_dc_pc_v3(shared_ptr c, bool initial_connection) { S_ServerInit_BB_03_9B prepare_server_init_contents_bb( const parray& server_key, const parray& client_key, - bool use_secondary_message) { + uint8_t flags) { + bool use_secondary_message = (flags & SendServerInitFlag::USE_SECONDARY_MESSAGE); S_ServerInit_BB_03_9B cmd; cmd.copyright = use_secondary_message ? bb_pm_server_copyright : bb_game_server_copyright; cmd.server_key = server_key; @@ -147,12 +167,13 @@ S_ServerInit_BB_03_9B prepare_server_init_contents_bb( } void send_server_init_bb(shared_ptr s, shared_ptr c, - bool use_secondary_message) { + uint8_t flags) { + bool use_secondary_message = (flags & SendServerInitFlag::USE_SECONDARY_MESSAGE); parray server_key; parray client_key; random_data(server_key.data(), server_key.bytes()); random_data(client_key.data(), client_key.bytes()); - auto cmd = prepare_server_init_contents_bb(server_key, client_key, use_secondary_message); + auto cmd = prepare_server_init_contents_bb(server_key, client_key, flags); send_command_t(c, use_secondary_message ? 0x9B : 0x03, 0x00, cmd); static const string primary_expected_first_data("\xB4\x00\x93\x00\x00\x00\x00\x00", 8); @@ -181,20 +202,20 @@ void send_server_init_patch(shared_ptr c) { c->channel.crypt_in.reset(new PSOV2Encryption(client_key)); } -void send_server_init(shared_ptr s, shared_ptr c, - bool initial_connection, bool use_secondary_message) { +void send_server_init( + shared_ptr s, shared_ptr c, uint8_t flags) { switch (c->version) { case GameVersion::DC: case GameVersion::PC: case GameVersion::GC: case GameVersion::XB: - send_server_init_dc_pc_v3(c, initial_connection); + send_server_init_dc_pc_v3(c, flags); break; case GameVersion::PATCH: send_server_init_patch(c); break; case GameVersion::BB: - send_server_init_bb(s, c, use_secondary_message); + send_server_init_bb(s, c, flags); break; default: throw logic_error("unimplemented versioned command"); @@ -279,8 +300,8 @@ void send_reconnect(shared_ptr c, uint32_t address, uint16_t port) { send_command_t(c, (c->version == GameVersion::PATCH) ? 0x14 : 0x19, 0x00, cmd); } -void send_pc_gc_split_reconnect(shared_ptr c, uint32_t address, - uint16_t pc_port, uint16_t gc_port) { +void send_pc_console_split_reconnect(shared_ptr c, uint32_t address, + uint16_t pc_port, uint16_t console_port) { S_ReconnectSplit_19 cmd; cmd.pc_address = address; cmd.pc_port = pc_port; @@ -288,7 +309,7 @@ void send_pc_gc_split_reconnect(shared_ptr c, uint32_t address, cmd.gc_flag = 0x00; cmd.gc_size = 0x97; cmd.gc_address = address; - cmd.gc_port = gc_port; + cmd.gc_port = console_port; send_command_t(c, 0x19, 0x00, cmd); } @@ -676,7 +697,7 @@ void send_card_search_result_t( shared_ptr result, shared_ptr result_lobby) { static const vector version_to_port_name({ - "dc-lobby", "pc-lobby", "bb-lobby", "gc-lobby", "xb-lobby", "bb-lobby"}); + "console-lobby", "pc-lobby", "bb-lobby", "console-lobby", "console-lobby", "bb-lobby"}); const auto& port_name = version_to_port_name.at(static_cast(c->version)); S_GuildCardSearchResult cmd; diff --git a/src/SendCommands.hh b/src/SendCommands.hh index b150bbf9..b1f6aedd 100644 --- a/src/SendCommands.hh +++ b/src/SendCommands.hh @@ -6,6 +6,7 @@ #include #include +#include #include "Client.hh" #include "Lobby.hh" @@ -18,6 +19,9 @@ +extern const std::unordered_set v2_crypt_initial_client_commands; +extern const std::unordered_set v3_crypt_initial_client_commands; + // TODO: Many of these functions should take a Channel& instead of a // shared_ptr. Refactor functions appropriately. @@ -92,16 +96,21 @@ void send_command_with_header(Channel& c, const void* data, size_t size); -S_ServerInit_DC_PC_V3_02_17_91_9B prepare_server_init_contents_dc_pc_v3( - bool initial_connection, - uint32_t server_key, - uint32_t client_key); +enum SendServerInitFlag { + IS_INITIAL_CONNECTION = 0x01, + USE_SECONDARY_MESSAGE = 0x02, +}; + +S_ServerInit_DC_PC_V3_02_17_91_9B prepare_server_init_contents_console( + uint32_t server_key, uint32_t client_key, uint8_t flags); S_ServerInit_BB_03_9B prepare_server_init_contents_bb( const parray& server_key, const parray& client_key, - bool use_secondary_message); -void send_server_init(std::shared_ptr s, std::shared_ptr c, - bool initial_connection, bool use_secondary_message); + uint8_t flags); +void send_server_init( + std::shared_ptr s, + std::shared_ptr c, + uint8_t flags); void send_update_client_config(std::shared_ptr c); void send_function_call( @@ -113,8 +122,11 @@ void send_function_call( uint32_t checksum_size = 0); void send_reconnect(std::shared_ptr c, uint32_t address, uint16_t port); -void send_pc_gc_split_reconnect(std::shared_ptr c, uint32_t address, - uint16_t pc_port, uint16_t gc_port); +void send_pc_console_split_reconnect( + std::shared_ptr c, + uint32_t address, + uint16_t pc_port, + uint16_t console_port); void send_client_init_bb(std::shared_ptr c, uint32_t error); void send_team_and_key_config_bb(std::shared_ptr c); diff --git a/src/Version.cc b/src/Version.cc index 0790398e..b7f091e1 100644 --- a/src/Version.cc +++ b/src/Version.cc @@ -15,10 +15,6 @@ uint16_t flags_for_version(GameVersion version, int64_t sub_version) { case -1: // Initial check (before 9E recognition) switch (version) { case GameVersion::DC: - // TODO: For DCv1, the flags should be: - // Client::Flag::DCV1 | - // Client::Flag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION | - // Client::Flag::DOES_NOT_SUPPORT_SEND_FUNCTION_CALL return Client::Flag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION; case GameVersion::GC: case GameVersion::XB: @@ -35,14 +31,19 @@ uint16_t flags_for_version(GameVersion version, int64_t sub_version) { } break; + // TODO: Which other sub_versions of DC v1 and v2 exist? + case 0x21: // DCv1 US + return Client::Flag::DCV1 | + Client::Flag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION | + Client::Flag::DOES_NOT_SUPPORT_SEND_FUNCTION_CALL; + + case 0x26: // DCv2 US + return Client::Flag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION; + case 0x29: // PC return Client::Flag::NO_MESSAGE_BOX_CLOSE_CONFIRMATION | Client::Flag::SEND_FUNCTION_CALL_CHECKSUM_ONLY; - // TODO: GC Ep1&2 trial edition uses sub_version 0x30, but also uses PSO V2 - // encryption! Find a way to tell that version apart from the others before - // starting encryption (hopefully it connects on a port not shared by other - // versions). case 0x30: // GC Ep1&2 JP v1.02, at least one version of PSO XB case 0x31: // GC Ep1&2 US v1.00, GC US v1.01, GC EU v1.00, GC JP v1.00 case 0x34: // GC Ep1&2 JP v1.03 @@ -114,16 +115,12 @@ GameVersion version_for_name(const char* name) { const char* name_for_server_behavior(ServerBehavior behavior) { switch (behavior) { - case ServerBehavior::SPLIT_RECONNECT: - return "split_reconnect"; + case ServerBehavior::PC_CONSOLE_DETECT: + return "pc_console_detect"; case ServerBehavior::LOGIN_SERVER: return "login_server"; - case ServerBehavior::LOGIN_SERVER_GC_TRIAL_EDITION: - return "login_server_gcte"; case ServerBehavior::LOBBY_SERVER: return "lobby_server"; - case ServerBehavior::LOBBY_SERVER_GC_TRIAL_EDITION: - return "lobby_server_gcte"; case ServerBehavior::DATA_SERVER_BB: return "data_server_bb"; case ServerBehavior::PATCH_SERVER_PC: @@ -138,16 +135,12 @@ const char* name_for_server_behavior(ServerBehavior behavior) { } ServerBehavior server_behavior_for_name(const char* name) { - if (!strcasecmp(name, "split_reconnect")) { - return ServerBehavior::SPLIT_RECONNECT; + if (!strcasecmp(name, "pc_console_detect")) { + return ServerBehavior::PC_CONSOLE_DETECT; } else if (!strcasecmp(name, "login_server") || !strcasecmp(name, "login")) { return ServerBehavior::LOGIN_SERVER; - } else if (!strcasecmp(name, "login_server_gcte") || !strcasecmp(name, "login_gcte")) { - return ServerBehavior::LOGIN_SERVER_GC_TRIAL_EDITION; } else if (!strcasecmp(name, "lobby_server") || !strcasecmp(name, "lobby")) { return ServerBehavior::LOBBY_SERVER; - } else if (!strcasecmp(name, "lobby_server_gcte") || !strcasecmp(name, "lobby_gcte")) { - return ServerBehavior::LOBBY_SERVER_GC_TRIAL_EDITION; } else if (!strcasecmp(name, "data_server_bb") || !strcasecmp(name, "data_server") || !strcasecmp(name, "data")) { return ServerBehavior::DATA_SERVER_BB; } else if (!strcasecmp(name, "patch_server_pc") || !strcasecmp(name, "patch_pc")) { diff --git a/src/Version.hh b/src/Version.hh index da615a00..b8566b12 100644 --- a/src/Version.hh +++ b/src/Version.hh @@ -14,11 +14,9 @@ enum class GameVersion { }; enum class ServerBehavior { - SPLIT_RECONNECT = 0, + PC_CONSOLE_DETECT = 0, LOGIN_SERVER, - LOGIN_SERVER_GC_TRIAL_EDITION, LOBBY_SERVER, - LOBBY_SERVER_GC_TRIAL_EDITION, DATA_SERVER_BB, PATCH_SERVER_PC, PATCH_SERVER_BB, diff --git a/system/config.example.json b/system/config.example.json index 4e285d9a..0d860003 100644 --- a/system/config.example.json +++ b/system/config.example.json @@ -26,27 +26,28 @@ // TODO: GC Episodes 1&2 Trial Edition also uses port 9000, but a real // version of PSO uses that port too. Figure out a way to differentiate // between the two versions. - "gc-jp10": [9000, "gc", "login_server"], - "gc-jp11": [9001, "gc", "login_server"], - "gc-jp3te": [9002, "gc", "login_server"], - "gc-jp3": [9003, "gc", "login_server"], - "gc-us12t1": [9064, "gc", "login_server_gcte"], - "gc-us10": [9100, "pc", "split_reconnect"], - "gc-us3": [9103, "gc", "login_server"], - "gc-eu10": [9200, "gc", "login_server"], - "gc-eu11": [9201, "gc", "login_server"], - "gc-us12t2": [9202, "gc", "login_server_gcte"], - "gc-eu3": [9203, "gc", "login_server"], - "pc-login": [9300, "pc", "login_server"], - "pc-patch": [10000, "patch", "patch_server_pc"], - "bb-patch": [11000, "patch", "patch_server_bb"], - "bb-init": [12000, "bb", "data_server_bb"], + + "gc-jp10": [9000, "pc", "pc_console_detect"], + "gc-jp11": [9001, "pc", "pc_console_detect"], + "gc-jp3te": [9002, "pc", "pc_console_detect"], + "gc-jp3": [9003, "pc", "pc_console_detect"], + "gc-us12t1": [9064, "pc", "pc_console_detect"], + "gc-us10": [9100, "pc", "pc_console_detect"], + "gc-us3": [9103, "pc", "pc_console_detect"], + "gc-eu10": [9200, "pc", "pc_console_detect"], + "gc-eu11": [9201, "pc", "pc_console_detect"], + "gc-us12t2": [9202, "pc", "pc_console_detect"], + "gc-eu3": [9203, "pc", "pc_console_detect"], + "pc": [9300, "pc", "pc_console_detect"], + "pc-patch": [10000, "patch", "patch_server_pc"], + "bb-patch": [11000, "patch", "patch_server_bb"], + "bb-init": [12000, "bb", "data_server_bb"], // TODO: If Xbox support ever gets built, add this port to the above config. // "xb-login": [????, "xb", "login_server"], // Schthack PSOBB uses these ports. - // "bb-patch2": [10500, "patch", "patch_server"], + // "bb-patch2": [10500, "patch", "patch_server_bb"], // "bb-init2": [13000, "bb", "data_server_bb"], // Ephinea PSOBB uses these ports. Note that 13000 is also used by Schthack @@ -54,25 +55,23 @@ // support both Schthack and Ephinea PSOBB clients at the same time. This // may be fixed in the future using a similar technique as the // split_reconnect behavior, but this isn't implemented yet. - // "bb-patch3": [13000, "patch", "patch_server"], + // "bb-patch3": [13000, "patch", "patch_server_bb"], // "bb-init3": [14000, "bb", "data_server_bb"], // newserv uses these ports, but there is no external reason that these // numbers were chosen. You can change the port numbers here without any // issues. Note that the bb-data1 and bb-data2 ports must be sequential; // that is, the bb-data2 port must be the bb-data1 port + 1. - "pc-lobby": [9420, "pc", "lobby_server"], - "gc-lobby": [9421, "gc", "lobby_server"], - "bb-lobby": [9422, "bb", "lobby_server"], - "xb-lobby": [9423, "xb", "lobby_server"], - "gct-lobby": [9424, "gc", "lobby_server_gcte"], - "pc-proxy": [9520, "pc", "proxy_server"], - "gc-proxy": [9521, "gc", "proxy_server"], - "bb-proxy": [9522, "bb", "proxy_server"], - "xb-proxy": [9523, "xb", "proxy_server"], - // TODO: Implement proxy server for GC Trial Edition - "bb-data1": [12004, "bb", "data_server_bb"], - "bb-data2": [12005, "bb", "data_server_bb"], + "console-login": [5100, "gc", "login_server"], + "pc-login": [5101, "pc", "login_server"], + "console-lobby": [5110, "gc", "lobby_server"], + "pc-lobby": [5111, "pc", "lobby_server"], + "bb-lobby": [5112, "bb", "lobby_server"], + "console-proxy": [5120, "gc", "proxy_server"], + "pc-proxy": [5121, "pc", "proxy_server"], + "bb-proxy": [5122, "bb", "proxy_server"], + "bb-data1": [12004, "bb", "data_server_bb"], + "bb-data2": [12005, "bb", "data_server_bb"], }, // Where to listen for IP stack clients. This exists to interface with PSO GC diff --git a/tests/BB-CreateCharGame.test.txt b/tests/BB-CreateCharGame.test.txt index 690a8a67..3c029c19 100644 --- a/tests/BB-CreateCharGame.test.txt +++ b/tests/BB-CreateCharGame.test.txt @@ -29902,9 +29902,9 @@ I 80350 2022-07-07 23:27:02 - [Commands] Sending to C-7 (version=BB command=0007 I 80350 2022-07-07 23:27:03 - [Commands] Received from C-7 (version=BB command=0010 flag=00000000) 0000000000000000 | 10 00 10 00 00 00 00 00 11 00 00 11 11 22 22 11 | "" I 80350 2022-07-07 23:27:03 - [Commands] Sending to C-7 (version=BB command=0019 flag=00000000) -0000000000000000 | 10 00 19 00 00 00 00 00 0A 00 00 03 CE 24 00 00 | $ +0000000000000000 | 10 00 19 00 00 00 00 00 0A 00 00 03 F8 13 00 00 | $ I 80350 2022-07-07 23:27:03 - [Server] Client disconnected: C-7 on fd 29 -I 80350 2022-07-07 23:27:03 - [Server] Client connected: C-8 on fd 29 via 22 (T-9422-BB-bb-lobby-lobby_server) +I 80350 2022-07-07 23:27:03 - [Server] Client connected: C-8 on fd 29 via 22 (T-5112-BB-bb-lobby-lobby_server) I 80350 2022-07-07 23:27:03 - [Commands] Sending to C-8 (version=BB command=0003 flag=00000000) 0000000000000000 | 88 01 03 00 00 00 00 00 50 68 61 6E 74 61 73 79 | Phantasy 0000000000000010 | 20 53 74 61 72 20 4F 6E 6C 69 6E 65 20 42 6C 75 | Star Online Blu @@ -31254,9 +31254,9 @@ I 80350 2022-07-07 23:27:19 - [Commands] Sending to C-9 (version=BB command=0007 I 80350 2022-07-07 23:27:20 - [Commands] Received from C-9 (version=BB command=0010 flag=00000000) 0000000000000000 | 10 00 10 00 00 00 00 00 11 00 00 11 11 22 22 11 | "" I 80350 2022-07-07 23:27:20 - [Commands] Sending to C-9 (version=BB command=0019 flag=00000000) -0000000000000000 | 10 00 19 00 00 00 00 00 0A 00 00 03 CE 24 00 00 | $ +0000000000000000 | 10 00 19 00 00 00 00 00 0A 00 00 03 F8 13 00 00 | $ I 80350 2022-07-07 23:27:20 - [Server] Client disconnected: C-9 on fd 29 -I 80350 2022-07-07 23:27:20 - [Server] Client connected: C-A on fd 29 via 22 (T-9422-BB-bb-lobby-lobby_server) +I 80350 2022-07-07 23:27:20 - [Server] Client connected: C-A on fd 29 via 22 (T-5112-BB-bb-lobby-lobby_server) I 80350 2022-07-07 23:27:20 - [Commands] Sending to C-A (version=BB command=0003 flag=00000000) 0000000000000000 | 88 01 03 00 00 00 00 00 50 68 61 6E 74 61 73 79 | Phantasy 0000000000000010 | 20 53 74 61 72 20 4F 6E 6C 69 6E 65 20 42 6C 75 | Star Online Blu diff --git a/tests/GC-Episode3GameSmokeTest.test.txt b/tests/GC-Episode3GameSmokeTest.test.txt index 0954f802..b5fe1bc4 100644 --- a/tests/GC-Episode3GameSmokeTest.test.txt +++ b/tests/GC-Episode3GameSmokeTest.test.txt @@ -1,5 +1,23 @@ +I 22913 2022-06-30 23:45:35 - [IPStackSimulator] Client fd 29 connected via fd 28 +I 22913 2022-06-30 23:45:38 - [IPStackSimulator] Client opened TCP connection 29+23232323238C0707 (10.0.1.5:1799 -> 35.35.35.35:9100) +I 22913 2022-06-30 23:45:38 - [Server] Client connected: C-1 on virtual connection 0x1048042b0 via T-9100-PC-split_reconnect-VI +I 22913 2022-06-30 23:45:38 - [Commands] Sending to C-1 (version=PC command=0019 flag=00000000) +0000000000000000 | B0 00 19 00 23 23 23 23 ED 13 00 00 00 00 00 00 | ####T$ +0000000000000010 | 00 00 00 00 00 00 00 00 00 19 00 97 00 23 23 23 | ### +0000000000000020 | 23 EC 13 00 00 00 00 00 00 00 00 00 00 00 00 00 | #(# +0000000000000030 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0000000000000040 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0000000000000050 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0000000000000060 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0000000000000070 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0000000000000080 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0000000000000090 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +00000000000000A0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +I 22913 2022-06-30 23:45:38 - [IPStackSimulator] Connected TCP connection 29+23232323238C0707 (10.0.1.5:1799 -> 35.35.35.35:9100) to game server +I 22913 2022-06-30 23:45:38 - [IPStackSimulator] Client closed TCP connection 29+23232323238C0707 (10.0.1.5:1799 -> 35.35.35.35:9100) +I 22913 2022-06-30 23:45:38 - [Server] Client disconnected: C-1 on virtual connection 0x1048042b0 I 94711 2022-07-26 00:24:56 - [IPStackSimulator] Client opened TCP connection 31+23232323238F0671 (10.0.1.5:1649 -> 35.35.35.35:9103) -I 94711 2022-07-26 00:24:56 - [Server] Client connected: C-7 on virtual connection 0x107004340 via T-9103-GC-login_server-VI +I 94711 2022-07-26 00:24:56 - [Server] Client connected: C-7 on virtual connection 0x107004340 via T-5100-GC-login_server-VI I 94711 2022-07-26 00:24:56 - [Commands] Sending to C-7 (version=GC command=17 flag=00) 0000000000000000 | 17 00 0C 01 44 72 65 61 6D 43 61 73 74 20 50 6F | DreamCast Po 0000000000000010 | 72 74 20 4D 61 70 2E 20 43 6F 70 79 72 69 67 68 | rt Map. Copyrigh @@ -2041,13 +2059,13 @@ I 94711 2022-07-26 00:25:12 - [Commands] Sending to C-7 (version=GC command=B1 f 0000000000000000 | B1 00 1C 00 32 30 32 32 3A 30 37 3A 32 36 3A 20 | 2022:07:26: 0000000000000010 | 30 37 3A 32 35 3A 31 32 2E 30 30 30 | 07:25:12.000 I 94711 2022-07-26 00:25:12 - [Commands] Sending to C-7 (version=GC command=19 flag=00) -0000000000000000 | 19 00 0C 00 23 23 23 23 CD 24 00 00 | #### $ +0000000000000000 | 19 00 0C 00 23 23 23 23 F6 13 00 00 | #### $ I 94711 2022-07-26 00:25:14 - [Commands] Received from C-7 (version=GC command=99 flag=00) 0000000000000000 | 99 00 04 00 | I 94711 2022-07-26 00:25:14 - [IPStackSimulator] Client closed TCP connection 31+23232323238F0671 (10.0.1.5:1649 -> 35.35.35.35:9103) I 94711 2022-07-26 00:25:14 - [IPStackSimulator] Client opened TCP connection 31+2323232324CD0672 (10.0.1.5:1650 -> 35.35.35.35:9421) I 94711 2022-07-26 00:25:14 - [Server] Client disconnected: C-7 on virtual connection 0x107004340 -I 94711 2022-07-26 00:25:14 - [Server] Client connected: C-8 on virtual connection 0x1057045f0 via T-9421-GC-lobby_server-VI +I 94711 2022-07-26 00:25:14 - [Server] Client connected: C-8 on virtual connection 0x1057045f0 via T-5110-GC-lobby_server-VI I 94711 2022-07-26 00:25:14 - [Commands] Sending to C-8 (version=GC command=02 flag=00) 0000000000000000 | 02 00 0C 01 44 72 65 61 6D 43 61 73 74 20 4C 6F | DreamCast Lo 0000000000000010 | 62 62 79 20 53 65 72 76 65 72 2E 20 43 6F 70 79 | bby Server. Copy diff --git a/tests/GC-ForestGame.test.txt b/tests/GC-ForestGame.test.txt index e23bd59e..ec9d337a 100644 --- a/tests/GC-ForestGame.test.txt +++ b/tests/GC-ForestGame.test.txt @@ -2,9 +2,9 @@ I 26579 2022-07-01 10:22:10 - [IPStackSimulator] Client fd 29 connected via fd 2 I 26579 2022-07-01 10:22:13 - [IPStackSimulator] Client opened TCP connection 29+23232323238C05D8 (10.0.1.5:1496 -> 35.35.35.35:9100) I 26579 2022-07-01 10:22:13 - [Server] Client connected: C-5B on virtual connection 0x1473042b0 via T-9100-PC-split_reconnect-VI I 26579 2022-07-01 10:22:13 - [Commands] Sending to C-5B (version=PC command=0019 flag=00000000) -0000000000000000 | B0 00 19 00?23 23 23 23?54 24 00 00 00 00 00 00 | ####T$ -0000000000000010 | 00 00 00 00 00 00 00 00 00 19 00 97 00?23 23 23?| ### -0000000000000020 |?23?28 23 00 00 00 00 00 00 00 00 00 00 00 00 00 | #(# +0000000000000000 | B0 00 19 00 23 23 23 23 ED 13 00 00 00 00 00 00 | ####T$ +0000000000000010 | 00 00 00 00 00 00 00 00 00 19 00 97 00 23 23 23 | ### +0000000000000020 | 23 EC 13 00 00 00 00 00 00 00 00 00 00 00 00 00 | #(# 0000000000000030 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | 0000000000000040 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | 0000000000000050 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | @@ -17,7 +17,7 @@ I 26579 2022-07-01 10:22:13 - [IPStackSimulator] Connected TCP connection 29+232 I 26579 2022-07-01 10:22:13 - [IPStackSimulator] Client closed TCP connection 29+23232323238C05D8 (10.0.1.5:1496 -> 35.35.35.35:9100) I 26579 2022-07-01 10:22:13 - [Server] Client disconnected: C-5B on virtual connection 0x1473042b0 I 26579 2022-07-01 10:22:13 - [IPStackSimulator] Client opened TCP connection 29+23232323232805D9 (10.0.1.5:1497 -> 35.35.35.35:9000) -I 26579 2022-07-01 10:22:13 - [Server] Client connected: C-5C on virtual connection 0x147204560 via T-9000-GC-login_server-VI +I 26579 2022-07-01 10:22:13 - [Server] Client connected: C-5C on virtual connection 0x147204560 via T-5100-GC-login_server-VI I 26579 2022-07-01 10:22:13 - [Commands] Sending to C-5C (version=GC command=0017 flag=00000000) 0000000000000000 | 17 00 0C 01 44 72 65 61 6D 43 61 73 74 20 50 6F | DreamCast Po 0000000000000010 | 72 74 20 4D 61 70 2E 20 43 6F 70 79 72 69 67 68 | rt Map. Copyrigh @@ -125,13 +125,13 @@ I 26579 2022-07-01 10:22:15 - [Commands] Sending to C-5C (version=GC command=00B 0000000000000000 | B1 00 1C 00 32 30 32 32 3A 30 37 3A 30 31 3A 20 | 2022:07:01: 0000000000000010 | 31 37 3A 32 32 3A 31 35 2E 30 30 30 | 17:22:15.000 I 26579 2022-07-01 10:22:15 - [Commands] Sending to C-5C (version=GC command=0019 flag=00000000) -0000000000000000 | 19 00 0C 00 23 23 23 23 CD 24 00 00 | #### $ +0000000000000000 | 19 00 0C 00 23 23 23 23 F6 13 00 00 | #### $ I 26579 2022-07-01 10:22:17 - [IPStackSimulator] Client closed TCP connection 29+23232323232805D9 (10.0.1.5:1497 -> 35.35.35.35:9000) I 26579 2022-07-01 10:22:17 - [Commands] Received from C-5C (version=GC command=0099 flag=00000000) 0000000000000000 | 99 00 04 00 | I 26579 2022-07-01 10:22:17 - [Server] Client disconnected: C-5C on virtual connection 0x147204560 I 26579 2022-07-01 10:22:17 - [IPStackSimulator] Client opened TCP connection 29+2323232324CD05DA (10.0.1.5:1498 -> 35.35.35.35:9421) -I 26579 2022-07-01 10:22:17 - [Server] Client connected: C-5D on virtual connection 0x1472045f0 via T-9421-GC-lobby_server-VI +I 26579 2022-07-01 10:22:17 - [Server] Client connected: C-5D on virtual connection 0x1472045f0 via T-5110-GC-lobby_server-VI I 26579 2022-07-01 10:22:17 - [Commands] Sending to C-5D (version=GC command=0002 flag=00000000) 0000000000000000 | 02 00 0C 01 44 72 65 61 6D 43 61 73 74 20 4C 6F | DreamCast Lo 0000000000000010 | 62 62 79 20 53 65 72 76 65 72 2E 20 43 6F 70 79 | bby Server. Copy diff --git a/tests/GC-LoginSmokeTest.test.txt b/tests/GC-LoginSmokeTest.test.txt index 225b34ec..c0a997c1 100755 --- a/tests/GC-LoginSmokeTest.test.txt +++ b/tests/GC-LoginSmokeTest.test.txt @@ -2,9 +2,9 @@ I 22913 2022-06-30 23:45:35 - [IPStackSimulator] Client fd 29 connected via fd 2 I 22913 2022-06-30 23:45:38 - [IPStackSimulator] Client opened TCP connection 29+23232323238C0707 (10.0.1.5:1799 -> 35.35.35.35:9100) I 22913 2022-06-30 23:45:38 - [Server] Client connected: C-1 on virtual connection 0x1048042b0 via T-9100-PC-split_reconnect-VI I 22913 2022-06-30 23:45:38 - [Commands] Sending to C-1 (version=PC command=0019 flag=00000000) -0000000000000000 | B0 00 19 00 23 23 23 23 54 24 00 00 00 00 00 00 | ####T$ +0000000000000000 | B0 00 19 00 23 23 23 23 ED 13 00 00 00 00 00 00 | ####T$ 0000000000000010 | 00 00 00 00 00 00 00 00 00 19 00 97 00 23 23 23 | ### -0000000000000020 | 23 28 23 00 00 00 00 00 00 00 00 00 00 00 00 00 | #(# +0000000000000020 | 23 EC 13 00 00 00 00 00 00 00 00 00 00 00 00 00 | #(# 0000000000000030 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | 0000000000000040 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | 0000000000000050 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | @@ -17,7 +17,7 @@ I 22913 2022-06-30 23:45:38 - [IPStackSimulator] Connected TCP connection 29+232 I 22913 2022-06-30 23:45:38 - [IPStackSimulator] Client closed TCP connection 29+23232323238C0707 (10.0.1.5:1799 -> 35.35.35.35:9100) I 22913 2022-06-30 23:45:38 - [Server] Client disconnected: C-1 on virtual connection 0x1048042b0 I 22913 2022-06-30 23:45:38 - [IPStackSimulator] Client opened TCP connection 29+2323232323280708 (10.0.1.5:1800 -> 35.35.35.35:9000) -I 22913 2022-06-30 23:45:38 - [Server] Client connected: C-2 on virtual connection 0x103704560 via T-9000-GC-login_server-VI +I 22913 2022-06-30 23:45:38 - [Server] Client connected: C-2 on virtual connection 0x103704560 via T-5100-GC-login_server-VI I 22913 2022-06-30 23:45:38 - [Commands] Sending to C-2 (version=GC command=0017 flag=00000000) 0000000000000000 | 17 00 0C 01 44 72 65 61 6D 43 61 73 74 20 50 6F | DreamCast Po 0000000000000010 | 72 74 20 4D 61 70 2E 20 43 6F 70 79 72 69 67 68 | rt Map. Copyrigh diff --git a/tests/PC-BasicGame.test.txt b/tests/PC-BasicGame.test.txt index fe1db13c..4186ed8c 100644 --- a/tests/PC-BasicGame.test.txt +++ b/tests/PC-BasicGame.test.txt @@ -103,7 +103,21 @@ I 58384 2022-08-08 23:38:14 - [Commands] Sending to C-1 (version=Patch command=0 I 58384 2022-08-08 23:38:14 - [Commands] Sending to C-1 (version=Patch command=12 flag=00) 0000000000000000 | 04 00 12 00 | I 80820 2022-07-07 23:33:27 - [Server] Client disconnected: C-1 on fd 29 -I 80820 2022-07-07 23:34:04 - [Server] Client connected: C-2 on fd 29 via 12 (T-9300-PC-pc-login-login_server) +I 22913 2022-06-30 23:45:38 - [Server] Client connected: C-10 on virtual connection 0x1048042b0 via T-9100-PC-split_reconnect-VI +I 22913 2022-06-30 23:45:38 - [Commands] Sending to C-10 (version=PC command=0019 flag=00000000) +0000000000000000 | B0 00 19 00 23 23 23 23 ED 13 00 00 00 00 00 00 | ####T$ +0000000000000010 | 00 00 00 00 00 00 00 00 00 19 00 97 00 23 23 23 | ### +0000000000000020 | 23 EC 13 00 00 00 00 00 00 00 00 00 00 00 00 00 | #(# +0000000000000030 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0000000000000040 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0000000000000050 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0000000000000060 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0000000000000070 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0000000000000080 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +0000000000000090 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +00000000000000A0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | +I 22913 2022-06-30 23:45:38 - [Server] Client disconnected: C-10 on virtual connection 0x1048042b0 +I 80820 2022-07-07 23:34:04 - [Server] Client connected: C-2 on fd 29 via 12 (T-5101-PC-pc-login-login_server) I 80820 2022-07-07 23:34:04 - [Commands] Sending to C-2 (version=PC command=17 flag=00) 0000000000000000 | 0C 01 17 00 44 72 65 61 6D 43 61 73 74 20 50 6F | DreamCast Po 0000000000000010 | 72 74 20 4D 61 70 2E 20 43 6F 70 79 72 69 67 68 | rt Map. Copyrigh @@ -204,11 +218,11 @@ I 80820 2022-07-07 23:34:10 - [Commands] Sending to C-2 (version=PC command=B1 f 0000000000000000 | 1C 00 B1 00 32 30 32 32 3A 30 37 3A 30 38 3A 20 | 2022:07:08: 0000000000000010 | 30 36 3A 33 34 3A 31 30 2E 30 30 30 | 06:34:10.000 I 80820 2022-07-07 23:34:10 - [Commands] Sending to C-2 (version=PC command=19 flag=00) -0000000000000000 | 0C 00 19 00 0A 00 00 03 CC 24 00 00 | $ +0000000000000000 | 0C 00 19 00 0A 00 00 03 F7 13 00 00 | $ I 80820 2022-07-07 23:34:10 - [Commands] Received from C-2 (version=PC command=99 flag=00) 0000000000000000 | 04 00 99 00 | I 80820 2022-07-07 23:34:10 - [Server] Client disconnected: C-2 on fd 29 -I 80820 2022-07-07 23:34:10 - [Server] Client connected: C-3 on fd 29 via 24 (T-9420-PC-pc-lobby-lobby_server) +I 80820 2022-07-07 23:34:10 - [Server] Client connected: C-3 on fd 29 via 24 (T-5111-PC-pc-lobby-lobby_server) I 80820 2022-07-07 23:34:10 - [Commands] Sending to C-3 (version=PC command=02 flag=00) 0000000000000000 | 0C 01 02 00 44 72 65 61 6D 43 61 73 74 20 4C 6F | DreamCast Lo 0000000000000010 | 62 62 79 20 53 65 72 76 65 72 2E 20 43 6F 70 79 | bby Server. Copy @@ -2103,9 +2117,9 @@ I 80820 2022-07-07 23:37:10 - [Commands] Sending to C-3 (Kallea) (version=PC com I 80820 2022-07-07 23:37:10 - [Commands] Sending to C-3 (Kallea) (version=PC command=1A flag=00) 0000000000000000 | 08 00 1A 00 00 00 00 00 | I 80820 2022-07-07 23:37:10 - [Commands] Sending to C-3 (Kallea) (version=PC command=19 flag=00) -0000000000000000 | 0C 00 19 00 0A 00 00 03 54 24 00 00 | T$ +0000000000000000 | 0C 00 19 00 0A 00 00 03 ED 13 00 00 | T$ I 80820 2022-07-07 23:37:10 - [Server] Client disconnected: C-3 on fd 29 -I 80820 2022-07-07 23:37:10 - [Server] Client connected: C-4 on fd 29 via 12 (T-9300-PC-pc-login-login_server) +I 80820 2022-07-07 23:37:10 - [Server] Client connected: C-4 on fd 29 via 12 (T-5101-PC-pc-login-login_server) I 80820 2022-07-07 23:37:10 - [Commands] Sending to C-4 (version=PC command=17 flag=00) 0000000000000000 | 0C 01 17 00 44 72 65 61 6D 43 61 73 74 20 50 6F | DreamCast Po 0000000000000010 | 72 74 20 4D 61 70 2E 20 43 6F 70 79 72 69 67 68 | rt Map. Copyrigh diff --git a/tests/config.json b/tests/config.json index 71431c6a..59663ff5 100644 --- a/tests/config.json +++ b/tests/config.json @@ -17,35 +17,34 @@ "EnableItemTracking": true, "PortConfiguration": { - "gc-jp10": [9000, "gc", "login_server"], - "gc-jp11": [9001, "gc", "login_server"], - "gc-jp3te": [9002, "gc", "login_server"], - "gc-jp3": [9003, "gc", "login_server"], - "gc-us12t1": [9064, "gc", "login_server_gcte"], - "gc-us10": [9100, "pc", "split_reconnect"], - "gc-us3": [9103, "gc", "login_server"], - "gc-eu10": [9200, "gc", "login_server"], - "gc-eu11": [9201, "gc", "login_server"], - "gc-us12t2": [9202, "gc", "login_server_gcte"], - "gc-eu3": [9203, "gc", "login_server"], - "pc-login": [9300, "pc", "login_server"], - "pc-patch": [10000, "patch", "patch_server_pc"], - "bb-patch": [11000, "patch", "patch_server_bb"], - "bb-init": [12000, "bb", "data_server_bb"], - "bb-patch2": [10500, "patch", "patch_server_bb"], - "bb-init2": [13000, "bb", "data_server_bb"], - "bb-proxy2": [9932, "bb", "proxy_server"], - "bb-data1": [12004, "bb", "data_server_bb"], - "bb-data2": [12005, "bb", "data_server_bb"], - "pc-lobby": [9420, "pc", "lobby_server"], - "gc-lobby": [9421, "gc", "lobby_server"], - "bb-lobby": [9422, "bb", "lobby_server"], - "xb-lobby": [9423, "xb", "lobby_server"], - "gct-lobby": [9424, "gc", "lobby_server_gcte"], - "pc-proxy": [9520, "pc", "proxy_server"], - "gc-proxy": [9521, "gc", "proxy_server"], - "bb-proxy": [9522, "bb", "proxy_server"], - "xb-proxy": [9523, "xb", "proxy_server"], + "gc-jp10": [9000, "pc", "pc_console_detect"], + "gc-jp11": [9001, "pc", "pc_console_detect"], + "gc-jp3te": [9002, "pc", "pc_console_detect"], + "gc-jp3": [9003, "pc", "pc_console_detect"], + "gc-us12t1": [9064, "pc", "pc_console_detect"], + "gc-us10": [9100, "pc", "pc_console_detect"], + "gc-us3": [9103, "pc", "pc_console_detect"], + "gc-eu10": [9200, "pc", "pc_console_detect"], + "gc-eu11": [9201, "pc", "pc_console_detect"], + "gc-us12t2": [9202, "pc", "pc_console_detect"], + "gc-eu3": [9203, "pc", "pc_console_detect"], + "pc": [9300, "pc", "pc_console_detect"], + "pc-patch": [10000, "patch", "patch_server_pc"], + "bb-patch": [11000, "patch", "patch_server_bb"], + "bb-init": [12000, "bb", "data_server_bb"], + "bb-patch2": [10500, "patch", "patch_server_bb"], + "bb-proxy2": [9932, "bb", "proxy_server"], + "bb-patch3": [13000, "bb", "data_server_bb"], + "console-login": [5100, "gc", "login_server"], + "pc-login": [5101, "pc", "login_server"], + "console-lobby": [5110, "gc", "lobby_server"], + "pc-lobby": [5111, "pc", "lobby_server"], + "bb-lobby": [5112, "bb", "lobby_server"], + "console-proxy": [5120, "gc", "proxy_server"], + "pc-proxy": [5121, "pc", "proxy_server"], + "bb-proxy": [5122, "bb", "proxy_server"], + "bb-data1": [12004, "bb", "data_server_bb"], + "bb-data2": [12005, "bb", "data_server_bb"], }, "ProxyDestinations-GC": {