- Alexis Métaireau
- Journal
- Code, etc.
- Notes hebdo
- Lectures
- Projets

It’s been a while since I’ve used IRC, but I needed to connect to it today to discuss around Peewee.

The main issue with IRC is that you need to be connected to see the answer, and to get the context of the conversation. Unless… you set up a bouncer.

The bouncer is named ZNC, and the IRC client I use is Weechat.

So, that’s what I did:

## Installation of ZNC

    apt install znc
    sudo -u _znc /usr/bin/znc --datadir=/var/lib/znc --makeconf
    sudo systemctl enable znc

You can answer the questions asked by `--makeconf`, it will generate you a configuration file like this (stored in `/var/lib/znc/configurations/znc.conf`):

    AnonIPLimit = 10
    AuthOnlyViaModule = false
    ConfigWriteDelay = 0
    ConnectDelay = 5
    HideVersion = false
    LoadModule = webadmin
    MaxBufferSize = 500
    ProtectWebSessions = true
    SSLCertFile = /var/lib/znc/znc.pem
    SSLDHParamFile = /var/lib/znc/znc.pem
    SSLKeyFile = /var/lib/znc/znc.pem
    ServerThrottle = 30
    Version = 1.8.2

    <Listener listener0>
        AllowIRC = true
        AllowWeb = true
        IPv4 = true
        IPv6 = true
        Port = 6697
        SSL = true
        URIPrefix = /
    </Listener>

    <User alexis>
        Admin = true
        Allow = *
        AltNick = alexis_
        AppendTimestamp = false
        AuthOnlyViaModule = false
        AutoClearChanBuffer = true
        AutoClearQueryBuffer = true
        BindHost = skate.notmyidea.org
        ChanBufferSize = 50
        DenyLoadMod = false
        DenySetBindHost = false
        Ident = alexis
        JoinTries = 10
        LoadModule = chansaver
        LoadModule = controlpanel
        MaxJoins = 0
        MaxNetworks = 1
        MaxQueryBuffers = 50
        MultiClients = true
        Nick = alexis
        NoTrafficTimeout = 180
        PrependTimestamp = true
        QueryBufferSize = 50
        QuitMsg = See you :)
        RealName = N/A
        StatusPrefix = *
        TimestampFormat = [%H:%M:%S]

        <Network liberachat>
            FloodBurst = 9
            FloodRate = 2.00
            IRCConnectEnabled = true
            JoinDelay = 0
            LoadModule = simple_away
            RealName = N/A
            Server = irc.libera.chat +6697
            TrustAllCerts = false
            TrustPKI = true

            <Chan #peewee>
            </Chan>
        </Network>

        <Pass password>
            Hash = REDACTED
            Method = SHA256
            Salt = REDACTED
        </Pass>
    </User>

You can access a web interface on the exposed port. I had to make a change in my Firefox configuration, in `about:config`, set `network.security.ports.banned.override` to `6697`, otherwise, Firefox prevents you from connecting to these ports (which might actually be a good idea).

## Weechat configuration

Now, to use this in weechat, here are some useful commands. First, get the fingerprint of the SSL certificate generated on your server:

    cat /var/log/znc/znc.pem | openssl x509 -sha512 -fingerprint -noout | tr -d ':' | tr 'A-Z' 'a-z' | cut -d = -f 2

Then, in weechat :

    /server add znc host/6697 -tls -username=<username> -password=<yourpass> -autoconnect
    /set irc.server.znc.tls_fingerprint <fingerprint-goes-here>
    /connect znc

And you should be all set!

Resources : The ZNC Wiki on Weechat and the Debian page on ZNC

#ZNC, #Weechat, #IRC - Posté dans la catégorie code