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