summaryrefslogtreecommitdiff
path: root/nodegen
blob: 12c2fec5a98a04c00dd43a7f21cecb54d6abc453 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/sh

echo 'static struct node nodes[] = {'

curl -s https://nodes.tox.chat/json |
jq --tab '[.nodes[] |
	select(.last_ping > 0) |
	select(.tcp_ports | length > 0) |
	{".addr4": .ipv4, ".addr6": .ipv6, ".udp_port": .port, ".tcp_port": .tcp_ports[0], ".idstr": .public_key}]' |
sed 's/"-"/NULL/; s/"NONE"/NULL/; s/"\(\.[0-9a-z_]\+\)":/\1 =/; 1d; $d'

echo '};'