mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
sys_net: Use np_handler dns if possible for sys_net_infoctl (#8557)
Without this, cellHttpSendRequest will use the hardcoded dns 192.168.1.1, which won't work if you're not on that network.
This commit is contained in:
parent
171e4fafed
commit
cb08c53f2f
@ -2347,8 +2347,27 @@ error_code sys_net_infoctl(ppu_thread& ppu, s32 cmd, vm::ptr<void> arg)
|
||||
{
|
||||
case 9:
|
||||
{
|
||||
// TODO: Find out if this string can change
|
||||
constexpr auto name = "nameserver 192.168.1.1\0"sv;
|
||||
constexpr auto nameserver = "nameserver \0"sv;
|
||||
constexpr auto default_ip = "192.168.1.1\0"sv;
|
||||
|
||||
char buffer[nameserver.size() + 80];
|
||||
std::memcpy(buffer, nameserver.data(), nameserver.size());
|
||||
|
||||
const auto nph = g_fxo->get<named_thread<np_handler>>();
|
||||
if (nph->get_dns())
|
||||
{
|
||||
struct sockaddr_in serv;
|
||||
std::memset(&serv, 0, sizeof(serv));
|
||||
serv.sin_addr.s_addr = nph->get_dns();
|
||||
inet_ntop(AF_INET, &serv.sin_addr, buffer + nameserver.size() - 1, sizeof(buffer) - nameserver.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::memcpy(buffer + nameserver.size() - 1, default_ip.data(), default_ip.size());
|
||||
}
|
||||
|
||||
std::string_view name{buffer};
|
||||
vm::static_ptr_cast<net_infoctl_cmd_9_t>(arg)->zero = 0;
|
||||
std::memcpy(vm::static_ptr_cast<net_infoctl_cmd_9_t>(arg)->server_name.get_ptr(), name.data(), name.size());
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user