Commit 3c7b9082 authored by nanahira's avatar nanahira

more fix

parent 6a5fbe5c
...@@ -4373,14 +4373,15 @@ unsigned int DuelClient::LookupHost(char *host) { ...@@ -4373,14 +4373,15 @@ unsigned int DuelClient::LookupHost(char *host) {
} }
bool DuelClient::LookupSRV(char *hostname, HostResult* result) { bool DuelClient::LookupSRV(char *hostname, HostResult* result) {
char resolved[100];
#ifdef _WIN32 #ifdef _WIN32
PDNS_RECORD ret; PDNS_RECORD ret;
DNS_STATUS status = DnsQuery_UTF8(hostname, DNS_TYPE_SRV, DNS_QUERY_STANDARD, NULL, &ret, NULL); DNS_STATUS status = DnsQuery_W(hostname, DNS_TYPE_SRV, DNS_QUERY_STANDARD, NULL, &ret, NULL);
if(status != 0) if(status != 0)
return false; return false;
result->host = LookupHost(ret->Data.SRV.pNameTarget); BufferIO::EncodeUTF8(ret->Data.SRV.pNameTarget, resolved);
result->port = ntohs(ret->Data.SRV.wPort); result->port = ntohs(ret->Data.SRV.wPort);
return true; DnsRecordListFree(ret, DnsFreeRecordListDeep);
#else #else
struct __res_state res; struct __res_state res;
int status = res_ninit(&res); int status = res_ninit(&res);
...@@ -4393,6 +4394,7 @@ bool DuelClient::LookupSRV(char *hostname, HostResult* result) { ...@@ -4393,6 +4394,7 @@ bool DuelClient::LookupSRV(char *hostname, HostResult* result) {
ns_msg nsMsg; ns_msg nsMsg;
ns_rr rr; ns_rr rr;
ns_initparse(answer, status, &nsMsg); ns_initparse(answer, status, &nsMsg);
bool found = false;
for (int i = 0; i < ns_msg_count(nsMsg, ns_s_an); i++) { for (int i = 0; i < ns_msg_count(nsMsg, ns_s_an); i++) {
if (ns_parserr(&nsMsg, ns_s_an, i, &rr) < 0 || ns_rr_type(rr) != T_SRV) if (ns_parserr(&nsMsg, ns_s_an, i, &rr) < 0 || ns_rr_type(rr) != T_SRV)
continue; continue;
...@@ -4405,11 +4407,13 @@ bool DuelClient::LookupSRV(char *hostname, HostResult* result) { ...@@ -4405,11 +4407,13 @@ bool DuelClient::LookupSRV(char *hostname, HostResult* result) {
// decompress domain name // decompress domain name
if (dn_expand(ns_msg_base(nsMsg), ns_msg_end(nsMsg), ns_rr_rdata(rr) + 3 * NS_INT16SZ, resolved, sizeof(resolved)) < 0) if (dn_expand(ns_msg_base(nsMsg), ns_msg_end(nsMsg), ns_rr_rdata(rr) + 3 * NS_INT16SZ, resolved, sizeof(resolved)) < 0)
continue; continue;
result->host = LookupHost(resolved); found = true;
return true;
} }
return false; if(!found)
return false;
#endif #endif
result->host = LookupHost(resolved);
return true;
} }
HostResult DuelClient::ParseHost(char *hostname) { HostResult DuelClient::ParseHost(char *hostname) {
......
...@@ -66,7 +66,7 @@ project "YGOPro" ...@@ -66,7 +66,7 @@ project "YGOPro"
filter {} filter {}
end end
end end
links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32" } links { "opengl32", "ws2_32", "winmm", "gdi32", "kernel32", "user32", "imm32", "Dnsapi" }
filter "not action:vs*" filter "not action:vs*"
buildoptions { "-std=c++14", "-fno-rtti" } buildoptions { "-std=c++14", "-fno-rtti" }
filter "not system:windows" filter "not system:windows"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment