*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-03-01 00:50:00 +00:00
parent 3108cd0182
commit 5d65eab1bd
8 changed files with 65 additions and 25 deletions

View File

@ -100,8 +100,7 @@ namespace libtorrent
// info about each block
block_info info[max_blocks_per_piece];
// TODO: store a crc and a peer_connection reference
// for each block. Then if the hash test fails on the
// TODO: If the hash test fails on the
// piece, redownload one block from another peer
// then the first time, and check the hash again.
// also maintain a counter how many times a piece-hash

View File

@ -270,6 +270,8 @@ namespace libtorrent
m_password = pw;
}
const address& current_tracker() const;
// DEBUG
#ifndef NDEBUG
logger* spawn_logger(const char* title);

View File

@ -105,6 +105,8 @@ namespace libtorrent
int response_code
, const std::string& description) = 0;
address m_tracker_address;
#ifndef NDEBUG
virtual void debug_log(const std::string& line) = 0;
#endif

View File

@ -109,6 +109,7 @@ namespace libtorrent
// TODO: this is a problem. DNS-lookup is blocking!
// (may block up to 5 seconds)
address a(connect_to_host->c_str(), port);
if (c) c->m_tracker_address = a;
boost::shared_ptr<socket> s(new socket(socket::tcp, false));
s->connect(a);

View File

@ -177,6 +177,9 @@ namespace libtorrent
else if (std::equal(f->id, f->id+2, "MT"))
identity << "Moonlight Torrent ";
else if (std::equal(f->id, f->id+2, "TS"))
identity << "TorrentStorm ";
// unknown client
else
identity << std::string(f->id, f->id+2) << " ";
@ -236,6 +239,21 @@ namespace libtorrent
return "XanTorrent";
}
if (std::equal(PID, PID + 7, "Plus---"))
{
return "Bittorrent Plus";
}
if (std::equal(PID, PID + 16, "Deadman Walking-"))
{
return "Deadman";
}
if (std::equal(PID, PID + 7, "btuga"))
{
return "BTugaXP";
}
if (std::equal(PID, PID + 7, "btfans"))
{
return "SimpleBT";

View File

@ -641,30 +641,30 @@ namespace libtorrent
}
}
// make sure we don't have too many
// unchoked peers
// TODO: this could result in two quick
// choke-unchoke messages.
while (m_num_unchoked > m_max_uploads)
if (m_max_uploads < m_torrent->num_peers())
{
// make sure we don't have too many
// unchoked peers
while (m_num_unchoked > m_max_uploads)
{
peer* p = find_choke_candidate();
assert(p);
p->connection->send_choke();
--m_num_unchoked;
}
// optimistic unchoke. trade the 'worst'
// unchoked peer with one of the choked
assert(m_num_unchoked <= m_torrent->num_peers());
peer* p = find_choke_candidate();
assert(p);
p->connection->send_choke();
--m_num_unchoked;
if (p)
{
p->connection->send_choke();
--m_num_unchoked;
unchoke_one_peer();
}
}
// optimistic unchoke. trade the 'worst'
// unchoked peer with one of the choked
assert(m_num_unchoked <= m_torrent->num_peers());
peer* p = find_choke_candidate();
if (p)
{
p->connection->send_choke();
--m_num_unchoked;
unchoke_one_peer();
}
// make sure we have enough
// unchoked peers
while (m_num_unchoked < m_max_uploads && unchoke_one_peer());
@ -691,10 +691,22 @@ namespace libtorrent
{
assert(!c.is_local());
// TODO: have an exception if the incoming connection
// is from the tracker
if(m_torrent->num_peers() >= m_max_connections)
// if the connection comes from the tracker,
// it's probably just a NAT-check. Ignore the
// num connections constraint then.
// TODO: mske sure this works
if (m_torrent->num_peers() >= m_max_connections
&& c.get_socket()->sender().ip() != m_torrent->current_tracker().ip())
{
throw protocol_error("too many connections, refusing incoming connection"); // cause a disconnect
}
#ifndef NDEBUG
if (c.get_socket()->sender().ip() == m_torrent->current_tracker().ip())
{
m_torrent->debug_log("overriding connection limit for tracker NAT-check");
}
#endif
std::vector<peer>::iterator i = std::find_if(
m_peers.begin()

View File

@ -718,6 +718,11 @@ namespace libtorrent
return true;
}
const address& torrent::current_tracker() const
{
return m_tracker_address;
}
torrent_status torrent::status() const
{
assert(std::accumulate(

View File

@ -74,6 +74,7 @@ namespace libtorrent
// TODO: this is a problem. DNS-lookup is blocking!
// (may block up to 5 seconds)
address a(hostname.c_str(), port);
if (c) c->m_tracker_address = a;
m_socket.reset(new socket(socket::udp, false));
m_socket->connect(a);