Skip to content
Rudde edited this page Sep 11, 2018 · 7 revisions

mktorrent

mktorrent is a simple command line utility to create BitTorrent metainfo files.
It has been tested on Linux, OSX, MinGW, OpenBSD and SunOS, but should work on many other POSIX compliant operating systems.

Features of the latest release

  • Creates a BitTorrent metainfo file from a file or directory in a simple and fast way.
  • Supports multiple trackers.
  • Can add a custom comment to the metainfo file.
  • Can add the private flag to dissalow DHT and Peer Exchange.
  • Can add web seed URLs.
  • Hashing can be done multi threaded and supports multiple CPUs.

Non-features of latest release

  • No explicit support for converting filenames to UTF-8. Reads and writes file names and comments exactly as reported by the OS.

Building mktorrent

Basics

Get the source code from the links above, extract the files, enter the directory and run make to build the program. However, see the recommend build one-liners below.

To install the program to /usr/bin do make PREFIX=/usr install as root.

Options

For portability reasons lots of useful features of mktorrent aren’t enabled by default. They are all documented in the Makefile. To enable features either edit the Makefile or add the options when you invoke make.

OpenSSL

mktorrent can optionally use the SHA1 algorithm in the OpenSSL library instead of compiling its own. Most systems have this library installed already, but on some systems (notably Ubuntu and other Debian derivatives) you’ll also need the development package in order to build the program. Usually it will be called something like “openssl-dev” or “libssl-dev”.

Recommended build one-liners

  • 32bit Linux
    make USE_PTHREADS=1 USE_OPENSSL=1 USE_LONG_OPTIONS=1 USE_LARGE_FILES=1
  • 64bit Linux
    make USE_PTHREADS=1 USE_OPENSSL=1 USE_LONG_OPTIONS=1
  • OSX
    make USE_PTHREADS=1 USE_OPENSSL=1 USE_LONG_OPTIONS=1

These only apply to the latest release. If it doesn’t work (and you’re sure you have the OpenSSL headers installed) or you successfully compiled mktorrent on some other OS, please let me know.

Changelog

1.0

  • Add an exception to the license to allow distributions to link mktorrent to the OpenSSL library.
  • Otherwise mostly a re-release of 0.7

0.7

  • Added proper support for large files on certain 32bit OS’s.
    Finally mktorrent properly handles files larger than 2Gb on 32bit Linux.
  • Fixes for use on Windows under MinGW/Cygwin.

0.6

  • Added support for multiple web seeds.
  • Raised allowable piece size.
  • Only add the announce-list entry if there are more than one tracker.
    Thanks to Vladimir Vučićević for reporting.
  • Include public domain SHA1 implementation to make the OpenSSL dependency optional.
  • Lots of portability improvements. Now compiles on Linux, MinGW, OpenBSD, OSX, SunOS and probably many more.
    A big thanks to Edwin Amsler for reporting and testing.
  • Rewrote multi threaded hashing to optimise CPU usage on multi processor machines.

0.5

  • Added support for multiple trackers.
  • Added support for web seed (thanks to Justin Camerer).
  • Better error messages.

0.4

  • Added support for the private flag.

0.3

  • Fixed bug concerning files longer than 2^32 bytes.
  • Fixed command line parameters.

0.2

  • Added support for single file torrents.
  • Support for long options can now be disabled at compile time.

0.1

  • Initial release.

License

mktorrent is free software. It is distributed under the terms of the GNU General Public License.

Useful links

The BitTorrent Specification

Feature requests

An exclude flag to keep certain files out of torrents

Perhaps something like

mktorrent -a http://lala.com/announce.php -x '*~' mytorrent

Trouble using mktorrent after make install

Remember to use the same flags for make install as for make.