Skip to content
On this page

Self Deployment

Prerequisites

ForNet is a client-server model program, you need to deploy server firstly, and ForNet now needs relay node to let devices connect each other. You need have a linux server to deploy the relay instance. We are in hard work to build SaaS backend server and implement p2p connection feature. You would only need to install client then.

If you like to build ForNet from the source code, please refer Develop Guide for more information.

Client

you can download client binary app at Github release page, it now supports macOS、Linux and Windows 11. Client needs root/administrator permission to run, unix is to create tun, Windows is to install driver.

Server

The manager server is written by Scala 3, you can deploy the jar or docker image. It uses Postgres to store data. and uses rmqtt to interact with client.

There is docker-compose.yml for quick start, you can ship it with:

shell
# must be in the directory
# it needs config files of backend and rmqtt
cd /command/docker-compose/simple
docker-compose up

If you would like to deploy with docker step by step, you can follow this:

Postgres

shell
# If platform is Mac/Windows, change --network=host to -p 5432:5432
docker run -d  --name postgres --network=host \
-e POSTGRES_PASSWORD=tnet_db_password \
-e POSTGRES_DB=tnet_db \
-e POSTGRES_USER=postgres \
-v $(pwd):/var/lib/postgresql/data \
postgres:15

Deploy RMQTT Docker

Here is an example of rmqtt config, you can run it after changed backend server url in config/plugin/rmqtt-auth-http.toml.

More details about RMQTT can be found here.

shell
cd /command/docker/mqtt
# RMQTT will use port:
# 1883(mqtt) 6060(http api) 5363(grpc)
docker run -d --name mqtt --network=host \
 -v $(pwd)/log:/var/log/rmqtt \
 -v $(pwd)/config/rmqtt.toml:/app/rmqtt/rmqtt.toml \
 -v $(pwd)/config/plugin:/app/rmqtt/plugin \
 rmqtt/rmqtt:latest

Deploy Server Docker

There is two config file: application.conf and logback.xml, you can get the example here. More details about config can be found here.

shell
# run server with database init, 8080 is for http api, 9000 is for grpc.
docker run -it -d \
-p 8080:8080 -p 9000:9000 \
-v ${local_machine/applcation.conf+logback.xml/path}:/config \
--name=fornet-backend \
fornetcode/fornet-backend:latest

Up and Running

Create Network

After the backend server up, visit the backend website: http://127.0.0.1:8080, If you use simple auth, just type the config value of auth.simple.token to login in. Then you could create network, and get invite code to let client node join in.

Client Join Network

There's fornet and fornet-cli, fornet is the background service, fornet-cli is used to interact with fornet.

shell
# run fornet in background 
sudo fornet &
# you could get the invite cod from the admin web.
sudo fornet-cli join ${invite code}

You can also use docker in Linux(thisdoes not support macOS, indows).

shell
# export config to host, otherwise private.key will miss if image delete
docker run -it --name=fornet \
--cap-add=NET_ADMIN \
--network=host \
--device=/dev/net/tun \
-v ${config_path}:/config \
fornet:latest
# join  network
docker exec -it fornet fornet-cli join ${invite code}

Auto Launch

Linux

ForNet now don't support automatically start after host reboot in Linux, you can get it with Systemd.

cp fornet /usr/local/bin/

create the Systemd configuration file at /etc/systemd/system/fornet.service

[Unit]
Description=ForNet client daemon
After=network.target

[Service]
Type=simple
User=root
Restart=always
ExecStart=/usr/local/bin/fornet

[Install]
WantedBy=multi-user.target

After that you're supposed to reload systemd:

systemctl daemon-reload

Launch fornet on system startup with:

systemctl enable fornet

Launch fornet immediately with:

systemctl start fornet

macOS

shell
sudo fornet-cli launch enable

What's More

If you are interested with this project, you can go roadmap to get more information.

Documentation released under CC 4.0 License