Add getnodes.py and generate bootstrap node list

This commit is contained in:
Håvard Pettersson 2017-02-09 23:10:16 -08:00
parent 599345752a
commit 2947cc1562
2 changed files with 132 additions and 63 deletions

64
misc/getnodes.py Executable file
View File

@ -0,0 +1,64 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017 Håvard Pettersson <mail@haavard.me>.
#
# 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/>.
#
import re
import sys
import json
import datetime
import textwrap
import urllib.request
if __name__ == '__main__':
with urllib.request.urlopen('https://nodes.tox.chat/json') as response:
data = json.load(response)
# get online nodes that are defined by IP address
nodes = [node for node in data['nodes']
if (node['status_tcp'] or node['status_udp'])
and re.match(r'^\d+\.\d+\.\d+\.\d+$', node['ipv4'])]
# extract relevant values from node dictionaries
addresses = [node['ipv4'] for node in nodes]
ports = [node['port'] for node in nodes]
pubkeys = [node['public_key'] for node in nodes]
comments = ['Maintainer: {}, location: {}'.format(
node['maintainer'], node['location']) for node in nodes]
# format data as C literals
addresses_c = ', '.join('"{}"'.format(address) for address in addresses)
ports_c = ', '.join('{}'.format(port) for port in ports)
pubkeys_c = ',\n '.join('/* {} */\n "{}"'.format(
comment, key) for comment, key in zip(comments, pubkeys))
# word-wrap and indent addresses and ports
addresses_c = textwrap.fill(addresses_c).replace('\n', '\n ')
ports_c = textwrap.fill(ports_c).replace('\n', '\n ')
# emit C code
print('/* bootstrap nodes generated by {}, do not modify'.format(__file__))
print(' * last generated', datetime.datetime.now().isoformat())
print(' */')
print('char *twc_bootstrap_keys[] = {')
print(' '*3, pubkeys_c, ' };\n')
print('char *twc_bootstrap_addresses[] = {')
print(' '*3, addresses_c, ' };\n')
print('uint16_t twc_bootstrap_ports[] = {')
print(' '*3, ports_c, ' };')

View File

@ -23,73 +23,78 @@
#include "twc-bootstrap.h" #include "twc-bootstrap.h"
/* bootstrap nodes generated by misc/getnodes.py, do not modify
* last generated 2017-02-09T23:08:31.399895
*/
char *twc_bootstrap_keys[] = {
/* Maintainer: Manolis, location: DE */
"461FA3776EF0FA655F1A05477DF1B3B614F7D6B124F7DB1DD4FE3C08B03B640F",
/* Maintainer: Busindre, location: US */
"A179B09749AC826FF01F37A9613F6B57118AE014D4196A0E1105A98F93A54702",
/* Maintainer: Busindre, location: US */
"1D5A5F2F5D6233058BF0259B09622FB40B482E4FA0931EB8FD3AB8E7BF7DAF6F",
/* Maintainer: ray65536, location: NL */
"8E7D0B859922EF569298B4D261A8CCB5FEA14FB91ED412A7603A585A25698832",
/* Maintainer: fluke571, location: SI */
"3CEE1F054081E7A011234883BC4FC39F661A55B73637A5AC293DDF1251D9432B",
/* Maintainer: MAH69K, location: UA */
"DA4E4ED4B697F2E9B000EEFE3A34B554ACD3F45F5C96EAEA2516DD7FF9AF7B43",
/* Maintainer: Rotkaermota, location: SE */
"5823FB947FF24CF83DDFAC3F3BAA18F96EA2018B16CC08429CB97FA502F40C23",
/* Maintainer: tastytea, location: DE */
"2B2137E094F743AC8BD44652C55F41DFACC502F125E99E4FE24D40537489E32F",
/* Maintainer: pucetox, location: DE */
"7AED21F94D82B05774F697B209628CD5A9AD17E0C073D9329076A4C28ED28147",
/* Maintainer: ru_maniac, location: US */
"0FB96EEBFB1650DDB52E70CF773DDFCABE25A95CC3BB50FC251082E4B63EF82A",
/* Maintainer: wildermesser, location: CA */
"EDEE8F2E839A57820DE3DA4156D88350E53D4161447068A3457EE8F59F362414",
/* Maintainer: a68366, location: FR */
"AEC204B9A4501412D5F0BB67D9C81B5DB3EE6ADA64122D32A3E9B093D544327D",
/* Maintainer: ru_maniac, location: RU */
"24156472041E5F220D1FA11D9DF32F7AD697D59845701CDD7BE7D1785EB9DB39",
/* Maintainer: t3mp, location: RU */
"5625A62618CB4FCA70E147A71B29695F38CC65FF0CBD68AD46254585BE564802",
/* Maintainer: HooinKyoma, location: SE */
"672DBE27B4ADB9D5FB105A6BB648B2F8FDB89B3323486A7A21968316E012023C",
/* Maintainer: LittleVulpix, location: FR */
"2C289F9F37C20D09DA83565588BF496FAB3764853FA38141817A72E3F18ACA0B",
/* Maintainer: Yani, location: NL */
"E59A0E71ADA20D35BD1B0957059D7EF7E7792B3D680AE25C6F4DBBA09114D165",
/* Maintainer: Cactus, location: RU */
"9906D65F2A4751068A59D30505C5FC8AE1A95E0843AE9372EAFA3BAB6AC16C2C",
/* Maintainer: linxon, location: RU */
"B38255EE4B054924F6D79A5E6E5889EC94B6ADF6FE9906F97A3D01E3D083223A",
/* Maintainer: Stranger, location: UA */
"813C8F4187833EF0655B10F7752141A352248462A567529A38B6BBF73E979307",
/* Maintainer: dvor, location: NL */
"2555763C8C460495B14157D234DD56B86300A2395554BCAE4621AC345B8C1B1B",
/* Maintainer: Madji, location: RU */
"CE678DEAFA29182EFD1B0C5B9BC6999E5A20B50A1A6EC18B91C8EBB591712416",
/* Maintainer: himura, location: RU */
"8F738BBC8FA9394670BCAB146C67A507B9907C8E564E28C2B59BEBB2FF68711B",
/* Maintainer: dolohow, location: FR */
"BEB71F97ED9C99C04B8489BB75579EB4DC6AB6F441B603D63533122F1858B51D",
/* Maintainer: ws, location: NZ */
"F202E0936ABEE09067F55B0955C3FF6A84ABEED3C750A9EB930D926D03248F4C",
/* Maintainer: clearmartin, location: DE */
"CD133B521159541FB1D326DE9850F5E56A6C724B5B8E5EB5CD8D950408E95707"
};
char *twc_bootstrap_addresses[] = { char *twc_bootstrap_addresses[] = {
"178.62.250.138", "130.133.110.14", "205.185.116.116", "198.98.51.198",
"130.133.110.14", "108.61.165.198", "194.249.212.109", "185.25.116.107",
"104.167.101.29", "95.215.46.114", "5.189.176.217", "148.251.23.146", "104.223.122.15",
"205.185.116.116", "104.233.104.126", "51.254.84.212", "185.58.206.164", "92.54.84.70",
"198.98.51.198", "95.215.44.78", "163.172.136.118", "37.97.185.116", "193.124.186.205",
"108.61.165.198", "80.87.193.193", "46.229.52.198", "185.14.30.213", "77.37.160.178",
"194.249.212.109", "85.21.144.224", "37.187.122.30", "202.36.75.162", "46.101.197.175"
"185.25.116.107",
"192.99.168.140",
"95.215.46.114",
"5.189.176.217",
"148.251.23.146",
"104.223.122.15",
"81.4.110.149",
"95.31.20.151",
"104.233.104.126",
"51.254.84.212",
"5.135.59.163",
"185.58.206.164",
"91.121.66.124",
"92.54.84.70",
"195.93.190.6",
"95.215.44.78",
"163.172.136.118",
"37.97.185.116",
"193.124.186.205",
"80.87.193.193",
"46.229.52.198"
}; };
uint16_t twc_bootstrap_ports[] = { uint16_t twc_bootstrap_ports[] = {
33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 5190, 2306, 33445,
33445, 33445, 5190, 2306, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 5228, 33445, 33445,
33445, 33445, 33445, 33445, 33445, 33445, 33445, 33445, 443, 33440, 33445, 33445, 33445, 443
33445, 5228, 33445, 33445
};
char *twc_bootstrap_keys[] = {
"788236D34978D1D5BD822F0A5BEBD2C53C64CC31CD3149350EE27D4D9A2F9B6B",
"461FA3776EF0FA655F1A05477DF1B3B614F7D6B124F7DB1DD4FE3C08B03B640F",
"5918AC3C06955962A75AD7DF4F80A5D7C34F7DB9E1498D2E0495DE35B3FE8A57",
"A179B09749AC826FF01F37A9613F6B57118AE014D4196A0E1105A98F93A54702",
"1D5A5F2F5D6233058BF0259B09622FB40B482E4FA0931EB8FD3AB8E7BF7DAF6F",
"8E7D0B859922EF569298B4D261A8CCB5FEA14FB91ED412A7603A585A25698832",
"3CEE1F054081E7A011234883BC4FC39F661A55B73637A5AC293DDF1251D9432B",
"DA4E4ED4B697F2E9B000EEFE3A34B554ACD3F45F5C96EAEA2516DD7FF9AF7B43",
"6A4D0607A296838434A6A7DDF99F50EF9D60A2C510BBF31FE538A25CB6B4652F",
"5823FB947FF24CF83DDFAC3F3BAA18F96EA2018B16CC08429CB97FA502F40C23",
"2B2137E094F743AC8BD44652C55F41DFACC502F125E99E4FE24D40537489E32F",
"7AED21F94D82B05774F697B209628CD5A9AD17E0C073D9329076A4C28ED28147",
"0FB96EEBFB1650DDB52E70CF773DDFCABE25A95CC3BB50FC251082E4B63EF82A",
"9E7BD4793FFECA7F32238FA2361040C09025ED3333744483CA6F3039BFF0211E",
"9CA69BB74DE7C056D1CC6B16AB8A0A38725C0349D187D8996766958584D39340",
"EDEE8F2E839A57820DE3DA4156D88350E53D4161447068A3457EE8F59F362414",
"AEC204B9A4501412D5F0BB67D9C81B5DB3EE6ADA64122D32A3E9B093D544327D",
"2D320F971EF2CA18004416C2AAE7BA52BF7949DB34EA8E2E21AF67BD367BE211",
"24156472041E5F220D1FA11D9DF32F7AD697D59845701CDD7BE7D1785EB9DB39",
"4E3F7D37295664BBD0741B6DBCB6431D6CD77FC4105338C2FC31567BF5C8224A",
"5625A62618CB4FCA70E147A71B29695F38CC65FF0CBD68AD46254585BE564802",
"FB4CE0DDEFEED45F26917053E5D24BDDA0FA0A3D83A672A9DA2375928B37023D",
"672DBE27B4ADB9D5FB105A6BB648B2F8FDB89B3323486A7A21968316E012023C",
"2C289F9F37C20D09DA83565588BF496FAB3764853FA38141817A72E3F18ACA0B",
"E59A0E71ADA20D35BD1B0957059D7EF7E7792B3D680AE25C6F4DBBA09114D165",
"9906D65F2A4751068A59D30505C5FC8AE1A95E0843AE9372EAFA3BAB6AC16C2C",
"B38255EE4B054924F6D79A5E6E5889EC94B6ADF6FE9906F97A3D01E3D083223A",
"813C8F4187833EF0655B10F7752141A352248462A567529A38B6BBF73E979307"
}; };
int twc_bootstrap_count = sizeof(twc_bootstrap_addresses) int twc_bootstrap_count = sizeof(twc_bootstrap_addresses)