Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
developers:client_examples:echo_bot [2020/03/22 20:56] – [Table] Update DHT bootstrap nodes as the current ones are offline nurupo | developers:client_examples:echo_bot [2020/03/23 22:08] (current) – Minor code fixes nurupo | ||
---|---|---|---|
Line 106: | Line 106: | ||
uint16_t port; | uint16_t port; | ||
const char key_hex[TOX_PUBLIC_KEY_SIZE*2 + 1]; // 1 for null terminator | const char key_hex[TOX_PUBLIC_KEY_SIZE*2 + 1]; // 1 for null terminator | ||
- | unsigned char key_bin[TOX_PUBLIC_KEY_SIZE]; | ||
} DHT_node; | } DHT_node; | ||
Line 113: | Line 112: | ||
DHT_node nodes[] = | DHT_node nodes[] = | ||
{ | { | ||
- | {"178.62.250.138", | + | {"85.143.221.42", |
- | {"2a03:b0c0:2:d0::16:1", | + | {"2a04:ac00:1:9f00:5054:ff:fe01:becd", 33445, "DA4E4ED4B697F2E9B000EEFE3A34B554ACD3F45F5C96EAEA2516DD7FF9AF7B43"}, |
- | {"tox.zodiaclabs.org", | + | {"78.46.73.141", |
- | {"163.172.136.118", | + | {"2a01: |
- | {"2001: | + | {"tox.initramfs.io", |
- | {"128.199.199.197", | + | {"tox2.abilinski.com", |
- | {"2400: | + | {"205.185.115.131", |
- | {"node.tox.biribiri.org", | + | {"tox.kurnevsky.net", |
}; | }; | ||
for (size_t i = 0; i < sizeof(nodes)/ | for (size_t i = 0; i < sizeof(nodes)/ | ||
- | sodium_hex2bin(nodes[i].key_bin, sizeof(nodes[i].key_bin), | + | |
- | nodes[i].key_hex, | + | |
- | tox_bootstrap(tox, | + | NULL, NULL, NULL); |
+ | tox_bootstrap(tox, | ||
} | } | ||
</ | </ | ||
Line 319: | Line 319: | ||
uint16_t port; | uint16_t port; | ||
const char key_hex[TOX_PUBLIC_KEY_SIZE*2 + 1]; | const char key_hex[TOX_PUBLIC_KEY_SIZE*2 + 1]; | ||
- | unsigned char key_bin[TOX_PUBLIC_KEY_SIZE]; | ||
} DHT_node; | } DHT_node; | ||
void friend_request_cb(Tox *tox, const uint8_t *public_key, | void friend_request_cb(Tox *tox, const uint8_t *public_key, | ||
- | void *user_data) | + | void *user_data) |
{ | { | ||
tox_friend_add_norequest(tox, | tox_friend_add_norequest(tox, | ||
Line 329: | Line 328: | ||
void friend_message_cb(Tox *tox, uint32_t friend_number, | void friend_message_cb(Tox *tox, uint32_t friend_number, | ||
- | size_t length, void *user_data) | + | size_t length, void *user_data) |
{ | { | ||
tox_friend_send_message(tox, | tox_friend_send_message(tox, | ||
Line 361: | Line 360: | ||
DHT_node nodes[] = | DHT_node nodes[] = | ||
{ | { | ||
- | {"178.62.250.138", | + | {"85.143.221.42", |
- | {"2a03:b0c0:2:d0::16:1", | + | {"2a04:ac00:1:9f00:5054:ff:fe01:becd", 33445, "DA4E4ED4B697F2E9B000EEFE3A34B554ACD3F45F5C96EAEA2516DD7FF9AF7B43"}, |
- | {"tox.zodiaclabs.org", | + | {"78.46.73.141", |
- | {"163.172.136.118", | + | {"2a01: |
- | {"2001: | + | {"tox.initramfs.io", |
- | {"128.199.199.197", | + | {"tox2.abilinski.com", |
- | {"2400: | + | {"205.185.115.131", |
- | {"node.tox.biribiri.org", | + | {"tox.kurnevsky.net", |
}; | }; | ||
for (size_t i = 0; i < sizeof(nodes)/ | for (size_t i = 0; i < sizeof(nodes)/ | ||
- | sodium_hex2bin(nodes[i].key_bin, sizeof(nodes[i].key_bin), | + | |
- | nodes[i].key_hex, | + | |
- | tox_bootstrap(tox, | + | NULL, NULL, NULL); |
+ | tox_bootstrap(tox, | ||
} | } | ||
Line 393: | Line 393: | ||
tox_callback_self_connection_status(tox, | tox_callback_self_connection_status(tox, | ||
+ | |||
+ | printf(" | ||
while (1) { | while (1) { | ||
Line 417: | Line 419: | ||
$ ./echo_bot | $ ./echo_bot | ||
Tox ID: 4F8E7814B40B22F7DBB8B18B8518EBB369F45DE6B40309F43F39AFECF340FD7624FC706CE668 | Tox ID: 4F8E7814B40B22F7DBB8B18B8518EBB369F45DE6B40309F43F39AFECF340FD7624FC706CE668 | ||
+ | Connecting... | ||
Online, using UDP | Online, using UDP | ||
</ | </ | ||
Line 472: | Line 475: | ||
uint16_t port; | uint16_t port; | ||
const char key_hex[TOX_PUBLIC_KEY_SIZE*2 + 1]; | const char key_hex[TOX_PUBLIC_KEY_SIZE*2 + 1]; | ||
- | unsigned char key_bin[TOX_PUBLIC_KEY_SIZE]; | ||
} DHT_node; | } DHT_node; | ||
Line 492: | Line 494: | ||
fseek(f, 0, SEEK_SET); | fseek(f, 0, SEEK_SET); | ||
- | | + | |
fread(savedata, | fread(savedata, | ||
Line 514: | Line 516: | ||
{ | { | ||
size_t size = tox_get_savedata_size(tox); | size_t size = tox_get_savedata_size(tox); | ||
- | | + | |
tox_get_savedata(tox, | tox_get_savedata(tox, | ||
Line 530: | Line 532: | ||
DHT_node nodes[] = | DHT_node nodes[] = | ||
{ | { | ||
- | {"178.62.250.138", | + | {"85.143.221.42", |
- | {"2a03:b0c0:2:d0::16:1", | + | {"2a04:ac00:1:9f00:5054:ff:fe01:becd", 33445, "DA4E4ED4B697F2E9B000EEFE3A34B554ACD3F45F5C96EAEA2516DD7FF9AF7B43"}, |
- | {"tox.zodiaclabs.org", | + | {"78.46.73.141", |
- | {"163.172.136.118", | + | {"2a01: |
- | {"2001: | + | {"tox.initramfs.io", |
- | {"128.199.199.197", | + | {"tox2.abilinski.com", |
- | {"2400: | + | {"205.185.115.131", |
- | {"node.tox.biribiri.org", | + | {"tox.kurnevsky.net", |
}; | }; | ||
for (size_t i = 0; i < sizeof(nodes)/ | for (size_t i = 0; i < sizeof(nodes)/ | ||
- | sodium_hex2bin(nodes[i].key_bin, sizeof(nodes[i].key_bin), | + | |
- | nodes[i].key_hex, | + | |
- | tox_bootstrap(tox, | + | NULL, NULL, NULL); |
+ | tox_bootstrap(tox, | ||
} | } | ||
} | } | ||
Line 563: | Line 566: | ||
void friend_request_cb(Tox *tox, const uint8_t *public_key, | void friend_request_cb(Tox *tox, const uint8_t *public_key, | ||
- | void *user_data) | + | void *user_data) |
{ | { | ||
tox_friend_add_norequest(tox, | tox_friend_add_norequest(tox, | ||
Line 571: | Line 574: | ||
void friend_message_cb(Tox *tox, uint32_t friend_number, | void friend_message_cb(Tox *tox, uint32_t friend_number, | ||
- | size_t length, void *user_data) | + | size_t length, void *user_data) |
{ | { | ||
tox_friend_send_message(tox, | tox_friend_send_message(tox, | ||
Line 611: | Line 614: | ||
update_savedata_file(tox); | update_savedata_file(tox); | ||
+ | |||
+ | printf(" | ||
while (1) { | while (1) { |