|< Day Day Up >|
Hack 100 Combine BitlBee and CtrlProxy
We've already covered both BitlBee and CtrlProxy separately, but IRC power users will be delighted to learn how effective the two combined can be.
As you may have noticed, these points don't really make sense when you run BitlBee and your IRC client on the same machine. But when you regularly connect to your BitlBee server from different (remote) places, they can prove to be very useful.
15.7.1 Setting Up CtrlProxy and BitlBee
Setting up CtrlProxy and BitlBee is quite easy. First, read the hacks [Hack #9] and [Hack #99] ) about the two programs to read how to install them. Reading the parts about getting and compiling them should be enough—you can skip the configuration part. When using CtrlProxy, you can leave out the bitlbeed/inetd setup, because CtrlProxy can start BitlBee directly, as demonstrated in the following configuration file:
<?xml version="1.0"?> <ctrlproxy> <plugins> <plugin autoload="1" file="libsocket"> <sslcertfile>/home/wilmer/.ctrlproxy/ctrlproxy.pem</sslcertfile> <sslkeyfile>/home/wilmer/.ctrlproxy/ctrlproxy.pem</sslkeyfile> </plugin> <plugin autoload="1" file="librepl_memory"/> <plugin autoload="1" file="libadmin"/> <plugin autoload="1" file="liblog_irssi"> <logfile>/home/wilmer/.ctrlproxy/logs/</logfile> </plugin> <plugin autoload="1" file="libstrip"/> <plugin autoload="1" file="libnickserv"/> <plugin autoload="1" file="libantiflood"/> <plugin autoload="1" file="libauto-away"> <message time="300">"I'm currently away, sorry!</message> </plugin> </plugins> <networks> <network autoconnect="1" client_pass="secret" name="BEE"> <listen> <ipv4 port="6668" ssl="1"/> </listen> <servers> <pipe> <path>/usr/sbin/bitlbee</path> <arg>-d/home/wilmer/.ctrlproxy/bitlbee/</arg> </pipe> </servers> <nickserv> <nick name="wilmer" password="beedifferent"/> </nickserv> </network> </networks> </ctrlproxy>
Obviously, you may need to change the file and path names to suit your setup. Don't forget this when copying the configuration file. Save this into a file called ctrlproxyrc in the .ctrlproxy directory in your home directory. If this directory doesn't exist yet, you must create it. Don't forget to create the log and BitlBee configuration directories you specified in this file as well, since they won't be created automatically. The password specified in the NickServ configuration will be the password you should use as your BitlBee NickServ password. Pick anything you want here, as CtrlProxy will take care of sending this information to BitlBee.
If you want to use SSL, you will need to create an SSL certificate/key. The script called mksslcert.sh in the CtrlProxy source directory can do this for you. It creates a file ctrlproxy.pem in the current directory. Just run the script and make sure you put the generated file at the place you refer to in the configuration file.
15.7.2 Starting CtrlProxy
% ctrlproxy -D -r ~/.ctrlproxy/ctrlproxyrc
When running CtrlProxy for the first time, it may be a good idea to leave out the -D argument, so the program will start in the foreground and send some information to the terminal so you can troubleshoot, if necessary.
When everything is OK, you should see something like this when you start the program:
ruby~$ ctrlproxy -r ~/.ctrlproxy/ctrlproxyrc ** Message: Using SSL certificate from /home/wilmer/.ctrlproxy/ctrlproxy.pem and SSL key from /home/wilmer/.ctrlproxy/ctrlproxy.pem Added linestack backend 'memory' Filter 'repl_simple' added Adding new client hook 'repl_simple' Filter 'admin' added Filter 'log_irssi' added Filter 'strip' added Adding lose client hook 'nickserv' Filter 'nickserv' added Filter 'antiflood' added Filter 'auto-away' added socket-Message: Listening on port 6668(socket 3) Connecting with pipe for server BEE Joining channel #bitlbee
The last line is especially important. If you don't get the "Joining channel #bitlbee", CtrlProxy probably failed to start BitlBee. Also, if the first line says something about a missing SSL certificate/key file, something went wrong while creating the ctrlproxy.pem file, which means SSL support will not work. A configuration problem is the most likely cause of this problem, so double-check what you have written in the configuration file.
Now, find out whether your IRC client supports SSL connections. Most decent clients know about SSL these days. irssi does, for example. SSL support for mIRC seems to be available as a plug-in. If you don't know whether your IRC client supports SSL connections yet, just check the documentation. If SSL is not supported, you can choose to switch to a different IRC client or disable SSL in CtrlProxy. You can do this by changing the 1 into a 0 in the ssl argument to the listener definition.
Finally, you can now try to connect the IRC client to the proxy. A simple /connect or /server with just the server name as an argument won't be enough. You have to tell the IRC client to connect to the correct port, use SSL, and send the password. If you use irssi, you can connect to a server called ruby by typing the following:
/connect -ssl ruby 6668 secret
15.7.3 Starting the Session
If everything went well, you'll see a regular BitlBee session coming up. You may notice some differences when you look at the server messages, but the control channel should look familiar to you if you have used BitlBee before.
Now, go ahead and set up the Bee [Hack #99] . When you register your nickname, don't forget to use the password you chose when you wrote the CtrlProxy configuration file. If the passwords don't match, automatic identification will not work, and you'll have to manually identify yourself to root and NickServ every time you sign in.
When you're done, it might be interesting to kill CtrlProxy. There are two ways to do it. Sending SIGTERM to the CtrlProxy process is one way, but you can also do it using your IRC client. Typing /CTRLPROXY DIE should do the job. If that doesn't work, try /QUOTE CTRLPROXY DIE. Now start up CtrlProxy again. If everything goes well, it will set up the BitlBee connection and identify you to NickServ automatically. So when you connect your IRC client to CtrlProxy, the session will be up and running already.
Now it's time for some more experimentation. Start up a second IRC client and connect it to the same CtrlProxy. See how you get exactly the same session there, and how you can do whatever you want in both sessions? Close both IRC clients and start one again to connect it to the proxy. You should notice that the whole session is reproduced, and nobody ever noticed you were away (unless you enabled the autoaway module). It should look something like Figure 15-5.
Figure 15-5. Viewing the same session through two different IRC clients
You will also have full logs of all your conversations on the machine where CtrlProxy runs. You can now disable logging in your IRC client, as there is little point in creating two copies. The benefit of using CtrlProxy to make your logs is that wherever you run your IRC client, your logs will always be in the same place.
15.7.4 Hacking the Hack
Maybe you're not completely comfortable yet? Maybe you want the logs to be formatted a bit differently? Maybe you want to connect to other networks as well? Maybe you don't like some of the BitlBee default settings? Most of these things are explained in the hacks about the two programs (see [Hack #9] and [Hack #99] ) or the online manuals. Don't forget to read them, as they cover far more topics than these hacks can. Many features requested by users already exist, but they're just not obvious enough to be discovered without reading some documentation.
—Wilmer van der Gaast
|< Day Day Up >|