summaryrefslogtreecommitdiff
path: root/other
diff options
context:
space:
mode:
Diffstat (limited to 'other')
-rw-r--r--other/bootstrap_daemon/README.md61
-rw-r--r--other/bootstrap_daemon/docker/Dockerfile127
-rwxr-xr-x[-rw-r--r--]other/bootstrap_daemon/docker/get-nodes.py28
-rw-r--r--other/bootstrap_daemon/docker/tox-bootstrapd.sha2561
-rwxr-xr-x[-rw-r--r--]other/fun/bootstrap_node_info.py2
5 files changed, 140 insertions, 79 deletions
diff --git a/other/bootstrap_daemon/README.md b/other/bootstrap_daemon/README.md
index d49b84d0..e108b415 100644
--- a/other/bootstrap_daemon/README.md
+++ b/other/bootstrap_daemon/README.md
@@ -216,22 +216,53 @@ sudo grep "tox-bootstrapd" /var/log/syslog
216 216
217### Setting up 217### Setting up
218 218
219If you are familiar with Docker and would rather run the daemon in a Docker container, run the following from this directory: 219If you are familiar with Docker and would rather run the daemon in a Docker container, you may download the latest official docker image. Check the GitHub [releases](https://github.com/TokTok/c-toxcore/releases) page for the latest version (e.g. v0.2.11), and run:
220 220
221```sh 221```sh
222sudo docker build -t tox-bootstrapd docker/ 222docker pull toxchat/bootstrap-node:0.2.11
223docker run --rm -it --entrypoint=sha256sum toxchat/bootstrap-node:latest /usr/local/bin/tox-bootstrapd
224```
223 225
224sudo useradd --home-dir /var/lib/tox-bootstrapd --create-home --system --shell /sbin/nologin --comment "Account to run Tox's DHT bootstrap daemon" --user-group tox-bootstrapd 226This will print the SHA256 checksum of the latest binary, which should agree with the SHA256 checksum in the Dockerfile.
227
228If you want to build the bootstrap node from source, check out the latest release:
229
230```sh
231git checkout $(git tag --list | grep -P '^v(\d+).(\d+).(\d+)$' | \
232 sed 's/v/v /g' | sed 's/\./ /g' | \
233 sort -snk4,4 | sort -snk3,3 | sort -snk2,2 | tail -n 1 | \
234 sed 's/v /v/g' | sed 's/ /\./g')
235```
236
237and run the following from the top level c-toxcore directory:
238
239```sh
240tar c $(git ls-files) | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node -
241
242sudo useradd \
243 --home-dir /var/lib/tox-bootstrapd \
244 --create-home \
245 --system \
246 --shell /sbin/nologin \
247 --comment "Account to run Tox's DHT bootstrap daemon" \
248 --user-group tox-bootstrapd
225sudo chmod 700 /var/lib/tox-bootstrapd 249sudo chmod 700 /var/lib/tox-bootstrapd
226 250
227sudo docker run -d --name tox-bootstrapd --restart always -v /var/lib/tox-bootstrapd/:/var/lib/tox-bootstrapd/ --ulimit nofile=32768:32768 -p 443:443 -p 3389:3389 -p 33445:33445 -p 33445:33445/udp tox-bootstrapd 251docker run -d --name tox-bootstrapd --restart always \
252 -v /var/lib/tox-bootstrapd/:/var/lib/tox-bootstrapd/ \
253 --ulimit nofile=32768:32768 \
254 -p 443:443 \
255 -p 3389:3389 \
256 -p 33445:33445 \
257 -p 33445:33445/udp \
258 toxchat/bootstrap-node
228``` 259```
229 260
230We create a new user and protect its home directory in order to mount it in the Docker image, so that the kyepair the daemon uses would be stored on the host system, which makes it less likely that you would loose the keypair while playing with or updating the Docker container. 261We create a new user and protect its home directory in order to mount it in the Docker image, so that the kyepair the daemon uses would be stored on the host system, which makes it less likely that you would loose the keypair while playing with or updating the Docker container.
231 262
232You can check logs for your public key or any errors: 263You can check logs for your public key or any errors:
233```sh 264```sh
234sudo docker logs tox-bootstrapd 265docker logs tox-bootstrapd
235``` 266```
236 267
237Note that the Docker container runs a script which pulls a list of bootstrap nodes off https://nodes.tox.chat/ and adds them in the config file. 268Note that the Docker container runs a script which pulls a list of bootstrap nodes off https://nodes.tox.chat/ and adds them in the config file.
@@ -243,26 +274,32 @@ You want to make sure that the daemon uses the newest toxcore, as there might ha
243To update the daemon, all you need is to erase current container with its image: 274To update the daemon, all you need is to erase current container with its image:
244 275
245```sh 276```sh
246sudo docker stop tox-bootstrapd 277docker stop tox-bootstrapd
247sudo docker rm tox-bootstrapd 278docker rm tox-bootstrapd
248sudo docker rmi tox-bootstrapd 279docker rmi toxchat/bootstrap-node
249``` 280```
250 281
251Then rebuild and run the image again: 282Then rebuild and run the image again:
252 283
253```sh 284```sh
254sudo docker build -t tox-bootstrapd docker/ 285tar c $(git ls-files) | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node -
255sudo docker run -d --name tox-bootstrapd --restart always -v /var/lib/tox-bootstrapd/:/var/lib/tox-bootstrapd/ -p 443:443 -p 3389:3389 -p 33445:33445 -p 33445:33445/udp tox-bootstrapd 286docker run -d --name tox-bootstrapd --restart always \
287 -v /var/lib/tox-bootstrapd/:/var/lib/tox-bootstrapd/ \
288 -p 443:443 \
289 -p 3389:3389 \
290 -p 33445:33445 \
291 -p 33445:33445/udp \
292 toxchat/bootstrap-node
256``` 293```
257 294
258### Troubleshooting 295### Troubleshooting
259 296
260- Check if the container is running: 297- Check if the container is running:
261```sh 298```sh
262sudo docker ps -a 299docker ps -a
263``` 300```
264 301
265- Check the log for errors: 302- Check the log for errors:
266```sh 303```sh
267sudo docker logs tox-bootstrapd 304docker logs tox-bootstrapd
268``` 305```
diff --git a/other/bootstrap_daemon/docker/Dockerfile b/other/bootstrap_daemon/docker/Dockerfile
index 5ef359cf..25a48b85 100644
--- a/other/bootstrap_daemon/docker/Dockerfile
+++ b/other/bootstrap_daemon/docker/Dockerfile
@@ -1,64 +1,81 @@
1FROM debian:buster-slim 1###########################################################
2# Builder image: we compile the code here (static build)
3FROM alpine:3.11.5 AS build
4
5RUN ["apk", "--no-cache", "add",\
6 "build-base",\
7 "cmake",\
8 "linux-headers",\
9 "libconfig-dev",\
10 "libconfig-static",\
11 "libsodium-dev",\
12 "libsodium-static",\
13 "ninja",\
14 "python3"\
15]
16
17WORKDIR /src/c-toxcore
18
19# Very selectively add files to the image, because we may have random stuff
20# lying around. In particular, we don't need to rebuild the docker image when
21# toxav changes or the Dockerfile changes down from the build.
22COPY cmake cmake
23COPY other/bootstrap_daemon/src other/bootstrap_daemon/src
24COPY other/bootstrap_node_packets.[ch] other/
25COPY other/DHT_bootstrap.c other/
26COPY other/pkgconfig other/pkgconfig
27COPY other/rpm other/rpm
28COPY testing/misc_tools.[ch] testing/
29COPY toxcore toxcore
30COPY toxencryptsave toxencryptsave
31COPY CMakeLists.txt so.version ./
32
33RUN ["cmake", "-B_build", "-H.",\
34 "-GNinja",\
35 "-DCMAKE_BUILD_TYPE=Release",\
36 "-DFULLY_STATIC=ON",\
37 "-DBUILD_TOXAV=OFF",\
38 "-DBOOTSTRAP_DAEMON=ON"\
39]
40RUN ["cmake", "--build", "_build", "--target", "install"]
2 41
3WORKDIR /tmp/tox 42# Verify checksum from dev-built binary, so we can be sure Docker Hub doesn't
43# mess with your binaries.
44COPY other/bootstrap_daemon/docker/tox-bootstrapd.sha256 other/bootstrap_daemon/docker/
45RUN ["sha256sum", "/usr/local/bin/tox-bootstrapd"]
46RUN ["sha256sum", "-c", "other/bootstrap_daemon/docker/tox-bootstrapd.sha256"]
47
48# Remove all the example bootstrap nodes from the config file.
49COPY other/bootstrap_daemon/tox-bootstrapd.conf other/bootstrap_daemon/
50# hadolint ignore=SC2086,SC2154
51RUN ["sed", "-i", "/^bootstrap_nodes = /,$d", "other/bootstrap_daemon/tox-bootstrapd.conf"]
52
53# Add bootstrap nodes from https://nodes.tox.chat/.
54COPY other/bootstrap_daemon/docker/get-nodes.py other/bootstrap_daemon/docker/
55RUN ["other/bootstrap_daemon/docker/get-nodes.py", "other/bootstrap_daemon/tox-bootstrapd.conf"]
56
57###########################################################
58# Final image build: this is what runs the bootstrap node
59FROM debian:buster-slim
4 60
5RUN export BUILD_PACKAGES="\ 61COPY --from=build /usr/local/bin/tox-bootstrapd /usr/local/bin/
6 build-essential \ 62COPY --from=build /src/c-toxcore/other/bootstrap_daemon/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
7 cmake \ 63RUN ["useradd", "--home-dir", "/var/lib/tox-bootstrapd", "--create-home",\
8 git \ 64 "--system", "--shell", "/sbin/nologin",\
9 libconfig-dev \ 65 "--comment", "Account to run the Tox DHT bootstrap daemon",\
10 libsodium-dev \ 66 "--user-group", "tox-bootstrapd"\
11 python3" && \ 67]
12 export RUNTIME_PACKAGES="\ 68RUN ["chmod", "644", "/etc/tox-bootstrapd.conf"]
13 libconfig9 \ 69RUN ["chmod", "700", "/var/lib/tox-bootstrapd"]
14 libsodium23" && \
15# get all deps
16 apt-get update && apt-get install -y $BUILD_PACKAGES $RUNTIME_PACKAGES && \
17# install toxcore and daemon
18 git clone https://github.com/TokTok/c-toxcore && \
19 cd c-toxcore && \
20 # checkout latest release version
21 git checkout $(git tag --list | grep -P '^v(\d+).(\d+).(\d+)$' | \
22 sed "s/v/v /g" | sed "s/\./ /g" | \
23 sort -snk4,4 | sort -snk3,3 | sort -snk2,2 | tail -n 1 | \
24 sed 's/v /v/g' | sed 's/ /\./g') && \
25 mkdir _build && \
26 cd _build && \
27 cmake .. \
28 -DCMAKE_BUILD_TYPE=Release \
29 -DENABLE_SHARED=ON \
30 -DENABLE_STATIC=OFF \
31 -DBUILD_TOXAV=OFF \
32 -DBOOTSTRAP_DAEMON=ON && \
33 make -j`nproc` && \
34 make install -j`nproc` && \
35 cd .. && \
36# add new user
37 useradd --home-dir /var/lib/tox-bootstrapd --create-home \
38 --system --shell /sbin/nologin \
39 --comment "Account to run Tox's DHT bootstrap daemon" \
40 --user-group tox-bootstrapd && \
41 chmod 700 /var/lib/tox-bootstrapd && \
42 cp other/bootstrap_daemon/tox-bootstrapd.conf /etc/tox-bootstrapd.conf && \
43# remove all the example bootstrap nodes from the config file
44 sed -i '/^bootstrap_nodes = /,$d' /etc/tox-bootstrapd.conf && \
45# add bootstrap nodes from https://nodes.tox.chat/
46 python3 other/bootstrap_daemon/docker/get-nodes.py >> /etc/tox-bootstrapd.conf && \
47# perform cleanup
48 apt-get remove --purge -y $BUILD_PACKAGES && \
49 apt-get clean && \
50 apt-get autoremove -y && \
51 rm -rf /var/lib/apt/lists/* && \
52 cd / && \
53 rm -rf /tmp/*
54 70
55WORKDIR /var/lib/tox-bootstrapd 71WORKDIR /var/lib/tox-bootstrapd
56 72
57USER tox-bootstrapd 73USER tox-bootstrapd
58 74
59ENTRYPOINT /usr/local/bin/tox-bootstrapd \ 75ENTRYPOINT ["/usr/local/bin/tox-bootstrapd",\
60 --config /etc/tox-bootstrapd.conf \ 76 "--config", "/etc/tox-bootstrapd.conf",\
61 --log-backend stdout \ 77 "--log-backend", "stdout",\
62 --foreground 78 "--foreground"\
79]
63 80
64EXPOSE 443/tcp 3389/tcp 33445/tcp 33445/udp 81EXPOSE 443/tcp 3389/tcp 33445/tcp 33445/udp
diff --git a/other/bootstrap_daemon/docker/get-nodes.py b/other/bootstrap_daemon/docker/get-nodes.py
index 821f089a..f38bd492 100644..100755
--- a/other/bootstrap_daemon/docker/get-nodes.py
+++ b/other/bootstrap_daemon/docker/get-nodes.py
@@ -24,26 +24,32 @@ THE SOFTWARE.
24# Gets a list of nodes from https://nodes.tox.chat/json and prints them out 24# Gets a list of nodes from https://nodes.tox.chat/json and prints them out
25# in the format of tox-bootstrapd config file. 25# in the format of tox-bootstrapd config file.
26 26
27import urllib.request
28import json 27import json
28import sys
29import urllib.request
29 30
30response = urllib.request.urlopen('https://nodes.tox.chat/json') 31response = urllib.request.urlopen('https://nodes.tox.chat/json')
31raw_json = response.read().decode('ascii', 'ignore') 32raw_json = response.read().decode('ascii', 'ignore')
32nodes = json.loads(raw_json)['nodes'] 33nodes = json.loads(raw_json)['nodes']
33 34
34output = 'bootstrap_nodes = (\n' 35def node_to_string(node):
35
36for node in nodes:
37 node_output = ' { // ' + node['maintainer'] + '\n' 36 node_output = ' { // ' + node['maintainer'] + '\n'
38 node_output += ' public_key = "' + node['public_key'] + '"\n' 37 node_output += ' public_key = "' + node['public_key'] + '"\n'
39 node_output += ' port = ' + str(node['port']) + '\n' 38 node_output += ' port = ' + str(node['port']) + '\n'
40 node_output += ' address = "' 39 node_output += ' address = "'
41 if len(node['ipv4']) > 4: 40 if len(node['ipv4']) > 4:
42 output += node_output + node['ipv4'] + '"\n },\n' 41 return node_output + node['ipv4'] + '"\n }'
43 if len(node['ipv6']) > 4: 42 if len(node['ipv6']) > 4:
44 output += node_output + node['ipv6'] + '"\n },\n' 43 return node_output + node['ipv6'] + '"\n }'
45 44 raise Exception('no IP address found for node ' + json.dumps(node))
46# remove last comma 45
47output = output[:-2] + '\n)\n' 46output = ('bootstrap_nodes = (\n' +
48 47 ',\n'.join(map(node_to_string, nodes)) +
49print(output) 48 '\n)')
49
50if len(sys.argv) > 1:
51 with open(sys.argv[1], 'a') as fh:
52 fh.write(output + '\n')
53 print("Wrote %d nodes to %s" % (len(nodes), sys.argv[1]))
54else:
55 print(output)
diff --git a/other/bootstrap_daemon/docker/tox-bootstrapd.sha256 b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256
new file mode 100644
index 00000000..775b095e
--- /dev/null
+++ b/other/bootstrap_daemon/docker/tox-bootstrapd.sha256
@@ -0,0 +1 @@
b99d22c87a2bcaa93eba33f2a140f1c1624f846b4f2d87ada9fc2d7788f13193 /usr/local/bin/tox-bootstrapd
diff --git a/other/fun/bootstrap_node_info.py b/other/fun/bootstrap_node_info.py
index ffda41e3..f4f5f73d 100644..100755
--- a/other/fun/bootstrap_node_info.py
+++ b/other/fun/bootstrap_node_info.py
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2""" 2"""
3Copyright (c) 2014 by nurupo <nurupo.contributions@gmail.com> 3Copyright (c) 2014 by nurupo <nurupo.contributions@gmail.com>
4 4