tox-weechat/src/twc-bootstrap.c

140 lines
5.4 KiB
C
Raw Normal View History

2014-09-28 01:29:34 +00:00
/*
2018-04-12 21:42:34 +00:00
* Copyright (c) 2018 Håvard Pettersson <mail@haavard.me>
2014-09-28 01:29:34 +00:00
*
* This file is part of Tox-WeeChat.
*
* Tox-WeeChat is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tox-WeeChat is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tox-WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
#include <tox/tox.h>
#include "twc-utils.h"
#include "twc-bootstrap.h"
2017-02-19 06:24:11 +00:00
struct t_twc_bootstrap_node
{
char const *const key;
char const *const address;
uint16_t const port;
};
/* bootstrap nodes generated by misc/getnodes.py
2018-04-12 20:40:52 +00:00
* last generated 2018-04-12T22:40:44.123211 */
2017-02-19 06:24:11 +00:00
static struct t_twc_bootstrap_node const twc_bootstrap_nodes[] = {
/* Maintainer: Manolis, location: DE */
2017-02-19 06:24:11 +00:00
{"461FA3776EF0FA655F1A05477DF1B3B614F7D6B124F7DB1DD4FE3C08B03B640F",
"130.133.110.14", 33445},
/* Maintainer: Busindre, location: US */
2017-02-19 06:24:11 +00:00
{"A179B09749AC826FF01F37A9613F6B57118AE014D4196A0E1105A98F93A54702",
"205.185.116.116", 33445},
/* Maintainer: Busindre, location: US */
2017-02-19 06:24:11 +00:00
{"1D5A5F2F5D6233058BF0259B09622FB40B482E4FA0931EB8FD3AB8E7BF7DAF6F",
"198.98.51.198", 33445},
2018-04-12 20:40:52 +00:00
/* Maintainer: ray65536, location: RU */
2017-02-19 06:24:11 +00:00
{"8E7D0B859922EF569298B4D261A8CCB5FEA14FB91ED412A7603A585A25698832",
2018-04-12 20:40:52 +00:00
"85.172.30.117", 33445},
/* Maintainer: fluke571, location: SI */
2017-02-19 06:24:11 +00:00
{"3CEE1F054081E7A011234883BC4FC39F661A55B73637A5AC293DDF1251D9432B",
"194.249.212.109", 33445},
/* Maintainer: MAH69K, location: UA */
2017-02-19 06:24:11 +00:00
{"DA4E4ED4B697F2E9B000EEFE3A34B554ACD3F45F5C96EAEA2516DD7FF9AF7B43",
"185.25.116.107", 33445},
2018-04-12 20:40:52 +00:00
/* Maintainer: pucetox, location: FR */
2017-02-19 06:24:11 +00:00
{"7AED21F94D82B05774F697B209628CD5A9AD17E0C073D9329076A4C28ED28147",
2018-04-12 20:40:52 +00:00
"217.182.143.254", 2306},
/* Maintainer: ru_maniac, location: US */
2017-02-19 06:24:11 +00:00
{"0FB96EEBFB1650DDB52E70CF773DDFCABE25A95CC3BB50FC251082E4B63EF82A",
"104.223.122.15", 33445},
/* Maintainer: a68366, location: FR */
2017-02-19 06:24:11 +00:00
{"AEC204B9A4501412D5F0BB67D9C81B5DB3EE6ADA64122D32A3E9B093D544327D",
"51.254.84.212", 33445},
2018-04-12 20:40:52 +00:00
/* Maintainer: Skey, location: NL */
{"B71E91E2F5029B0A84D3B1136319CDD3D1DB6D3702B6CEFA66A4BEB25A635916",
"213.183.51.211", 33445},
/* Maintainer: t3mp, location: RU */
2017-02-19 06:24:11 +00:00
{"5625A62618CB4FCA70E147A71B29695F38CC65FF0CBD68AD46254585BE564802",
"92.54.84.70", 33445},
/* Maintainer: HooinKyoma, location: SE */
2017-02-19 06:24:11 +00:00
{"672DBE27B4ADB9D5FB105A6BB648B2F8FDB89B3323486A7A21968316E012023C",
"95.215.44.78", 33445},
/* Maintainer: LittleVulpix, location: FR */
2017-02-19 06:24:11 +00:00
{"2C289F9F37C20D09DA83565588BF496FAB3764853FA38141817A72E3F18ACA0B",
"163.172.136.118", 33445},
/* Maintainer: Yani, location: NL */
2017-02-19 06:24:11 +00:00
{"E59A0E71ADA20D35BD1B0957059D7EF7E7792B3D680AE25C6F4DBBA09114D165",
"37.97.185.116", 33445},
/* Maintainer: linxon, location: RU */
2017-02-19 06:24:11 +00:00
{"B38255EE4B054924F6D79A5E6E5889EC94B6ADF6FE9906F97A3D01E3D083223A",
"80.87.193.193", 33445},
/* Maintainer: Stranger, location: UA */
2017-02-19 06:24:11 +00:00
{"813C8F4187833EF0655B10F7752141A352248462A567529A38B6BBF73E979307",
"46.229.52.198", 33445},
2018-04-12 20:40:52 +00:00
/* Maintainer: velusip, location: CA */
{"7E5668E0EE09E19F320AD47902419331FFEE147BB3606769CFBE921A2A2FD34C",
"149.56.140.5", 33445},
/* Maintainer: dvor, location: NL */
2017-02-19 06:24:11 +00:00
{"2555763C8C460495B14157D234DD56B86300A2395554BCAE4621AC345B8C1B1B",
"185.14.30.213", 443},
2018-04-12 20:40:52 +00:00
/* Maintainer: CeBe, location: DE */
{"6EE1FADE9F55CC7938234CC07C864081FC606D8FE7B751EDA217F268F1078A39",
"136.243.141.187", 443},
/* Maintainer: Pokemon, location: NL */
{"1B5A8AB25FFFB66620A531C4646B47F0F32B74C547B30AF8BD8266CA50A3AB59",
"37.48.122.22", 33445},
/* Maintainer: warlomak, location: RU */
{"FFAC871E85B1E1487F87AE7C76726AE0E60318A85F6A1669E04C47EB8DC7C72D",
"79.140.30.52", 33445},
/* Maintainer: ru_maniac, location: US */
{"3925752E43BF2F8EB4E12B0E9414311064FF2D76707DC7D5D2CCB43F75081F6B",
"104.223.122.204", 33445},
/* Maintainer: GDR!, location: PL */
{"B9D109CC820C69A5D97A4A1A15708107C6BA85C13BC6188CC809D374AFF18E63",
"77.55.211.53", 53},
/* Maintainer: clearmartin, location: DE */
2017-02-19 06:24:11 +00:00
{"CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707",
"46.101.197.175", 443},
};
2014-09-28 01:29:34 +00:00
2017-02-19 06:24:11 +00:00
static int const twc_bootstrap_count =
sizeof(twc_bootstrap_nodes) / sizeof(twc_bootstrap_nodes[0]);
2014-09-28 01:29:34 +00:00
/**
* Bootstrap a Tox object with a DHT bootstrap node. Returns the result of
* tox_bootstrap_from_address.
*/
int
2014-11-19 06:12:41 +00:00
twc_bootstrap_tox(Tox *tox, const char *address, uint16_t port,
2014-09-28 01:29:34 +00:00
const char *public_key)
{
uint8_t binary_key[TOX_ADDRESS_SIZE];
twc_hex2bin(public_key, TOX_ADDRESS_SIZE, binary_key);
TOX_ERR_BOOTSTRAP err;
2014-09-28 01:29:34 +00:00
int result = tox_bootstrap(tox, address, port, binary_key, &err);
2014-09-28 01:29:34 +00:00
return result;
}
/**
* Bootstrap a Tox object with a random DHT bootstrap node.
*/
void
twc_bootstrap_random_node(Tox *tox)
{
int i = rand() % twc_bootstrap_count;
2017-02-19 06:24:11 +00:00
struct t_twc_bootstrap_node const *const node = &twc_bootstrap_nodes[i];
twc_bootstrap_tox(tox, node->address, node->port, node->key);
2014-09-28 01:29:34 +00:00
}