summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2014-08-09 17:57:16 +0000
committerKirill Volinsky <mataes2007@gmail.com>2014-08-09 17:57:16 +0000
commitab807bf3e87863ef97412faf83dc2cac697d6a23 (patch)
tree74cb1861e535603e8fb5ef81da68714c653c3141
parent681ba8556e859f38a0d7c910e9d40a9a917b3280 (diff)
use more nodes
git-svn-id: http://svn.miranda-ng.org/main/trunk@10138 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/Tox/src/common.h11
-rw-r--r--protocols/Tox/src/tox_proto.cpp15
-rw-r--r--protocols/Tox/src/tox_proto.h1
-rw-r--r--protocols/Tox/src/tox_utils.cpp86
4 files changed, 94 insertions, 19 deletions
diff --git a/protocols/Tox/src/common.h b/protocols/Tox/src/common.h
index 00d98984d8..479bf8fbef 100644
--- a/protocols/Tox/src/common.h
+++ b/protocols/Tox/src/common.h
@@ -14,17 +14,12 @@
#include <m_database.h>
#include <m_langpack.h>
+#include "tox\tox.h"
+
#include "version.h"
#include "resource.h"
-
-#include "tox\tox.h"
+#include "tox_proto.h"
extern HINSTANCE g_hInstance;
-#define BOOTSTRAP_ADDRESS "23.226.230.47"
-#define BOOTSTRAP_PORT 33445
-#define BOOTSTRAP_KEY "A09162D68618E742FFBCA1C2C70385E6679604B2D80EA6E84AD0996A1AC8A074"
-
-#include "tox_proto.h"
-
#endif //_COMMON_H_ \ No newline at end of file
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp
index e2cc4f0407..b5bd446cb5 100644
--- a/protocols/Tox/src/tox_proto.cpp
+++ b/protocols/Tox/src/tox_proto.cpp
@@ -157,34 +157,27 @@ int __cdecl CToxProto::SetStatus(int iNewStatus)
char *name = "my_nickname";
int res = tox_set_name(tox, (uint8_t*)name, strlen(name));
- char *pub_key = HexToBinString(BOOTSTRAP_KEY);
- res = tox_bootstrap_from_address(tox, BOOTSTRAP_ADDRESS, 1, htons(BOOTSTRAP_PORT), (uint8_t *)pub_key);
- //mir_free(pub_key);
- if (!res)
- {
- SetStatus(ID_STATUS_OFFLINE);
- }
+ do_bootstrap(tox);
time_t timestamp0 = time(NULL);
int on = 0;
while (1) {
+ tox_do(tox);
+
if (on == 0) {
if (tox_isconnected(tox)) {
- //new_lines("[i] connected to DHT");
on = 1;
- mir_free(pub_key);
}
else {
time_t timestamp1 = time(NULL);
if (timestamp0 + 10 < timestamp1) {
timestamp0 = timestamp1;
- tox_bootstrap_from_address(tox, BOOTSTRAP_ADDRESS, 1, htons(BOOTSTRAP_PORT), (uint8_t *)pub_key);
+ do_bootstrap(tox);
}
}
}
- tox_do(tox);
}
res = tox_isconnected(tox);
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h
index 92cdf667e2..bd40afd4e4 100644
--- a/protocols/Tox/src/tox_proto.h
+++ b/protocols/Tox/src/tox_proto.h
@@ -104,6 +104,7 @@ private:
// utils
char *HexToBinString(const char *hex_string);
char *BinToHexString(uint8_t *bin_string);
+ void do_bootstrap(Tox *tox);
// dialogs
static INT_PTR CALLBACK AccountManagerProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp
index 38cb154ce5..97379c72c3 100644
--- a/protocols/Tox/src/tox_utils.cpp
+++ b/protocols/Tox/src/tox_utils.cpp
@@ -40,4 +40,90 @@ char *CToxProto::BinToHexString(uint8_t *bin_string)
ret[pos_extra] = 0;
return ret;
+}
+
+#define _HTONS(x) (uint16_t)((x << 8) | (x >> 8))
+
+struct bootstrap_node {
+ char *address;
+ uint16_t port;
+ uint8_t key[32];
+} bootstrap_nodes[] = {
+ {
+ "192.254.75.98",
+ _HTONS(33445),
+ {
+ 0x95, 0x1C, 0x88, 0xB7, 0xE7, 0x5C, 0x86, 0x74, 0x18, 0xAC, 0xDB, 0x5D, 0x27, 0x38, 0x21, 0x37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.46.133",
+ _HTONS(33445),
+ {
+ 0x7F, 0x31, 0xBF, 0xC9, 0x3B, 0x8E, 0x40, 0x16, 0xA9, 0x02, 0x14, 0x4D, 0x0B, 0x11, 0x0C, 0x3E,
+ 0xA9, 0x7C, 0xB7, 0xD4, 0x3F, 0x1C, 0x4D, 0x21, 0xBC, 0xAE, 0x99, 0x8A, 0x7C, 0x83, 0x88, 0x21
+ }
+ },
+
+ {
+ "192.210.149.121",
+ _HTONS(33445),
+ {
+ 0xF4, 0x04, 0xAB, 0xAA, 0x1C, 0x99, 0xA9, 0xD3, 0x7D, 0x61, 0xAB, 0x54, 0x89, 0x8F, 0x56, 0x79,
+ 0x3E, 0x1D, 0xEF, 0x8B, 0xD4, 0x6B, 0x10, 0x38, 0xB9, 0xD8, 0x22, 0xE8, 0x46, 0x0F, 0xAB, 0x67
+ }
+ },
+};
+
+#undef _HTONS
+
+/* bootstrap to dht with bootstrap_nodes */
+void CToxProto::do_bootstrap(Tox *tox)
+{
+ static int j = 0;
+ int i = 0;
+ while (i < 2) {
+ struct bootstrap_node *d = &bootstrap_nodes[j % SIZEOF(bootstrap_nodes)];
+ tox_bootstrap_from_address(tox, d->address, 1, d->port, d->key);
+ i++;
+ j++;
+ }
} \ No newline at end of file