How to setup soju (the IRC bouncer)

· Francesco · 4 min read · 782 words
Table of Contents

Photo by Ansel Lee from Pexels

Recently I got back to IRC (Internet Relay Chat). Actually, I’ve never really been on that side of the internet, so I didn’t get back, I’m just exploring a new world.

The first thing I noticed is that it’s full of experienced people with incredible knowledge. They know everything and, most importantly, they’re so friendly. Even if you don’t know something, they are there to help you (if you want to be helped). However, since there’s no centralized server, when I close my laptop or quit the application I don’t receive any messages from others.

So it can happen that you ask for something, wait 30 minutes, then quit because you need to do other stuff, and you lose the answer if someone replies. That’s where soju comes in! (or znc if you prefer).

What’s a bouncer?

An IRC bouncer is a piece of software that stays connected to IRC on your behalf. Think of it as a middleman: it sits on a server, keeps the connection alive 24/7, and buffers all the messages. When you reconnect from your laptop or phone, it replays everything you missed.

Without a bouncer you’d have to stay connected all the time to not miss anything, which is annoying and not really practical.

Requirements

  • soju (obv)
  • A server that’s always on (it could be your Raspberry Pi or a VPS)
  • An IRC client (I’m using halloy)

Setup

Admin user

The first step is to create an admin user using sojudb:

1
$ sojudb create-user <username> -admin

Config file

Now it’s time to update the config file. The file we’re looking for is /etc/soju/config, add these lines:

1
2
3
4
5
6
hostname <your_server_domain>
db sqlite3 /etc/soju/main.db
listen ircs://0.0.0.0:6697
listen unix+admin:///run/soju/admin.sock
tls /etc/soju/fullchain.pem /etc/soju/privkey.pem
message-store fs /var/lib/soju/logs/

Explanation:

  • hostname: this is the public domain or IP of your server (I use 127.0.0.1)
  • db: where soju stores its database
  • listen ircs://0.0.0.0:6697: the main listener, I use ircs:// (IRC over TLS) on port 6697
  • listen unix+admin:///run/soju/admin.sock: a Unix socket for local admin commands
  • tls: path to your TLS certificate and private key
  • message-store fs: where soju logs messages

TLS certificates

Remember that we need the TLS keys to enable IRCs (the secure version of IRC). I generated them using certbot, but you can use whatever software you want.

Then copy the certificates to the paths you specified in the config.

Remember to add port 6697 to the firewall and/or WAF.

Soju user

Now we need to create the user that we’ll actually use to connect to the bouncer. The admin user we created earlier is for managing soju, this one is for everyday IRC usage. We’re going to use sojuctl:

1
$ sojuctl -config /etc/soju/config user create -username <username> -password <password>

Starting soju

If you installed soju from a package, it probably came with a systemd service. Enable and start it:

1
2
$ sudo systemctl enable soju
$ sudo systemctl start soju

You can check if everything is running fine:

1
$ sudo systemctl status soju

IRC client setup

I’m using halloy as my IRC client, so you’ll need to adjust the configuration for your preferred client. In halloy, add this to your config file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[servers.soju]
nickname = "<username>"
server = "<server_ip_or_url>"
port = 6697
use_tls = true
autoconnect = true

[servers.soju.sasl.plain]
username = "<username>@pc"
password = "<password>"

Connecting

Open your IRC client and message BouncerServ. This is soju’s built-in management bot: you use it to configure your networks, set up authentication, and more:

1
/msg BouncerServ help

This will list all available commands. Now let’s connect to a network. I’m going to connect to Libera.Chat:

1
/msg BouncerServ network create -name libera -addr irc.libera.chat -port 6697 -tls

This tells soju to create a new network called libera that connects to irc.libera.chat on port 6697 with TLS enabled. You can add as many networks as you want this way.

After adding the network, you can list your configured networks with:

1
/msg BouncerServ network list

Automatic login

To set up automatic login, Libera.Chat uses SASL (Simple Authentication and Security Layer). This way you authenticate directly through the bouncer without needing to manually identify every time. Just message BouncerServ and type:

1
/msg BouncerServ sasl set-plain -network libera <nickserv_username> <nickserv_password>

Replace <nickserv_username> and <nickserv_password> with your actual Libera.Chat NickServ credentials.

Restart Halloy and you should connect and authenticate automatically!

Channels

One nice thing about soju: if you use /join #channel, the bouncer will automatically add the channel to your list permanently. You don’t need to set up any autojoin feature.

Documentation

If you want to learn more or customize soju, see here.