Build
We're now going to discuss how to build the binary for the groups.fiatjaf.com example provided by the relay29 repository which uses the Khatru29 wrapper.
Dependencies
Before building the binary, we need to install Go and Git.
Git
We need to install Git to be able to clone the relay29 repository:
Go
We're now going to discuss how to install Go on your relay.
First, you need to determine which version of Go you want to install which you can do by going to the All releases page on the Go website.
Make sure to choose the appropriate download file for your relay's operating system (OS) and architecture. Since we're using Debian with an AMD processor, we're going to download the linux-amd64
file.
At the time of writing the current version of Go is 1.23.2
, so we'll be downloading the go1.23.2.linux-amd64.tar.gz
file.
We'll be downloading the file to the /tmp
directory which is cleared when the system reboots. We’ll be downloading the file here because we won’t need this file after the installation process is completed.
Since we're using a headless server, we can use the wget
command to download Go:
Be sure to replace go1.23.2.linux-amd64.tar.gz
with whatever version of Go you're downloading and with whatever architecture you're using.
Before extracting the contents of the file, be sure to first remove any previously installed version of Go:
You can now extract the contents of the file into the /usr/local
directory:
Be sure to not extract the contents into an already existing /usr/local/go
directory since this can break the Go installation.
After successfully extracting the contents, you should see a go
directory in the /usr/local
directory:
You can now add /usr/local/go/bin
to the PATH
environment variable by adding export PATH=$PATH:/usr/local/go/bin
to your $HOME/.bashrc
file.
First, open the file with a text editor of your choice, e.g., nano
:
Then add the following to the end of the file:
Save the changes made to the .bashrc
file and exit the editor.
The changes may not take effect until after you log back into the server.
To apply the changes immediately run:
Verify the installation was successful by running:
The command should output:
Clone the Repository
Before cloning the relay29 repository, we're going to first create the following directories in the $HOME
directory:
We can now navigate to the relays
directory:
We're now ready to clone the relay29 repository:
After cloning the repository, navigate to the relay29/examples/groups.fiatjaf.com
directory:
You can use the repository to update Khatru29, so we're going to keep the repository on the relay.
Build Khatru29 Example
We're now ready to build the groups.fiatjaf.com
example which uses the Khatru29 wrapper:
The compilation could take a while depending on your server's specs, so be patient while the binary is being built.
When the compilation is finished the binary will be located in the relay29/examples/groups.fiatjaf.com
directory.
You can list out the contents of that directory to see the binary:
You should see the binary file which should be named groups.fiatjaf.com
.
We're going to use a more general name for the binary by renaming it to khatru29
:
Check Version
At the time of writing, the latest version of the relay29 library is v0.4.0
which is what the rest of the guide is currently based on.
Run Binary
To run Khatru29 you need to provide a secret key which will be used as the relay's private key.
Be sure to input your secret key securely, i.e., don't let anyone, any camera, etc. see your secret key, clear your clipboard if you're copying and pasting the value, turn off your terminal history on your server, etc.
The server terminal is using bash
, so you can temporarily turn off the history for the current shell session by running:
You can now run the binary:
DOMAIN="relay.relayrunner.xyz" RELAY_NAME="Relay Runner's Khatru29 Relay" RELAY_PRIVKEY="<your-secret-key>" ./khatru29
Be sure to replace the values of the following:
-
DOMAIN
with the domain name of your server -
RELAY_NAME
with the name you're going to use with your relay -
RELAY_PRIVKEY
with the secret key you're going to use with your relay which should be passed as a 32-byte hex
Khatru29 should now be listening on 0.0.0.0:5577
. A relay database will also be created in your current directory called db
.
To stop the relay press Ctrl+C
.
If you were able to successfully run the binary, you can turn on the history for the current shell session by running: