mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-09 08:21:29 +12:00
Fix rpcn create/login not returning proper error
This commit is contained in:
parent
d58df667b9
commit
df39bd39b0
2 changed files with 47 additions and 28 deletions
|
@ -732,10 +732,11 @@ error_code sceNpBasicSetPresence(vm::cptr<u8> data, u64 size)
|
||||||
return SCE_NP_BASIC_ERROR_NOT_REGISTERED;
|
return SCE_NP_BASIC_ERROR_NOT_REGISTERED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data || !data[0])
|
// TODO: Correct but causes issues atm(breaks bomberman ultra)
|
||||||
{
|
// if (!data || !data[0])
|
||||||
return SCE_NP_BASIC_ERROR_INVALID_ARGUMENT;
|
// {
|
||||||
}
|
// return SCE_NP_BASIC_ERROR_INVALID_ARGUMENT;
|
||||||
|
// }
|
||||||
|
|
||||||
if (size > SCE_NP_BASIC_MAX_PRESENCE_SIZE)
|
if (size > SCE_NP_BASIC_MAX_PRESENCE_SIZE)
|
||||||
{
|
{
|
||||||
|
@ -979,7 +980,7 @@ error_code sceNpBasicSendMessageAttachment(vm::cptr<SceNpId> to, vm::cptr<char>
|
||||||
|
|
||||||
// TODO: SCE_NP_BASIC_ERROR_NOT_SUPPORTED, might be in between argument checks
|
// TODO: SCE_NP_BASIC_ERROR_NOT_SUPPORTED, might be in between argument checks
|
||||||
|
|
||||||
if (strlen(subject.get_ptr()) > SCE_NP_BASIC_BODY_CHARACTER_MAX || strlen(body.get_ptr()) > SCE_NP_BASIC_BODY_CHARACTER_MAX)
|
if (strlen(subject.get_ptr()) > SCE_NP_BASIC_SUBJECT_CHARACTER_MAX || strlen(body.get_ptr()) > SCE_NP_BASIC_BODY_CHARACTER_MAX)
|
||||||
{
|
{
|
||||||
return SCE_NP_BASIC_ERROR_EXCEEDS_MAX;
|
return SCE_NP_BASIC_ERROR_EXCEEDS_MAX;
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,6 +195,7 @@ namespace rpcn
|
||||||
|
|
||||||
if (!result_login)
|
if (!result_login)
|
||||||
{
|
{
|
||||||
|
rpcn_log.notice("MT: login attempt failed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -503,12 +504,6 @@ namespace rpcn
|
||||||
if (!get_reply(packet_id, reply_data))
|
if (!get_reply(packet_id, reply_data))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (is_error(static_cast<ErrorType>(reply_data[0])))
|
|
||||||
{
|
|
||||||
// disconnect();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,13 +549,13 @@ namespace rpcn
|
||||||
|
|
||||||
bool rpcn_client::connect(const std::string& host)
|
bool rpcn_client::connect(const std::string& host)
|
||||||
{
|
{
|
||||||
rpcn_log.warning("Attempting to connect to RPCN!");
|
rpcn_log.warning("connect: Attempting to connect");
|
||||||
|
|
||||||
state = rpcn_state::failure_no_failure;
|
state = rpcn_state::failure_no_failure;
|
||||||
|
|
||||||
if (host.empty())
|
if (host.empty())
|
||||||
{
|
{
|
||||||
rpcn_log.error("RPCN host is empty!");
|
rpcn_log.error("connect: RPCN host is empty!");
|
||||||
state = rpcn_state::failure_input;
|
state = rpcn_state::failure_input;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -568,7 +563,7 @@ namespace rpcn
|
||||||
auto splithost = fmt::split(host, {":"});
|
auto splithost = fmt::split(host, {":"});
|
||||||
if (splithost.size() != 1 && splithost.size() != 2)
|
if (splithost.size() != 1 && splithost.size() != 2)
|
||||||
{
|
{
|
||||||
rpcn_log.error("RPCN host is invalid!");
|
rpcn_log.error("connect: RPCN host is invalid!");
|
||||||
state = rpcn_state::failure_input;
|
state = rpcn_state::failure_input;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -580,7 +575,7 @@ namespace rpcn
|
||||||
port = std::stoul(splithost[1]);
|
port = std::stoul(splithost[1]);
|
||||||
if (port == 0)
|
if (port == 0)
|
||||||
{
|
{
|
||||||
rpcn_log.error("RPCN port is invalid!");
|
rpcn_log.error("connect: RPCN port is invalid!");
|
||||||
state = rpcn_state::failure_input;
|
state = rpcn_state::failure_input;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -595,14 +590,14 @@ namespace rpcn
|
||||||
|
|
||||||
if (wolfSSL_Init() != WOLFSSL_SUCCESS)
|
if (wolfSSL_Init() != WOLFSSL_SUCCESS)
|
||||||
{
|
{
|
||||||
rpcn_log.error("Failed to initialize wolfssl");
|
rpcn_log.error("connect: Failed to initialize wolfssl");
|
||||||
state = rpcn_state::failure_wolfssl;
|
state = rpcn_state::failure_wolfssl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wssl_ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == nullptr)
|
if ((wssl_ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == nullptr)
|
||||||
{
|
{
|
||||||
rpcn_log.error("Failed to create wolfssl context");
|
rpcn_log.error("connect: Failed to create wolfssl context");
|
||||||
state = rpcn_state::failure_wolfssl;
|
state = rpcn_state::failure_wolfssl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -611,7 +606,7 @@ namespace rpcn
|
||||||
|
|
||||||
if ((read_wssl = wolfSSL_new(wssl_ctx)) == nullptr)
|
if ((read_wssl = wolfSSL_new(wssl_ctx)) == nullptr)
|
||||||
{
|
{
|
||||||
rpcn_log.error("Failed to create wolfssl object");
|
rpcn_log.error("connect: Failed to create wolfssl object");
|
||||||
state = rpcn_state::failure_wolfssl;
|
state = rpcn_state::failure_wolfssl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -624,7 +619,7 @@ namespace rpcn
|
||||||
hostent* host_addr = gethostbyname(splithost[0].c_str());
|
hostent* host_addr = gethostbyname(splithost[0].c_str());
|
||||||
if (!host_addr)
|
if (!host_addr)
|
||||||
{
|
{
|
||||||
rpcn_log.error("Failed to resolve %s", host);
|
rpcn_log.error("connect: Failed to resolve %s", host);
|
||||||
state = rpcn_state::failure_resolve;
|
state = rpcn_state::failure_resolve;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -646,21 +641,23 @@ namespace rpcn
|
||||||
|
|
||||||
if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast<char*>(&timeout), sizeof(timeout)) < 0)
|
if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast<char*>(&timeout), sizeof(timeout)) < 0)
|
||||||
{
|
{
|
||||||
rpcn_log.error("Failed to setsockopt!");
|
rpcn_log.error("connect: Failed to setsockopt!");
|
||||||
state = rpcn_state::failure_other;
|
state = rpcn_state::failure_other;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (::connect(sockfd, reinterpret_cast<struct sockaddr*>(&addr_rpcn), sizeof(addr_rpcn)) != 0)
|
if (::connect(sockfd, reinterpret_cast<struct sockaddr*>(&addr_rpcn), sizeof(addr_rpcn)) != 0)
|
||||||
{
|
{
|
||||||
rpcn_log.error("Failed to connect to RPCN server!");
|
rpcn_log.error("connect: Failed to connect to RPCN server!");
|
||||||
state = rpcn_state::failure_connect;
|
state = rpcn_state::failure_connect;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpcn_log.notice("connect: Connection successful");
|
||||||
|
|
||||||
if (wolfSSL_set_fd(read_wssl, sockfd) != WOLFSSL_SUCCESS)
|
if (wolfSSL_set_fd(read_wssl, sockfd) != WOLFSSL_SUCCESS)
|
||||||
{
|
{
|
||||||
rpcn_log.error("Failed to associate wolfssl to the socket");
|
rpcn_log.error("connect: Failed to associate wolfssl to the socket");
|
||||||
state = rpcn_state::failure_wolfssl;
|
state = rpcn_state::failure_wolfssl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -672,13 +669,15 @@ namespace rpcn
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
state = rpcn_state::failure_wolfssl;
|
state = rpcn_state::failure_wolfssl;
|
||||||
rpcn_log.error("Handshake failed with RPCN Server: %s", get_wolfssl_error(read_wssl, ret_connect));
|
rpcn_log.error("connect: Handshake failed with RPCN Server: %s", get_wolfssl_error(read_wssl, ret_connect));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpcn_log.notice("connect: Handshake successful");
|
||||||
|
|
||||||
if ((write_wssl = wolfSSL_write_dup(read_wssl)) == NULL)
|
if ((write_wssl = wolfSSL_write_dup(read_wssl)) == NULL)
|
||||||
{
|
{
|
||||||
rpcn_log.error("Failed to create write dup for SSL");
|
rpcn_log.error("connect: Failed to create write dup for SSL");
|
||||||
state = rpcn_state::failure_wolfssl;
|
state = rpcn_state::failure_wolfssl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -689,6 +688,8 @@ namespace rpcn
|
||||||
sem_reader.release();
|
sem_reader.release();
|
||||||
sem_writer.release();
|
sem_writer.release();
|
||||||
|
|
||||||
|
rpcn_log.notice("connect: Waiting for protocol version");
|
||||||
|
|
||||||
while (!server_info_received && connected && !terminate)
|
while (!server_info_received && connected && !terminate)
|
||||||
{
|
{
|
||||||
std::this_thread::sleep_for(5ms);
|
std::this_thread::sleep_for(5ms);
|
||||||
|
@ -707,6 +708,8 @@ namespace rpcn
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpcn_log.notice("connect: Protocol version matches");
|
||||||
|
|
||||||
last_ping_time = steady_clock::now() - 5s;
|
last_ping_time = steady_clock::now() - 5s;
|
||||||
last_pong_time = last_ping_time;
|
last_pong_time = last_ping_time;
|
||||||
|
|
||||||
|
@ -720,6 +723,8 @@ namespace rpcn
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpcn_log.notice("Attempting to login!");
|
||||||
|
|
||||||
std::vector<u8> data;
|
std::vector<u8> data;
|
||||||
std::copy(npid.begin(), npid.end(), std::back_inserter(data));
|
std::copy(npid.begin(), npid.end(), std::back_inserter(data));
|
||||||
data.push_back(0);
|
data.push_back(0);
|
||||||
|
@ -731,8 +736,10 @@ namespace rpcn
|
||||||
u64 req_id = rpcn_request_counter.fetch_add(1);
|
u64 req_id = rpcn_request_counter.fetch_add(1);
|
||||||
|
|
||||||
std::vector<u8> packet_data;
|
std::vector<u8> packet_data;
|
||||||
|
|
||||||
if (!forge_send_reply(CommandType::Login, req_id, data, packet_data))
|
if (!forge_send_reply(CommandType::Login, req_id, data, packet_data))
|
||||||
{
|
{
|
||||||
|
state = rpcn_state::failure_other;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,6 +819,7 @@ namespace rpcn
|
||||||
std::vector<u8> packet_data;
|
std::vector<u8> packet_data;
|
||||||
if (!forge_send_reply(CommandType::Create, req_id, data, packet_data))
|
if (!forge_send_reply(CommandType::Create, req_id, data, packet_data))
|
||||||
{
|
{
|
||||||
|
state = rpcn_state::failure_other;
|
||||||
return ErrorType::CreationError;
|
return ErrorType::CreationError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,10 +960,20 @@ namespace rpcn
|
||||||
memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE);
|
memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE);
|
||||||
|
|
||||||
if (!forge_send_reply(CommandType::GetServerList, req_id, data, reply_data))
|
if (!forge_send_reply(CommandType::GetServerList, req_id, data, reply_data))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec_stream reply(reply_data);
|
||||||
|
auto error = static_cast<ErrorType>(reply.get<u8>());
|
||||||
|
|
||||||
|
if (is_error(error))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
vec_stream reply(reply_data, 1);
|
|
||||||
u16 num_servs = reply.get<u16>();
|
u16 num_servs = reply.get<u16>();
|
||||||
|
|
||||||
server_list.clear();
|
server_list.clear();
|
||||||
for (u16 i = 0; i < num_servs; i++)
|
for (u16 i = 0; i < num_servs; i++)
|
||||||
{
|
{
|
||||||
|
@ -1570,9 +1588,9 @@ namespace rpcn
|
||||||
case LoginInvalidPassword: rpcn_log.error("Login error: invalid password!"); break;
|
case LoginInvalidPassword: rpcn_log.error("Login error: invalid password!"); break;
|
||||||
case LoginInvalidToken: rpcn_log.error("Login error: invalid token!"); break;
|
case LoginInvalidToken: rpcn_log.error("Login error: invalid token!"); break;
|
||||||
case CreationError: rpcn_log.error("Error creating an account!"); break;
|
case CreationError: rpcn_log.error("Error creating an account!"); break;
|
||||||
case CreationExistingUsername: rpcn_log.error("Error creating an account: existing username!");
|
case CreationExistingUsername: rpcn_log.error("Error creating an account: existing username!"); break;
|
||||||
case CreationBannedEmailProvider: rpcn_log.error("Error creating an account: banned email provider!");
|
case CreationBannedEmailProvider: rpcn_log.error("Error creating an account: banned email provider!"); break;
|
||||||
case CreationExistingEmail: rpcn_log.error("Error creating an account: an account with that email already exist!");
|
case CreationExistingEmail: rpcn_log.error("Error creating an account: an account with that email already exist!"); break;
|
||||||
case AlreadyJoined: rpcn_log.error("User has already joined!"); break;
|
case AlreadyJoined: rpcn_log.error("User has already joined!"); break;
|
||||||
case DbFail: rpcn_log.error("A db query failed on the server!"); break;
|
case DbFail: rpcn_log.error("A db query failed on the server!"); break;
|
||||||
case EmailFail: rpcn_log.error("An email action failed on the server!"); break;
|
case EmailFail: rpcn_log.error("An email action failed on the server!"); break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue