diff options
author | iphydf <iphydf@users.noreply.github.com> | 2020-04-23 16:18:15 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2020-04-26 16:13:24 +0000 |
commit | a2d586b78254f6ba3b12d20f2398f31e9ee66235 (patch) | |
tree | 699a4d40fe84547a129743ce9e32454baf2b8464 | |
parent | 087eede3a3e75cd7861e7a9b9c949bf36016829e (diff) |
Rework the toxchat/bootstrap-node Docker image.
* Use fully static build for the bootstrap daemon.
* Store a sha256sum of the binary in the repo.
* Updated documentation for it.
* Add support for fully static build in cmake.
* Enable the docker build on every PR, so we catch changes to the
checksum. I realise this is adding toil, but having the checksum is
valuable for security of released binaries.
-rw-r--r-- | .travis.yml | 9 | ||||
-rwxr-xr-x | .travis/tox-bootstrapd-docker | 47 | ||||
-rw-r--r-- | cmake/ModulePackage.cmake | 10 | ||||
-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 |
8 files changed, 175 insertions, 110 deletions
diff --git a/.travis.yml b/.travis.yml index bfebbd71..510fb984 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -39,6 +39,10 @@ jobs: | |||
39 | install: .travis/$JOB install | 39 | install: .travis/$JOB install |
40 | script: .travis/$JOB script | 40 | script: .travis/$JOB script |
41 | - stage: "Stage 1" | 41 | - stage: "Stage 1" |
42 | env: JOB=tox-bootstrapd-docker | ||
43 | services: [docker] | ||
44 | script: .travis/$JOB | ||
45 | - stage: "Stage 1" | ||
42 | if: type IN (push, api, cron) | 46 | if: type IN (push, api, cron) |
43 | env: JOB=cmake-win32 | 47 | env: JOB=cmake-win32 |
44 | services: [docker] | 48 | services: [docker] |
@@ -61,11 +65,6 @@ jobs: | |||
61 | os: osx | 65 | os: osx |
62 | install: .travis/$JOB install | 66 | install: .travis/$JOB install |
63 | script: .travis/$JOB script | 67 | script: .travis/$JOB script |
64 | - stage: "Stage 1" | ||
65 | if: type IN (push, api, cron) | ||
66 | env: JOB=tox-bootstrapd-docker | ||
67 | services: [docker] | ||
68 | script: .travis/$JOB | ||
69 | - stage: "Stage 2" | 68 | - stage: "Stage 2" |
70 | if: type IN (push, api, cron) | 69 | if: type IN (push, api, cron) |
71 | env: JOB=cmake-freebsd | 70 | env: JOB=cmake-freebsd |
diff --git a/.travis/tox-bootstrapd-docker b/.travis/tox-bootstrapd-docker index 5dc39628..bd192f07 100755 --- a/.travis/tox-bootstrapd-docker +++ b/.travis/tox-bootstrapd-docker | |||
@@ -2,28 +2,23 @@ | |||
2 | 2 | ||
3 | set -exu | 3 | set -exu |
4 | 4 | ||
5 | # Copy source code to other/bootstrap_daemon/docker/c-toxcore | 5 | tar c $(git ls-files) | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node - |
6 | OLD_PWD=$PWD | 6 | sudo useradd \ |
7 | cd /tmp | 7 | --home-dir /var/lib/tox-bootstrapd \ |
8 | cp -a $OLD_PWD c-toxcore | 8 | --create-home \ |
9 | mv c-toxcore $OLD_PWD/other/bootstrap_daemon/docker | 9 | --system \ |
10 | cd $OLD_PWD | 10 | --shell /sbin/nologin \ |
11 | ls -lbh other/bootstrap_daemon/docker | 11 | --comment "Account to run Tox's DHT bootstrap daemon" \ |
12 | ls -lbh other/bootstrap_daemon/docker/c-toxcore | 12 | --user-group tox-bootstrapd |
13 | |||
14 | cd other/bootstrap_daemon | ||
15 | |||
16 | # Make Docker container use our current source code instead of master branch | ||
17 | sed -i "s|WORKDIR /tmp/tox|WORKDIR /tmp/tox\nADD /c-toxcore ./c-toxcore/|g" docker/Dockerfile | ||
18 | sed -i 's|git clone|echo \\\#git clone|g' docker/Dockerfile | ||
19 | sed -i 's|git checkout|echo \\\#git checkout|g' docker/Dockerfile | ||
20 | |||
21 | cat docker/Dockerfile | ||
22 | |||
23 | sudo docker build -t tox-bootstrapd docker/ | ||
24 | 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 | ||
25 | sudo chmod 700 /var/lib/tox-bootstrapd | 13 | sudo chmod 700 /var/lib/tox-bootstrapd |
26 | sudo docker run -d --name tox-bootstrapd -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 | 14 | docker run -d --name tox-bootstrapd \ |
15 | -v /var/lib/tox-bootstrapd/:/var/lib/tox-bootstrapd/ \ | ||
16 | --ulimit nofile=32768:32768 \ | ||
17 | -p 443:443 \ | ||
18 | -p 3389:3389 \ | ||
19 | -p 33445:33445 \ | ||
20 | -p 33445:33445/udp \ | ||
21 | toxchat/bootstrap-node | ||
27 | 22 | ||
28 | sudo ls -lbh /var/lib/tox-bootstrapd | 23 | sudo ls -lbh /var/lib/tox-bootstrapd |
29 | 24 | ||
@@ -35,14 +30,14 @@ fi | |||
35 | COUNTER=0 | 30 | COUNTER=0 |
36 | COUNTER_END=120 | 31 | COUNTER_END=120 |
37 | while [ $COUNTER -lt $COUNTER_END ]; do | 32 | while [ $COUNTER -lt $COUNTER_END ]; do |
38 | if sudo docker logs tox-bootstrapd | grep -q "Connected to another bootstrap node successfully" ; then | 33 | if docker logs tox-bootstrapd | grep -q "Connected to another bootstrap node successfully" ; then |
39 | break | 34 | break |
40 | fi | 35 | fi |
41 | sleep 1 | 36 | sleep 1 |
42 | COUNTER=$(($COUNTER+1)) | 37 | COUNTER=$(($COUNTER+1)) |
43 | done | 38 | done |
44 | 39 | ||
45 | sudo docker logs tox-bootstrapd | 40 | docker logs tox-bootstrapd |
46 | 41 | ||
47 | if [ "$COUNTER" = "$COUNTER_END" ]; then | 42 | if [ "$COUNTER" = "$COUNTER_END" ]; then |
48 | echo "Error: Didn't connect to any nodes" | 43 | echo "Error: Didn't connect to any nodes" |
@@ -52,9 +47,9 @@ fi | |||
52 | # Wait a bit befrore testing if the container is still running | 47 | # Wait a bit befrore testing if the container is still running |
53 | sleep 30 | 48 | sleep 30 |
54 | 49 | ||
55 | sudo docker ps -a | 50 | docker ps -a |
56 | 51 | ||
57 | if [ "`sudo docker inspect -f {{.State.Running}} tox-bootstrapd`" != "true" ]; then | 52 | if [ "`docker inspect -f {{.State.Running}} tox-bootstrapd`" != "true" ]; then |
58 | echo "Error: Container is not running" | 53 | echo "Error: Container is not running" |
59 | exit 1 | 54 | exit 1 |
60 | fi | 55 | fi |
@@ -65,7 +60,7 @@ if ! cat /proc/$(pidof tox-bootstrapd)/limits | grep -P '^Max open files(\s+)327 | |||
65 | exit 1 | 60 | exit 1 |
66 | fi | 61 | fi |
67 | 62 | ||
68 | if ! python3 ../fun/bootstrap_node_info.py ipv4 localhost 33445 ; then | 63 | if ! other/fun/bootstrap_node_info.py ipv4 localhost 33445 ; then |
69 | echo "Error: Unable to get bootstrap node info" | 64 | echo "Error: Unable to get bootstrap node info" |
70 | exit 1 | 65 | exit 1 |
71 | fi | 66 | fi |
diff --git a/cmake/ModulePackage.cmake b/cmake/ModulePackage.cmake index 77911b1d..9cc21863 100644 --- a/cmake/ModulePackage.cmake +++ b/cmake/ModulePackage.cmake | |||
@@ -9,6 +9,16 @@ if(NOT ENABLE_SHARED AND NOT ENABLE_STATIC) | |||
9 | set(ENABLE_SHARED ON) | 9 | set(ENABLE_SHARED ON) |
10 | endif() | 10 | endif() |
11 | 11 | ||
12 | option(FULLY_STATIC "Build fully static executables" OFF) | ||
13 | if(FULLY_STATIC) | ||
14 | set(CMAKE_EXE_LINKER_FLAGS "-static -no-pie") | ||
15 | # remove -Wl,-Bdynamic | ||
16 | set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) | ||
17 | set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS) | ||
18 | set(ENABLE_SHARED OFF) | ||
19 | set(ENABLE_STATIC ON) | ||
20 | endif() | ||
21 | |||
12 | find_package(PkgConfig) | 22 | find_package(PkgConfig) |
13 | 23 | ||
14 | function(pkg_use_module mod pkg) | 24 | function(pkg_use_module mod pkg) |
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 | ||