tomato/other/bootstrap_daemon
Green Sky 9ddeea3d06 Squashed 'external/toxcore/c-toxcore/' changes from d4b06edc2a..adbd5b32d8
adbd5b32d8 feat: add ngc events
15ee46d431 add simple test for max sized lossy custom group packet
01e7950c67 increase lossy custom packet size in ngc to the toxcore common max of 1373
9b3c1089f1 Make group saving/loading more forgiving with data errors
55a76003b0 Replace memset(int32_t*, -1, _) with a for-loop
66453439ac fix: also Install header for private/experimental API functions with autotools
3983369103 fix: Enable debug flag for ubsan.
4d1db21102 Update tox-boostrapd hash
e700c31b70 Fix memory leak in group connection
2994441d9c Fix memory leak in save-generator
d0400df13d Fix memory leak in tox-bootstrapd
7a6d50ebe3 Install header for private/experimental API functions
d89677fb5f Remove defunct IRC channel from README.md
26d41fc604 Replace DEFAULT_TCP_RELAY_PORTS_COUNT with a compile-time calculation
63fb2941ca Clarify disabling of static assert checks
65b3375b98 refactor: Use Bin_Pack for packing Node_format.
84ba154f6a group connection queries now return our own connection type
a4df2862ed Replace tabs with spaces
1b6dee7594 Update tox-bootstrapd's base Docker images
a030cdee5c Fix Docker tox-bootstrapd hash update failing when using BuildKit
7cfe35dff2 cleanup: Remove explicit layering_check feature.
d390947245 chore: Upgrade sonar-scan jvm to java 17.
d1e850c56c fix: Add missing `htons` call when adding configured TCP relay.
814090f2b8 chore: Cancel old PR builds on docker and sonar-scan workflows.
83efb17367 perf: Add a KVM FreeBSD build on cirrus ci.
a927183233 test: Add a test for encrypting 100MB of data.
28f39049f6 chore: Retry freebsd tests 2 times.
47e77d1bb0 chore: Use C99 on MSVC instead of C11.
7155f7f60e test: Add an s390x build (on alpine) for CI.
6c35cef63f chore: Add a compcert docker run script.
41e6ea865e cleanup: Use tcc docker image for CI.
e726b197b0 refactor: Store time in Mono_Time in milliseconds.
REVERT: d4b06edc2a feat: add ngc events

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: adbd5b32d85d9c13800f5ece17c0a9dce99faacd
2023-12-15 15:21:40 +01:00
..
bash-completion/completions Squashed 'external/toxcore/c-toxcore/' content from commit 67badf69 2023-07-25 11:53:09 +02:00
docker Squashed 'external/toxcore/c-toxcore/' changes from d4b06edc2a..adbd5b32d8 2023-12-15 15:21:40 +01:00
src Squashed 'external/toxcore/c-toxcore/' changes from d4b06edc2a..adbd5b32d8 2023-12-15 15:21:40 +01:00
websocket Squashed 'external/toxcore/c-toxcore/' changes from d4b06edc2a..adbd5b32d8 2023-12-15 15:21:40 +01:00
BUILD.bazel Squashed 'external/toxcore/c-toxcore/' changes from d4b06edc2a..adbd5b32d8 2023-12-15 15:21:40 +01:00
CMakeLists.txt Squashed 'external/toxcore/c-toxcore/' content from commit 67badf69 2023-07-25 11:53:09 +02:00
README.md Squashed 'external/toxcore/c-toxcore/' content from commit 67badf69 2023-07-25 11:53:09 +02:00
tox-bootstrapd.conf Squashed 'external/toxcore/c-toxcore/' content from commit 67badf69 2023-07-25 11:53:09 +02:00
tox-bootstrapd.service Squashed 'external/toxcore/c-toxcore/' content from commit 67badf69 2023-07-25 11:53:09 +02:00
tox-bootstrapd.sh Squashed 'external/toxcore/c-toxcore/' content from commit 67badf69 2023-07-25 11:53:09 +02:00

Instructions

These instructions are primarily tested on Debian Linux, Wheezy for SysVinit and Jessie for systemd, but they should work on other POSIX-compliant systems too.

For systemd users

Setting up

For security reasons we run the daemon under its own user.

Create a new user by executing the following:

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

Restrict access to home directory:

sudo chmod 700 /var/lib/tox-bootstrapd

Copy tox-bootstrapd.conf file to where ExecStart= from tox-bootstrapd.service points to. By default it's /etc/tox-bootstrapd.conf.

sudo cp tox-bootstrapd.conf /etc/tox-bootstrapd.conf

Go over everything in the copied tox-bootstrapd.conf file. Set options you want and add actual working nodes to the bootstrap_nodes list, instead of the example ones, if you want your node to connect to the Tox network. Make sure pid_file_path matches PIDFile= from tox-bootstrapd.service.

Copy tox-bootstrapd.service to /etc/systemd/system/:

sudo cp tox-bootstrapd.service /etc/systemd/system/

You must uncomment the next line in tox-bootstrapd.service, if you want to use port number < 1024:

#CapabilityBoundingSet=CAP_NET_BIND_SERVICE

and, possibly, install libcap2-bin or libcap2 package, depending of your distribution.

Reload systemd units definitions, enable service for automatic start (if needed), start it and verify it's running:

sudo systemctl daemon-reload
sudo systemctl enable tox-bootstrapd.service
sudo systemctl start tox-bootstrapd.service
sudo systemctl status tox-bootstrapd.service

Get your public key and check that the daemon initialized correctly:

sudo grep "tox-bootstrapd" /var/log/syslog

Updating

You want to make sure that the daemon uses the newest toxcore, as there might have been some changes done to the DHT, so it's advised to update the daemon at least once every month.

To update the daemon first stop it:

sudo systemctl stop tox-bootstrapd.service

Then update your toxcore git repository, rebuild the toxcore and the daemon and make sure to install them.

Check if tox-bootstrapd.service in toxcore git repository was modified since the last time you copied it, as you might need to update it too.

Reload tox-bootstrapd.service if you have updated modified it:

sudo systemctl daemon-reload

After all of this is done, simply start the daemon back again:

sudo systemctl start tox-bootstrapd.service

Troubleshooting

  • Check daemon's status:
sudo systemctl status tox-bootstrapd.service
  • Check the log for errors:
sudo grep "tox-bootstrapd" /var/log/syslog
# or
sudo journalctl --pager-end
# or
sudo journalctl -f _SYSTEMD_UNIT=tox-bootstrapd.service
  • Make sure tox-bootstrapd user has write permission for keys and pid files.

  • Make sure tox-bootstrapd has read permission for the config file.

  • Make sure tox-bootstrapd location matches its path in tox-bootstrapd.service file.

For SysVinit users

Setting up

For security reasons we run the daemon under its own user.

Create a new user by executing the following:

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

Restrict access to home directory:

sudo chmod 700 /var/lib/tox-bootstrapd

Copy tox-bootstrapd.conf file to where CFGFILE variable from tox-bootstrapd.sh points to. By default it's /etc/tox-bootstrapd.conf.

sudo cp tox-bootstrapd.conf /etc/tox-bootstrapd.conf

Go over everything in the copied tox-bootstrapd.conf file. Set options you want and add actual working nodes to the bootstrap_nodes list, instead of the example ones, if you want your node to connect to the Tox network. Make sure pid_file_path matches PIDFILE from tox-bootstrapd.sh.

Look at the variable declarations in the beginning of tox-bootstrapd.sh init script to see if you need to change anything for it to work on your system. The default values must be fine for most users and we assume that you use those next.

If you have configured the daemon to use any port numbers that are lower than 1024, you need to execute the command below, as by default non-privileged users cannot open ports <1024. The change persists through reboot:

sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/tox-bootstrapd

Copy tox-bootstrapd.sh init script to /etc/init.d/tox-bootstrapd (note the disappearance of ".sh" ending):

sudo cp tox-bootstrapd.sh /etc/init.d/tox-bootstrapd

Set permissions for the init system to run the script:

sudo chmod 755 /etc/init.d/tox-bootstrapd

Make the init system aware of the script, start the daemon and verify it's running:

sudo update-rc.d tox-bootstrapd defaults
sudo service tox-bootstrapd start
sudo service tox-bootstrapd status

Get your public key and check that the daemon initialized correctly:

sudo grep "tox-bootstrapd" /var/log/syslog

Updating

You want to make sure that the daemon uses the newest toxcore, as there might have been some changes done to the DHT, so it's advised to update the daemon at least once every month.

To update the daemon first stop it:

sudo service tox-bootstrapd stop

Then update your toxcore git repository, rebuild the toxcore and the daemon and make sure to install them.

Check if tox-bootstrapd.sh in toxcore git repository was modified since the last time you copied it, as you might need to update it too.

After all of this is done, simply start the daemon back again:

sudo service tox-bootstrapd start

Troubleshooting

  • Check daemon's status:
sudo service tox-bootstrapd status
  • Check the log for errors:
sudo grep "tox-bootstrapd" /var/log/syslog
  • Check that variables in the beginning of /etc/init.d/tox-bootstrapd are valid.

  • Make sure tox-bootstrapd user has write permission for keys and pid files.

  • Make sure tox-bootstrapd has read permission for the config file.

  • Make sure tox-bootstrapd location matches its path in the /etc/init.d/tox-bootstrapd init script.

For Docker users:

Setting up

If you are familiar with Docker and would rather run the daemon in a Docker container, you may download the latest official docker image. To download the latest image run:

docker pull toxchat/bootstrap-node:latest
docker run --rm -it --entrypoint=sha256sum toxchat/bootstrap-node:latest /usr/local/bin/tox-bootstrapd

This will print the SHA256 checksum of the latest binary, which should agree with the SHA256 checksum in the Dockerfile.

If you want to build the bootstrap node from source, check out the latest release:

git checkout $(git tag --list | grep -P '^v(\d+).(\d+).(\d+)$' | \
  sed 's/v/v /g' | sed 's/\./ /g' | \
  sort -snk4,4 | sort -snk3,3 | sort -snk2,2 | tail -n 1 | \
  sed 's/v /v/g' | sed 's/ /\./g')

and run the following from the top level c-toxcore directory:

tar c $(git ls-files) | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node -

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
sudo chmod 700 /var/lib/tox-bootstrapd

docker run -d --name tox-bootstrapd --restart always \
  --user "$(id -u tox-bootstrapd):$(id -g 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 \
  toxchat/bootstrap-node

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.

You can check logs for your public key or any errors:

docker logs tox-bootstrapd

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.

Updating

You want to make sure that the daemon uses the newest toxcore, as there might have been some changes done to the DHT, so it's advised to update the daemon at least once every month.

To update the daemon, all you need is to erase current container with its image:

docker stop tox-bootstrapd
docker rm tox-bootstrapd
docker rmi toxchat/bootstrap-node

Then rebuild and run the image again:

tar c $(git ls-files) | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node -
docker run -d --name tox-bootstrapd --restart always \
  --user "$(id -u tox-bootstrapd):$(id -g 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 \
  toxchat/bootstrap-node

Troubleshooting

  • Check if the container is running:
docker ps -a
  • Check the log for errors:
docker logs tox-bootstrapd