*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-01-08 17:03:04 +00:00
parent cfe5da0588
commit 8137e5002d
7 changed files with 67 additions and 22 deletions

View File

@ -469,6 +469,8 @@ Its declaration looks like this::
bool is_valid();
entry write_resume_data();
void force_reannounce();
void connect_peer(const address& adr) const;
boost::filsystem::path save_path() const;
@ -488,6 +490,17 @@ any operation on an uninitialized handle, it will throw ``invalid_handle``.
``save_path()`` returns the path that was given to ``add_torrent()`` when this torrent
was started.
``force_reannounce()`` will force this torrent to do another tracker request, to receive new
peers. If the torrent is invalid, queued or in checking mode, this functions will throw
invalid_handle_.
``connect_peer()`` is a way to manually connect to peers that one believe is a part of the
torrent. If the peer does not respond, or is not a member of this torrent, it will simply
be disconnected. No harm can be done by using this other than an unnecessary connection
attempt is made. If the torrent is uninitialized or in queued or checking mode, this
will throw invalid_handle_.
``info_hash()`` returns the info hash for the torrent.
``set_max_uploads()`` sets the maximum number of peers that's unchoked at the same time on this
@ -676,7 +689,7 @@ the payload data.
``id`` is the peer's id as used in the bit torrent protocol. This id can be used to
extract 'fingerprints' from the peer. Sometimes it can tell you which client the peer
is using.
is using. See identify_client_
``pieces`` is a vector of booleans that has as many entries as there are pieces
in the torrent. Each boolean tells you if the peer has that piece (if it's set to true)
@ -908,6 +921,18 @@ version of your client. All these numbers must be within the range [0, 9].
``to_string()`` will generate the actual string put in the peer-id, and return it.
identify_client
~~~~~~~~~~~~~~~
There's a function, in the header ``libtorrent/identify_client.hpp``, that can be used
to extract a string describing a client version from its peer-id. It has the following
declaration::
std::string identify_client(const peer_id& id);
It will recognize most clients that have this kind of identification in the peer-id.
alerts
======

View File

@ -127,10 +127,16 @@ namespace libtorrent
return m_next_request < boost::posix_time::second_clock::local_time();
}
void force_tracker_request()
{
m_next_request = boost::posix_time::second_clock::local_time();
}
void print(std::ostream& os) const;
void check_files(detail::piece_checker_data& data,
boost::mutex& mutex);
void check_files(
detail::piece_checker_data& data
, boost::mutex& mutex);
stat statistics() const { return m_stat; }
size_type bytes_left() const;
@ -141,7 +147,7 @@ namespace libtorrent
const address& a
, const peer_id& id);
const torrent_info& torrent_file() const throw()
const torrent_info& torrent_file() const
{ return m_torrent_file; }
policy& get_policy() { return *m_policy; }

View File

@ -135,12 +135,17 @@ namespace libtorrent
entry write_resume_data();
// TODO: add force reannounce
// forces this torrent to reannounce
// (make a rerequest from the tracker)
void force_reannounce() const;
// TODO: add a feature where the user can ask the torrent
// to finish all pieces currently in the pipeline, and then
// abort the torrent.
// manually connect a peer
void connect_peer(const address& adr) const;
// TODO: add finish_file_allocation, which will force the
// torrent to allocate storage for all pieces.

View File

@ -131,8 +131,6 @@ namespace libtorrent
} // namespace unnamed
// TODO: document
std::string identify_client(const peer_id& p)
{
peer_id::const_iterator PID = p.begin();

View File

@ -1264,20 +1264,7 @@ namespace libtorrent
}
#endif
if (m_active)
{
// verify peer_id
// TODO: It seems like the original client ignores to check the peer id
// can that be correct?
if (!std::equal(m_recv_buffer.begin(), m_recv_buffer.begin() + 20, (const char*)m_peer_id.begin()))
{
#ifndef NDEBUG
(*m_logger) << m_socket->sender().as_string() << " invalid peer_id (it doesn't equal the one from the tracker)\n";
#endif
throw network_error(0);
}
}
else
if (!m_active)
{
// check to make sure we don't have another connection with the same
// info_hash and peer_id. If we do. close this connection.

View File

@ -721,7 +721,7 @@ namespace libtorrent
}
// TODO: this function should also take the
// HTTP-response code as an argument
// HTTP-response code as an argument.
// with some codes, we should just consider
// the tracker as a failure and not retry
// it anymore

View File

@ -276,6 +276,30 @@ namespace libtorrent
throw invalid_handle();
}
void torrent_handle::connect_peer(const address& adr) const
{
if (m_ses == 0) throw invalid_handle();
boost::mutex::scoped_lock l(m_ses->m_mutex);
torrent* t = m_ses->find_torrent(m_info_hash);
if (t == 0) throw invalid_handle();
peer_id id;
std::fill(id.begin(), id.end(), 0);
t->get_policy().peer_from_tracker(adr, id);
}
void torrent_handle::force_reannounce() const
{
if (m_ses == 0) throw invalid_handle();
boost::mutex::scoped_lock l(m_ses->m_mutex);
torrent* t = m_ses->find_torrent(m_info_hash);
if (t == 0) throw invalid_handle();
t->force_tracker_request();
}
void torrent_handle::get_peer_info(std::vector<peer_info>& v) const
{
v.clear();