summaryrefslogtreecommitdiff
path: root/protocols/Tox/src
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-02-18 20:47:25 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-02-18 20:47:25 +0000
commitf843b6efbcaa17582efcc9ae1fe35d1d22edcb63 (patch)
tree0bd42b549fce377c34e7bfeccaab6ac2f93f1007 /protocols/Tox/src
parenta434de21b52ff537346f279bb358a486759b6f25 (diff)
Tox: nodes index starts with 0
git-svn-id: http://svn.miranda-ng.org/main/trunk@12188 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r--protocols/Tox/src/tox_network.cpp23
-rw-r--r--protocols/Tox/src/tox_options.cpp35
2 files changed, 29 insertions, 29 deletions
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));
- }
}
}
}
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp
index e99c73dcd5..db7e8bedbc 100644
--- a/protocols/Tox/src/tox_options.cpp
+++ b/protocols/Tox/src/tox_options.cpp
@@ -428,25 +428,28 @@ INT_PTR CALLBACK ToxNodesOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
lvi.iImage = -1;
lvi.mask = LVIF_TEXT | LVIF_IMAGE;
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV4, lvi.iItem + 1);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV4, lvi.iItem);
lvi.iSubItem = 0;
lvi.pszText = db_get_sa(NULL, MODULE, setting);
SendMessage(hwndList, LVM_INSERTITEMA, 0, (LPARAM)&lvi);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, lvi.iItem + 1);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, lvi.iItem);
lvi.iSubItem = 1;
lvi.pszText = db_get_sa(NULL, MODULE, setting);
SendMessage(hwndList, LVM_SETITEMA, 0, (LPARAM)&lvi);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, lvi.iItem + 1);
- int port = db_get_w(NULL, MODULE, setting, 33445);
- char portNum[10];
- itoa(port, portNum, 10);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, lvi.iItem);
+ int port = db_get_w(NULL, MODULE, setting, 0);
+ if (port > 0)
+ {
+ char portNum[10];
+ itoa(port, portNum, 10);
+ lvi.pszText = mir_strdup(portNum);
+ }
lvi.iSubItem = 2;
- lvi.pszText = mir_strdup(portNum);
SendMessage(hwndList, LVM_SETITEMA, 0, (LPARAM)&lvi);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, lvi.iItem + 1);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, lvi.iItem);
lvi.iSubItem = 3;
lvi.pszText = db_get_sa(NULL, MODULE, setting);
SendMessage(hwndList, LVM_SETITEMA, 0, (LPARAM)&lvi);
@@ -515,35 +518,35 @@ INT_PTR CALLBACK ToxNodesOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
{
lvi.iSubItem = 0;
SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&lvi);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV4, lvi.iItem + 1);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV4, lvi.iItem);
db_set_s(NULL, MODULE, setting, lvi.pszText);
lvi.iSubItem = 1;
SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&lvi);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, lvi.iItem + 1);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, lvi.iItem);
db_set_s(NULL, MODULE, setting, lvi.pszText);
lvi.iSubItem = 2;
SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&lvi);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, lvi.iItem + 1);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, lvi.iItem);
db_set_w(NULL, MODULE, setting, atoi(lvi.pszText));
lvi.iSubItem = 3;
SendMessage(hwndList, LVM_GETITEMA, 0, (LPARAM)&lvi);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, lvi.iItem + 1);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, lvi.iItem);
db_set_s(NULL, MODULE, setting, lvi.pszText);
}
int nodeCount = db_get_b(NULL, MODULE, TOX_SETTINGS_NODE_COUNT, 0);
for (lvi.iItem = itemCount; lvi.iItem < nodeCount; lvi.iItem++)
{
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV4, lvi.iItem + 1);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV4, lvi.iItem);
db_unset(NULL, MODULE, setting);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, lvi.iItem + 1);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_IPV6, lvi.iItem);
db_unset(NULL, MODULE, setting);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, lvi.iItem + 1);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, lvi.iItem);
db_unset(NULL, MODULE, setting);
- mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, lvi.iItem + 1);
+ mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, lvi.iItem);
db_unset(NULL, MODULE, setting);
}