IRC Load Balancer

I wrote an IRC load balancer for my kubernetes cluster
Posted on 03 Mar 2020 by Mr. Ree in tech

Unfortunately with digital ocean only 1 type of load balancer is supported and it either does HTTP(S), TCP, or UDP connections to a backend server. In web applications and UDP applications this is okay because the source address is either given or spoofed to the service. Unfortunately in the world of IRC it's a little bit different.
To get the client's IP from a load balancer requires the load balancer to send the WEBIRC command along with a configured password. This is where irclb steps in!

With irclb, you simple npm i irclb, configure, then run irclb with the new configuration. By default, irclb will listen on non-ssl port 6667 and ssl port 6697. Connecting to the non-ssl port simply tells the user that they must use SSL to connect to the server and then disconnects them.
The IRC connection is made over SSL, so please bear that in mind when configuring your load balancer.


{
    "network": {
        "name": "6697",
        "host": "irc.6697.co.uk"
    },
    "listener": {
        "address": "0.0.0.0",
        "port": 6697,
        "plainPort": 6667,
        "ssl": {
            "key": "/etc/irclb/key.pem",
            "cert": "/etc/irclb/cert.pem"
        }
    },
    "servers": [
        {
            "host":"10.0.0.5",
            "port":6697,
            "webirc":{
                "username": "irclb",
                "password": "superSecretPassword:)"
            }
        }
    ]
}
    
Once configured, you can run the program like this (assuming your configuration is in /etc/irclb/config.json): irclb --config /etc/irclb/config.json
Also make sure webirc is configured properly on the IRCd or you will not get connection information such as IP and hostname of the client.


Published: