Separated bootstrap process to a function.

This commit is contained in:
Håvard Pettersson 2014-09-02 23:36:24 +02:00
parent c4622ab509
commit 2192806a41
2 changed files with 15 additions and 4 deletions

View file

@ -210,6 +210,14 @@ tox_weechat_status_message_callback(Tox *tox,
tox_weechat_chat_refresh_timer_callback, chat); tox_weechat_chat_refresh_timer_callback, chat);
} }
void
tox_weechat_bootstrap(char *address, uint16_t port, char *public_key)
{
uint8_t *binary_key = tox_weechat_hex2bin(public_key);
tox_bootstrap_from_address(tox, address, htons(port), binary_key);
free(binary_key);
}
void void
tox_weechat_tox_init() tox_weechat_tox_init()
{ {
@ -224,10 +232,8 @@ tox_weechat_tox_init()
} }
free(data_file_path); free(data_file_path);
// bootstrap // bootstrap DHT
uint8_t *pub_key = tox_weechat_hex2bin(BOOTSTRAP_KEY); tox_weechat_bootstrap(BOOTSTRAP_ADDRESS, BOOTSTRAP_PORT, BOOTSTRAP_KEY);
tox_bootstrap_from_address(tox, BOOTSTRAP_ADDRESS, htons(BOOTSTRAP_PORT), pub_key);
free(pub_key);
// start tox_do loop // start tox_do loop
tox_weechat_do_timer_cb(NULL, 0); tox_weechat_do_timer_cb(NULL, 0);

View file

@ -8,6 +8,11 @@
*/ */
void tox_weechat_tox_init(); void tox_weechat_tox_init();
/**
* Bootstrap DHT using an inet address, port and a Tox address.
*/
void tox_weechat_bootstrap(char *address, uint16_t port, char *public_key);
/** /**
* Dump Tox to file and de-initialize. * Dump Tox to file and de-initialize.
*/ */