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 | |
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')
-rw-r--r-- | protocols/Tox/Tox_12.vcxproj | 1 | ||||
-rw-r--r-- | protocols/Tox/Tox_12.vcxproj.filters | 3 | ||||
-rw-r--r-- | protocols/Tox/docs/tox.ini | 8 | ||||
-rw-r--r-- | protocols/Tox/src/tox_address.h | 4 | ||||
-rw-r--r-- | protocols/Tox/src/tox_dns.h | 26 | ||||
-rw-r--r-- | protocols/Tox/src/tox_network.cpp | 26 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 5 | ||||
-rw-r--r-- | protocols/Tox/src/tox_search.cpp | 88 | ||||
-rw-r--r-- | protocols/Tox/tools/cv2pdb.exe (renamed from protocols/Tox/docs/cv2pdb.exe) | bin | 200192 -> 200192 bytes | |||
-rw-r--r-- | protocols/Tox/tools/cv2pdb_readme.txt (renamed from protocols/Tox/docs/cv2pdb_readme.txt) | 0 |
10 files changed, 80 insertions, 81 deletions
diff --git a/protocols/Tox/Tox_12.vcxproj b/protocols/Tox/Tox_12.vcxproj index 1a5fbaf657..9afe2be779 100644 --- a/protocols/Tox/Tox_12.vcxproj +++ b/protocols/Tox/Tox_12.vcxproj @@ -208,7 +208,6 @@ copy docs\tox.ini "$(SolutionDir)$(Configuration)64\Plugins" /y</Command> <ClInclude Include="src\resource.h" />
<ClInclude Include="src\tox_address.h" />
<ClInclude Include="src\tox_chatrooms.h" />
- <ClInclude Include="src\tox_dns.h" />
<ClInclude Include="src\tox_icons.h" />
<ClInclude Include="src\tox_menus.h" />
<ClInclude Include="src\tox_options.h" />
diff --git a/protocols/Tox/Tox_12.vcxproj.filters b/protocols/Tox/Tox_12.vcxproj.filters index dd4311df49..d04033b672 100644 --- a/protocols/Tox/Tox_12.vcxproj.filters +++ b/protocols/Tox/Tox_12.vcxproj.filters @@ -33,9 +33,6 @@ <ClInclude Include="src\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\tox_dns.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\tox_transfer.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/protocols/Tox/docs/tox.ini b/protocols/Tox/docs/tox.ini index ea73f5476f..842a5b3c4a 100644 --- a/protocols/Tox/docs/tox.ini +++ b/protocols/Tox/docs/tox.ini @@ -1,3 +1,11 @@ +[Dns_0]
+Domain=toxme.se
+PubKey=5D72C517DF6AEC54F1E977A6B6F25914EA4CF7277A85027CD9F5196DF17E0B13
+
+[Dns_1]
+Domain=utox.org
+PubKey=D3154F65D28A5B41A05D4AC7E4B39C6B1C233CC857FB365C56E8392737462A12
+
[Node_0]
IPv4=miranda-ng.now.im
PubKey=D0CA4D926C359E87946603E6D091AC9665E137811E069BC1C6D72316AEA09178
diff --git a/protocols/Tox/src/tox_address.h b/protocols/Tox/src/tox_address.h index 4270e23ee2..f9be08c767 100644 --- a/protocols/Tox/src/tox_address.h +++ b/protocols/Tox/src/tox_address.h @@ -32,7 +32,7 @@ public: }
const bool IsEmpty() const
{
- return hexData.length() == 0;
+ return hexData.empty();
}
const ToxHexAddress GetPubKey() const
{
@@ -45,7 +45,7 @@ public: }
static ToxHexAddress Empty()
{
- return ToxHexAddress("");
+ return ToxHexAddress("", 0);
}
ToxBinAddress ToBin() const;
};
diff --git a/protocols/Tox/src/tox_dns.h b/protocols/Tox/src/tox_dns.h deleted file mode 100644 index 394ea9f61f..0000000000 --- a/protocols/Tox/src/tox_dns.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _TOX_DNS_H_
-#define _TOX_DNS_H_
-
-struct dns_server
-{
- char *domain;
- uint8_t key[32];
-} dns_servers[] =
-{
- {
- "toxme.se",
- {
- 0x5D, 0x72, 0xC5, 0x17, 0xDF, 0x6A, 0xEC, 0x54, 0xF1, 0xE9, 0x77, 0xA6, 0xB6, 0xF2, 0x59, 0x14,
- 0xEA, 0x4C, 0xF7, 0x27, 0x7A, 0x85, 0x02, 0x7C, 0xD9, 0xF5, 0x19, 0x6D, 0xF1, 0x7E, 0x0B, 0x13
- }
- },
- {
- "utox.org",
- {
- 0xD3, 0x15, 0x4F, 0x65, 0xD2, 0x8A, 0x5B, 0x41, 0xA0, 0x5D, 0x4A, 0xC7, 0xE4, 0xB3, 0x9C, 0x6B,
- 0x1C, 0x23, 0x3C, 0xC8, 0x57, 0xFB, 0x36, 0x5C, 0x56, 0xE8, 0x39, 0x27, 0x37, 0x46, 0x2A, 0x12
- }
- },
-};
-
-#endif //_TOX_DNS_H_
\ No newline at end of file diff --git a/protocols/Tox/src/tox_network.cpp b/protocols/Tox/src/tox_network.cpp index 109cedbf99..52c66120b9 100644 --- a/protocols/Tox/src/tox_network.cpp +++ b/protocols/Tox/src/tox_network.cpp @@ -5,9 +5,16 @@ bool CToxProto::IsOnline() return isConnected && m_iStatus > ID_STATUS_OFFLINE;
}
-int CToxProto::BootstrapNodesFromDb(bool isIPv6)
+void CToxProto::BootstrapNode(const char *address, int port, const uint8_t *pubKey)
+{
+ if (!tox_bootstrap_from_address(tox, address, port, pubKey))
+ {
+ debugLogA("CToxProto::BootstrapNode: failed to bootstrap node %s:%d (%s)", address, port, (const char*)ToxHexAddress(pubKey));
+ }
+}
+
+void CToxProto::BootstrapNodesFromDb(bool isIPv6)
{
- int nodesLoaded = 0;
char module[MAX_PATH];
mir_snprintf(module, SIZEOF(module), "%s_NODES", m_szModuleName);
int nodeCount = db_get_w(NULL, module, TOX_SETTINGS_NODE_COUNT, 0);
@@ -21,22 +28,20 @@ int CToxProto::BootstrapNodesFromDb(bool isIPv6) mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, i);
int port = db_get_w(NULL, module, setting, 33445);
mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, i);
- ptrA pubKey(db_get_sa(NULL, module, setting));
- nodesLoaded += tox_bootstrap_from_address(tox, address, port, ToxBinAddress(pubKey));
+ ToxBinAddress pubKey(ptrA(db_get_sa(NULL, module, setting)));
+ BootstrapNode(address, port, pubKey);
if (isIPv6)
{
mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, i);
address = db_get_sa(NULL, module, setting);
- nodesLoaded += tox_bootstrap_from_address(tox, address, port, ToxBinAddress(pubKey));
+ BootstrapNode(address, port, pubKey);
}
}
}
- return nodesLoaded;
}
-int CToxProto::BootstrapNodesFromIni(bool isIPv6)
+void CToxProto::BootstrapNodesFromIni(bool isIPv6)
{
- int nodesLoaded = 0;
if (IsFileExists((TCHAR*)VARST(_T(TOX_INI_PATH))))
{
char fileName[MAX_PATH];
@@ -54,18 +59,17 @@ int CToxProto::BootstrapNodesFromIni(bool isIPv6) int port = GetPrivateProfileIntA(section, "Port", 33445, fileName);
GetPrivateProfileStringA(section, "PubKey", NULL, value, SIZEOF(value), fileName);
ToxBinAddress pubKey(value);
- nodesLoaded += tox_bootstrap_from_address(tox, address, port, pubKey);
+ BootstrapNode(address, port, pubKey);
if (isIPv6)
{
GetPrivateProfileStringA(section, "IPv6", NULL, value, SIZEOF(value), fileName);
address = mir_strdup(value);
- nodesLoaded += tox_bootstrap_from_address(tox, address, port, pubKey);
+ BootstrapNode(address, port, pubKey);
}
}
section += strlen(section) + 1;
}
}
- return nodesLoaded;
}
void CToxProto::BootstrapNodes()
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 9a00b20c5a..f6292bdc20 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -101,8 +101,9 @@ private: // tox network
bool IsOnline();
- int BootstrapNodesFromDb(bool isIPv6);
- int BootstrapNodesFromIni(bool isIPv6);
+ void BootstrapNode(const char *address, int port, const uint8_t *pubKey);
+ void BootstrapNodesFromDb(bool isIPv6);
+ void BootstrapNodesFromIni(bool isIPv6);
void BootstrapNodes();
void TryConnect();
void CheckConnection(int &retriesCount);
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;
}
}
diff --git a/protocols/Tox/docs/cv2pdb.exe b/protocols/Tox/tools/cv2pdb.exe Binary files differindex 0826b1890e..0826b1890e 100644 --- a/protocols/Tox/docs/cv2pdb.exe +++ b/protocols/Tox/tools/cv2pdb.exe diff --git a/protocols/Tox/docs/cv2pdb_readme.txt b/protocols/Tox/tools/cv2pdb_readme.txt index 141f7dcd8b..141f7dcd8b 100644 --- a/protocols/Tox/docs/cv2pdb_readme.txt +++ b/protocols/Tox/tools/cv2pdb_readme.txt |