mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Remove "Secondary DNS" as a setting.
This commit is contained in:
parent
1a03d60022
commit
c5cde0f218
6 changed files with 26 additions and 23 deletions
|
@ -322,19 +322,24 @@ struct DNSHeader {
|
|||
};
|
||||
|
||||
// Function to convert a domain name to DNS query format
|
||||
// http://www.tcpipguide.com/free/t_DNSNameNotationandMessageCompressionTechnique.htm
|
||||
static void encode_domain_name(const char *domain, unsigned char *encoded) {
|
||||
const char *pos = domain;
|
||||
unsigned char *ptr = encoded;
|
||||
|
||||
while (*pos) {
|
||||
const char *start = pos;
|
||||
while (*pos && *pos != '.') pos++;
|
||||
while (*pos && *pos != '.') {
|
||||
pos++;
|
||||
}
|
||||
|
||||
*ptr++ = (unsigned char)(pos - start);
|
||||
*ptr++ = (unsigned char)(pos - start); // length field
|
||||
memcpy(ptr, start, pos - start);
|
||||
ptr += pos - start;
|
||||
|
||||
if (*pos == '.') pos++;
|
||||
if (*pos == '.') {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
*ptr = 0; // End of domain name
|
||||
}
|
||||
|
@ -418,20 +423,20 @@ bool DirectDNSLookupIPV4(const char *dns_server_ip, const char *domain, uint32_t
|
|||
return false;
|
||||
}
|
||||
|
||||
int sockfd;
|
||||
SOCKET sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
// Create UDP socket
|
||||
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
|
||||
if (sockfd < 0) {
|
||||
ERROR_LOG(Log::sceNet, "Socket creation for direct DNS failed");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct sockaddr_in server_addr {};
|
||||
struct sockaddr_in server_addr{};
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_port = htons(DNS_PORT);
|
||||
|
||||
if (net::inet_pton(AF_INET, dns_server_ip, &server_addr.sin_addr) <= 0) {
|
||||
ERROR_LOG(Log::sceNet,"Invalid DNS server IP address %s", dns_server_ip);
|
||||
close(sockfd);
|
||||
closesocket(sockfd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -451,7 +456,7 @@ bool DirectDNSLookupIPV4(const char *dns_server_ip, const char *domain, uint32_t
|
|||
|
||||
// Send DNS query
|
||||
size_t query_len = sizeof(DNSHeader) + (qinfo - buffer) + 4;
|
||||
if (sendto(sockfd, (const char *)buffer, query_len, 0, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
|
||||
if (sendto(sockfd, (const char *)buffer, (int)query_len, 0, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
|
||||
ERROR_LOG(Log::sceNet, "Failed to send DNS query");
|
||||
closesocket(sockfd);
|
||||
return 1;
|
||||
|
|
|
@ -901,8 +901,7 @@ static const ConfigSetting networkSettings[] = {
|
|||
ConfigSetting("EnableAdhocServer", &g_Config.bEnableAdhocServer, false, CfgFlag::PER_GAME),
|
||||
ConfigSetting("proAdhocServer", &g_Config.proAdhocServer, "socom.cc", CfgFlag::PER_GAME),
|
||||
ConfigSetting("PortOffset", &g_Config.iPortOffset, 10000, CfgFlag::PER_GAME),
|
||||
ConfigSetting("PrimaryDNSServer", &g_Config.primaryDNSServer, "67.222.156.250", CfgFlag::PER_GAME),
|
||||
ConfigSetting("SecondaryDNSServer", &g_Config.secondaryDNSServer, "0.0.0.0", CfgFlag::PER_GAME),
|
||||
ConfigSetting("PrimaryDNSServer", &g_Config.sInfrastructureDNSServer, "67.222.156.250", CfgFlag::PER_GAME),
|
||||
ConfigSetting("MinTimeout", &g_Config.iMinTimeout, 0, CfgFlag::PER_GAME),
|
||||
ConfigSetting("ForcedFirstConnect", &g_Config.bForcedFirstConnect, false, CfgFlag::PER_GAME),
|
||||
ConfigSetting("EnableUPnP", &g_Config.bEnableUPnP, false, CfgFlag::PER_GAME),
|
||||
|
|
|
@ -457,13 +457,13 @@ public:
|
|||
bool bSavedataUpgrade;
|
||||
|
||||
// Networking
|
||||
std::string proAdhocServer;
|
||||
std::string primaryDNSServer;
|
||||
std::string secondaryDNSServer;
|
||||
std::string sInfrastructureUsername; // Username used for Infrastructure play. Different restrictions.
|
||||
bool bEnableWlan;
|
||||
std::map<std::string, std::string> mHostToAlias; // TODO: mPostShaderSetting
|
||||
bool bEnableAdhocServer;
|
||||
std::string proAdhocServer;
|
||||
std::string sInfrastructureDNSServer;
|
||||
std::string sInfrastructureUsername; // Username used for Infrastructure play. Different restrictions.
|
||||
|
||||
bool bEnableWlan;
|
||||
std::map<std::string, std::string> mHostToAlias; // Local DNS database stored in ini file
|
||||
bool bEnableUPnP;
|
||||
bool bUPnPUseOriginalPort;
|
||||
bool bForcedFirstConnect;
|
||||
|
@ -472,7 +472,7 @@ public:
|
|||
int iWlanAdhocChannel;
|
||||
bool bWlanPowerSave;
|
||||
bool bEnableNetworkChat;
|
||||
//for chat position , moveable buttons is better than this
|
||||
|
||||
int iChatButtonPosition;
|
||||
int iChatScreenPosition;
|
||||
|
||||
|
|
|
@ -785,10 +785,10 @@ void NetApctl_InitInfo(int confId) {
|
|||
truncate_cpy(netApctlInfo.gateway, sizeof(netApctlInfo.gateway), ipstr);
|
||||
// We should probably use public DNS Server instead of localhost IP since most people don't have DNS Server running on localhost (ie. Untold Legends The Warrior's Code is trying to lookup dns using the primary dns), but accessing public DNS Server from localhost may result to ENETUNREACH error if the gateway can't access the public server (ie. using SO_DONTROUTE)
|
||||
//if (strcmp(ipstr, "127.0.0.1") == 0)
|
||||
truncate_cpy(netApctlInfo.primaryDns, sizeof(netApctlInfo.primaryDns), g_Config.primaryDNSServer.c_str()); // Private Servers may need to use custom DNS Server
|
||||
truncate_cpy(netApctlInfo.primaryDns, sizeof(netApctlInfo.primaryDns), g_Config.sInfrastructureDNSServer.c_str()); // Private Servers may need to use custom DNS Server
|
||||
//else
|
||||
// truncate_cpy(netApctlInfo.primaryDns, sizeof(netApctlInfo.primaryDns), ipstr);
|
||||
truncate_cpy(netApctlInfo.secondaryDns, sizeof(netApctlInfo.secondaryDns), g_Config.secondaryDNSServer.c_str()); // Fireteam Bravo 2 seems to try to use secondary DNS too if it's not 0.0.0.0
|
||||
truncate_cpy(netApctlInfo.secondaryDns, sizeof(netApctlInfo.secondaryDns), "0.0.0.0"); // Fireteam Bravo 2 seems to try to use secondary DNS too if it's not 0.0.0.0
|
||||
truncate_cpy(netApctlInfo.subNetMask, sizeof(netApctlInfo.subNetMask), "255.255.255.0");
|
||||
}
|
||||
|
||||
|
|
|
@ -109,14 +109,14 @@ int NetResolver_StartNtoA(u32 resolverId, u32 hostnamePtr, u32 inAddrPtr, int ti
|
|||
|
||||
// Now use the configured primary DNS server to do a lookup.
|
||||
// TODO: Pick a DNS server per-game according to a table downloaded from ppsspp.org.
|
||||
if (net::DirectDNSLookupIPV4(g_Config.primaryDNSServer.c_str(), hostname.c_str(), &resolvedAddr)) {
|
||||
if (net::DirectDNSLookupIPV4(g_Config.sInfrastructureDNSServer.c_str(), hostname.c_str(), &resolvedAddr)) {
|
||||
INFO_LOG(Log::sceNet, "Direct lookup of '%s' succeeded: %08x", hostname.c_str(), resolvedAddr);
|
||||
resolver->SetIsRunning(false);
|
||||
Memory::Write_U32(resolvedAddr, inAddrPtr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
WARN_LOG(Log::sceNet, "Direct DNS lookup of '%s' at DNS server '%s' failed. Trying OS DNS...", hostname.c_str(), g_Config.primaryDNSServer.c_str());
|
||||
WARN_LOG(Log::sceNet, "Direct DNS lookup of '%s' at DNS server '%s' failed. Trying OS DNS...", hostname.c_str(), g_Config.sInfrastructureDNSServer.c_str());
|
||||
|
||||
// Attempt to execute a DNS resolution
|
||||
if (!net::DNSResolve(hostname, "", &resolved, err)) {
|
||||
|
|
|
@ -951,8 +951,7 @@ void GameSettingsScreen::CreateNetworkingSettings(UI::ViewGroup *networkingSetti
|
|||
return UI::EVENT_DONE;
|
||||
});
|
||||
|
||||
networkingSettings->Add(new PopupTextInputChoice(GetRequesterToken(), &g_Config.primaryDNSServer, n->T("Primary DNS server"), "", 32, screenManager()));
|
||||
networkingSettings->Add(new PopupTextInputChoice(GetRequesterToken(), &g_Config.secondaryDNSServer, n->T("Secondary DNS server"), "", 32, screenManager()));
|
||||
networkingSettings->Add(new PopupTextInputChoice(GetRequesterToken(), &g_Config.sInfrastructureDNSServer, n->T("DNS server"), "", 32, screenManager()));
|
||||
|
||||
networkingSettings->Add(new ItemHeader(n->T("Chat")));
|
||||
networkingSettings->Add(new CheckBox(&g_Config.bEnableNetworkChat, n->T("Enable network chat", "Enable network chat")));
|
||||
|
|
Loading…
Add table
Reference in a new issue