dropped some iostream dependencies
This commit is contained in:
parent
ac7e4fed7e
commit
aba5b2e9d0
|
@ -114,9 +114,10 @@ namespace libtorrent
|
|||
virtual char const* what() const { return "read piece"; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << torrent_alert::message() << ": piece " << (buffer ? "successful " : "failed ") << piece;
|
||||
return ret.str();
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "%s: piece %s %u", torrent_alert::message().c_str()
|
||||
, buffer ? "successful" : "failed", piece);
|
||||
return msg;
|
||||
}
|
||||
|
||||
boost::shared_array<char> buffer;
|
||||
|
@ -141,10 +142,10 @@ namespace libtorrent
|
|||
virtual char const* what() const { return "file renamed"; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << torrent_alert::message() << ": file "
|
||||
<< index << " renamed to " << name;
|
||||
return ret.str();
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "%s: file %d renamed to %s", torrent_alert::message().c_str()
|
||||
, index, name.c_str());
|
||||
return msg;
|
||||
}
|
||||
|
||||
std::string name;
|
||||
|
@ -167,10 +168,10 @@ namespace libtorrent
|
|||
virtual char const* what() const { return "file rename failed"; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << torrent_alert::message() << ": failed to rename file "
|
||||
<< index << ": " << msg;
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s: failed to rename file %d: %s"
|
||||
, torrent_alert::message().c_str(), index, msg.c_str());
|
||||
return ret;
|
||||
}
|
||||
|
||||
const static int static_category = alert::storage_notification;
|
||||
|
@ -273,10 +274,10 @@ namespace libtorrent
|
|||
virtual char const* what() const { return "tracker error"; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << tracker_alert::message() << " (" << status_code << ") "
|
||||
<< msg << " (" << times_in_row << ")";
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s (%u) %s (%d)"
|
||||
, torrent_alert::message().c_str(), status_code, msg.c_str(), times_in_row);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int times_in_row;
|
||||
|
@ -325,10 +326,10 @@ namespace libtorrent
|
|||
virtual char const* what() const { return "tracker scrape reply"; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << tracker_alert::message() << " scrape reply: " << incomplete
|
||||
<< " " << complete;
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s scrape reply: %u %u"
|
||||
, torrent_alert::message().c_str(), incomplete, complete);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -370,10 +371,10 @@ namespace libtorrent
|
|||
virtual char const* what() const { return "tracker reply"; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << tracker_alert::message() << " received peers: "
|
||||
<< num_peers;
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s received peers: %u"
|
||||
, torrent_alert::message().c_str(), num_peers);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -392,10 +393,10 @@ namespace libtorrent
|
|||
virtual char const* what() const { return "DHT reply"; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << torrent_alert::message() << " received DHT peers: "
|
||||
<< num_peers;
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s received DHT peers: %u"
|
||||
, torrent_alert::message().c_str(), num_peers);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -435,10 +436,10 @@ namespace libtorrent
|
|||
virtual int category() const { return static_category; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << torrent_alert::message() << " hash for piece "
|
||||
<< piece_index << " failed";
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s hash for piece %u failed"
|
||||
, torrent_alert::message().c_str(), piece_index);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int piece_index;
|
||||
|
@ -567,11 +568,10 @@ namespace libtorrent
|
|||
virtual char const* what() const { return "invalid piece request"; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << peer_alert::message() << " peer sent an invalid piece request "
|
||||
"( piece: " << request.piece << " start: " << request.start
|
||||
<< " len: " << request.length << ")";
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s peer sent an invalid piece request (piece: %u start: %u len: %u)"
|
||||
, torrent_alert::message().c_str(), request.piece, request.start, request.length);
|
||||
return ret;
|
||||
}
|
||||
|
||||
peer_request request;
|
||||
|
@ -613,10 +613,10 @@ namespace libtorrent
|
|||
virtual int category() const { return static_category; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << torrent_alert::message() << " piece " << piece_index
|
||||
<< " finished downloading";
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s piece: %u finished downloading"
|
||||
, torrent_alert::message().c_str(), piece_index);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -640,10 +640,10 @@ namespace libtorrent
|
|||
virtual int category() const { return static_category; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << peer_alert::message() << " peer dropped block ( piece: "
|
||||
<< piece_index << " block: " << block_index << ")";
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s peer dropped block ( piece: %u block: %u)"
|
||||
, torrent_alert::message().c_str(), piece_index, block_index);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -667,10 +667,10 @@ namespace libtorrent
|
|||
virtual int category() const { return static_category; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << peer_alert::message() << " peer timed out request ( piece: "
|
||||
<< piece_index << " block: " << block_index << ")";
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s peer timed out request ( piece: %u block: %u)"
|
||||
, torrent_alert::message().c_str(), piece_index, block_index);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -693,10 +693,10 @@ namespace libtorrent
|
|||
virtual int category() const { return static_category; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << peer_alert::message() << " block finished downloading ( piece: "
|
||||
<< piece_index << " block: " << block_index << ")";
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s block finished downloading (piece: %u block: %u)"
|
||||
, torrent_alert::message().c_str(), piece_index, block_index);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -721,10 +721,10 @@ namespace libtorrent
|
|||
virtual int category() const { return static_category; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << peer_alert::message() << " requested block ( piece: "
|
||||
<< piece_index << " block: " << block_index << ") " << peer_speedmsg;
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s requested block (piece: %u block: %u) %s"
|
||||
, torrent_alert::message().c_str(), piece_index, block_index, peer_speedmsg);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -745,10 +745,10 @@ namespace libtorrent
|
|||
virtual char const* what() const { return "unwanted block received"; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
std::stringstream ret;
|
||||
ret << peer_alert::message() << " received block not in download queue ( piece: "
|
||||
<< piece_index << " block: " << block_index << ")";
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s received block not in download queue (piece: %u block: %u)"
|
||||
, torrent_alert::message().c_str(), piece_index, block_index);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1059,11 +1059,10 @@ namespace libtorrent
|
|||
virtual int category() const { return static_category; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
error_code ec;
|
||||
std::stringstream ret;
|
||||
ret << "listening on " << endpoint
|
||||
<< " failed: " << error.message();
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "listening on %s failed: %s"
|
||||
, print_endpoint(endpoint).c_str(), error.message().c_str());
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1082,10 +1081,9 @@ namespace libtorrent
|
|||
virtual int category() const { return static_category; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
error_code ec;
|
||||
std::stringstream ret;
|
||||
ret << "successfully listening on " << endpoint;
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "successfully listening on %s", print_endpoint(endpoint).c_str());
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1131,10 +1129,10 @@ namespace libtorrent
|
|||
virtual std::string message() const
|
||||
{
|
||||
static char const* type_str[] = {"NAT-PMP", "UPnP"};
|
||||
std::stringstream ret;
|
||||
ret << "successfully mapped port using " << type_str[type]
|
||||
<< ". external port: " << external_port;
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "successfully mapped port using %s. external port: %u"
|
||||
, type_str[type], external_port);
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1155,9 +1153,9 @@ namespace libtorrent
|
|||
virtual std::string message() const
|
||||
{
|
||||
static char const* type_str[] = {"NAT-PMP", "UPnP"};
|
||||
std::stringstream ret;
|
||||
ret << type_str[type] << ": " << msg;
|
||||
return ret.str();
|
||||
char ret[200];
|
||||
snprintf(ret, 200, "%s: %s", type_str[type], msg.c_str());
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1224,10 +1222,12 @@ namespace libtorrent
|
|||
virtual std::string message() const
|
||||
{
|
||||
error_code ec;
|
||||
std::stringstream ret;
|
||||
ret << "incoming dht annonce: " << ip.to_string(ec) << ":"
|
||||
<< port << " (" << info_hash << ")";
|
||||
return ret.str();
|
||||
char ih_hex[41];
|
||||
to_hex((const char*)&info_hash[0], 20, ih_hex);
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "incoming dht announce: %s:%u (%s)"
|
||||
, ip.to_string(ec).c_str(), port, ih_hex);
|
||||
return msg;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1246,10 +1246,11 @@ namespace libtorrent
|
|||
virtual int category() const { return static_category; }
|
||||
virtual std::string message() const
|
||||
{
|
||||
error_code ec;
|
||||
std::stringstream ret;
|
||||
ret << "incoming dht get_peers: " << info_hash;
|
||||
return ret.str();
|
||||
char ih_hex[41];
|
||||
to_hex((const char*)&info_hash[0], 20, ih_hex);
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "incoming dht get_peers: %s", ih_hex);
|
||||
return msg;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -650,20 +650,24 @@ namespace libtorrent
|
|||
, int incomplete
|
||||
, address const& external_ip)
|
||||
{
|
||||
std::stringstream s;
|
||||
s << "TRACKER RESPONSE:\n"
|
||||
"interval: " << interval << "\n"
|
||||
"peers:\n";
|
||||
std::string s;
|
||||
s = "TRACKER RESPONSE:\n";
|
||||
char tmp[200];
|
||||
snprintf(tmp, 200, "interval: %d\npeers:\n", interval);
|
||||
s += tmp;
|
||||
for (std::vector<peer_entry>::const_iterator i = peers.begin();
|
||||
i != peers.end(); ++i)
|
||||
{
|
||||
s << " " << std::setfill(' ') << std::setw(16) << i->ip
|
||||
<< " " << std::setw(5) << std::dec << i->port << " ";
|
||||
if (!i->pid.is_all_zeros()) s << " " << i->pid;
|
||||
s << "\n";
|
||||
char pid[41];
|
||||
to_hex((const char*)&i->pid[0], 20, pid);
|
||||
if (i->pid.is_all_zeros()) pid[0] = 0;
|
||||
|
||||
snprintf(tmp, 200, " %16s %5d %s\n", i->ip.c_str(), i->port, pid);
|
||||
s += tmp;
|
||||
}
|
||||
s << "external ip: " << external_ip << "\n";
|
||||
debug_log(s.str());
|
||||
snprintf(tmp, 200, "external ip: %s\n", print_address(external_ip).c_str());
|
||||
s += tmp;
|
||||
debug_log(s);
|
||||
}
|
||||
|
||||
void tracker_request_timed_out(
|
||||
|
|
|
@ -88,6 +88,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define TORRENT_USE_MLOCK 1
|
||||
#define TORRENT_USE_READV 1
|
||||
#define TORRENT_USE_WRITEV 1
|
||||
#define TORRENT_USE_IOSTREAM 1
|
||||
|
||||
// should wpath or path be used?
|
||||
#if defined UNICODE && !defined BOOST_FILESYSTEM_NARROW_ONLY \
|
||||
|
|
|
@ -33,9 +33,15 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef TORRENT_DEBUG_HPP_INCLUDED
|
||||
#define TORRENT_DEBUG_HPP_INCLUDED
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
|
||||
#include <string>
|
||||
#include "libtorrent/config.hpp"
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push, 1)
|
||||
|
@ -60,6 +66,8 @@ namespace libtorrent
|
|||
{
|
||||
logger(fs::path const& logpath, fs::path const& filename, int instance, bool append = true)
|
||||
{
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
|
@ -74,21 +82,27 @@ namespace libtorrent
|
|||
{
|
||||
std::cerr << "failed to create log '" << filename.string() << "': " << e.what() << std::endl;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
logger& operator<<(T const& v)
|
||||
{
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
m_file << v;
|
||||
m_file.flush();
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
std::ofstream m_file;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
#endif // TORRENT_DEBUG
|
||||
|
||||
#endif // TORRENT_DEBUG_HPP_INCLUDED
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@ namespace libtorrent
|
|||
std::string const& url, std::string argument);
|
||||
|
||||
TORRENT_EXPORT std::string to_hex(std::string const& s);
|
||||
TORRENT_EXPORT void to_hex(char const *in, int len, char* out);
|
||||
TORRENT_EXPORT bool from_hex(char const *in, int len, char* out);
|
||||
|
||||
#if TORRENT_USE_WPATH
|
||||
TORRENT_EXPORT std::wstring convert_to_wstring(std::string const& s);
|
||||
|
|
|
@ -43,6 +43,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include "libtorrent/config.hpp"
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
struct torrent_plugin;
|
||||
|
@ -50,5 +54,7 @@ namespace libtorrent
|
|||
boost::shared_ptr<torrent_plugin> create_logger_plugin(torrent*);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // TORRENT_LOGGER_HPP_INCLUDED
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define TORRENT_IP_FILTER_HPP
|
||||
|
||||
#include <set>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push, 1)
|
||||
|
|
|
@ -33,6 +33,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef TORRENT_LOGGING_HPP
|
||||
#define TORRENT_LOGGING_HPP
|
||||
|
||||
#include "libtorrent/config.hpp"
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "libtorrent/time.hpp"
|
||||
|
@ -143,5 +147,7 @@ public:
|
|||
if (libtorrent::dht::inverted_log_event event_object__ = name ## _log()); \
|
||||
else static_cast<log_event&>(event_object__)
|
||||
|
||||
#endif // TORRENT_USE_IOSTREAM
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -35,12 +35,15 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include "libtorrent/config.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
#include "libtorrent/size_type.hpp"
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
#include <iosfwd>
|
||||
#endif
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
struct lazy_entry;
|
||||
|
@ -227,7 +230,9 @@ namespace libtorrent
|
|||
char const* m_end;
|
||||
};
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
TORRENT_EXPORT std::ostream& operator<<(std::ostream& os, lazy_entry const& e);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifndef TORRENT_PEER_ID_HPP_INCLUDED
|
||||
#define TORRENT_PEER_ID_HPP_INCLUDED
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cctype>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
@ -44,6 +42,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/assert.hpp"
|
||||
#include "libtorrent/escape_string.hpp"
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#endif
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
|
||||
|
@ -160,41 +163,23 @@ namespace libtorrent
|
|||
typedef big_number peer_id;
|
||||
typedef big_number sha1_hash;
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
inline std::ostream& operator<<(std::ostream& os, big_number const& peer)
|
||||
{
|
||||
for (big_number::const_iterator i = peer.begin();
|
||||
i != peer.end(); ++i)
|
||||
{
|
||||
os << std::hex << std::setw(2) << std::setfill('0')
|
||||
<< static_cast<unsigned int>(*i);
|
||||
}
|
||||
os << std::dec << std::setfill(' ');
|
||||
return os;
|
||||
char out[41];
|
||||
to_hex((char const*)&peer[0], big_number::size, out);
|
||||
return os << out;
|
||||
}
|
||||
|
||||
inline std::istream& operator>>(std::istream& is, big_number& peer)
|
||||
{
|
||||
for (big_number::iterator i = peer.begin();
|
||||
i != peer.end(); ++i)
|
||||
{
|
||||
char c[2];
|
||||
is >> c[0] >> c[1];
|
||||
c[0] = tolower(c[0]);
|
||||
c[1] = tolower(c[1]);
|
||||
if (
|
||||
((c[0] < '0' || c[0] > '9') && (c[0] < 'a' || c[0] > 'f'))
|
||||
|| ((c[1] < '0' || c[1] > '9') && (c[1] < 'a' || c[1] > 'f'))
|
||||
|| is.fail())
|
||||
{
|
||||
is.setstate(std::ios_base::failbit);
|
||||
return is;
|
||||
}
|
||||
*i = ((is_digit(c[0])?c[0]-'0':c[0]-'a'+10) << 4)
|
||||
+ (is_digit(c[1])?c[1]-'0':c[1]-'a'+10);
|
||||
}
|
||||
char hex[40];
|
||||
is.read(hex, 40);
|
||||
if (from_hex(hex, 40, (char*)&peer[0]) == -1)
|
||||
is.setstate(std::ios_base::failbit);
|
||||
return is;
|
||||
}
|
||||
|
||||
#endif // TORRENT_USE_IOSTREAM
|
||||
}
|
||||
|
||||
#endif // TORRENT_PEER_ID_HPP_INCLUDED
|
||||
|
|
|
@ -74,6 +74,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/io.hpp"
|
||||
#include "libtorrent/time.hpp"
|
||||
#include "libtorrent/error_code.hpp"
|
||||
#include "libtorrent/escape_string.hpp" // for to_string
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
|
@ -114,6 +115,36 @@ namespace libtorrent
|
|||
typedef boost::asio::basic_deadline_timer<libtorrent::ptime> deadline_timer;
|
||||
#endif
|
||||
|
||||
inline std::string print_address(address const& addr)
|
||||
{
|
||||
error_code ec;
|
||||
return addr.to_string(ec);
|
||||
}
|
||||
|
||||
inline std::string print_endpoint(tcp::endpoint const& ep)
|
||||
{
|
||||
error_code ec;
|
||||
std::string ret;
|
||||
address const& addr = ep.address();
|
||||
#if TORRENT_USE_IPV6
|
||||
if (addr.is_v6())
|
||||
{
|
||||
ret += '[';
|
||||
ret += addr.to_string(ec);
|
||||
ret += ']';
|
||||
ret += ':';
|
||||
ret += to_string(ep.port()).elems;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ret += addr.to_string(ec);
|
||||
ret += ':';
|
||||
ret += to_string(ep.port()).elems;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
inline std::ostream& print_address(std::ostream& os, address const& addr)
|
||||
{
|
||||
error_code ec;
|
||||
|
@ -137,7 +168,7 @@ namespace libtorrent
|
|||
os << ep.port();
|
||||
return os;
|
||||
}
|
||||
|
||||
*/
|
||||
namespace detail
|
||||
{
|
||||
template<class OutIt>
|
||||
|
|
|
@ -37,7 +37,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <vector>
|
||||
#include <set>
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push, 1)
|
||||
|
@ -204,9 +203,6 @@ namespace libtorrent
|
|||
|
||||
void second_tick(stat& accumulator, float tick_interval);
|
||||
|
||||
// debug purpose only
|
||||
void print(std::ostream& os) const;
|
||||
|
||||
std::string name() const;
|
||||
|
||||
stat statistics() const { return m_stat; }
|
||||
|
|
|
@ -34,8 +34,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
|
@ -1013,11 +1011,10 @@ namespace libtorrent
|
|||
if (t->valid_metadata()
|
||||
&& packet_size() - 1 != (t->torrent_file().num_pieces() + 7) / 8)
|
||||
{
|
||||
std::stringstream msg;
|
||||
msg << "got bitfield with invalid size: " << (packet_size() - 1)
|
||||
<< " bytes. expected: " << ((t->torrent_file().num_pieces() + 7) / 8)
|
||||
<< " bytes";
|
||||
disconnect(msg.str().c_str(), 2);
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "got bitfield with invalid size: %d bytes. expected: %d bytes"
|
||||
, int(packet_size()-1), int((t->torrent_file().num_pieces() + 7) / 8));
|
||||
disconnect(msg, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1433,9 +1430,9 @@ namespace libtorrent
|
|||
}
|
||||
#endif
|
||||
|
||||
std::stringstream msg;
|
||||
msg << "unknown extended message id: " << extended_id;
|
||||
disconnect(msg.str().c_str(), 2);
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "unknown extended message id: %d", extended_id);
|
||||
disconnect(msg, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1558,9 +1555,9 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
m_statistics.received_bytes(0, received);
|
||||
std::stringstream msg;
|
||||
msg << "unkown message id: " << packet_type << " size: " << packet_size();
|
||||
disconnect(msg.str().c_str(), 2);
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "unknown message message id: %d size: %d", packet_type, packet_size());
|
||||
disconnect(msg, 2);
|
||||
return packet_finished();
|
||||
}
|
||||
|
||||
|
@ -1743,14 +1740,15 @@ namespace libtorrent
|
|||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
(*m_logger) << time_now_string() << " ==> BITFIELD ";
|
||||
|
||||
std::stringstream bitfield_string;
|
||||
char bitfield_string[1000];
|
||||
for (int k = 0; k < num_pieces; ++k)
|
||||
{
|
||||
if (i.begin[k / 8] & (0x80 >> (k % 8))) bitfield_string << "1";
|
||||
else bitfield_string << "0";
|
||||
if (i.begin[k / 8] & (0x80 >> (k % 8))) bitfield_string[k] = '1';
|
||||
else bitfield_string[k] = '0';
|
||||
}
|
||||
bitfield_string << "\n";
|
||||
(*m_logger) << bitfield_string.str();
|
||||
bitfield_string[num_pieces] = '\n';
|
||||
bitfield_string[num_pieces + 1] = '\0';
|
||||
(*m_logger) << bitfield_string;
|
||||
#endif
|
||||
#ifdef TORRENT_DEBUG
|
||||
m_sent_bitfield = true;
|
||||
|
@ -2728,18 +2726,18 @@ namespace libtorrent
|
|||
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
{
|
||||
peer_id tmp;
|
||||
std::copy(recv_buffer.begin, recv_buffer.begin + 20, (char*)tmp.begin());
|
||||
std::stringstream s;
|
||||
s << "received peer_id: " << tmp << " client: " << identify_client(tmp) << "\n";
|
||||
s << "as ascii: ";
|
||||
for (peer_id::iterator i = tmp.begin(); i != tmp.end(); ++i)
|
||||
char hex_pid[41];
|
||||
to_hex(recv_buffer.begin, 20, hex_pid);
|
||||
char ascii_pid[21];
|
||||
for (int i = 0; i != 20; ++i)
|
||||
{
|
||||
if (std::isprint(*i)) s << *i;
|
||||
else s << ".";
|
||||
if (isprint(recv_buffer.begin[i])) ascii_pid[i] = recv_buffer.begin[i];
|
||||
else ascii_pid[i] = '.';
|
||||
}
|
||||
s << "\n";
|
||||
(*m_logger) << s.str();
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "received peer_id: %s client: %s\nas ascii: %s\n"
|
||||
, hex_pid, identify_client(peer_id(recv_buffer.begin)).c_str(), ascii_pid);
|
||||
(*m_logger) << msg;
|
||||
}
|
||||
#endif
|
||||
peer_id pid;
|
||||
|
@ -2875,9 +2873,9 @@ namespace libtorrent
|
|||
{
|
||||
m_statistics.received_bytes(0, bytes_transferred);
|
||||
// packet too large
|
||||
std::stringstream msg;
|
||||
msg << "packet > 1 MB (" << (unsigned int)packet_size << " bytes)";
|
||||
disconnect(msg.str().c_str(), 2);
|
||||
char msg[200];
|
||||
printf("packet > 1 MB (%u bytes)", (unsigned int)packet_size);
|
||||
disconnect(msg, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#if defined TORRENT_DEBUG && TORRENT_USE_IOSTREAM
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#endif
|
||||
#include <boost/bind.hpp>
|
||||
#include "libtorrent/entry.hpp"
|
||||
#include "libtorrent/config.hpp"
|
||||
|
@ -353,6 +355,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(false);
|
||||
}
|
||||
|
||||
#if defined TORRENT_DEBUG && TORRENT_USE_IOSTREAM
|
||||
void entry::print(std::ostream& os, int indent) const
|
||||
{
|
||||
TORRENT_ASSERT(indent >= 0);
|
||||
|
@ -415,5 +418,6 @@ namespace libtorrent
|
|||
os << "<uninitialized>\n";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -33,12 +33,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <cctype>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <cstring>
|
||||
|
||||
|
@ -54,7 +50,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <boost/filesystem/exception.hpp>
|
||||
#include "libtorrent/utf8.hpp"
|
||||
|
||||
#endif
|
||||
|
@ -150,20 +145,21 @@ namespace libtorrent
|
|||
return ret;
|
||||
}
|
||||
|
||||
// http://www.ietf.org/rfc/rfc2396.txt
|
||||
// section 2.3
|
||||
// some trackers seems to require that ' is escaped
|
||||
//static const char unreserved_chars[] = "-_.!~*'()";
|
||||
static const char unreserved_chars[] = "/-_.!~*()"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789";
|
||||
static const char hex_chars[] = "0123456789abcdef";
|
||||
|
||||
std::string escape_string(const char* str, int len)
|
||||
{
|
||||
TORRENT_ASSERT(str != 0);
|
||||
TORRENT_ASSERT(len >= 0);
|
||||
// http://www.ietf.org/rfc/rfc2396.txt
|
||||
// section 2.3
|
||||
// some trackers seems to require that ' is escaped
|
||||
// static const char unreserved_chars[] = "-_.!~*'()";
|
||||
static const char unreserved_chars[] = "-_.!~*()"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789";
|
||||
|
||||
std::stringstream ret;
|
||||
ret << std::hex << std::setfill('0');
|
||||
std::string ret;
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
if (std::count(
|
||||
|
@ -171,29 +167,25 @@ namespace libtorrent
|
|||
, unreserved_chars+sizeof(unreserved_chars)-1
|
||||
, *str))
|
||||
{
|
||||
ret << *str;
|
||||
ret += *str;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret << '%'
|
||||
<< std::setw(2)
|
||||
<< (int)static_cast<unsigned char>(*str);
|
||||
ret += '%';
|
||||
ret += hex_chars[((unsigned int)*str) >> 4];
|
||||
ret += hex_chars[((unsigned int)*str) & 15];
|
||||
}
|
||||
++str;
|
||||
}
|
||||
return ret.str();
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string escape_path(const char* str, int len)
|
||||
{
|
||||
TORRENT_ASSERT(str != 0);
|
||||
TORRENT_ASSERT(len >= 0);
|
||||
static const char unreserved_chars[] = "/-_.!~*()"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789";
|
||||
|
||||
std::stringstream ret;
|
||||
ret << std::hex << std::setfill('0');
|
||||
std::string ret;
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
if (std::count(
|
||||
|
@ -201,17 +193,17 @@ namespace libtorrent
|
|||
, unreserved_chars+sizeof(unreserved_chars)-1
|
||||
, *str))
|
||||
{
|
||||
ret << *str;
|
||||
ret += *str;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret << '%'
|
||||
<< std::setw(2)
|
||||
<< (int)static_cast<unsigned char>(*str);
|
||||
ret += '%';
|
||||
ret += hex_chars[((unsigned int)*str) >> 4];
|
||||
ret += hex_chars[((unsigned int)*str) & 15];
|
||||
}
|
||||
++str;
|
||||
}
|
||||
return ret.str();
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string base64encode(const std::string& s)
|
||||
|
@ -400,15 +392,46 @@ namespace libtorrent
|
|||
TORRENT_EXPORT std::string to_hex(std::string const& s)
|
||||
{
|
||||
std::string ret;
|
||||
char const* digits = "0123456789abcdef";
|
||||
for (std::string::const_iterator i = s.begin(); i != s.end(); ++i)
|
||||
{
|
||||
ret += digits[((unsigned char)*i) >> 4];
|
||||
ret += digits[((unsigned char)*i) & 0xf];
|
||||
ret += hex_chars[((unsigned char)*i) >> 4];
|
||||
ret += hex_chars[((unsigned char)*i) & 0xf];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
TORRENT_EXPORT void to_hex(char const *in, int len, char* out)
|
||||
{
|
||||
for (char const* end = in + len; in < end; ++in)
|
||||
{
|
||||
*out++ = hex_chars[((unsigned char)*in) >> 4];
|
||||
*out++ = hex_chars[((unsigned char)*in) & 0xf];
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
|
||||
int hex_to_int(char in)
|
||||
{
|
||||
if (in >= '0' && in <= '9') return int(in) - '0';
|
||||
if (in >= 'A' && in <= 'F') return int(in) - 'A' + 10;
|
||||
if (in >= 'a' && in <= 'f') return int(in) - 'a' + 10;
|
||||
return -1;
|
||||
}
|
||||
|
||||
TORRENT_EXPORT bool from_hex(char const *in, int len, char* out)
|
||||
{
|
||||
for (char const* end = in + len; in < end; ++in, ++out)
|
||||
{
|
||||
int t = hex_to_int(*in);
|
||||
if (t == -1) return false;
|
||||
*out = t << 4;
|
||||
t = hex_to_int(*in);
|
||||
if (t == -1) return false;
|
||||
*out |= t & 15;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#if TORRENT_USE_WPATH
|
||||
std::wstring convert_to_wstring(std::string const& s)
|
||||
{
|
||||
|
|
|
@ -35,8 +35,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/file_pool.hpp"
|
||||
#include "libtorrent/error_code.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
using boost::multi_index::nth_index;
|
||||
|
|
|
@ -33,11 +33,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <boost/bind.hpp>
|
||||
#include <sstream>
|
||||
|
||||
#include "libtorrent/http_seed_connection.hpp"
|
||||
#include "libtorrent/session.hpp"
|
||||
|
@ -355,9 +352,9 @@ namespace libtorrent
|
|||
// add the redirected url and remove the current one
|
||||
t->add_web_seed(location, web_seed_entry::http_seed);
|
||||
t->remove_web_seed(m_url, web_seed_entry::http_seed);
|
||||
std::stringstream msg;
|
||||
msg << "redirecting to \"" << location << "\"";
|
||||
disconnect(msg.str().c_str());
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "redirecting to \"%s\"", location.c_str());
|
||||
disconnect(msg, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <cctype>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
#include "libtorrent/config.hpp"
|
||||
|
@ -148,9 +145,9 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
url += "&key=";
|
||||
std::stringstream key_string;
|
||||
key_string << std::hex << tracker_req().key;
|
||||
url += key_string.str();
|
||||
char key[200];
|
||||
snprintf(key, 200, "%x", tracker_req().key);
|
||||
url += key;
|
||||
|
||||
url += "&compact=1";
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/ip_filter.hpp"
|
||||
#include <boost/utility.hpp>
|
||||
//#include <iostream>
|
||||
|
||||
|
||||
namespace libtorrent
|
||||
|
|
|
@ -893,7 +893,9 @@ namespace libtorrent { namespace dht
|
|||
ret["nodes"] = nodes;
|
||||
}
|
||||
|
||||
ret["node-id"] = boost::lexical_cast<std::string>(m_dht.nid());
|
||||
char node_id[41];
|
||||
to_hex((char*)&m_dht.nid()[0], 20, node_id);
|
||||
ret["node-id"] = node_id;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,9 +32,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/lazy_entry.hpp"
|
||||
#include "libtorrent/escape_string.hpp"
|
||||
#include <cstring>
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cstring>
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -363,6 +366,7 @@ namespace libtorrent
|
|||
return return_t(m_begin, m_end - m_begin);
|
||||
}
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
std::ostream& operator<<(std::ostream& os, lazy_entry const& e)
|
||||
{
|
||||
switch (e.type())
|
||||
|
@ -431,6 +435,6 @@ namespace libtorrent
|
|||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
#endif // TORRENT_USE_IOSTREAM
|
||||
};
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/peer_request.hpp"
|
||||
#include "libtorrent/peer_connection.hpp"
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
|
||||
namespace libtorrent {
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
@ -229,4 +231,5 @@ namespace libtorrent
|
|||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
31
src/lsd.cpp
31
src/lsd.cpp
|
@ -83,17 +83,19 @@ void lsd::announce(sha1_hash const& ih, int listen_port)
|
|||
{
|
||||
if (m_disabled) return;
|
||||
|
||||
std::stringstream btsearch;
|
||||
btsearch << "BT-SEARCH * HTTP/1.1\r\n"
|
||||
char ih_hex[41];
|
||||
to_hex((char const*)&ih[0], 20, ih_hex);
|
||||
char msg[200];
|
||||
int msg_len = snprintf(msg, 200,
|
||||
"BT-SEARCH * HTTP/1.1\r\n"
|
||||
"Host: 239.192.152.143:6771\r\n"
|
||||
"Port: " << to_string(listen_port).elems << "\r\n"
|
||||
"Infohash: " << ih << "\r\n"
|
||||
"\r\n\r\n";
|
||||
std::string const& msg = btsearch.str();
|
||||
"Port: %d\r\n"
|
||||
"Infohash: %s\r\n"
|
||||
"\r\n\r\n", listen_port, ih_hex);
|
||||
|
||||
m_retry_count = 1;
|
||||
error_code ec;
|
||||
m_socket.send(msg.c_str(), int(msg.size()), ec);
|
||||
m_socket.send(msg, msg_len, ec);
|
||||
if (ec)
|
||||
{
|
||||
m_disabled = true;
|
||||
|
@ -101,8 +103,9 @@ void lsd::announce(sha1_hash const& ih, int listen_port)
|
|||
}
|
||||
|
||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
||||
m_log << time_now_string()
|
||||
<< " ==> announce: ih: " << ih << " port: " << to_string(listen_port).elems << std::endl;
|
||||
snprintf(msg, 200, "%s ==> announce: ih: %s port: %u\n"
|
||||
, time_now_string(), ih_hex, listen_port);
|
||||
m_log << msg;
|
||||
#endif
|
||||
|
||||
m_broadcast_timer.expires_from_now(milliseconds(250 * m_retry_count), ec);
|
||||
|
@ -174,16 +177,16 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
|
|||
}
|
||||
|
||||
sha1_hash ih(0);
|
||||
std::istringstream ih_sstr(ih_str);
|
||||
ih_sstr >> ih;
|
||||
from_hex(ih_str.c_str(), 40, (char*)&ih[0]);
|
||||
int port = std::atoi(port_str.c_str());
|
||||
|
||||
if (!ih.is_all_zeros() && port != 0)
|
||||
{
|
||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
||||
m_log << time_now_string()
|
||||
<< " *** incoming local announce " << from.address()
|
||||
<< ":" << to_string(port).elems << " ih: " << ih << std::endl;
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "%s *** incoming local announce %s:%d ih: %s\n"
|
||||
, time_now_string(), print_address(from.address()).c_str()
|
||||
, port, ih_str.c_str());
|
||||
#endif
|
||||
// we got an announce, pass it on through the callback
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
|
|
|
@ -33,8 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
|
@ -1395,11 +1393,10 @@ namespace libtorrent
|
|||
if (t->valid_metadata()
|
||||
&& (bits.size() + 7) / 8 != (m_have_piece.size() + 7) / 8)
|
||||
{
|
||||
std::stringstream msg;
|
||||
msg << "got bitfield with invalid size: " << ((bits.size() + 7) / 8)
|
||||
<< "bytes. expected: " << ((m_have_piece.size() + 7) / 8)
|
||||
<< " bytes";
|
||||
disconnect(msg.str().c_str(), 2);
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "got bitfield with invalid size: %d bytes. expected: %d bytes"
|
||||
, int((bits.size() + 7) / 8), int((m_have_piece.size() + 7) / 8));
|
||||
disconnect(msg, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push, 1)
|
||||
#endif
|
||||
|
@ -834,9 +832,12 @@ namespace libtorrent
|
|||
// it again.
|
||||
|
||||
error_code ec;
|
||||
m_torrent->debug_log("already connected to peer: " + remote.address().to_string(ec) + ":"
|
||||
+ boost::lexical_cast<std::string>(remote.port()) + " "
|
||||
+ boost::lexical_cast<std::string>(i->second.connection->pid()));
|
||||
char hex_pid[41];
|
||||
to_hex((char*)&i->second.connection->pid()[0], 20, hex_pid);
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "already connected to peer: %s %s"
|
||||
, print_endpoint(remote).c_str(), hex_pid);
|
||||
m_torrent->debug_log(msg);
|
||||
|
||||
TORRENT_ASSERT(i->second.connection->associated_torrent().lock().get() == m_torrent);
|
||||
}
|
||||
|
|
|
@ -33,9 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
|
|
@ -672,10 +672,10 @@ namespace aux {
|
|||
if (m_alerts.should_post<listen_failed_alert>())
|
||||
m_alerts.post_alert(listen_failed_alert(ep, ec));
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
std::stringstream msg;
|
||||
msg << "cannot bind to interface '";
|
||||
print_endpoint(msg, ep) << "' " << ec.message();
|
||||
(*m_logger) << msg.str() << "\n";
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "cannot bind to interface \"%s\": %s"
|
||||
, print_endpoint(ep).c_str(), ec.message().c_str());
|
||||
(*m_logger) << msg << "\n";
|
||||
#endif
|
||||
return listen_socket_t();
|
||||
}
|
||||
|
@ -686,10 +686,10 @@ namespace aux {
|
|||
if (m_alerts.should_post<listen_failed_alert>())
|
||||
m_alerts.post_alert(listen_failed_alert(ep, ec));
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
std::stringstream msg;
|
||||
msg << "cannot listen on interface '";
|
||||
print_endpoint(msg, ep) << "' " << ec.message();
|
||||
(*m_logger) << msg.str() << "\n";
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "cannot listen on interface \"%s\": %s"
|
||||
, print_endpoint(ep).c_str(), ec.message().c_str());
|
||||
(*m_logger) << msg << "\n";
|
||||
#endif
|
||||
return listen_socket_t();
|
||||
}
|
||||
|
|
|
@ -45,8 +45,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/filesystem/convenience.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
@ -72,13 +70,15 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/disk_buffer_holder.hpp"
|
||||
#include "libtorrent/alloca.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
//#define TORRENT_PARTIAL_HASH_LOG
|
||||
|
||||
#ifdef TORRENT_DEBUG
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <ios>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
@ -110,7 +110,7 @@ using boost::bind;
|
|||
using namespace ::boost::multi_index;
|
||||
using boost::multi_index::multi_index_container;
|
||||
|
||||
#if defined TORRENT_DEBUG && defined TORRENT_STORAGE_DEBUG
|
||||
#if defined TORRENT_DEBUG && defined TORRENT_STORAGE_DEBUG && TORRENT_USE_IOSTREAM
|
||||
namespace
|
||||
{
|
||||
using namespace libtorrent;
|
||||
|
@ -1644,7 +1644,7 @@ ret:
|
|||
// only save the partial hash if the write succeeds
|
||||
if (ret != size) return ret;
|
||||
|
||||
#ifdef TORRENT_PARTIAL_HASH_LOG
|
||||
#if defined TORRENT_PARTIAL_HASH_LOG && TORRENT_USE_IOSTREAM
|
||||
std::ofstream out("partial_hash.log", std::ios::app);
|
||||
#endif
|
||||
|
||||
|
@ -1657,7 +1657,7 @@ ret:
|
|||
for (file::iovec_t* i = iov, *end(iov + num_bufs); i < end; ++i)
|
||||
ph.h.update((char const*)i->iov_base, i->iov_len);
|
||||
|
||||
#ifdef TORRENT_PARTIAL_HASH_LOG
|
||||
#if defined TORRENT_PARTIAL_HASH_LOG && TORRENT_USE_IOSTREAM
|
||||
out << time_now_string() << " NEW ["
|
||||
" s: " << this
|
||||
<< " p: " << piece_index
|
||||
|
@ -2713,7 +2713,7 @@ ret:
|
|||
&& m_slot_to_piece[piece_index] >= 0)
|
||||
{
|
||||
|
||||
#if defined TORRENT_DEBUG && defined TORRENT_STORAGE_DEBUG
|
||||
#if defined TORRENT_DEBUG && defined TORRENT_STORAGE_DEBUG && TORRENT_USE_IOSTREAM
|
||||
std::stringstream s;
|
||||
|
||||
s << "there is another piece at our slot, swapping..";
|
||||
|
@ -2953,7 +2953,7 @@ ret:
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef TORRENT_STORAGE_DEBUG
|
||||
#ifdef TORRENT_STORAGE_DEBUG && TORRENT_USE_IOSTREAM
|
||||
void piece_manager::debug_log() const
|
||||
{
|
||||
std::stringstream s;
|
||||
|
|
|
@ -33,8 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <ctime>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
@ -79,6 +77,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/assert.hpp"
|
||||
#include "libtorrent/broadcast_socket.hpp"
|
||||
|
||||
#if TORRENT_USE_IOSTREAM
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
using namespace libtorrent;
|
||||
using boost::tuples::tuple;
|
||||
using boost::tuples::get;
|
||||
|
@ -1166,7 +1168,7 @@ namespace libtorrent
|
|||
if (complete >= 0 && incomplete >= 0)
|
||||
m_last_scrape = now;
|
||||
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
||||
#if (defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING) && TORRENT_USE_IOSTREAM
|
||||
std::stringstream s;
|
||||
s << "TRACKER RESPONSE:\n"
|
||||
"interval: " << interval << "\n"
|
||||
|
@ -2783,10 +2785,10 @@ namespace libtorrent
|
|||
{
|
||||
if (m_ses.m_alerts.should_post<url_seed_alert>())
|
||||
{
|
||||
std::stringstream msg;
|
||||
msg << "HTTP seed hostname lookup failed: " << e.message();
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "HTTP seed hostname lookup failed: %s", e.message().c_str());
|
||||
m_ses.m_alerts.post_alert(
|
||||
url_seed_alert(get_handle(), web.url, msg.str()));
|
||||
url_seed_alert(get_handle(), web.url, msg));
|
||||
}
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
(*m_ses.m_logger) << " ** HOSTNAME LOOKUP FAILED!**: " << web.url << "\n";
|
||||
|
|
|
@ -33,9 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
|
|
@ -33,9 +33,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#if !defined TORRENT_NO_DEPRECATE && TORRENT_USE_IOSTREAM
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#endif
|
||||
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
|
@ -903,7 +906,7 @@ namespace libtorrent
|
|||
< bind(&announce_entry::tier, _2));
|
||||
}
|
||||
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
#if !defined TORRENT_NO_DEPRECATE && TORRENT_USE_IOSTREAM
|
||||
// ------- start deprecation -------
|
||||
|
||||
void torrent_info::print(std::ostream& os) const
|
||||
|
|
|
@ -33,10 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <cctype>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
|
|
|
@ -33,10 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <cctype>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
#include "zlib.h"
|
||||
|
||||
|
@ -46,11 +43,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
||||
#include <boost/lexical_cast.hpp>
|
||||
using boost::lexical_cast;
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
@ -195,9 +187,9 @@ namespace libtorrent
|
|||
{
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
||||
boost::shared_ptr<request_callback> cb = requester();
|
||||
std::stringstream msg;
|
||||
msg << "*** UDP_TRACKER [ timed out url: " << tracker_req().url << " ]";
|
||||
if (cb) cb->debug_log(msg.str().c_str());
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "*** UDP_TRACKER [ timed out url: %s ]", tracker_req().url.c_str());
|
||||
if (cb) cb->debug_log(msg);
|
||||
#endif
|
||||
m_socket.close();
|
||||
m_name_lookup.cancel();
|
||||
|
@ -230,9 +222,9 @@ namespace libtorrent
|
|||
boost::shared_ptr<request_callback> cb = requester();
|
||||
if (cb)
|
||||
{
|
||||
std::stringstream msg;
|
||||
msg << "<== UDP_TRACKER_PACKET [ size: " << size << " ]";
|
||||
cb->debug_log(msg.str());
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "<== UDP_TRACKER_PACKET [ size: %d ]", size);
|
||||
cb->debug_log(msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -248,9 +240,9 @@ namespace libtorrent
|
|||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
||||
if (cb)
|
||||
{
|
||||
std::stringstream msg;
|
||||
msg << "*** UDP_TRACKER_PACKET [ acton: " << action << " ]";
|
||||
cb->debug_log(msg.str());
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "*** UDP_TRACKER_PACKET [ action: %d ]", action);
|
||||
cb->debug_log(msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -269,9 +261,10 @@ namespace libtorrent
|
|||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
||||
if (cb)
|
||||
{
|
||||
std::stringstream msg;
|
||||
msg << "*** UDP_TRACKER_RESPONSE [ cid: " << m_connection_id << " ]";
|
||||
cb->debug_log(msg.str());
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "*** UDP_TRACKER_RESPONSE [ cid: %x%x ]"
|
||||
, int(m_connection_id >> 32), int(m_connection_id & 0xffffffff));
|
||||
cb->debug_log(msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -315,8 +308,11 @@ namespace libtorrent
|
|||
boost::shared_ptr<request_callback> cb = requester();
|
||||
if (cb)
|
||||
{
|
||||
cb->debug_log("==> UDP_TRACKER_CONNECT ["
|
||||
+ lexical_cast<std::string>(tracker_req().info_hash) + "]");
|
||||
char hex_ih[41];
|
||||
to_hex((char const*)&tracker_req().info_hash[0], 20, hex_ih);
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "==> UDP_TRACKER_CONNECT [%s]", hex_ih);
|
||||
cb->debug_log(msg);
|
||||
}
|
||||
#endif
|
||||
if (!m_socket.is_open()) return; // the operation was aborted
|
||||
|
@ -398,9 +394,9 @@ namespace libtorrent
|
|||
if (cb)
|
||||
{
|
||||
boost::shared_ptr<request_callback> cb = requester();
|
||||
std::stringstream msg;
|
||||
msg << "<== UDP_ANNOUNCE_RESPONSE [ url: " << tracker_req().url << " ]";
|
||||
cb->debug_log(msg.str().c_str());
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "<== UDP_TRACKER_RESPONSE [ url: %s ]", tracker_req().url.c_str());
|
||||
cb->debug_log(msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -415,12 +411,13 @@ namespace libtorrent
|
|||
{
|
||||
// TODO: don't use a string here
|
||||
peer_entry e;
|
||||
std::stringstream s;
|
||||
s << (int)detail::read_uint8(buf) << ".";
|
||||
s << (int)detail::read_uint8(buf) << ".";
|
||||
s << (int)detail::read_uint8(buf) << ".";
|
||||
s << (int)detail::read_uint8(buf);
|
||||
e.ip = s.str();
|
||||
char ip_string[100];
|
||||
unsigned int a = detail::read_uint8(buf);
|
||||
unsigned int b = detail::read_uint8(buf);
|
||||
unsigned int c = detail::read_uint8(buf);
|
||||
unsigned int d = detail::read_uint8(buf);
|
||||
snprintf(ip_string, 100, "%u.%u.%u.%u", a, b, c, d);
|
||||
e.ip = ip_string;
|
||||
e.port = detail::read_uint16(buf);
|
||||
e.pid.clear();
|
||||
peer_list.push_back(e);
|
||||
|
@ -521,11 +518,11 @@ namespace libtorrent
|
|||
|
||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
||||
boost::shared_ptr<request_callback> cb = requester();
|
||||
if (cb)
|
||||
{
|
||||
cb->debug_log("==> UDP_TRACKER_ANNOUNCE ["
|
||||
+ lexical_cast<std::string>(req.info_hash) + "]");
|
||||
}
|
||||
char hex_ih[41];
|
||||
to_hex((char const*)&req.info_hash[0], 20, hex_ih);
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "==> UDP_TRACKER_ANNOUNCE [%s]", hex_ih);
|
||||
cb->debug_log(msg);
|
||||
#endif
|
||||
|
||||
error_code ec;
|
||||
|
|
|
@ -33,11 +33,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/pch.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <boost/bind.hpp>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libtorrent/web_peer_connection.hpp"
|
||||
|
@ -448,19 +445,19 @@ namespace libtorrent
|
|||
if (i == std::string::npos)
|
||||
{
|
||||
t->remove_web_seed(m_url, web_seed_entry::url_seed);
|
||||
std::stringstream msg;
|
||||
msg << "got invalid HTTP redirection location (\"" << location << "\") "
|
||||
"expected it to end with: " << path;
|
||||
disconnect(msg.str().c_str(), 2);
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "got invalid HTTP redirection location (\"%s\") "
|
||||
"expected it to end with: %s", location.c_str(), path.c_str());
|
||||
disconnect(msg, 2);
|
||||
return;
|
||||
}
|
||||
location.resize(i);
|
||||
}
|
||||
t->add_web_seed(location, web_seed_entry::url_seed);
|
||||
t->remove_web_seed(m_url, web_seed_entry::url_seed);
|
||||
std::stringstream msg;
|
||||
msg << "redirecting to \"" << location << "\"";
|
||||
disconnect(msg.str().c_str());
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "redirecting to \"%s\"", location.c_str());
|
||||
disconnect(msg, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -488,17 +485,29 @@ namespace libtorrent
|
|||
size_type range_end;
|
||||
if (m_parser.status_code() == 206)
|
||||
{
|
||||
std::stringstream range_str(m_parser.header("content-range"));
|
||||
char dummy;
|
||||
std::string bytes;
|
||||
range_str >> bytes >> range_start >> dummy >> range_end;
|
||||
if (!range_str)
|
||||
std::string const& range_str = m_parser.header("content-range");
|
||||
|
||||
bool success = true;
|
||||
char const* ptr = range_str.c_str();
|
||||
char* end;
|
||||
range_start = strtoll(ptr, &end, 10);
|
||||
if (end == ptr) success = false;
|
||||
else if (*end != '-') success = false;
|
||||
else
|
||||
{
|
||||
ptr = end + 1;
|
||||
range_end = strtoll(ptr, &end, 10);
|
||||
if (end == ptr) success = false;
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
// we should not try this server again.
|
||||
t->remove_web_seed(m_url, web_seed_entry::url_seed);
|
||||
std::stringstream msg;
|
||||
msg << "invalid range in HTTP response: " << range_str.str();
|
||||
disconnect(msg.str().c_str(), 2);
|
||||
char msg[200];
|
||||
snprintf(msg, 200, "invalid range in HTTP response: %s"
|
||||
, range_str.c_str());
|
||||
disconnect(msg, 2);
|
||||
return;
|
||||
}
|
||||
// the http range is inclusive
|
||||
|
|
Loading…
Reference in New Issue