From f843b6efbcaa17582efcc9ae1fe35d1d22edcb63 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 18 Feb 2015 20:47:25 +0000 Subject: Tox: nodes index starts with 0 git-svn-id: http://svn.miranda-ng.org/main/trunk@12188 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_network.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'protocols/Tox/src/tox_network.cpp') diff --git a/protocols/Tox/src/tox_network.cpp b/protocols/Tox/src/tox_network.cpp index 2db215a01d..3e4b9ed52c 100644 --- a/protocols/Tox/src/tox_network.cpp +++ b/protocols/Tox/src/tox_network.cpp @@ -9,14 +9,14 @@ void CToxProto::BootstrapNodes() { debugLogA("CToxProto::BootstrapDht: bootstraping DHT"); - bool isIPv4Only = getBool("DisableIPv6", 0); + bool isIPv6 = !getBool("DisableIPv6", 0); int nodeCount = db_get_w(NULL, MODULE, TOX_SETTINGS_NODE_COUNT, 0); if (!nodeCount) { tox_bootstrap_from_address( tox, "192.254.75.102", 33445, ToxBinAddress("951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F")); - if (!isIPv4Only) + if (isIPv6) tox_bootstrap_from_address( tox, "2607:5600:284::2", 33445, ToxBinAddress("951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F")); @@ -26,22 +26,19 @@ void CToxProto::BootstrapNodes() char setting[MAX_PATH]; for (int i = 0; i < nodeCount; i++) { - mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV4, i + 1); + mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV4, i); ptrA address(db_get_sa(NULL, MODULE, setting)); - mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, i + 1); - ptrA addressv6(db_get_sa(NULL, MODULE, setting)); - mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, i + 1); - int port = db_get_w(NULL, MODULE, setting, 0); - mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, i + 1); + 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)); - if (pubKey && address && port) + tox_bootstrap_from_address(tox, address, port, ToxBinAddress(pubKey)); + if (isIPv6) { + mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, i); + address = db_get_sa(NULL, MODULE, setting); tox_bootstrap_from_address(tox, address, port, ToxBinAddress(pubKey)); } - if (!isIPv4Only && pubKey && addressv6 && port) - { - tox_bootstrap_from_address(tox, addressv6, port, ToxBinAddress(pubKey)); - } } } } -- cgit v1.2.3