mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #13309 from ANR2ME/initlocalhostip
Avoid using getaddrinfo during initialization
This commit is contained in:
commit
a60759cca3
2 changed files with 4 additions and 18 deletions
|
@ -113,7 +113,7 @@ void AfterApctlMipsCall::SetData(int HandlerID, int OldState, int NewState, int
|
||||||
argsAddr = ArgsAddr;
|
argsAddr = ArgsAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int InitLocalhostIP() {
|
void InitLocalhostIP() {
|
||||||
// The entire 127.*.*.* is reserved for loopback.
|
// The entire 127.*.*.* is reserved for loopback.
|
||||||
uint32_t localIP = 0x7F000001 + PPSSPP_ID - 1;
|
uint32_t localIP = 0x7F000001 + PPSSPP_ID - 1;
|
||||||
|
|
||||||
|
@ -121,22 +121,8 @@ static int InitLocalhostIP() {
|
||||||
g_localhostIP.in.sin_addr.s_addr = htonl(localIP);
|
g_localhostIP.in.sin_addr.s_addr = htonl(localIP);
|
||||||
g_localhostIP.in.sin_port = 0;
|
g_localhostIP.in.sin_port = 0;
|
||||||
|
|
||||||
// If lookup fails, we'll assume it's not local.
|
std::string serverStr = StripSpaces(g_Config.proAdhocServer);
|
||||||
isLocalServer = false;
|
isLocalServer = (!strcasecmp(serverStr.c_str(), "localhost") || serverStr.find("127.") == 0);
|
||||||
|
|
||||||
addrinfo *resultAddr = nullptr;
|
|
||||||
std::string error;
|
|
||||||
if (net::DNSResolve(g_Config.proAdhocServer, "", &resultAddr, error, net::DNSType::IPV4)) {
|
|
||||||
for (addrinfo *ptr = resultAddr; ptr != nullptr; ptr = ptr->ai_next) {
|
|
||||||
auto addr4 = ((sockaddr_in *)ptr->ai_addr)->sin_addr.s_addr;
|
|
||||||
isLocalServer = (ntohl(addr4) & 0x7F000000) == 0x7F000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
net::DNSResolveFree(resultAddr);
|
|
||||||
resultAddr = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __NetApctlInit() {
|
void __NetApctlInit() {
|
||||||
|
|
|
@ -1930,7 +1930,7 @@ bool HostnameSelectScreen::CanComplete(DialogResult result) {
|
||||||
|
|
||||||
void HostnameSelectScreen::OnCompleted(DialogResult result) {
|
void HostnameSelectScreen::OnCompleted(DialogResult result) {
|
||||||
if (result == DR_OK)
|
if (result == DR_OK)
|
||||||
*value_ = addrView_->GetText();
|
*value_ = StripSpaces(addrView_->GetText());
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingInfoMessage::SettingInfoMessage(int align, UI::AnchorLayoutParams *lp)
|
SettingInfoMessage::SettingInfoMessage(int align, UI::AnchorLayoutParams *lp)
|
||||||
|
|
Loading…
Add table
Reference in a new issue