WebSocket support

UnrealIRCd 4.0.10 and later support the WebSocket protocol. This allows HTML/Javascript clients to directly connect to IRC, without the need of intermediate 'gateways'.

1. Load the websocket module
Add this to your unrealircd.conf: loadmodule "websocket"; And then rehash the server.

Connect a client
You can now connect to your server from javascript using websockets. Use ws://yourip:port/

TODO: example code

Using SSL/TLS with websocket
Websocket has two URI's, ws:// which is plaintext and wss:// which is secure. This is similar to http and https, the former is plaintext and the later is over SSL/TLS.

First of all, you need to have a valid official SSL certificate for your server. You cannot use self-signed certificates as all browsers will reject them. How to acquire such a certificate is beyond the scope of this documentation. You can use a "real" certificate authority like Comodo or use free Let's Encrypt.

Now, you need to configure a special port for websocket:

listen { ip *; port 6800; options { ssl; }; ssl-options { certificate "ssl/server.cert.pem"; key "ssl/server.key.pem"; options { no-client-certificate; }; }; };

And then you can connect to this server from javascript using wss://ip:6800/

The key thing here is the no-client-certificate. This tells UnrealIRCd NOT to ask for a client certificate. If you don't do this then wss will work fine in Firefox but not on Chrome and possibly other browsers.

As you can see, the certificate and key can be specified for this specific port. This may be useful when using Let's Encrypt.

BONUS: Use port 443
If you are serious about using wss:// then you will want UnrealIRCd to be reachable on port 443 so your users can easily bypass firewalls they may encounter. Now, do NOT let UnrealIRCd listen directly on port 443 as this would require root privileges and must NOT run UnrealIRCd as root. Use a firewall redirect instead. On Linux you can use iptables to redirect traffic to port 443 to another port (like 6800 in the example of above). This way UnrealIRCd can still run as a low privileged user (eg: ircd).

The command (run this as root) would be: iptables -I PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 6800

NOTE: No other application should be using port 443! (eg: apache or nginx)