From da6afd3553ac4e189071efbffb27cc0c9c951dff Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 19 Feb 2015 20:12:41 +0000 Subject: Tox: - twiked connection algorithm - added ability to load nodes from ini automatically git-svn-id: http://svn.miranda-ng.org/main/trunk@12202 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/docs/autoexec_tox_nodes.ini | 73 ------------------ protocols/Tox/docs/tox.ini | 108 ++++++++++++++++++++++++++ protocols/Tox/docs/tox_nodes.ini | 73 ++++++++++++++++++ protocols/Tox/src/common.h | 14 ++-- protocols/Tox/src/tox_network.cpp | 124 +++++++++++++++++++----------- protocols/Tox/src/tox_proto.h | 2 + 6 files changed, 273 insertions(+), 121 deletions(-) delete mode 100644 protocols/Tox/docs/autoexec_tox_nodes.ini create mode 100644 protocols/Tox/docs/tox.ini create mode 100644 protocols/Tox/docs/tox_nodes.ini (limited to 'protocols/Tox') diff --git a/protocols/Tox/docs/autoexec_tox_nodes.ini b/protocols/Tox/docs/autoexec_tox_nodes.ini deleted file mode 100644 index aaa452bb44..0000000000 --- a/protocols/Tox/docs/autoexec_tox_nodes.ini +++ /dev/null @@ -1,73 +0,0 @@ -SETTINGS: - -[TOX] -NodeCount=b20 -Node_0_IPv4=s192.254.75.102 -Node_0_IPv6=s2607:5600:284::2 -Node_0_PubKey=s951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F -Node_0_Port=w33445 -Node_1_IPv4=s144.76.60.215 -Node_1_IPv6=s2a01:4f8:191:64d6::1 -Node_1_PubKey=s04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F -Node_1_Port=w33445 -Node_2_IPv4=s23.226.230.47 -Node_2_IPv6=s2604:180:1::3ded:b280 -Node_2_PubKey=sA09162D68618E742FFBCA1C2C70385E6679604B2D80EA6E84AD0996A1AC8A074 -Node_2_Port=w33445 -Node_3_IPv4=s178.62.125.224 -Node_3_IPv6=s2a03:b0c0:1:d0::178:6001 -Node_3_PubKey=s10B20C49ACBD968D7C80F2E8438F92EA51F189F4E70CFBBB2C2C8C799E97F03E -Node_3_Port=w33445 -Node_4_IPv4=s178.21.112.187 -Node_4_IPv6=s2a02:2308::216:3eff:fe82:eaef -Node_4_PubKey=s4B2C19E924972CB9B57732FB172F8A8604DE13EEDA2A6234E348983344B23057 -Node_4_Port=w33445 -Node_5_IPv4=s195.154.119.113 -Node_5_IPv6=s2001:bc8:3698:101::1 -Node_5_PubKey=sE398A69646B8CEACA9F0B84F553726C1C49270558C57DF5F3C368F05A7D71354 -Node_5_Port=w33445 -Node_6_IPv4=s192.210.149.121 -Node_6_PubKey=sF404ABAA1C99A9D37D61AB54898F56793E1DEF8BD46B1038B9D822E8460FAB67 -Node_6_Port=w33445 -Node_7_IPv4=s104.219.184.206 -Node_7_PubKey=s8CD087E31C67568103E8C2A28653337E90E6B8EDA0D765D57C6B5172B4F1F04C -Node_7_Port=w443 -Node_8_IPv4=s76.191.23.96 -Node_8_PubKey=s93574A3FAB7D612FEA29FD8D67D3DD10DFD07A075A5D62E8AF3DD9F5D0932E11 -Node_8_Port=w33445 -Node_9_IPv4=s46.38.239.179 -Node_9_PubKey=sF5A1A38EFB6BD3C2C8AF8B10D85F0F89E931704D349F1D0720C3C4059AF2440A -Node_9_Port=w33445 -Node_10_IPv4=s178.62.250.138 -Node_10_IPv6=s2a03:b0c0:2:d0::16:1 -Node_10_PubKey=s788236D34978D1D5BD822F0A5BEBD2C53C64CC31CD3149350EE27D4D9A2F9B6B -Node_10_Port=w33445 -Node_11_IPv4=s78.225.128.39 -Node_11_PubKey=s7A2306BFBA665E5480AE59B31E116BE9C04DCEFE04D9FE25082316FA34B4DA0C -Node_11_Port=w33445 -Node_12_IPv4=s130.133.110.14 -Node_12_IPv6=s2001:6f8:1c3c:babe::14:1 -Node_12_PubKey=s461FA3776EF0FA655F1A05477DF1B3B614F7D6B124F7DB1DD4FE3C08B03B640F -Node_12_Port=w33445 -Node_13_IPv4=s104.167.101.29 -Node_13_PubKey=s5918AC3C06955962A75AD7DF4F80A5D7C34F7DB9E1498D2E0495DE35B3FE8A57 -Node_13_Port=w33445 -Node_14_IPv4=s195.154.109.148 -Node_14_PubKey=s391C96CB67AE893D4782B8E4495EB9D89CF1031F48460C06075AA8CE76D50A21 -Node_14_Port=w33445 -Node_15_IPv4=s192.3.173.88 -Node_15_PubKey=s3E1FFDEB667BFF549F619EC6737834762124F50A89C8D0DBF1DDF64A2DD6CD1B -Node_15_Port=w33445 -Node_16_IPv4=s205.185.116.116 -Node_16_PubKey=sA179B09749AC826FF01F37A9613F6B57118AE014D4196A0E1105A98F93A54702 -Node_16_Port=w33445 -Node_17_IPv4=s198.98.51.198 -Node_17_IPv6=s2605:6400:1:fed5:22:45af:ec10:f329 -Node_17_PubKey=s1D5A5F2F5D6233058BF0259B09622FB40B482E4FA0931EB8FD3AB8E7BF7DAF6F -Node_17_Port=w33445 -Node_18_IPv4=s80.232.246.79 -Node_18_PubKey=s0B8DCEAA7BDDC44BB11173F987CAE3566A2D7057D8DD3CC642BD472B9391002A -Node_18_Port=w33445 -Node_19_IPv4=s108.61.165.198 -Node_19_PubKey=s8E7D0B859922EF569298B4D261A8CCB5FEA14FB91ED412A7603A585A25698832 -Node_19_Port=w33445 diff --git a/protocols/Tox/docs/tox.ini b/protocols/Tox/docs/tox.ini new file mode 100644 index 0000000000..43ff1b23ff --- /dev/null +++ b/protocols/Tox/docs/tox.ini @@ -0,0 +1,108 @@ +[Node_0] +IPv4=192.254.75.102 +IPv6=2607:5600:284::2 +PubKey=951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F +Port=33445 + +[Node_1] +IPv4=144.76.60.215 +IPv6=2a01:4f8:191:64d6::1 +PubKey=04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F +Port=33445 + +[Node_2] +IPv4=23.226.230.47 +IPv6=2604:180:1::3ded:b280 +PubKey=A09162D68618E742FFBCA1C2C70385E6679604B2D80EA6E84AD0996A1AC8A074 +Port=33445 + +[Node_3] +IPv4=178.62.125.224 +IPv6=2a03:b0c0:1:d0::178:6001 +PubKey=10B20C49ACBD968D7C80F2E8438F92EA51F189F4E70CFBBB2C2C8C799E97F03E +Port=33445 + +[Node_4] +IPv4=178.21.112.187 +IPv6=2a02:2308::216:3eff:fe82:eaef +PubKey=4B2C19E924972CB9B57732FB172F8A8604DE13EEDA2A6234E348983344B23057 +Port=33445 + +[Node_5] +IPv4=195.154.119.113 +IPv6=2001:bc8:3698:101::1 +PubKey=E398A69646B8CEACA9F0B84F553726C1C49270558C57DF5F3C368F05A7D71354 +Port=33445 + +[Node_6] +IPv4=192.210.149.121 +PubKey=F404ABAA1C99A9D37D61AB54898F56793E1DEF8BD46B1038B9D822E8460FAB67 +Port=33445 + +[Node_7] +IPv4=104.219.184.206 +PubKey=8CD087E31C67568103E8C2A28653337E90E6B8EDA0D765D57C6B5172B4F1F04C +Port=443 + +[Node_8] +IPv4=76.191.23.96 +PubKey=93574A3FAB7D612FEA29FD8D67D3DD10DFD07A075A5D62E8AF3DD9F5D0932E11 +Port=33445 + +[Node_9] +IPv4=46.38.239.179 +PubKey=F5A1A38EFB6BD3C2C8AF8B10D85F0F89E931704D349F1D0720C3C4059AF2440A +Port=33445 + +[Node_10] +IPv4=178.62.250.138 +IPv6=2a03:b0c0:2:d0::16:1 +PubKey=788236D34978D1D5BD822F0A5BEBD2C53C64CC31CD3149350EE27D4D9A2F9B6B +Port=33445 + +[Node_11] +IPv4=78.225.128.39 +PubKey=7A2306BFBA665E5480AE59B31E116BE9C04DCEFE04D9FE25082316FA34B4DA0C +Port=33445 + +[Node_12] +IPv4=130.133.110.14 +IPv6=2001:6f8:1c3c:babe::14:1 +PubKey=461FA3776EF0FA655F1A05477DF1B3B614F7D6B124F7DB1DD4FE3C08B03B640F +Port=33445 + +[Node_13] +IPv4=104.167.101.29 +PubKey=5918AC3C06955962A75AD7DF4F80A5D7C34F7DB9E1498D2E0495DE35B3FE8A57 +Port=33445 + +[Node_14] +IPv4=195.154.109.148 +PubKey=391C96CB67AE893D4782B8E4495EB9D89CF1031F48460C06075AA8CE76D50A21 +Port=33445 + +[Node_15] +IPv4=192.3.173.88 +PubKey=3E1FFDEB667BFF549F619EC6737834762124F50A89C8D0DBF1DDF64A2DD6CD1B +Port=33445 + +[Node_16] +IPv4=205.185.116.116 +PubKey=A179B09749AC826FF01F37A9613F6B57118AE014D4196A0E1105A98F93A54702 +Port=33445 + +[Node_17] +IPv4=198.98.51.198 +IPv6=2605:6400:1:fed5:22:45af:ec10:f329 +PubKey=1D5A5F2F5D6233058BF0259B09622FB40B482E4FA0931EB8FD3AB8E7BF7DAF6F +Port=33445 + +[Node_18] +IPv4=80.232.246.79 +PubKey=0B8DCEAA7BDDC44BB11173F987CAE3566A2D7057D8DD3CC642BD472B9391002A +Port=33445 + +[Node_19] +IPv4=108.61.165.198 +PubKey=8E7D0B859922EF569298B4D261A8CCB5FEA14FB91ED412A7603A585A25698832 +Port=33445 diff --git a/protocols/Tox/docs/tox_nodes.ini b/protocols/Tox/docs/tox_nodes.ini new file mode 100644 index 0000000000..aaa452bb44 --- /dev/null +++ b/protocols/Tox/docs/tox_nodes.ini @@ -0,0 +1,73 @@ +SETTINGS: + +[TOX] +NodeCount=b20 +Node_0_IPv4=s192.254.75.102 +Node_0_IPv6=s2607:5600:284::2 +Node_0_PubKey=s951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F +Node_0_Port=w33445 +Node_1_IPv4=s144.76.60.215 +Node_1_IPv6=s2a01:4f8:191:64d6::1 +Node_1_PubKey=s04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F +Node_1_Port=w33445 +Node_2_IPv4=s23.226.230.47 +Node_2_IPv6=s2604:180:1::3ded:b280 +Node_2_PubKey=sA09162D68618E742FFBCA1C2C70385E6679604B2D80EA6E84AD0996A1AC8A074 +Node_2_Port=w33445 +Node_3_IPv4=s178.62.125.224 +Node_3_IPv6=s2a03:b0c0:1:d0::178:6001 +Node_3_PubKey=s10B20C49ACBD968D7C80F2E8438F92EA51F189F4E70CFBBB2C2C8C799E97F03E +Node_3_Port=w33445 +Node_4_IPv4=s178.21.112.187 +Node_4_IPv6=s2a02:2308::216:3eff:fe82:eaef +Node_4_PubKey=s4B2C19E924972CB9B57732FB172F8A8604DE13EEDA2A6234E348983344B23057 +Node_4_Port=w33445 +Node_5_IPv4=s195.154.119.113 +Node_5_IPv6=s2001:bc8:3698:101::1 +Node_5_PubKey=sE398A69646B8CEACA9F0B84F553726C1C49270558C57DF5F3C368F05A7D71354 +Node_5_Port=w33445 +Node_6_IPv4=s192.210.149.121 +Node_6_PubKey=sF404ABAA1C99A9D37D61AB54898F56793E1DEF8BD46B1038B9D822E8460FAB67 +Node_6_Port=w33445 +Node_7_IPv4=s104.219.184.206 +Node_7_PubKey=s8CD087E31C67568103E8C2A28653337E90E6B8EDA0D765D57C6B5172B4F1F04C +Node_7_Port=w443 +Node_8_IPv4=s76.191.23.96 +Node_8_PubKey=s93574A3FAB7D612FEA29FD8D67D3DD10DFD07A075A5D62E8AF3DD9F5D0932E11 +Node_8_Port=w33445 +Node_9_IPv4=s46.38.239.179 +Node_9_PubKey=sF5A1A38EFB6BD3C2C8AF8B10D85F0F89E931704D349F1D0720C3C4059AF2440A +Node_9_Port=w33445 +Node_10_IPv4=s178.62.250.138 +Node_10_IPv6=s2a03:b0c0:2:d0::16:1 +Node_10_PubKey=s788236D34978D1D5BD822F0A5BEBD2C53C64CC31CD3149350EE27D4D9A2F9B6B +Node_10_Port=w33445 +Node_11_IPv4=s78.225.128.39 +Node_11_PubKey=s7A2306BFBA665E5480AE59B31E116BE9C04DCEFE04D9FE25082316FA34B4DA0C +Node_11_Port=w33445 +Node_12_IPv4=s130.133.110.14 +Node_12_IPv6=s2001:6f8:1c3c:babe::14:1 +Node_12_PubKey=s461FA3776EF0FA655F1A05477DF1B3B614F7D6B124F7DB1DD4FE3C08B03B640F +Node_12_Port=w33445 +Node_13_IPv4=s104.167.101.29 +Node_13_PubKey=s5918AC3C06955962A75AD7DF4F80A5D7C34F7DB9E1498D2E0495DE35B3FE8A57 +Node_13_Port=w33445 +Node_14_IPv4=s195.154.109.148 +Node_14_PubKey=s391C96CB67AE893D4782B8E4495EB9D89CF1031F48460C06075AA8CE76D50A21 +Node_14_Port=w33445 +Node_15_IPv4=s192.3.173.88 +Node_15_PubKey=s3E1FFDEB667BFF549F619EC6737834762124F50A89C8D0DBF1DDF64A2DD6CD1B +Node_15_Port=w33445 +Node_16_IPv4=s205.185.116.116 +Node_16_PubKey=sA179B09749AC826FF01F37A9613F6B57118AE014D4196A0E1105A98F93A54702 +Node_16_Port=w33445 +Node_17_IPv4=s198.98.51.198 +Node_17_IPv6=s2605:6400:1:fed5:22:45af:ec10:f329 +Node_17_PubKey=s1D5A5F2F5D6233058BF0259B09622FB40B482E4FA0931EB8FD3AB8E7BF7DAF6F +Node_17_Port=w33445 +Node_18_IPv4=s80.232.246.79 +Node_18_PubKey=s0B8DCEAA7BDDC44BB11173F987CAE3566A2D7057D8DD3CC642BD472B9391002A +Node_18_Port=w33445 +Node_19_IPv4=s108.61.165.198 +Node_19_PubKey=s8E7D0B859922EF569298B4D261A8CCB5FEA14FB91ED412A7603A585A25698832 +Node_19_Port=w33445 diff --git a/protocols/Tox/src/common.h b/protocols/Tox/src/common.h index 13aadf38aa..1d75169087 100644 --- a/protocols/Tox/src/common.h +++ b/protocols/Tox/src/common.h @@ -46,18 +46,22 @@ extern HINSTANCE g_hInstance; #define TOX_ERROR -1 +#define TOX_MAX_CONNECT_RETRIES 200 #define TOX_MAX_DISCONNECT_RETRIES 100 +#define TOX_INI_PATH "%miranda_path%\\Plugins\\tox.ini" + #define TOX_SETTINGS_ID "ToxID" #define TOX_SETTINGS_DNS "DnsID" #define TOX_SETTINGS_GROUP "DefaultGroup" #define TOX_SETTINGS_AVATAR_HASH "AvatarHash" -#define TOX_SETTINGS_NODE_IPV4 "Node_%d_IPv4" -#define TOX_SETTINGS_NODE_IPV6 "Node_%d_IPv6" -#define TOX_SETTINGS_NODE_PORT "Node_%d_Port" -#define TOX_SETTINGS_NODE_PKEY "Node_%d_PubKey" -#define TOX_SETTINGS_NODE_COUNT "NodeCount" +#define TOX_SETTINGS_NODE_PREFIX "Node_" +#define TOX_SETTINGS_NODE_IPV4 TOX_SETTINGS_NODE_PREFIX"%d_IPv4" +#define TOX_SETTINGS_NODE_IPV6 TOX_SETTINGS_NODE_PREFIX"%d_IPv6" +#define TOX_SETTINGS_NODE_PORT TOX_SETTINGS_NODE_PREFIX"%d_Port" +#define TOX_SETTINGS_NODE_PKEY TOX_SETTINGS_NODE_PREFIX"%d_PubKey" +#define TOX_SETTINGS_NODE_COUNT TOX_SETTINGS_NODE_PREFIX"Count" #define TOX_DB_EVENT_TYPE_ACTION 10001 diff --git a/protocols/Tox/src/tox_network.cpp b/protocols/Tox/src/tox_network.cpp index 588a41a8fc..dcc7f39153 100644 --- a/protocols/Tox/src/tox_network.cpp +++ b/protocols/Tox/src/tox_network.cpp @@ -5,23 +5,11 @@ bool CToxProto::IsOnline() return isConnected && m_iStatus > ID_STATUS_OFFLINE; } -void CToxProto::BootstrapNodes() +int CToxProto::BootstrapNodesFromDb(bool isIPv6) { - debugLogA("CToxProto::BootstrapDht: bootstraping DHT"); - - bool isIPv6 = !getBool("DisableIPv6", 0); + int nodesLoaded = 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 (isIPv6) - tox_bootstrap_from_address( - tox, "2607:5600:284::2", 33445, - ToxBinAddress("951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F")); - } - else + if (nodeCount > 0) { char setting[MAX_PATH]; for (int i = 0; i < nodeCount; i++) @@ -32,15 +20,71 @@ void CToxProto::BootstrapNodes() 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)); - tox_bootstrap_from_address(tox, address, port, ToxBinAddress(pubKey)); + nodesLoaded += 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)); + nodesLoaded += tox_bootstrap_from_address(tox, address, port, ToxBinAddress(pubKey)); } } } + return nodesLoaded; +} + +int CToxProto::BootstrapNodesFromIni(bool isIPv6) +{ + int nodesLoaded = 0; + if (IsFileExists((TCHAR*)VARST(_T(TOX_INI_PATH)))) + { + char fileName[MAX_PATH]; + mir_strcpy(fileName, VARS(TOX_INI_PATH)); + + char *section, sections[MAX_PATH], value[MAX_PATH]; + GetPrivateProfileSectionNamesA(sections, SIZEOF(sections), fileName); + section = sections; + while (*section != NULL) + { + if (strstr(section, TOX_SETTINGS_NODE_PREFIX) == section) + { + GetPrivateProfileStringA(section, "IPv4", NULL, value, SIZEOF(value), fileName); + ptrA address(mir_strdup(value)); + 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); + if (isIPv6) + { + GetPrivateProfileStringA(section, "IPv6", NULL, value, SIZEOF(value), fileName); + address = mir_strdup(value); + nodesLoaded += tox_bootstrap_from_address(tox, address, port, pubKey); + } + } + section += strlen(section) + 1; + } + } + return nodesLoaded; +} + +void CToxProto::BootstrapNodes() +{ + debugLogA("CToxProto::BootstrapDht: bootstraping DHT"); + bool isIPv6 = !getBool("DisableIPv6", 0); + int nodesLoaded = + BootstrapNodesFromDb(isIPv6) + + BootstrapNodesFromIni(isIPv6); + if (!nodesLoaded) + { + tox_bootstrap_from_address( + tox, "192.254.75.102", 33445, + ToxBinAddress("951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F")); + if (isIPv6) + { + tox_bootstrap_from_address( + tox, "2607:5600:284::2", 33445, + ToxBinAddress("951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F")); + } + } } void CToxProto::TryConnect() @@ -57,14 +101,11 @@ void CToxProto::TryConnect() tox_set_user_status(tox, MirandaToToxStatus(m_iStatus)); debugLogA("CToxProto::PollingThread: changing status from %i to %i", ID_STATUS_CONNECTING, m_iDesiredStatus); } - else + else if (m_iStatus++ > TOX_MAX_CONNECT_RETRIES) { - if (m_iStatus++ > MAX_CONNECT_RETRIES) - { - SetStatus(ID_STATUS_OFFLINE); - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, (HANDLE)NULL, LOGINERR_NONETWORK); - debugLogA("CToxProto::PollingThread: failed to connect to DHT"); - } + SetStatus(ID_STATUS_OFFLINE); + ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, (HANDLE)NULL, LOGINERR_NONETWORK); + debugLogA("CToxProto::PollingThread: failed to connect to DHT"); } } @@ -72,32 +113,29 @@ void CToxProto::CheckConnection(int &retriesCount) { if (!isConnected) { - debugLogA("CToxProto::CheckConnection: lost connection with DHT"); TryConnect(); } + else if (tox_isconnected(tox)) + { + if (retriesCount < TOX_MAX_DISCONNECT_RETRIES) + { + debugLogA("CToxProto::CheckConnection: restored connection with DHT"); + retriesCount = TOX_MAX_DISCONNECT_RETRIES; + } + } else { - if (tox_isconnected(tox)) + if (retriesCount == TOX_MAX_DISCONNECT_RETRIES - 10) { - if (retriesCount < TOX_MAX_DISCONNECT_RETRIES) - { - debugLogA("CToxProto::CheckConnection: restored connection with DHT"); - retriesCount = TOX_MAX_DISCONNECT_RETRIES; - } + debugLogA("CToxProto::CheckConnection: lost connection with DHT"); + retriesCount--; + BootstrapNodes(); } - else + else if (!(--retriesCount)) { - if (retriesCount == TOX_MAX_DISCONNECT_RETRIES) - { - retriesCount --; - BootstrapNodes(); - } - else if (!(--retriesCount)) - { - isConnected = false; - debugLogA("CToxProto::CheckConnection: disconnected from DHT"); - SetStatus(ID_STATUS_OFFLINE); - } + isConnected = false; + debugLogA("CToxProto::CheckConnection: disconnected from DHT"); + SetStatus(ID_STATUS_OFFLINE); } } } diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 2dfec2ba12..047969eca2 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -91,6 +91,8 @@ private: // tox network bool IsOnline(); + int BootstrapNodesFromDb(bool isIPv6); + int BootstrapNodesFromIni(bool isIPv6); void BootstrapNodes(); void TryConnect(); void CheckConnection(int &retriesCount); -- cgit v1.2.3