diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-03-05 18:01:07 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-03-05 18:01:07 +0000 |
commit | 0611ac72c7020b46466309c19622afe0fb3bc122 (patch) | |
tree | fb5df43af76edebba590449c1b54922d91b07707 /protocols/Tox/src/tox_search.cpp | |
parent | 4492ddd696ed03f015c7a2de457d0aff6f96de62 (diff) |
Tox:
- removed dns3 servers from code
- cv2pdb moved to tools
git-svn-id: http://svn.miranda-ng.org/main/trunk@12330 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_search.cpp')
-rw-r--r-- | protocols/Tox/src/tox_search.cpp | 88 |
1 files changed, 52 insertions, 36 deletions
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp index 910b5497a9..49a1b54099 100644 --- a/protocols/Tox/src/tox_search.cpp +++ b/protocols/Tox/src/tox_search.cpp @@ -1,5 +1,4 @@ #include "common.h"
-#include "tox_dns.h"
ToxHexAddress ResolveToxAddressFromDnsRecordV1(const std::string &dnsRecord)
{
@@ -47,52 +46,69 @@ void CToxProto::SearchByNameAsync(void *arg) int resolved = 0;
- for (size_t i = 0; i < SIZEOF(dns_servers); i++)
+ if (IsFileExists((TCHAR*)VARST(_T(TOX_INI_PATH))))
{
- struct dns_server *server = &dns_servers[i];
- if (domain == NULL || mir_strcmpi(domain, server->domain) == 0)
- {
- void *dns = tox_dns3_new(server->key);
+ char fileName[MAX_PATH];
+ mir_strcpy(fileName, VARS(TOX_INI_PATH));
- uint32_t requestId = 0;
- uint8_t dnsString[MAX_PATH];
- int length = tox_generate_dns3_string(dns, dnsString, sizeof(dnsString), &requestId, (uint8_t*)name, mir_strlen(name));
- if (length != TOX_ERROR)
+ char *section, sections[MAX_PATH], value[MAX_PATH];
+ GetPrivateProfileSectionNamesA(sections, SIZEOF(sections), fileName);
+ section = sections;
+ while (*section != NULL)
+ {
+ if (strstr(section, "Dns_") == section)
{
- dnsString[length] = 0;
- char dnsQuery[MAX_PATH * 2];
- mir_snprintf(dnsQuery, SIZEOF(dnsQuery), "_%s._tox.%s", dnsString, server->domain);
+ GetPrivateProfileStringA(section, "Domain", NULL, value, SIZEOF(value), fileName);
+ ptrA dnsDomain(mir_strdup(value));
+ GetPrivateProfileStringA(section, "PubKey", NULL, value, SIZEOF(value), fileName);
+ ToxBinAddress dnsPubKey(value);
- DNS_RECORDA *record = NULL;
- DNS_STATUS status = DnsQuery_A(dnsQuery, DNS_TYPE_TEXT, 0, NULL, (PDNS_RECORD*)&record, NULL);
- while (status == ERROR_SUCCESS && record)
+ if (domain == NULL || mir_strcmpi(domain, dnsDomain) == 0)
{
- DNS_TXT_DATAA *txt = &record->Data.Txt;
- if (record->wType == DNS_TYPE_TEXT && txt->dwStringCount)
- {
- ToxHexAddress address = ResolveToxAddressFromDnsRecordV3(dns, requestId, txt->pStringArray[0]);
- if (!address.IsEmpty())
- {
- PROTOSEARCHRESULT psr = { sizeof(PROTOSEARCHRESULT) };
- psr.flags = PSR_TCHAR;
- psr.id = mir_a2t(address);
- psr.nick = mir_utf8decodeT(name);
+ void *dns = tox_dns3_new((uint8_t*)(const uint8_t*)dnsPubKey);
- TCHAR email[MAX_PATH];
- mir_sntprintf(email, SIZEOF(email), _T("%s@%s"), psr.nick, _A2T(server->domain));
- psr.email = mir_tstrdup(email);
-
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr);
+ uint32_t requestId = 0;
+ uint8_t dnsString[MAX_PATH];
+ int length = tox_generate_dns3_string(dns, dnsString, sizeof(dnsString), &requestId, (uint8_t*)name, mir_strlen(name));
+ if (length != TOX_ERROR)
+ {
+ dnsString[length] = 0;
+ char dnsQuery[MAX_PATH * 2];
+ mir_snprintf(dnsQuery, SIZEOF(dnsQuery), "_%s._tox.%s", dnsString, dnsDomain);
- resolved++;
- break;
+ DNS_RECORDA *record = NULL;
+ DNS_STATUS status = DnsQuery_A(dnsQuery, DNS_TYPE_TEXT, 0, NULL, (PDNS_RECORD*)&record, NULL);
+ while (status == ERROR_SUCCESS && record)
+ {
+ DNS_TXT_DATAA *txt = &record->Data.Txt;
+ if (record->wType == DNS_TYPE_TEXT && txt->dwStringCount)
+ {
+ ToxHexAddress address = ResolveToxAddressFromDnsRecordV3(dns, requestId, txt->pStringArray[0]);
+ if (!address.IsEmpty())
+ {
+ PROTOSEARCHRESULT psr = { sizeof(PROTOSEARCHRESULT) };
+ psr.flags = PSR_TCHAR;
+ psr.id = mir_a2t(address);
+ psr.nick = mir_utf8decodeT(name);
+
+ TCHAR email[MAX_PATH];
+ mir_sntprintf(email, SIZEOF(email), _T("%s@%s"), psr.nick, _A2T(dnsDomain));
+ psr.email = mir_tstrdup(email);
+
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr);
+
+ resolved++;
+ break;
+ }
+ }
+ record = record->pNext;
}
+ DnsRecordListFree((PDNS_RECORD*)record, DnsFreeRecordList);
}
- record = record->pNext;
+ tox_dns3_kill(dns);
}
- DnsRecordListFree((PDNS_RECORD*)record, DnsFreeRecordList);
}
- tox_dns3_kill(dns);
+ section += strlen(section) + 1;
}
}
|