Running Diarkis Server In Local Environment

We will explain how to prepare for local Diarkis server development.

Preparation

Make sure you have golang 1.16 or higher version. If not, please install it.
Diarkis server development can be done on Linux or macOS.

This document has been tested on Ubuntu 20.04 (WSL1 on Windows 10).
Please use WSL1 because WSL2 does not support UDP forwarding.
If you are not using WSL1, you can start PowerShell with administrator privileges and use the command "wsl --set-version Ubuntu-20.04 1" to convert the WSL environment.

Diarkis CLI Installation

Download the CLI for your environment from here and pass the PATH.
If PATH is passed, the following commands will work.

$ diarkis-cli
Usage:
  diarkis-cli [command]

Available Commands:
  build
  help        Help about any command
  version     Print the version number of diarkis-cli

Flags:
      --builderToken string
  -h, --help                  help for diarkis-cli
      --host string
      --port string            (default "443")
      --projectId string
      --verbose
  -v, --version               version for diarkis-cli

Use "diarkis-cli [command] --help" for more information about a command.

Download and Deployment of Server Templates

Download the server template from here and go to the directory where you extracted it.
You can generate boilerplate for your project with the following command

$ make init project={name of your application} project_id={project ID} builder_token={build token} output={absolute path to install}

Do not include "/" at the end of the output value.

When the command is executed, the boilerplate of the server will be extracted to the path specified by output=.

Build with CLI

*In case of macOS

By adding the following description to build.yml, binaries for macOS will be generated. (If no description is added, binaries for Linux will be generated.)

GOOS: darwin
GOARCH: {Your Mac's CPU architecture}

Go to the boilerplate directory and execute the following command to generate a Diarkis server binary in the remote_bin directory.

$ diarkis-cli build --host builder.diarkis.io 
$ ls remote_bin/
http  mars  tcp  udp  ws

Grant execution rights to the generated binary.

$ chmod +x remote_bin/*
$ ls -la remote_bin/
total 41716
drwxr-xr-x 2 taz taz    4096 Aug  4 17:02 .
drwxr-xr-x 8 taz taz    4096 Aug  4 17:02 ..
-rwxr-xr-x 1 taz taz 8061543 Aug  4 17:02 http
-rwxr-xr-x 1 taz taz 7838259 Aug  4 17:02 mars
-rwxr-xr-x 1 taz taz 8749492 Aug  4 17:02 tcp
-rwxr-xr-x 1 taz taz 8816139 Aug  4 17:02 udp
-rwxr-xr-x 1 taz taz 9232273 Aug  4 17:02 ws

Start locally

Run mars

$ ./remote_bin/mars ./configs/mars/main.json

Run http

$ ./remote_bin/http ./configs/http/main.json

Run udp

$ ./remote_bin/udp ./configs/udp/main.json

Obtaining connection information

If mars, http, or udp is running, connection information can be retrieved.

$ curl http://127.0.0.1:7000/auth/test
{"UDP":"127.0.0.1:7100","sid":"2d3320600d874d848a60863ecb7da67e","encryptionKey":"6e9c529042c3415d8ed84289f28fc1b2","encryptionIV":"2bda04b8011a4ed2b73e5463b7db4d90","encryptionMacKey":"0876954d76e74411971a7a59e331c83a"}