summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_search.cpp
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2017-12-30 00:42:35 +0300
committeraunsane <aunsane@gmail.com>2017-12-30 00:42:49 +0300
commitcc65f8dbead036bfdd29d397195f9152839d4919 (patch)
tree8e8188f7db65f8a538d5e423e1d0b3491706efc4 /protocols/Tox/src/tox_search.cpp
parent81cd378b0a0ee5e26d58c085a3b10bd89a7244c2 (diff)
Tox: project cleanup
- updated libtox - removed deprecated toxDNS support - removed unused references
Diffstat (limited to 'protocols/Tox/src/tox_search.cpp')
-rw-r--r--protocols/Tox/src/tox_search.cpp130
1 files changed, 0 insertions, 130 deletions
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp
index d8077fedd1..b395c5c649 100644
--- a/protocols/Tox/src/tox_search.cpp
+++ b/protocols/Tox/src/tox_search.cpp
@@ -1,58 +1,5 @@
#include "stdafx.h"
-ToxHexAddress ResolveToxAddressFromDnsRecordV1(const std::string &dnsRecord)
-{
- std::smatch match;
- std::regex regex("^v=tox1;id=([A-Fa-f0-9]{76})(;sign=(\\S+))?$");
- if (std::regex_search(dnsRecord, match, regex))
- return ToxHexAddress(match[1]);
- return ToxHexAddress::Empty();
-}
-
-ToxHexAddress ResolveToxAddressFromDnsRecordV2(const std::string &/*dnsRecord*/)
-{
- // unsupported
- /*std::smatch match;
- std::regex regex("^v=tox2;pub=([A-Fa-f0-9]{64});check=([A-Fa-f0-9]{8});sign=(\\S+))?$");
- if (std::regex_search(dnsRecord, match, regex))
- {
- }*/
- return ToxHexAddress::Empty();
-}
-
-ToxHexAddress ResolveToxAddressFromDnsRecordV3(void *dns, uint32_t requestId, const std::string &dnsRecord)
-{
- std::smatch match;
- std::regex regex("^v=tox3;id=([a-z0-5.]+)$");
- if (std::regex_search(dnsRecord, match, regex)) {
- std::string id = match[1];
- uint8_t data[TOX_ADDRESS_SIZE];
- if (tox_decrypt_dns3_TXT(dns, data, (uint8_t*)id.c_str(), (uint32_t)id.length(), requestId) != TOX_ERROR) {
- return ToxHexAddress(data, TOX_ADDRESS_SIZE);
- }
- }
- return ToxHexAddress::Empty();
-}
-
-ToxHexAddress ResolveToxAddressFromDns(const char *dnsQuery)
-{
- ToxHexAddress address = ToxHexAddress::Empty();
-
- DNS_RECORDA *record = nullptr;
- DNS_STATUS status = DnsQuery_A(dnsQuery, DNS_TYPE_TEXT, DNS_QUERY_STANDARD, nullptr, (PDNS_RECORD*)&record, nullptr);
- while (status == ERROR_SUCCESS && record) {
- DNS_TXT_DATAA *txt = &record->Data.Txt;
- if (record->wType == DNS_TYPE_TEXT && txt->dwStringCount) {
- address = ResolveToxAddressFromDnsRecordV1(txt->pStringArray[0]);
- break;
- }
- record = record->pNext;
- }
- DnsRecordListFree((PDNS_RECORD*)record, DnsFreeRecordList);
-
- return address;
-}
-
ToxHexAddress ResolveToxAddressFromToxme(HNETLIBUSER hNetlib, const char *query)
{
ToxHexAddress address = ToxHexAddress::Empty();
@@ -83,83 +30,6 @@ void CToxProto::SearchByNameAsync(void *arg)
char *query = (char*)arg;
char *name = strtok(query, "@");
- // char *domain = strtok(NULL, "");
-
- /*int resolved = 0;
-
- if (IsFileExists((wchar_t*)VARSW(_T(TOX_INI_PATH))))
- {
- char fileName[MAX_PATH];
- mir_strcpy(fileName, VARS(TOX_INI_PATH));
-
- char *section, sections[MAX_PATH], value[TOX_PUBLIC_KEY_SIZE * 2];
- GetPrivateProfileSectionNamesA(sections, _countof(sections), fileName);
- section = sections;
- while (*section != NULL)
- {
- if (strstr(section, "Dns_") == section)
- {
- GetPrivateProfileStringA(section, "Domain", NULL, value, _countof(value), fileName);
- ptrA dnsDomain(mir_strdup(value));
- GetPrivateProfileStringA(section, "PubKey", NULL, value, _countof(value), fileName);
- ToxBinAddress dnsPubKey = value;
-
- if (domain == NULL || mir_strcmpi(domain, dnsDomain) == 0)
- {
- void *dns = tox_dns3_new((uint8_t*)(const uint8_t*)dnsPubKey);
-
- uint32_t requestId = 0;
- uint8_t dnsString[MAX_PATH];
- size_t length = tox_generate_dns3_string(dns, dnsString, sizeof(dnsString), &requestId, (uint8_t*)CharLowerA(name), (uint8_t)mir_strlen(name));
- if (length != TOX_ERROR)
- {
- dnsString[length] = 0;
- char dnsQuery[MAX_PATH * 2];
- mir_snprintf(dnsQuery, "_%s._tox.%s", dnsString, dnsDomain);
-
- ToxHexAddress address = ResolveToxAddressFromDns(dnsQuery);
- if (!address.IsEmpty())
- {
- PROTOSEARCHRESULT psr = { sizeof(PROTOSEARCHRESULT) };
- psr.flags = PSR_UTF8;
- psr.id.a = mir_strdup(address);
- psr.nick.a = mir_strdup(name);
-
- char email[MAX_PATH];
- mir_snprintf(email, "%s@%s", name, domain);
- psr.email.a = mir_strdup(email);
-
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr);
- break;
- }
- }
- tox_dns3_kill(dns);
- }
- }
- section += mir_strlen(section) + 1;
- }
- }
-
- if (resolved == 0 && domain)
- {
- char dnsQuery[MAX_PATH];
- mir_snprintf(dnsQuery, "%s._tox.%s", name, domain);
-
- ToxHexAddress address = ResolveToxAddressFromDns(dnsQuery);
- if (!address.IsEmpty())
- {
- PROTOSEARCHRESULT psr = { sizeof(PROTOSEARCHRESULT) };
- psr.flags = PSR_UTF8;
- psr.id.a = mir_strdup(address);
- psr.nick.a = mir_strdup(name);
-
- char email[MAX_PATH];
- mir_snprintf(email, "%s@%s", name, domain);
- psr.email.a = mir_strdup(email);
-
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr);
- }
- }*/
ToxHexAddress address = ResolveToxAddressFromToxme(m_hNetlibUser, query);
if (!address.IsEmpty()) {