From 2192806a4106037832142a7ebf5ea197507b0f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersson?= Date: Tue, 2 Sep 2014 23:36:24 +0200 Subject: [PATCH] Separated bootstrap process to a function. --- src/tox-weechat-tox.c | 14 ++++++++++---- src/tox-weechat-tox.h | 5 +++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/tox-weechat-tox.c b/src/tox-weechat-tox.c index 04bf6f3..4dd370c 100644 --- a/src/tox-weechat-tox.c +++ b/src/tox-weechat-tox.c @@ -210,6 +210,14 @@ tox_weechat_status_message_callback(Tox *tox, 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 tox_weechat_tox_init() { @@ -224,10 +232,8 @@ tox_weechat_tox_init() } free(data_file_path); - // bootstrap - uint8_t *pub_key = tox_weechat_hex2bin(BOOTSTRAP_KEY); - tox_bootstrap_from_address(tox, BOOTSTRAP_ADDRESS, htons(BOOTSTRAP_PORT), pub_key); - free(pub_key); + // bootstrap DHT + tox_weechat_bootstrap(BOOTSTRAP_ADDRESS, BOOTSTRAP_PORT, BOOTSTRAP_KEY); // start tox_do loop tox_weechat_do_timer_cb(NULL, 0); diff --git a/src/tox-weechat-tox.h b/src/tox-weechat-tox.h index bff95e4..45255ac 100644 --- a/src/tox-weechat-tox.h +++ b/src/tox-weechat-tox.h @@ -8,6 +8,11 @@ */ 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. */