Sunday, June 26, 2016

qBitorrent Unban / Undo when you Ban peer permanently

If you use the open-source, qBittorrent, this blog entry is for you.

When you right click on a peer in qBittorrent, you are given an option to "Ban peer permanently". When used, the ban takes affect immediately. All communication with the client's IP address ceases, and that IP address remains a black hole in current and future qBittorent sessions.

If you happen to be dealing with a leecher client, this sort of command is useful, especially with leechers who have a static IP address. Your ban halts all future communication with them.

The command is not useful, however, if the client using the IP address is only using it for a short duration of time. This is a common occurrence with ISPs whose customers share a pool of IP addresses that change each time they establish communication with their ISP/Internet. The client with such an ISP, if he/she reconnects to the ISP, will appear using a new IP address. In this case, your ban may prevent a different customer from the same ISP from establishing communication with you - a client that is not a leecher.

The ban is also unhelpful if you use the ban command by mistake, or purposely, and had hoped an "unban peer permanently" command would miraculously replace the existing ban command when you right clicked in the window again after making a mistake. Sadly, this does not occur, and your "momentary test ban" does indeed become permanent.

qBittorrent users get stuck at this point. The program assumes you use the ban command wisely. Of course, not all of us are as sage as the developers think we are, and we make bans we do not want to keep... All can easily be undone. You can undo the ban, or un-ban the banned peer with a simple text editor. But qTorrent doesn't offer you any facility to do it. You are forced to do it yourself.

qBittorrent for Windows stores the bans within it's "qBittorrent.ini" file. It is an integral file to the program, and should be treated with care. If you want my advice, I would suggest you make a copy of this file before making any changes to the file. That way any changes you might make to the file can be undone (restoring the file), by replacing the modified file with the un-altered copy of the original.

In Windows 7, "qBittorrent.ini" is located in...

"?:\Users\(ACCOUNT)\AppData\Roaming\qBittorrent\"

...where "?" is usually "C",  the C hard drive, and "(ACCOUNT)" is the account you use to log in to Windows. If you have another flavour of Windows, the path of the file - its location - may be slightly different. But the file name will be identical, and it will certainly be in a qBittorrent folder.

Whenever qBittorent is booted, the contents of qBittorent.ini are read and used to restore the application to its previously saved state. It reads the banned IP data in the file and re-impliments the ban each time the program is run.

Like any text file, you need to use a text editor that supports the native format of the file. When or if you have such an editor, the means of un-doing or un-banning the peer could not be simpler.

Open the file. Home in on the text "[Preferences]", which appears a certain number lines into the file. The line or lines containing bans appear shortly after the preferences heading line. It should look similar to this...

[Preferences]
General\SystrayEnabled=true
General\PreventFromSuspend=false
Downloads\TorrentExportDir=
Downloads\StartInPause=true
Connection\MaxHalfOpenConnec=20
Connection\Interface

... and so on.

Each line of text in the file is a single, specific instruction to qBittorrent. Each line of text, except the line with the ban, should be left, as is, within this file. These lines are the very preferences/choices you have made in the application as to how the program operates. ie: what trackers it uses, which features are enabled/disabled, or which values a feature uses, etc. You want to keep everything in this file, except the ban line.

Your ban was added to this file as a single line and it will look as follows...

IPFilter\BannedIPs=10.1.99.255

The IP address numbers will obviously be different, such as 123.456.789.0, or something like that. But the entire line is the ban. It is what is stopping communication with the IP address, and it is this line that requires your attention. If you have banned more than one IP address, there will be multiple entries on the same line. Each IP address will be separated by a comma, such as IPFilter\BannedIPs=10.1.99.255,10.1.99.254,255.99.1.10

All the lines of text above and below the ban line are vital data to the program.

When you wish to remove the ban line, you must leave all the data above and below it intact, and then save the file. This removes the ban data from the file, and nothing more. All your preferences and settings and choices are as they were, and will be if you only wish to remove the ban. If the program is currently running when you edit the file, you must re-start the program in order for the removal of the ban to take place.

How to remove the ban.

Below is an example of how such a line is removed correctly. The text above and below in the example is purely for demonstration purposes and is meant to make it painfully obvious as to what content is the ban line that should be removed, and what is not. In reality, there are numerous lines before and after the ban line. The example does not contain the actual text that would appear above or below the ban line.

Text before the ban is removed:

LINE OF TEXT ABOVE=HERE
IPFilter\BannedIPs=111.222.333.444
LINE OF TEXT BELOW=HERE



Text after the ban is removed:

LINE OF TEXT ABOVE=HERE
LINE OF TEXT BELOW=HERE


Save the file, and you are done. If you banned the client/it's IP address only moments ago, and watched as the client disappeared, that same client at the affected IP address should return, if it can be found once the program is quickly restarted (locating peers is not always instantaneous).

2 comments:

  1. Thank you for the detailed workaround. However, months after this piece, a permanent solution was made. For those who stumble upon this page instead of the latest github paeg, look here: https://github.com/qbittorrent/qBittorrent/pull/5877

    ReplyDelete
  2. Thanks for the link, Prashanth. It has been quite a while since I've fired up any file-sharing software. Nevertheless, anyone forced into using the older versions may still benefit from the post. And as long as qBitorrent remains the good software it was for me, I would wholeheartedly recommend an up-to-date version to anyone that can get their hands on a new version.

    ReplyDelete