IRCD

From Wikitech
If you're looking for instructions on managing our IRC channels, please check the Libera Chat instructions.

This page discusses IRC notification for recent changes on Wikimedia wikis, with a particular focus on the setup of the server at irc.wikimedia.org. It also gives a simplified method to set up IRC notification on your own MediaWiki server.

Clients can instead use HTTP to connect to the Event Platform/EventStreams service on stream.wikimedia.org as a modern alternative to monitoring IRC channel activity.

Services

If for some reason kraz (the vm that currently hosts this service) has to be restarted, 2 main things have to be running:

root@kraz:/usr/local/bin$ systemctl status ircd
● ircd.service - IRCd for Mediawiki RecentChanges feed
   Loaded: loaded (/etc/systemd/system/ircd.service; disabled)
   Active: active (running) since Sun 2016-05-22 14:47:20 UTC; 1h 12min ago
 Main PID: 1175 (ircd)
   CGroup: /system.slice/ircd.service
           └─1175 /usr/bin/ircd -foreground

root@kraz:/usr/local/bin$ systemctl status ircecho
● ircecho.service - IRC bot for the MW RC IRCD
   Loaded: loaded (/etc/systemd/system/ircecho.service; disabled)
   Active: active (running) since Sun 2016-05-22 16:00:04 UTC; 2s ago
 Main PID: 7972 (python)
   CGroup: /system.slice/ircecho.service
           └─7972 python /usr/local/bin/udpmxircecho.py

There is a bug, that makes ircecho start before ircd, making IRC up but changes not work- ircecho must be started after ircd. This should be enforced by systemd init, and it is currently tracked on T134875.

Otherwise, the following error will be produced by udpmxircecho:

May 22 15:59:07 kraz udpmxircecho.py[934]: Not connected.

pmtpa

This page contains historical information. It may be outdated or unreliable.

We use a patched version of ircd-ratbox (a fork of ircd-hybrid), running on ekrem. It can be started with:

su -c /usr/local/ircd-ratbox/bin/ircd irc

There's no need to run it in the background, it forks automatically. The RC bot works as follows:

  • RecentChange::save() sends UDP packets to ekrem. The data sent is IRC-ready, and prefixed with the channel name as specified by $wgRC2UDPPrefix (in InitialiseSettings.php)
  • udpmxircecho.py receives the UDP packets and connects to the local ircd. The oper password is inside udpmxircecho.py, so don't check it in to CVS. It's restricted by hostname so it's not a huge issue, it's just the principle of the thing.
ircd-ratbox-notalk.patch in our SVN

The configure line is:

./configure --enable-services --with-nicklen=50 --with-topiclen=300 --enable-ipv6 --prefix=/usr/local/ircd-ratbox

IRCD can be configured at runtime by changing /usr/local/ircd-ratbox/etc/ircd.conf and either restarting or rehashing. Rehashing can be done by either sending the "rehash" command when logged in as an oper, or sending SIGHUP to the daemon. Restarting has the disadvantage of disconnecting everyone, resetting the channel list, and possibly crashing mxircecho.py. Rehashing sometimes causes ircd to lock up with 100% CPU, requiring a restart.

To update the MOTD, change the file and then send SIGUSR1.

Documentation for ircd-ratbox is poor. The best source for information about ircd.conf is apparently etc/example.conf. Some configuration variables can be changed by opers using /set. Quite a lot of server information is available with /stats. Documentation for oper commands is available with /help (/raw help in mIRC).

Starting the bot

After ircd is restarted, you will want to start up the bot if it is not running already.

systemctl start ircecho

will get it going.

You can check the status with systemctl status ircecho

If it appears to be running but it not logged in on IRC it might be T134875, in that case restart it with systemctl restart ircecho

Firewall

The UDP receiver needs to be firewalled to avoid allowing people to RC lines to it from external networks. Typical configuration with iptables:

iptables -A INPUT -p udp --dport 9390 -s 208.80.152.0/22 -j ACCEPT
iptables -A INPUT -p udp --dport 9390 -s 10.0.0.0/8 -j ACCEPT
iptables -A INPUT -p udp --dport 9390 -j DROP

Most distros provide a facility to set up firewall rules like these on startup, use the standard method.

How to do it on your own server

We get a lot of questions on how to set up IRC notification for non-Wikimedia wikis. Here is the procedure. You need two programs:

  • Some simple IRC client such as ircII with the -d switch.
  • A netcat which supports UDP receive, such as GNU netcat

Put this in your LocalSettings.php:

$wgRC2UDPAddress = '127.0.0.1'; # the host where the IRC client is running
$wgRC2UDPPort = 9390; # or whatever
$wgRC2UDPPrefix = '';

Now start your IRC client. Here's the command line for the above suggested configuration:

netcat -ulp 9390 | irc -d -c \#channelname nickname irc.example.com &

For multiple wikis, I suggest you use a different port number for each one, and a separate IRC connection. This should be OK for up to about 10 wikis. Wikimedia uses a more complex setup to multiplex IRC connections, but this should be unnecessary for small installations.

Reloading config

One can send SIGHUP to the ircd process to have it reload its config or send SIGUSR1 to have it reload its motd