From 0611ac72c7020b46466309c19622afe0fb3bc122 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 5 Mar 2015 18:01:07 +0000 Subject: 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 --- protocols/Tox/Tox_12.vcxproj | 1 - protocols/Tox/Tox_12.vcxproj.filters | 3 - protocols/Tox/docs/cv2pdb.exe | Bin 200192 -> 0 bytes protocols/Tox/docs/cv2pdb_readme.txt | 139 ---------------------------------- protocols/Tox/docs/tox.ini | 8 ++ protocols/Tox/src/tox_address.h | 4 +- protocols/Tox/src/tox_dns.h | 26 ------- protocols/Tox/src/tox_network.cpp | 26 ++++--- protocols/Tox/src/tox_proto.h | 5 +- protocols/Tox/src/tox_search.cpp | 88 ++++++++++++--------- protocols/Tox/tools/cv2pdb.exe | Bin 0 -> 200192 bytes protocols/Tox/tools/cv2pdb_readme.txt | 139 ++++++++++++++++++++++++++++++++++ 12 files changed, 219 insertions(+), 220 deletions(-) delete mode 100644 protocols/Tox/docs/cv2pdb.exe delete mode 100644 protocols/Tox/docs/cv2pdb_readme.txt delete mode 100644 protocols/Tox/src/tox_dns.h create mode 100644 protocols/Tox/tools/cv2pdb.exe create mode 100644 protocols/Tox/tools/cv2pdb_readme.txt 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 - 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 @@ Header Files - - Header Files - Header Files diff --git a/protocols/Tox/docs/cv2pdb.exe b/protocols/Tox/docs/cv2pdb.exe deleted file mode 100644 index 0826b1890e..0000000000 Binary files a/protocols/Tox/docs/cv2pdb.exe and /dev/null differ diff --git a/protocols/Tox/docs/cv2pdb_readme.txt b/protocols/Tox/docs/cv2pdb_readme.txt deleted file mode 100644 index 141f7dcd8b..0000000000 --- a/protocols/Tox/docs/cv2pdb_readme.txt +++ /dev/null @@ -1,139 +0,0 @@ - -This is the README file for cv2pdb, a -converter of DMD CodeView/DWARF debug information to PDB files - -Copyright (c) 2009-2010 by Rainer Schuetze, All Rights Reserved - -The goal of this project is to make debugging of D applications that -were created with the Digital Mars DMD compiler, as seamless as possible -in current versions of Visual Studio (i.e Visual Studio 2008 and -VCExpress). -As a side effect, other applications might also benefit from the -converted debug information, like WinDbg or DMC. - -Features --------- -* conversion of DMD CodeView information to PDB file -* conversion of DWARF information to PDB file -* converted line number info allows setting breakpoints -* display of variables, fields and objects in watch, local and auto window and in data tooltips -* generates generic debug info for dynamic arrays, associative arrays and delegates -* autoexp.dat allows convenient display of dynamic and associative arrays in watch windows -* demangles function names for convenient display of callstack -* also works debugging executables built with the Digital Mars C/C++ compiler DMC - -License information -------------------- - -This code is distributed under the term of the Artistic License 2.0. -For more details, see the full text of the license in the file LICENSE. - -The file demangle.cpp is an adaption of denangle.d to C++ distributed with -the DMD compiler. It is placed into the Public Domain. - -The file mscvpdb.h is taken from the WINE-project (http://www.winehq.org) -and is distributed under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. -See the file header for more details and -http://www.gnu.org/licenses/lgpl.html for the full license. - -The file dwarf.h is taken from the libdwarf project -(http://reality.sgiweb.org/davea/dwarf.html) -and is distributed under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. -See the file header for more details and -http://www.gnu.org/licenses/lgpl.html for the full license. - -Installation ------------- -Sorry, there is no full featured installer available yet, you'll have -to do some simple manual steps to use cv2pdb. - -See the file INSTALL for further details. - -Usage ------ - -Quick start: - -Simply run - - cv2pdb debuggee.exe - -on your executable to debug and start the debugger, e.g. - - devenv debuggee.exe -or - vcexpress debuggee.exe - -Description: - -cv2pdb.exe is a command line tool which outputs its usage information -if run without arguments: - - usage: cv2pdb [-Dversion|-C] [new-exe-file] [pdb-file] - -With the -D option, you can specify the version of the DMD compiler -you are using. Unfortunately, this information is not embedded into -the debug information. The default is -D2. So far, this information -is only needed to determine whether "char[]" or "const char[]" is -translated to "string". - -Starting with DMD 2.043, assoiciative arrays have a slightly different -implementation, so debug information needs to be adjusted aswell. -Use -D 2.043 or higher to produce the matching debug info. - -Option -C tells the program, that you want to debug a program compiled -with DMC, the Digital Mars C/C++ compiler. It will disable some of the -D specific functions and will enable adjustment of stack variable names. - -The first file name on the command line is expected to be the executable -or dynamic library compiled by the DMD compiler and containing the -CodeView debug information (-g option used when running dmd). - -If no further file name is given, a PDB file will be created with the -same base name as the executable, but with extension "pdb", and the -executable will be modified to redirect debuggers to this pdb-file instead -of the original debug information. - -Example: - cv2pdb debuggee.exe - -In an environment using make-like tools, it is often useful to create -a new file instead of modifying existing files. That way the file -modification time can be used to continue the build process at the -correct step. -If another file name is specified, the new executable is written -to this file and leaves the input executable unmodified.. The naming -of the pdb-file will use the base name of the output file. - -Example: - cv2pdb debuggee.exe debuggee_pdb.exe - -Last but not least, the resulting pdb-file can be renamed by specifying -a third file name. - -Example: - cv2pdb debuggee.exe debuggee_pdb.exe debug.pdb - - - -Changes -------- - -For documentation on the changes between this version and -previous versions, please see the file CHANGES. - -Feedback --------- -The project home for cv2pdb is here: - - http://www.dsource.org/projects/cv2pdb - https://github.com/rainers/cv2pdb - -There's also a forum, where you can leave your comments and suggestions. - -Have fun, -Rainer Schuetze 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/tools/cv2pdb.exe b/protocols/Tox/tools/cv2pdb.exe new file mode 100644 index 0000000000..0826b1890e Binary files /dev/null and b/protocols/Tox/tools/cv2pdb.exe differ diff --git a/protocols/Tox/tools/cv2pdb_readme.txt b/protocols/Tox/tools/cv2pdb_readme.txt new file mode 100644 index 0000000000..141f7dcd8b --- /dev/null +++ b/protocols/Tox/tools/cv2pdb_readme.txt @@ -0,0 +1,139 @@ + +This is the README file for cv2pdb, a +converter of DMD CodeView/DWARF debug information to PDB files + +Copyright (c) 2009-2010 by Rainer Schuetze, All Rights Reserved + +The goal of this project is to make debugging of D applications that +were created with the Digital Mars DMD compiler, as seamless as possible +in current versions of Visual Studio (i.e Visual Studio 2008 and +VCExpress). +As a side effect, other applications might also benefit from the +converted debug information, like WinDbg or DMC. + +Features +-------- +* conversion of DMD CodeView information to PDB file +* conversion of DWARF information to PDB file +* converted line number info allows setting breakpoints +* display of variables, fields and objects in watch, local and auto window and in data tooltips +* generates generic debug info for dynamic arrays, associative arrays and delegates +* autoexp.dat allows convenient display of dynamic and associative arrays in watch windows +* demangles function names for convenient display of callstack +* also works debugging executables built with the Digital Mars C/C++ compiler DMC + +License information +------------------- + +This code is distributed under the term of the Artistic License 2.0. +For more details, see the full text of the license in the file LICENSE. + +The file demangle.cpp is an adaption of denangle.d to C++ distributed with +the DMD compiler. It is placed into the Public Domain. + +The file mscvpdb.h is taken from the WINE-project (http://www.winehq.org) +and is distributed under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. +See the file header for more details and +http://www.gnu.org/licenses/lgpl.html for the full license. + +The file dwarf.h is taken from the libdwarf project +(http://reality.sgiweb.org/davea/dwarf.html) +and is distributed under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. +See the file header for more details and +http://www.gnu.org/licenses/lgpl.html for the full license. + +Installation +------------ +Sorry, there is no full featured installer available yet, you'll have +to do some simple manual steps to use cv2pdb. + +See the file INSTALL for further details. + +Usage +----- + +Quick start: + +Simply run + + cv2pdb debuggee.exe + +on your executable to debug and start the debugger, e.g. + + devenv debuggee.exe +or + vcexpress debuggee.exe + +Description: + +cv2pdb.exe is a command line tool which outputs its usage information +if run without arguments: + + usage: cv2pdb [-Dversion|-C] [new-exe-file] [pdb-file] + +With the -D option, you can specify the version of the DMD compiler +you are using. Unfortunately, this information is not embedded into +the debug information. The default is -D2. So far, this information +is only needed to determine whether "char[]" or "const char[]" is +translated to "string". + +Starting with DMD 2.043, assoiciative arrays have a slightly different +implementation, so debug information needs to be adjusted aswell. +Use -D 2.043 or higher to produce the matching debug info. + +Option -C tells the program, that you want to debug a program compiled +with DMC, the Digital Mars C/C++ compiler. It will disable some of the +D specific functions and will enable adjustment of stack variable names. + +The first file name on the command line is expected to be the executable +or dynamic library compiled by the DMD compiler and containing the +CodeView debug information (-g option used when running dmd). + +If no further file name is given, a PDB file will be created with the +same base name as the executable, but with extension "pdb", and the +executable will be modified to redirect debuggers to this pdb-file instead +of the original debug information. + +Example: + cv2pdb debuggee.exe + +In an environment using make-like tools, it is often useful to create +a new file instead of modifying existing files. That way the file +modification time can be used to continue the build process at the +correct step. +If another file name is specified, the new executable is written +to this file and leaves the input executable unmodified.. The naming +of the pdb-file will use the base name of the output file. + +Example: + cv2pdb debuggee.exe debuggee_pdb.exe + +Last but not least, the resulting pdb-file can be renamed by specifying +a third file name. + +Example: + cv2pdb debuggee.exe debuggee_pdb.exe debug.pdb + + + +Changes +------- + +For documentation on the changes between this version and +previous versions, please see the file CHANGES. + +Feedback +-------- +The project home for cv2pdb is here: + + http://www.dsource.org/projects/cv2pdb + https://github.com/rainers/cv2pdb + +There's also a forum, where you can leave your comments and suggestions. + +Have fun, +Rainer Schuetze -- cgit v1.2.3