mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-02 13:01:27 +12:00
Bind RPCN client socket only if bind_ip is set
Some checks are pending
Generate Translation Template / Generate Translation Template (push) Waiting to run
Build RPCS3 / RPCS3 Linux ubuntu-24.04 gcc (push) Waiting to run
Build RPCS3 / RPCS3 Linux ubuntu-24.04-arm clang (push) Waiting to run
Build RPCS3 / RPCS3 Linux ubuntu-24.04 clang (push) Waiting to run
Build RPCS3 / RPCS3 Windows (push) Waiting to run
Some checks are pending
Generate Translation Template / Generate Translation Template (push) Waiting to run
Build RPCS3 / RPCS3 Linux ubuntu-24.04 gcc (push) Waiting to run
Build RPCS3 / RPCS3 Linux ubuntu-24.04-arm clang (push) Waiting to run
Build RPCS3 / RPCS3 Linux ubuntu-24.04 clang (push) Waiting to run
Build RPCS3 / RPCS3 Windows (push) Waiting to run
This commit is contained in:
parent
6854e9b974
commit
b1b02e0425
4 changed files with 26 additions and 13 deletions
|
@ -75,16 +75,14 @@ nt_p2p_port::nt_p2p_port(u16 port)
|
|||
else
|
||||
{
|
||||
::sockaddr_in p2p_ipv4_addr{.sin_family = AF_INET, .sin_port = be_port};
|
||||
p2p_ipv4_addr.sin_addr.s_addr = nph.get_bind_ip();
|
||||
const u32 bind_ip = nph.get_bind_ip();
|
||||
p2p_ipv4_addr.sin_addr.s_addr = bind_ip;
|
||||
|
||||
if (ret_bind = ::bind(p2p_socket, reinterpret_cast<const sockaddr*>(&p2p_ipv4_addr), sizeof(p2p_ipv4_addr)); ret_bind == -1)
|
||||
if (ret_bind = ::bind(p2p_socket, reinterpret_cast<const sockaddr*>(&p2p_ipv4_addr), sizeof(p2p_ipv4_addr)); ret_bind == -1 && bind_ip)
|
||||
{
|
||||
if (nph.get_bind_ip())
|
||||
{
|
||||
sys_net.error("Failed to bind to %s:%d, falling back to 0.0.0.0:%d", np::ip_to_string(nph.get_bind_ip()), port, port);
|
||||
p2p_ipv4_addr.sin_addr.s_addr = 0;
|
||||
ret_bind = ::bind(p2p_socket, reinterpret_cast<const sockaddr*>(&p2p_ipv4_addr), sizeof(p2p_ipv4_addr));
|
||||
}
|
||||
sys_net.error("Failed to bind to %s:%d, falling back to 0.0.0.0:%d", np::ip_to_string(bind_ip), port, port);
|
||||
p2p_ipv4_addr.sin_addr.s_addr = 0;
|
||||
ret_bind = ::bind(p2p_socket, reinterpret_cast<const sockaddr*>(&p2p_ipv4_addr), sizeof(p2p_ipv4_addr));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
#include "sys_net_helpers.h"
|
||||
#include "network_context.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Emu/NP/np_handler.h"
|
||||
#include "Emu/NP/np_helpers.h"
|
||||
#endif
|
||||
|
||||
LOG_CHANNEL(sys_net);
|
||||
|
||||
int get_native_error()
|
||||
|
@ -159,8 +164,19 @@ sys_net_sockaddr native_addr_to_sys_net_addr(const ::sockaddr_storage& native_ad
|
|||
// Windows doesn't support sending packets to 0.0.0.0 but it works on unixes, send to 127.0.0.1 instead
|
||||
if (native_addr.sin_addr.s_addr == 0x00000000)
|
||||
{
|
||||
sys_net.warning("[Native] Redirected 0.0.0.0 to 127.0.0.1");
|
||||
native_addr.sin_addr.s_addr = std::bit_cast<u32, be_t<u32>>(0x7F000001);
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (const u32 bind_addr = nph.get_bind_ip(); bind_addr != 0)
|
||||
{
|
||||
// If bind IP is set 0.0.0.0 was bound to binding_ip so we need to connect to that ip
|
||||
sys_net.warning("[Native] Redirected 0.0.0.0 to %s", np::ip_to_string(bind_addr));
|
||||
native_addr.sin_addr.s_addr = bind_addr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise we connect to localhost which should be bound
|
||||
sys_net.warning("[Native] Redirected 0.0.0.0 to 127.0.0.1");
|
||||
native_addr.sin_addr.s_addr = std::bit_cast<u32, be_t<u32>>(0x7F000001);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include "Emu/Cell/lv2/sys_net/sys_net_helpers.h"
|
||||
#include "stdafx.h"
|
||||
#include "Emu/system_config.h"
|
||||
#include "ip_address.h"
|
||||
|
|
|
@ -1078,9 +1078,9 @@ namespace rpcn
|
|||
sockaddr_in sock_addr = {.sin_family = AF_INET};
|
||||
sock_addr.sin_addr.s_addr = binding_address;
|
||||
|
||||
if (::bind(sockfd, reinterpret_cast<const sockaddr*>(&sock_addr), sizeof(sock_addr)) == -1)
|
||||
if (binding_address != 0 && ::bind(sockfd, reinterpret_cast<const sockaddr*>(&sock_addr), sizeof(sock_addr)) == -1)
|
||||
{
|
||||
rpcn_log.error("bind: Failed to bind RPCN client socket to binding address!");
|
||||
rpcn_log.error("bind: Failed to bind RPCN client socket to binding address(%s): 0x%x!", np::ip_to_string(binding_address), get_native_error());
|
||||
state = rpcn_state::failure_binding;
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue