WeeChat: configure an IRC client with TLS, Tor and a ZNC bouncer
WeeChat memo: TLS connection, Tor proxy, ZNC bouncer, secrets, CTCP privacy and bar customisation.
Configuration memo for WeeChat (terminal IRC client): direct TLS connection, connection through Tor, using a ZNC bouncer, privacy settings, interface bars and useful commands. Values (servers, accounts, passwords) are generic examples.
Direct TLS connection
/server add examplenet irc.example.com/6697 -ssl
/set irc.server.examplenet.nicks "user1,user1_"
/set irc.server.examplenet.username "user1"
/set irc.server.examplenet.realname "user1"
/set irc.server.examplenet.command "/msg nickserv identify <PASSWORD>"
/set irc.server.examplenet.autojoin "#channel1,#channel2"
/set irc.server.examplenet.autoconnect on
By default WeeChat verifies the server certificate. /set irc.server.examplenet.ssl_verify off disables the check: avoid it unless the certificate is a known self-signed one (prefer ssl_fingerprint).
Connecting through Tor
Declare a local SOCKS5 proxy (Tor listens on 127.0.0.1:9050 by default), then attach it to the server.
/proxy add tor socks5 127.0.0.1 9050
/server add examplenet-tor exampleonionaddress.onion/443 -ssl -username=user1 -password='<PASSWORD>'
/set irc.server.examplenet-tor.proxy tor
/set irc.server.examplenet-tor.nicks "user1,user1_"
/set irc.server.examplenet-tor.autoconnect on
/set irc.server.examplenet-tor.autojoin "#channel1,#channel2"
/set irc.server.examplenet-tor.local_hostname "127.0.0.1"
Passwords should not stay in clear text in irc.conf: see the /secure section.
Registering or changing nickname (NickServ)
/nick user1_
/msg nickserv register <PASSWORD> user@example.com
/msg nickserv identify <PASSWORD>
Connecting to a ZNC bouncer
/server add ZNC 127.0.0.1/23200 -ssl -username=user1 -password='<PASSWORD>'
/set irc.server.ZNC.ssl_verify off
With ZNC the username can include the network: user1/network1, user1/network2. To stop WeeChat from switching to buffers automatically on join:
/set irc.look.buffer_switch_autojoin off
/set irc.look.buffer_switch_join off
ZNC commands from WeeChat (the alias saves typing /quote):
/alias add znc /quote znc
/znc Help
/znc LoadMod fail2ban
/znc *fail2ban help
/znc *fail2ban list
/znc *fail2ban ban 192.0.2.11
/znc *fail2ban un 192.0.2.11
/quote znc rehash
To pin the ZNC certificate, compute its SHA-512 fingerprint:
cat ~/.znc/znc.pem | openssl x509 -sha512 -fingerprint -noout | tr -d ':' | tr 'A-Z' 'a-z' | cut -d = -f 2
Storing secrets with /secure
/secure passphrase <passphrase>
/secure set zncpass <PASSWORD>
/server add ZNC 127.0.0.1/23200 -ssl -username=user1/network1 -autoconnect
/set irc.server.ZNC.password ${sec.data.zncpass}
/set irc.server.ZNC.ssl_fingerprint <sha512-fingerprint>
The password is then encrypted in sec.conf and referenced as ${sec.data.name}.
Exposing less information
/set irc.server_default.msg_part ""
/set irc.server_default.msg_quit ""
/set irc.ctcp.clientinfo ""
/set irc.ctcp.finger ""
/set irc.ctcp.source ""
/set irc.ctcp.time ""
/set irc.ctcp.userinfo ""
/set irc.ctcp.version ""
/set irc.ctcp.ping ""
/plugin unload xfer
/set weechat.plugin.autoload "*,!xfer"
This empties CTCP replies and part/quit messages, and disables the file transfer plugin (xfer).
Filtering join/part/quit messages
/set irc.look.smart_filter on
/filter add irc_smart * irc_smart_filter *
Common commands
/fset irc.* # browse irc options
/fset irc.server.examplenet.* # options of one server
/set *nicklist* # search for an option
/logger list
/set logger.file.auto_log off # disable logging (on to re-enable)
/logger disable
/mouse enable
/bar toggle nicklist
/buflist toggle
/set irc.look.server_buffer independent
Configuration is stored in ~/.weechat/irc.conf (and the other *.conf files in the same folder). On Arch Linux, pacman -Qi weechat shows whether the package and its dependencies are installed.
Customising the display
Buffer list (buflist):
/set buflist.format.buffer "${format_number}${indent}${eval:${format_name}}${format_hotlist} ${color:31}${buffer.local_variables.filter}${buffer.local_variables.buflist}"
/set buflist.format.hotlist " ${color:239}${hotlist}${color:239}"
/set buflist.format.hotlist_highlight "${color:163}"
/set buflist.format.hotlist_message "${color:229}"
/set buflist.format.hotlist_private "${color:121}"
/set weechat.bar.buflist.size 25
/set weechat.bar.buflist.size_max 30
Active buffer title bar and inactive title bar:
/bar add activetitle window top 1 0 buffer_title
/set weechat.bar.activetitle.priority 500
/set weechat.bar.activetitle.conditions "${active}"
/set weechat.bar.activetitle.color_fg white
/set weechat.bar.activetitle.color_bg 31
/set weechat.bar.activetitle.separator on
/set weechat.bar.title.conditions "${inactive}"
/set weechat.bar.title.color_fg black
/set weechat.bar.title.color_bg 31
Status bar moved to the root:
/bar add rootstatus root bottom 1 0 [time],[buffer_count],[buffer_plugin],buffer_number+:+buffer_name+(buffer_modes)+{buffer_nicklist_count}+buffer_filter,[lag],[aspell_dict],[aspell_suggest],completion,scroll
/set weechat.bar.rootstatus.color_fg 31
/set weechat.bar.rootstatus.color_bg 234
/set weechat.bar.rootstatus.separator on
/set weechat.bar.rootstatus.priority 500
/bar del status
/bar set rootstatus name status
Input bar at the root:
/bar add rootinput root bottom 1 0 [mode_indicator]+[buffer_name]+[input_prompt]+(away),[input_search],[input_paste],input_text,[vi_buffer]
/set weechat.bar.rootinput.color_bg black
/set weechat.bar.rootinput.priority 1000
/bar del input
/bar set rootinput name input
Nick list:
/set weechat.bar.nicklist.color_fg 229
/set weechat.bar.nicklist.separator on
/set weechat.bar.nicklist.conditions "${nicklist} && ${window.number} == 1"
/set weechat.bar.nicklist.size_max 20
/set weechat.bar.nicklist.size 16
Notes
- In xfce4-terminal, the F11 key (full screen) can be disabled if it conflicts with WeeChat shortcuts.
- References: WeeChat quickstart, WeeChat user guide, ZNC commands, ZNC and WeeChat, filtering join/part/quit.