Using WeeChat and weechat-android on Windows 11
Internet Relay Chat (IRC) is an old text-based chat system that, while seemingly in decline, still has many users around the world. It’s not as convenient as modern alternatives, but for those of us that are familiar with it, and especially those of us that have friends there, it’s still a very viable way to communicate.
There are a number of IRC clients available. On windows, mIRC is popular and easy to set up, but it shows its age. IRCCloud is very convenient, especially if you want to use a mobile device, but it lacks some common features, and you are limited to two servers on the free account. There are other options, of course, but they all have limitations.
If you like doing things the hard way, you can use WeeChat like me. It’s powerful, has a bunch of plugins, and importantly, is still maintained. It also has a relay protocol that allows remote clients (like one on your phone) to read and respond to messages when you need to step away. It is, however, a terminal application, so it can take some getting used to.
WeeChat is built for Linux, but it is still very possible to run it on modern Windows. I’m confident you can get it working with the following steps.
Running WeeChat in a Podman Container
The best method I’ve found for running WeeChat is inside a Podman container. Podman is a container engine similar to Docker, but free on Windows. Setting it up to run WeeChat is rather easy:
- (Recommended, but not required): Install Windows Terminal:
winget install Microsoft.WindowsTerminal
- Download and install the Podman CLI from the Podman Releases page. See the Podman installation instructions for more info.
- Create a directory for storing WeeChat configuration and logs. I use
$HOME/OneDrive/WeeChat
in the examples here, but you can use any location you like - Run the following in Windows Terminal (PowerShell). Or better yet, save it as a script somewhere in your path for easy use later:
1
2
3
4
5
6if ((podman machine info | Out-String).Contains('machinestate: Stopped'))
{
podman machine start
}
podman run --rm -it --pull newer --env 'WEECHAT_HOME=/home/user/weechat' -v $HOME/OneDrive/WeeChat:/home/user/weechat --tz local weechat/weechat:latest-alpine weechat @args
And that’s it. You should now be running WeeChat.
Some notes about the startup script:
- The first block of the script runs the
podman machine start
command for you automatically if needed. This saves you a step the first time you run podman after each reboot of your computer - The container is being re-created and deleted every time it’s run (because of
podman run
and--rm
), and new images are automatically downloaded (because of--pull newer
). You could create a container and start it each time, but continually recreating it this way ensures that you get updates automatically when new images are published - the left half of
-v
specifies where data will be saved on your computer (outside the container). This is important, because everything else inside the container will be reset every time you run this script - The
--env
command forces WeeChat (via a supported environment variable) to write everything (configuration and logs) into a single folder inside the container which allows the file mapping with a single-v
- (Added 2024-10)
weechat @args
at the end of the command line allows the PowerShell script to pass arguments through to WeeChat. I have been using this to sometimes send the--no-connect
option when I want to prevent auto-connect or auto-join.
Why not use WSL directly
It is absolutely possible to run WeeChat in WSL, but I prefer the Podman approach because:
- it’s easier to expose the WeeChat Relay port - I found it difficult to share a port for an app in WSL to my local network
- you get updates to WeeChat automatically without running
apt update; apt upgrade
- you are certain no state is being secretly left behind inside the WSL environment
- you don’t have to worry about breaking WeeChat if you break WSL, and don’t lose anything if you decide to reset it
- it uses less space. The normal Ubuntu image used by WSL is pretty big, which is wasteful if you aren’t using it for anything else
Using WeeChat Relay and a mobile client
One of the main reasons I went with WeeChat was the WeeChat Relay protocol and clients like weechat-android. This allows you to keep WeeChat running on your main computer, but access it remotely to check for or respond to messages. I find this handy when I need to do a chore or take a break. Because IRC depends on persistent connections, it is hard to use it (reliably) on a mobile device directly. And because WeeChat is exposing the relay, people don’t even know that you’re switching devices.
You can set up the relay service with the following steps. There are also detailed instructions in the documentation if you have specific questions.
- Make up a password
- Use the following commands in WeeChat to store the password, and use it for your relay server:
1
2/secure set relay new_password
/set relay.network.password "${sec.data.relay}" - Use the following command in WeeChat to enable WeeChat Relay:
1
/relay add weechat 9500
- Run the following in PowerShell (as Administrator) to allow WeeChat Relay through the Windows firewall, and to proxy any traffic from the local network to the relay in the container:
1
2
3New-NetFirewallRule -DisplayName "WeeChat Relay" -Direction Inbound -Protocol TCP -LocalPort 9500 -Action Allow
netsh interface portproxy set v4tov4 listenport=9500 listenaddress=0.0.0.0 connectport=9500 connectaddress=127.0.0.1 - Add the following to the
podman run
command to expose the relay port from the container:-p 9500:9500
. The complete command will now be:1
podman run --rm -it --pull newer --env 'WEECHAT_HOME=/home/user/weechat' -v $HOME/OneDrive/WeeChat:/home/user/weechat --tz local -p 9500:9500 weechat/weechat:latest-alpine weechat @args
- Install weechat-android on your Android device. I haven’t found an iOS equivalent. If you have one you’d recommend, please post it in the comments.
- Configure your client. You can use the following settings in weechat-android:
- Connect type: Plain Connection
- Relay host: IP address of the computer running WeeChat (inside your network)
- Relay port: 9500
- Relay password: The password you created earlier
As long as WeeChat is running on your computer, and the client is connected to the same network, you should now be able to connect to the relay.
If you want to access WeeChat relay from outside your home, you’ll have to set up some sort of vpn to your home network. I do not suggest opening this port to the internet directly without setting up TLS encryption first.
Setting up WeeChat Relay with TLS
WeeChat supports TLS for the relay protocol, which makes it much safer for connections going over the internet. However, it requires a DNS record that points to your WeeChat instance, and a self-signed certificate that matches the name. This appears to be a security limitation in Android itself, so you’ll have to deal with it if you want TLS.
For my own purposes, I stuck an A record in one of my domains that points to the local fixed IP address of my main computer. If you’re also using the relay protocol over your home network, you could use a dynamic DNS service like Duck DNS that allows you to specify the IP address manually. Dynamic DNS will also be helpful if you are opening the port to the internet from your router.
Once you have DNS figured out, generating a self-signed certificate can be done relatively easily.
- Run the following in PowerShell to start an interactive shell in a temporary container:
1
podman run --rm -it -v $HOME/OneDrive/WeeChat:/weechat --entrypoint sh alpine/openssl
- Note: Make sure the directory mapping (on the left) matches the location on your host machine where you store your WeeChat data.
- Run the following with the DNS name you set up:
1
export HOSTNAME=yourweechatrelay.duckdns.org
- Run the following to generate a self-signed certificate in the WeeChat directory:
1
2
3
4mkdir -p weechat/tls
openssl req -x509 -newkey rsa:4096 -nodes \
-keyout weechat/tls/relay.pem -out weechat/tls/relay.pem \
-days 3650 -subj "/CN=$HOSTNAME" -addext "subjectAltName=DNS:$HOSTNAME" - Run
exit
to stop the container - Run the following in WeeChat to replace the relay server with a TLS-enabled relay server
1
2
3/relay del weechat
/set relay.network.tls_cert_key "${weechat_config_dir}/tls/relay.pem"
/relay add ssl.weechat 9500
From weechat-android, you can change the Connect type to “WeeChat SSL”. The next time you connect, you’ll be asked to verify the certificate. After this all communication between WeeChat and your client should be encrypted.