Tor Hidden Service

From NeoWiki

This will detail how to setup a Tor hidden service that points to your UnrealIRCd install. I'm only interested in providing Tor users with access to the network/server. I don't really care about UnrealIRCd leaking information which might make the hidden service not so hidden.

Contents

[edit] Install Tor

I'd recommend using your distribution's binaries because they'll be updated automatically (when you run pacman -Syu or apt-get update && apt-get upgrade) so you don't have to worry about your release being out of date.

Of course, you may not trust your OS's package maintainers to update Tor as quickly as it is released. If that's the case then I'd suggest you install from source and subscribe to the Tor mailing lists (especially or-announce).

Either way, make sure you keep your tor binaries up-to-date as not doing so may leave your box vulnerable.

[edit] Configure torrc

As described in Configuring Hidden Services for Tor you want to add the following two lines to Tor's main configuration file torrc:

# grep HiddenService < /etc/tor/torrc
HiddenServiceDir /var/lib/tor/hidden_service/
HiddenServicePort 6667 127.0.0.239:6667

You can change hidden_service to something more descriptive like unreal-hidden-service.

The important thing to note here is that we used 127.0.0.239 (or any unique IP in 127.0.0.0/8) instead of 127.0.0.1 as this will allow UnrealIRCd to track which users are connecting from tor.

Now restart Tor. If you're using Debian and you've installed Debian's Tor package run:

/etc/init.d/tor restart

Tor should have created two files in /var/lib/tor/hidden_service

# ls /var/lib/tor/hidden_service
hostname  private_key

The private_key is a public/private keypair and should be kept secret. Back it up so in case of a server failure you can bring back your hidden service at the same address.

The hostname is your hidden service's .onion address. Share it with anyone you want to connect to your server.

# cat /var/lib/tor/hidden_service/hostname
qnwpupud3hyir6qp.onion

[edit] Configure UnrealIRCd

Now that you've set up Tor you have to setup UnrealIRCd to treat Tor users differently than normal users. Yes, unfortunately we live in an unequal world.

Switch to your UnrealIRCd user. If you've followed the UnrealIRCd article on NeoWiki this user should be ircd. Then switch to the folder with Unreal's configuration.

# su ircd
$ cd ~/Unreal3.2

Add the following to unrealircd.conf:

class tor
{
        maxclients 5; # change this depending on how many Tor users you want to allow
        pingfreq 90;
        sendq 100000;
        recvq 3000;
};
# add this after your *@* allow block
allow {
        ip *@127.0.0.239; # change this depending on what you choose in the above steps
        hostname *@localhost;
        class tor;
        maxperip 5; # remember to change this if you change it from above
        options {
                useip;
        };
};

Save the file and rehash UnrealIRCd with the new configuration.

$ ./unreal rehash

The start/stop/restart/rehash script should exit without error and you should be able to accept connections from Tor users.

[edit] Test the connection

Before you make your .onion url public you should probably check to see that you can connect. See the Connecting through Tor NeoWiki article for more information.