Git Product home page Git Product logo

libtorrent's Introduction

libtorrent's People

Contributors

andrakis avatar arvidn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libtorrent's Issues

Python3 bencode()

Hello,

Looks like python3 support remains problematic.
Opening a torrent fails with UnicodeDecodeError with something as simple as:
t = open(torrent_path,'rb')
t_ = libtorrent.bdecode(t.read())

My version of libtorrent: 0.16.17

There is a ticket on google code but I wasn't able to post a comment, I can't sign up because of a bug in google code. Pretty annoying. Apparently you thought this bug was resolved. I do not think it is the case.

Best,
Michaël

debian compile issue

im using debian linux trying to compile current code
used following commands

./autotool.sh
./configure --disable-debug --prefix=/usr && make clean && make

get following error

lazy_bdecode.cpp: In function 'std::string libtorrent::print_entry(const libtorrent::lazy_entry&)':
lazy_bdecode.cpp:384:56: error: 'snprintf' was not declared in this scope
lazy_bdecode.cpp:408:62: error: 'snprintf' was not declared in this scope
make[1]: *** [lazy_bdecode.lo] Error 1
make[1]: Leaving directory `/root/qBittorrent_compiling/libtorrent/src'
make: *** [all-recursive] Error 1

Install LibTorrent in CentOS with Python 3.5.x

Hi, is there a way to install libtorrent on CentOS 7.x and Python 3.5?
Note: CentOS has python2.7 builtin and I've installed Python 3.5 separately.

moreover

$ python -V
Python 2.6.6
$ python3 -V
Python 3.5.2
# pip -V
pip 9.0.1 from /usr/lib/python2.7/site-packages (python 2.7)
# pip3.5 -V
pip 9.0.1 from /usr/lib/python3.5/site-packages (python 3.5)

macos 10.12 build and load issue

in macos 10.12 build all ok,but load failed, i also tried gcc and it load failed too,but the missing symbol is different,my boost version is 1.59.some one met this issue?

import libtorrent
Traceback (most recent call last):
File "", line 1, in
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/libtorrent.so, 2): Symbol not found: __ZN5boost6python6detail13current_scopeE
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/libtorrent.so
Expected in: flat namespace
in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/libtorrent.so

Support for per tracker dht/pex/... and all that settings.

Private trackers want them turned off and public ones work better with them turned on. Which complicates things for users a lot since you have to somehow run 2 instances of qbittorrent or whichever torrent download sw you are using. Which is a waste of memory, i/o, cpu, ....

Define state of torrent in plugin (extension)

Dear all.

I'm using libtorrent, but I have issue relate with plugin (extension).
In peer_plugin, I need define torrent is seeding or downloading.
Please help.

I had try using m_torrent.state(), m_torrent.is_seed() but it still return the sample result in downloading and seeding.

My code:

const char extension_name[] = "my_metadata";
struct my_peer_plugin : peer_plugin
{
my_peer_plugin(torrent& t, peer_connection& pc, my_metadata_plugin& tp)
:m_torrent(t) ,m_pc(pc) ,m_tp(tp)
{
}

virtual char const* type() const { return extension_name;}

virtual void add_handshake(entry& h)
{
        //TODO how to check torrent is downloading or seeding
}

virtual bool on_extension_handshake(lazy_entry const& h)
{
         //TODO how to check torrent is downloading or seeding
}

private:
torrent& m_torrent;
peer_connection& m_pc;
my_metadata_plugin& m_tp;
};

Thanks!

Be more network friendly

I've noticed that several game launcher-updaters, which appear to use libtorrent, are extremely greedy in their use of the network - even by BitTorrent standards - to the point where they can overwhelm even the most competent of QoS implementations (such as the one I develop). This makes it difficult to use the Internet for anything else while they are updating, especially on a slow connection where one would prefer to leave the update running in the background for an extended period of time.

A common factor is that these publishers apparently maintain a large bank (50 to 250) of web seeds, effectively turning libtorrent into a massively parallel HTTP download engine. The P2P nature of the torrent protocol is effectively subverted and made ineffective, since libtorrent makes very few connections to peers when so many web seeds are available.

Here are some concrete suggestions to improve matters:

  • Change the default TOS marking to the already suggested 0x20 (aka CS1, or Background). This should be a one-liner with immediately positive effects for users behind a Diffserv-aware QoS router. Although this would have no direct effect on web seeds, some QoS systems can interpret an outgoing TOS marking as applying to the corresponding inbound traffic as well.

  • Limit the number of simultaneous connections to web seeds, in line with existing HTTP best practices. I'm inclined to quote Monty Python: "Then shalt thou count to three... Five is right out!" I could go into great detail about why a large number of HTTP connections is counterproductive, and I will if necessary.

  • When a download rate limit is specified, throttle the production of block requests (both HTTP and BT), not merely the acceptance of data, and put a tuned limit on the number of outstanding requests. I'm flexible about how the latter is calculated, as long as it's sane (somewhere around 10 seconds' worth, perhaps). This avoids the phenomenon of seeds stuffing data at full bore into every buffer they can reach, until they run out of the total receive window across however many connections. This should be useful for people both with and without QoS routers, since the latter are typically placed after the bottleneck in the download direction (not the optimal position, which is before the bottleneck).

  • Implement uTP with the LEDBAT congestion control algorithm, and/or apply LEDBAT to TCP sockets when possible. The latter probably won't be any help on Windows, but since it can be done on Linux, it's a start. The effect of this is to reduce the latency induced by upload traffic for people without QoS routers.

boost::io_service wrapper files

Please provide the following information

libtorrent version (or branch): git 7fe75dd

platform/architecture: Linux

compiler and compiler version: GCC 7.3.1

please describe what symptom you see, what you would expect to see instead and
how to reproduce it.

EDIT: Here was incorrect reasoning about io_service wrapper that actually in part came from new Boost ASIO.

The error will be something like this:

/libtorrent/include/libtorrent/io_service_fwd.hpp:46:8: error: using typedef-name ‘boost::asio::io_service’ after ‘class’
  class io_service;

I'm new to libtorrent, and not familiar with the project structure. If there's no special concerns against it, I'd suggest to create a single io_service wrapper file that handles the cases for both simulation and ASIO-compatiblity. This way it will be possible to combine the wrapper reasoning for the two of them.

Separate DHT peer reader for some locally seeded torrent injects and shows its own port as the peer port instead of showing the real one

I have the torrent client running with the popular Arch torrent seeded on it at port 6881 (forwarded in from the router).

On the same host I run the libtorrent-based scanning program that returns the list of peers for the same torrent, it listens on port 19001.

The problem is that after a while this program begins to return my own IP with that port 19001 as a peer for this torrent, when the port where the torrent is hosted is 6881.

This happens consistently, it returns sometimes 6881 and sometimes 19001. There is some confusion, and this port 19001, where no torrents are hosted at all, is getting added to the peer list.


Then I created the test torrent, that only I have, and was watching for it with the same program on the same host. This program actually has trouble finding it, and only was able to find it once out of ~50 times I ran it (this is also very strange). But the other host that has different IP now sees that test torrent with the port 19001 too (!!!). So this python scanner also injected its port for this new test torrent too. How can others even download the torrent if its port is wrong in DHT? Also, this other client just can't download my test torrent. Despite the correct port sometimes showing up in the peer list, and this port being open on the peer (my main host). I couldn't understand why the other client can't download when IP/port are correct, the port is open, and the torrent is available.

So, to summarize, there are 3 problems:

  1. DHT scanner injects its own port into the peer list
  2. DHT scanner fails to find the newly created and seeded torrent most of the times
  3. Remote client fails to download my torrent even though it should be possible due to ip/port info available, port being open and data available.

(Obviously torrents work, I just suspect there is some bug I stumbled upon, that may be impeding other torrent downloads as well)

--- test program: DHT scanner for specific torrent---

import libtorrent as lt
import time
import sys

my_ip = '<MY-IP>'
link = "magnet:...."

cycle=0

def print_peers(pp):
    global cycle
    cycle = cycle+1
    print('===> [%d] Peer info (%d peers)' % (cycle, len(pp)))
    me = ''
    for i in pp:
        if i.ip[0] == my_ip:
            me = ' <===== ME'
        else:
            me = ''
        print("peer -> %s %s" % (str(i.ip), me))
    print('<=== [%d] Peer info' % (cycle))

ses = lt.session()
ses.listen_on(19001, 19011)
params = {
    'save_path': './download',
    'storage_mode': lt.storage_mode_t(2),
    'paused': False,
    'auto_managed': True,
    'duplicate_is_error': True
    }

h = lt.add_magnet_uri(ses, link, params)

ses.add_dht_router("router.utorrent.com", 6881)
ses.add_dht_router("router.bittorrent.com", 6881)
ses.add_dht_router("dht.transmissionbt.com", 6881)
ses.start_dht()
while (not h.has_metadata()):
    time.sleep(.1)
print("--have metadata, waiting for peers--")

npeers = len(h.get_peer_info())
print('before: npeers=%d' % (npeers))
while True:
    print_peers(h.get_peer_info())
    time.sleep(10)
    new_npeers = len(h.get_peer_info())
    if new_npeers <= npeers:
        break
    else:
        print('npeers: %d -> %d' % (npeers, new_npeers))
        npeers = new_npeers
print('after: npeers=%d' % (npeers))
print_peers(h.get_peer_info())

py27-libtorrent-rasterbar-0.16.19_1
FreeBSD 10.1

[Enhancement] Storage(Swarm) Merge/ File Proxy

Currently the default storage manager does not support torrent or swarm merging, implemented in some major clients (e.g. Vuze):
https://wiki.vuze.com/w/Swarm_Merging

Often torrent files contain one or more files which may be duplicates found in other torrent files,these can be merged to prevent duplication and speed up download. Files may share any of the following attributes, which may fingerprint them as being identical:

  • basename
  • size
  • hash (if provided)

This tends to happen a lot with patched or aggregated data. A convenient, though of course sketchy example would be downloading a TV series, as it iterates torrents may be created to aggregate data
single episode -> single season -> entire series -> entire series + extras -> entire franchise
More legitimate use cases

  • Scientific:weatherdata-Jan,Feb,Mar->weatherdata2001->weatherdata2000,2010
  • Installers:{patch01,patch02}->{aggregate-patch01,02}
    As these aggregate torrents build they each share data from the previous, which may in part already be on the user's system.

Ideally there should be something like the following:

//Fires when a file that can be merged is detected
struct storage_mergable_alert final : torrent_alert
{
   virtual std::string message () const override;
   char const** storage_paths () const;
   static const int static_category = alert::storage_notification;
};

//Fires when an aliased file's piece doesn't match what we expected, this might happen if we chose the wrong file to merge, but only discovered this when more of the file was downloaded.  If you get this message you can try other merge candidates fork_backing_storage_for_file() to keep partial similarities and continue treating this file as a separate new file.
struct storage_mergable_mismatch final : torrent_alert
{
   virtual std::string message () const override;
   char const* storage_path () const;
   static const int static_category = alert::storage_notification;
};

//Scan the storage for mergeable candidates, fires storage_mergable_alert if found, scan all paths if alias_path is NULL,otherwise search only for file like alias path.
virtual storage_interface::scan_for_alias_candidates(char* alias_path,bool checkSize,bool checkName, bool checkHash)//might be more elegant to make the flags an OR-able enum

//set the backing storage of aliased path to the file at target_path, by default allow only read( either another torrent is modifying this file or it's in archival storage, so disallow modify)
virtual bool storage_interface::set_backing_storage_for_file(char* target_path, char* aliased_path, const char* mode='r');

//Return the real path of the merged storage
virtual const char* storage_interface::get_backing_storage_for_file(char* path);

//Copies backing storage into a new file at the the alias path, using //copy_backing_storage_for_file(), and sends appropriate file moved messages
virtual const char* storage_interface::fork_backing_storage_for_file(char* path);

//An aliased path may be converted into a representation in the file system, this is implementation dependant.
//If running an archival server it may never be desirable to render duplicates in the filesystem
//libtorrent doesn't do anything by default.  Depending on use case you may want to create a filesystem representation of the alias

//copy the contents of the backing storage for this file to the aliased path
//especially useful solution for copy-on-write filesystems.
virtual bool storage_interface::copy_backing_storage_for_file(char* alias_path);

//Create a symlink representation in the filesystem of the specified alias path
virtual bool storage_interface::symlinklink_backing_storage_for_file(char* alias_path);

//Hardlink the backing storage of an aliased path to its original
virtual bool storage_interface::hardlink_backing_storage_for_file(char* alias_path);

When a file is aliased its torrent will receive piece_finished_alert for non partial pieces which overlap with its backing storage and a file_completed_alert corresponding to it target. Since it is impossible to tell if incomplete files with the same size or name (or indeed hash if the creator lied) are indeed the same, libtorrent should try to download pieces at overlapping offsets and check if a chunk of the contents is the same(hopefully it's not just padded with zeros), then the chunk should be a good enough check for uniqueness

libtorrent version (or branch):
master

platform/architecture:
all

compiler and compiler version:
LLVM version 8.0.0

peer_connection compile error

In file included from ../include/libtorrent/torrent_info.hpp:61:0,
                 from ../include/libtorrent/storage.hpp:54,
                 from ../include/libtorrent/peer_connection.hpp:62,
                 from peer_connection.cpp:39:
../include/libtorrent/file_storage.hpp:103:8: error: 'void libtorrent::file_storage::add_file(const wpath&, libtorrent::size_type, int)' cannot be overloaded
   void add_file(fs::wpath const& p, size_type size, int flags = 0);
        ^
../include/libtorrent/file_storage.hpp:99:8: error: with 'void libtorrent::file_storage::add_file(const boost::filesystem::path&, libtorrent::size_type, int)'
   void add_file(fs::path const& p, size_type size, int flags = 0);
        ^
In file included from ../include/libtorrent/storage.hpp:54:0,
                 from ../include/libtorrent/peer_connection.hpp:62,
                 from peer_connection.cpp:39:
../include/libtorrent/torrent_info.hpp:172:3: error: 'libtorrent::torrent_info::torrent_info(const wpath&)' cannot be overloaded
   torrent_info(fs::wpath const& filename);
   ^
../include/libtorrent/torrent_info.hpp:170:3: error: with 'libtorrent::torrent_info::torrent_info(const boost::filesystem::path&)'
   torrent_info(fs::path const& filename);
   ^
../include/libtorrent/torrent_info.hpp:181:3: error: 'libtorrent::torrent_info::torrent_info(const wpath&, boost::system::error_code&)' cannot be overloaded
   torrent_info(fs::wpath const& filename, error_code& ec);
   ^
../include/libtorrent/torrent_info.hpp:179:3: error: with 'libtorrent::torrent_info::torrent_info(const boost::filesystem::path&, boost::system::error_code&)'
   torrent_info(fs::path const& filename, error_code& ec);
   ^
In file included from ../include/libtorrent/peer_connection.hpp:65:0,
                 from peer_connection.cpp:39:
../include/libtorrent/torrent_handle.hpp:524:8: error: 'void libtorrent::torrent_handle::move_storage(const wpath&) const' cannot be overloaded
   void move_storage(fs::wpath const& save_path) const;
        ^
../include/libtorrent/torrent_handle.hpp:520:8: error: with 'void libtorrent::torrent_handle::move_storage(const boost::filesystem::path&) const'
   void move_storage(fs::path const& save_path) const;
        ^
../include/libtorrent/torrent_handle.hpp:525:8: error: 'void libtorrent::torrent_handle::rename_file(int, const wpath&) const' cannot be overloaded
   void rename_file(int index, fs::wpath const& new_name) const;
        ^
../include/libtorrent/torrent_handle.hpp:521:8: error: with 'void libtorrent::torrent_handle::rename_file(int, const boost::filesystem::path&) const'
   void rename_file(int index, fs::path const& new_name) const;
        ^
Makefile:710: recipe for target 'peer_connection.lo' failed
make[1]: *** [peer_connection.lo] Error 1
make[1]: Leaving directory '/home/voltagex/src/libtorrent/src'
Makefile:550: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

Stuck in the loop while (not h.has_metadata()):

Hi, I'm trying to get the torrent by passing infohash but the problem is that the code stuck in while loop. I tried with different info hashes and none of them work. below is the code.

can you please help to see if I'm doing anything wrong?

import libtorrent as lt
import time
import sys

ses = lt.session()
ses.listen_on(6881, 6891)
params = {
	'save_path': '.',
	'storage_mode': lt.storage_mode_t(2),
	'paused': False,
	'auto_managed': True,
	'duplicate_is_error': True
	}

info_hash = "2B3AF3B4977EB5485D39F96FE414729530F48386"
link = "magnet:?xt=urn:btih:" + info_hash

h = lt.add_magnet_uri(ses, link, params)

ses.add_dht_router("router.utorrent.com", 6881)
ses.add_dht_router("router.bittorrent.com", 6881)
ses.add_dht_router("dht.transmissionbt.com", 6881)
ses.start_dht()

while (not h.has_metadata()):
	time.sleep(1)

torinfo = h.get_torrent_info()

python setup.py build

Using the command as the documentation say:
python setup.py build
seems to do nothing. Adding --bjam at the end of the command tries to do the proper think...

I'm wrong or the documentation is not ok?

Create a search only through the BitTorrent network

Creating a search without a server, search downloads through the hash.
For example: If the title(name) of any download calculate the hash, then you can search without trackers, you can look directly into the network by UDP.
How it works: Everyone who creates seed should input the naming of 3-5 titles, each of which will be determined by the hash. These hashes are to be assigned to the seed. Example hashes for the titles: "Terminator", "Terminator 2", "Терминатор", "Терминатор 2".
When searched, it must be performed to compare and contrast hashes seeds. Example: when searching display a list of all the names that have a only one certain desired hash, ie in the table are displayed when searching for a different distribution of the hash (which is defined by its name), each line is a separate distribution of torrents.
.
The result is a search engine that is not possible to block on any tracker. None of the copyright.
.
And of course it is obvious that this is a very complex function.
But the meaning of it is that if it is. It client will not be just the same as everyone. It client will be at 4 heads above all the clients together.
A very large popularity.
.
The creation of such a function is similar to the invention Bitcoins.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.