running-an-irc-server.md

  1---
  2title: Running an IRC server
  3description: Easy guide on setting up a modern IRC server
  4author: Amolith
  5cover: /assets/pngs/irc.png
  6date: 2020-12-05T16:55:00-04:00
  7toc: true
  8categories:
  9  - Technology
 10tags:
 11  - IRC
 12  - Chat
 13  - Oragono
 14  - Sysadmin
 15---
 16
 17Many people will disagree but I think IRC is still one of the best chat
 18platforms there is for a [number of
 19reasons.](https://drewdevault.com/2019/07/01/Absence-of-features-in-IRC.html)
 20However, the documentation surrounding it is sometimes lacking, commands
 21are esoteric and can differ from server to server, some networks have
 22stupid requirements/defaults, etc. But who says you have to join them?
 23IRC is very easy to set up, use, and maintain and this post should be a
 24decent guide on doing just that.
 25
 26## Picking an IRCd
 27
 28First, `ircd` is short for *IRC daemon*; it's just a server running in
 29the background. Second, there are a *ton* of choices, from
 30[charybdis](https://github.com/charybdis-ircd/charybdis) and
 31[ngIRCd](https://github.com/ngircd/ngircd/) to
 32[UnrealIRCd,](https://www.unrealircd.org/)
 33[InspIRCd,](https://www.inspircd.org/) and many others. The ircd this
 34guide will focus on is [Oragono](https://oragono.io/) because it's one
 35of the simpler options yet has support for [IRCv3](https://ircv3.net/)
 36and comes with [services](https://en.wikipedia.org/wiki/IRC_services)
 37out of the box.
 38
 39## Setup
 40While we could run Oragono as root or under whatever account you use,
 41that's a stupid idea. We're going to create an `oragono` user to make
 42sure things are properly separated.
 43
 44``` bash
 45adduser --disabled-login oragono
 46```
 47
 48Press the enter key a bunch of times and you're good. After that, run
 49`sudo su - oragono` to log into that user account then head to the
 50[GitHub releases
 51page](https://github.com/oragono/oragono/releases/latest) and download
 52the latest gzipped tarball[^1] for your architecture. Decompress it with
 53`tar xvf oragono-*.tar.gz`. I *don't* recommend renaming the folder to
 54something else; having the version name right there will make it easy to
 55figure out when you need to upgrade in the future.
 56
 57Copy the default config to the production config with `cp default.yaml
 58ircd.yaml`, open it in your favourite TUI editor, and start exploring
 59the options! The file is commented very well but I'll list a few
 60specific options and values I recommend.
 61
 62## Configuration
 63* Obtain a TLS cert from [Let's Encrypt](https://letsencrypt.org/) and
 64  use it if possible. If not, use Oragono's self-signed certificates.
 65  Don't enable plaintext use.
 66* Consider setting [Tor](https://community.torproject.org/onion-services/) up
 67  and allowing users to connect through it.
 68* If you're using a TLS cert from Let's Encrypt (like you should be),
 69  set `sts.enabled` and `sts.preload` to `true`.
 70* Unless you specifically want [IRC
 71  cloaks](https://meta.wikimedia.org/wiki/IRC/Cloaks) to indicate
 72  position, status, or affiliation, set `lookup-hostnames: true` and
 73  `forward-confirm-hostnames: false`.
 74* Always make a cool MoTD. It's essential for any IRC server.[^2] I
 75  recommend using something like
 76  [TAAG](https://www.patorjk.com/software/taag/) to come up with it.
 77* You *may* want to enable email authentication but it's a pain to set
 78  up properly. I haven't bothered.
 79* I recommend setting `channels.default-modes` to `+nts`. The `+s` flag
 80  just indicates that it's a secret channel and won't show up in the
 81  global list when someone runs `/list`. After creating a channel, if
 82  you want it publicly listed, just run `/mode -s`.
 83* You *may* want to uncomment `opers.admin.modes` but it can get very
 84  spammy when there are a lot of people on your server.
 85* If you plan to leave `history.enabled: true` and store channel message
 86  history server-side, I highly recommend setting
 87  `datastore.mysql.enabled` to `true` and going through that
 88  configuration.
 89* Roleplay can be fun so it's a good idea to look through that section.
 90* If you enabled `datastore.mysql`, also enable `history.persistent`
 91* For privacy reasons, I *highly* recommend setting
 92  `history.persistent.registered-channels` to `"opt-out"`. Message
 93  history will not be stored by default but the channel owner can decide
 94  to enable it if they wish. Same goes for
 95  `history.persistent.direct-messages`.
 96* I recommend enabling both of the options under `history.retention`.
 97
 98## Running the server
 99If you're using self-signed certs, run `./oragono mkcerts` and make sure
100the paths are correct in your `ircd.yaml`. Assuming your config is
101valid, you should be able to run `./oragono run` and connect to it. If
102you can't, make sure port 6697 is open, your credentials are correct,
103and nothing is wrong in the config.
104
105You can always run Oragono in [tmux](https://en.wikipedia.org/wiki/Tmux)
106or something but it would be much better to do it with
107[systemd,](https://en.wikipedia.org/wiki/Systemd)
108[OpenRC,](https://en.wikipedia.org/wiki/OpenRC)
109[runit,](https://en.wikipedia.org/wiki/Runit) etc. I personally use
110systemd and this service file should go in
111`/etc/systemd/system/oragono.service` or something similar.
112
113``` ini
114[Unit]
115Description=oragono
116After=network.target
117Wants=mysql.service
118After=network.target mysql.service
119
120[Service]
121Type=simple
122User=oragono
123WorkingDirectory=/home/oragono/oragono
124ExecStart=/home/oragono/oragono/oragono run --conf /home/oragono/oragono/ircd.yaml
125ExecReload=/bin/kill -HUP $MAINPID
126Restart=on-failure
127LimitNOFILE=1048576
128
129[Install]
130WantedBy=multi-user.target
131```
132
133Run the following commands to ensure Oragono starts when your server boots.
134
135``` bash
136systemctl daemon-reload
137systemctl enable --now oragono
138```
139
140## Commands
141As I said in the first section, IRC has a lot of commands and they can
142be confusing to work with. I still don't know everything I should. That
143said, here are a (very) few of the essentials:
144
145| Command  | Example          | Operation                                  |
146|----------|------------------|--------------------------------------------|
147| `/quote` | `/quote helpop`  | Send argument as a command to the server   |
148| `/join`  | `/join #channel` | Join a channel                             |
149| `/leave` | `/leave`         | Leave a channel                            |
150| `/me`    | `/me yawns`      | Result will look like `* Amolith yawns`    |
151| `/query` | `/query amolith` | Open a direct message buffer with amolith  |
152| `/mode`  | `/mode -s`       | Add/remove flags from a channel[^3]        |
153| `/op`    | `/op amolith`    | Make amolith a channel operator            |
154| `/voice` | `/voice amolith` | Let amolith speak when channel set to `+M` |
155
156The one command *every* Oragono oper[^4] should know is `/quote helpop
157index`. It will list all the available commands so you can read through
158them and discover what each does.
159
160You've reached the end of the post. You are now disallowed from telling
161anyone that IRC is too complicated. If you want to test a server you're
162setting up, feel free to use my instance of [The
163Lounge;](https://thelounge.chat/) it's at
164[irc.nixnet.services](https://irc.nixnet.services/) and any IRCd details
165can be entered but mine are default. Speaking of my IRC server, you
166should [join #secluded](ircs://irc.nixnet.services:6697/secluded) and
167mention this post :D
168
169[^1]: A *gzipped tarball* is just a compressed archive like a zip file
170[^2]: You should definitely [join
171    mine](https://docs.nixnet.services/IRC) and look at our awesome MoTD
172[^3]: See `/quote help cmodes` for all the flag options
173[^4]: Short for [IRC operator](https://en.wikipedia.org/wiki/IRC_operator)