mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Makes DNS processing more consistent
This commit is contained in:
parent
8c8048f037
commit
d9d354c981
@ -212,8 +212,8 @@ error_code cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
|
|||||||
case CELL_NET_CTL_INFO_LINK_TYPE: info->link_type = CELL_NET_CTL_LINK_TYPE_10BASE_FULL; break;
|
case CELL_NET_CTL_INFO_LINK_TYPE: info->link_type = CELL_NET_CTL_LINK_TYPE_10BASE_FULL; break;
|
||||||
case CELL_NET_CTL_INFO_IP_CONFIG: info->ip_config = CELL_NET_CTL_IP_STATIC; break;
|
case CELL_NET_CTL_INFO_IP_CONFIG: info->ip_config = CELL_NET_CTL_IP_STATIC; break;
|
||||||
case CELL_NET_CTL_INFO_DEFAULT_ROUTE: strcpy_trunc(info->default_route, "192.168.1.1"); break;
|
case CELL_NET_CTL_INFO_DEFAULT_ROUTE: strcpy_trunc(info->default_route, "192.168.1.1"); break;
|
||||||
case CELL_NET_CTL_INFO_PRIMARY_DNS: strcpy_trunc(info->primary_dns, "8.8.8.8"); break;
|
case CELL_NET_CTL_INFO_PRIMARY_DNS: strcpy_trunc(info->primary_dns, np_handler::ip_to_string(nph->get_dns_ip())); break;
|
||||||
case CELL_NET_CTL_INFO_SECONDARY_DNS: strcpy_trunc(info->secondary_dns, "8.8.8.8"); break;
|
case CELL_NET_CTL_INFO_SECONDARY_DNS: strcpy_trunc(info->secondary_dns, np_handler::ip_to_string(nph->get_dns_ip())); break;
|
||||||
case CELL_NET_CTL_INFO_IP_ADDRESS: strcpy_trunc(info->ip_address, np_handler::ip_to_string(nph->get_local_ip_addr())); break;
|
case CELL_NET_CTL_INFO_IP_ADDRESS: strcpy_trunc(info->ip_address, np_handler::ip_to_string(nph->get_local_ip_addr())); break;
|
||||||
case CELL_NET_CTL_INFO_NETMASK: strcpy_trunc(info->netmask, "255.255.255.255"); break;
|
case CELL_NET_CTL_INFO_NETMASK: strcpy_trunc(info->netmask, "255.255.255.255"); break;
|
||||||
case CELL_NET_CTL_INFO_HTTP_PROXY_CONFIG: info->http_proxy_config = 0; break;
|
case CELL_NET_CTL_INFO_HTTP_PROXY_CONFIG: info->http_proxy_config = 0; break;
|
||||||
|
@ -1510,7 +1510,7 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr
|
|||||||
{
|
{
|
||||||
const auto nph = g_fxo->get<named_thread<np_handler>>();
|
const auto nph = g_fxo->get<named_thread<np_handler>>();
|
||||||
|
|
||||||
// Hack for DNS (8.8.8.8:53)
|
// Hack for DNS
|
||||||
name.sin_port = std::bit_cast<u16, be_t<u16>>(53);
|
name.sin_port = std::bit_cast<u16, be_t<u16>>(53);
|
||||||
name.sin_addr.s_addr = nph->get_dns_ip();
|
name.sin_addr.s_addr = nph->get_dns_ip();
|
||||||
|
|
||||||
@ -3426,23 +3426,13 @@ error_code sys_net_infoctl(ppu_thread& ppu, s32 cmd, vm::ptr<void> arg)
|
|||||||
case 9:
|
case 9:
|
||||||
{
|
{
|
||||||
constexpr auto nameserver = "nameserver \0"sv;
|
constexpr auto nameserver = "nameserver \0"sv;
|
||||||
constexpr auto default_ip = "192.168.1.1\0"sv;
|
|
||||||
|
|
||||||
char buffer[nameserver.size() + 80];
|
char buffer[nameserver.size() + 80]{};
|
||||||
std::memcpy(buffer, nameserver.data(), nameserver.size());
|
std::memcpy(buffer, nameserver.data(), nameserver.size());
|
||||||
|
|
||||||
const auto nph = g_fxo->get<named_thread<np_handler>>();
|
const auto nph = g_fxo->get<named_thread<np_handler>>();
|
||||||
if (nph->get_dns_ip())
|
const auto dns_str = np_handler::ip_to_string(nph->get_dns_ip());
|
||||||
{
|
std::memcpy(buffer + nameserver.size() - 1, dns_str.data(), dns_str.size());
|
||||||
struct sockaddr_in serv;
|
|
||||||
std::memset(&serv, 0, sizeof(serv));
|
|
||||||
serv.sin_addr.s_addr = nph->get_dns_ip();
|
|
||||||
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};
|
std::string_view name{buffer};
|
||||||
vm::static_ptr_cast<net_infoctl_cmd_9_t>(arg)->zero = 0;
|
vm::static_ptr_cast<net_infoctl_cmd_9_t>(arg)->zero = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user