diff options
Diffstat (limited to 'other')
-rw-r--r-- | other/bootstrap_daemon/README.md | 61 | ||||
-rw-r--r-- | other/bootstrap_daemon/docker/Dockerfile | 127 | ||||
-rwxr-xr-x[-rw-r--r--] | other/bootstrap_daemon/docker/get-nodes.py | 28 | ||||
-rw-r--r-- | other/bootstrap_daemon/docker/tox-bootstrapd.sha256 | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | other/fun/bootstrap_node_info.py | 2 |
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 | ||
219 | If you are familiar with Docker and would rather run the daemon in a Docker container, run the following from this directory: | 219 | If 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 |
222 | sudo docker build -t tox-bootstrapd docker/ | 222 | docker pull toxchat/bootstrap-node:0.2.11 |
223 | docker run --rm -it --entrypoint=sha256sum toxchat/bootstrap-node:latest /usr/local/bin/tox-bootstrapd | ||
224 | ``` | ||
223 | 225 | ||
224 | sudo 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 | 226 | This will print the SHA256 checksum of the latest binary, which should agree with the SHA256 checksum in the Dockerfile. |
227 | |||
228 | If you want to build the bootstrap node from source, check out the latest release: | ||
229 | |||
230 | ```sh | ||
231 | git 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 | |||
237 | and run the following from the top level c-toxcore directory: | ||
238 | |||
239 | ```sh | ||
240 | tar c $(git ls-files) | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node - | ||
241 | |||
242 | sudo 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 | ||
225 | sudo chmod 700 /var/lib/tox-bootstrapd | 249 | sudo chmod 700 /var/lib/tox-bootstrapd |
226 | 250 | ||
227 | sudo 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 | 251 | docker 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 | ||
230 | We 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. | 261 | We 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 | ||
232 | You can check logs for your public key or any errors: | 263 | You can check logs for your public key or any errors: |
233 | ```sh | 264 | ```sh |
234 | sudo docker logs tox-bootstrapd | 265 | docker logs tox-bootstrapd |
235 | ``` | 266 | ``` |
236 | 267 | ||
237 | Note 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. | 268 | Note 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 | |||
243 | To update the daemon, all you need is to erase current container with its image: | 274 | To update the daemon, all you need is to erase current container with its image: |
244 | 275 | ||
245 | ```sh | 276 | ```sh |
246 | sudo docker stop tox-bootstrapd | 277 | docker stop tox-bootstrapd |
247 | sudo docker rm tox-bootstrapd | 278 | docker rm tox-bootstrapd |
248 | sudo docker rmi tox-bootstrapd | 279 | docker rmi toxchat/bootstrap-node |
249 | ``` | 280 | ``` |
250 | 281 | ||
251 | Then rebuild and run the image again: | 282 | Then rebuild and run the image again: |
252 | 283 | ||
253 | ```sh | 284 | ```sh |
254 | sudo docker build -t tox-bootstrapd docker/ | 285 | tar c $(git ls-files) | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node - |
255 | sudo 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 | 286 | docker 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 |
262 | sudo docker ps -a | 299 | docker ps -a |
263 | ``` | 300 | ``` |
264 | 301 | ||
265 | - Check the log for errors: | 302 | - Check the log for errors: |
266 | ```sh | 303 | ```sh |
267 | sudo docker logs tox-bootstrapd | 304 | docker 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 @@ | |||
1 | FROM debian:buster-slim | 1 | ########################################################### |
2 | # Builder image: we compile the code here (static build) | ||
3 | FROM alpine:3.11.5 AS build | ||
4 | |||
5 | RUN ["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 | |||
17 | WORKDIR /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. | ||
22 | COPY cmake cmake | ||
23 | COPY other/bootstrap_daemon/src other/bootstrap_daemon/src | ||
24 | COPY other/bootstrap_node_packets.[ch] other/ | ||
25 | COPY other/DHT_bootstrap.c other/ | ||
26 | COPY other/pkgconfig other/pkgconfig | ||
27 | COPY other/rpm other/rpm | ||
28 | COPY testing/misc_tools.[ch] testing/ | ||
29 | COPY toxcore toxcore | ||
30 | COPY toxencryptsave toxencryptsave | ||
31 | COPY CMakeLists.txt so.version ./ | ||
32 | |||
33 | RUN ["cmake", "-B_build", "-H.",\ | ||
34 | "-GNinja",\ | ||
35 | "-DCMAKE_BUILD_TYPE=Release",\ | ||
36 | "-DFULLY_STATIC=ON",\ | ||
37 | "-DBUILD_TOXAV=OFF",\ | ||
38 | "-DBOOTSTRAP_DAEMON=ON"\ | ||
39 | ] | ||
40 | RUN ["cmake", "--build", "_build", "--target", "install"] | ||
2 | 41 | ||
3 | WORKDIR /tmp/tox | 42 | # Verify checksum from dev-built binary, so we can be sure Docker Hub doesn't |
43 | # mess with your binaries. | ||
44 | COPY other/bootstrap_daemon/docker/tox-bootstrapd.sha256 other/bootstrap_daemon/docker/ | ||
45 | RUN ["sha256sum", "/usr/local/bin/tox-bootstrapd"] | ||
46 | RUN ["sha256sum", "-c", "other/bootstrap_daemon/docker/tox-bootstrapd.sha256"] | ||
47 | |||
48 | # Remove all the example bootstrap nodes from the config file. | ||
49 | COPY other/bootstrap_daemon/tox-bootstrapd.conf other/bootstrap_daemon/ | ||
50 | # hadolint ignore=SC2086,SC2154 | ||
51 | RUN ["sed", "-i", "/^bootstrap_nodes = /,$d", "other/bootstrap_daemon/tox-bootstrapd.conf"] | ||
52 | |||
53 | # Add bootstrap nodes from https://nodes.tox.chat/. | ||
54 | COPY other/bootstrap_daemon/docker/get-nodes.py other/bootstrap_daemon/docker/ | ||
55 | RUN ["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 | ||
59 | FROM debian:buster-slim | ||
4 | 60 | ||
5 | RUN export BUILD_PACKAGES="\ | 61 | COPY --from=build /usr/local/bin/tox-bootstrapd /usr/local/bin/ |
6 | build-essential \ | 62 | COPY --from=build /src/c-toxcore/other/bootstrap_daemon/tox-bootstrapd.conf /etc/tox-bootstrapd.conf |
7 | cmake \ | 63 | RUN ["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="\ | 68 | RUN ["chmod", "644", "/etc/tox-bootstrapd.conf"] |
13 | libconfig9 \ | 69 | RUN ["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 | ||
55 | WORKDIR /var/lib/tox-bootstrapd | 71 | WORKDIR /var/lib/tox-bootstrapd |
56 | 72 | ||
57 | USER tox-bootstrapd | 73 | USER tox-bootstrapd |
58 | 74 | ||
59 | ENTRYPOINT /usr/local/bin/tox-bootstrapd \ | 75 | ENTRYPOINT ["/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 | ||
64 | EXPOSE 443/tcp 3389/tcp 33445/tcp 33445/udp | 81 | EXPOSE 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 | ||
27 | import urllib.request | ||
28 | import json | 27 | import json |
28 | import sys | ||
29 | import urllib.request | ||
29 | 30 | ||
30 | response = urllib.request.urlopen('https://nodes.tox.chat/json') | 31 | response = urllib.request.urlopen('https://nodes.tox.chat/json') |
31 | raw_json = response.read().decode('ascii', 'ignore') | 32 | raw_json = response.read().decode('ascii', 'ignore') |
32 | nodes = json.loads(raw_json)['nodes'] | 33 | nodes = json.loads(raw_json)['nodes'] |
33 | 34 | ||
34 | output = 'bootstrap_nodes = (\n' | 35 | def node_to_string(node): |
35 | |||
36 | for 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 | |
47 | output = output[:-2] + '\n)\n' | 46 | output = ('bootstrap_nodes = (\n' + |
48 | 47 | ',\n'.join(map(node_to_string, nodes)) + | |
49 | print(output) | 48 | '\n)') |
49 | |||
50 | if 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])) | ||
54 | else: | ||
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 | """ |
3 | Copyright (c) 2014 by nurupo <nurupo.contributions@gmail.com> | 3 | Copyright (c) 2014 by nurupo <nurupo.contributions@gmail.com> |
4 | 4 | ||