diff --git a/libtorrent/bindings/python/src/session.cpp b/libtorrent/bindings/python/src/session.cpp index 9202079de..5d9e9fddf 100755 --- a/libtorrent/bindings/python/src/session.cpp +++ b/libtorrent/bindings/python/src/session.cpp @@ -300,6 +300,7 @@ void bind_session() .def("stop_dht", allow_threads(&session::stop_dht), session_stop_dht_doc) .def("dht_state", allow_threads(&session::dht_state), session_dht_state_doc) .def("set_dht_proxy", allow_threads(&session::set_dht_proxy)) + .def("dht_proxy", allow_threads(&session::dht_proxy), return_value_policy()) #endif .def("add_torrent", &add_torrent, session_add_torrent_doc) #ifndef TORRENT_NO_DEPRECATE @@ -373,6 +374,9 @@ void bind_session() .def("set_peer_proxy", allow_threads(&session::set_peer_proxy)) .def("set_tracker_proxy", allow_threads(&session::set_tracker_proxy)) .def("set_web_seed_proxy", allow_threads(&session::set_web_seed_proxy)) + .def("peer_proxy", allow_threads(&session::peer_proxy), return_value_policy()) + .def("tracker_proxy", allow_threads(&session::tracker_proxy), return_value_policy()) + .def("web_seed_proxy", allow_threads(&session::web_seed_proxy), return_value_policy()) .def("start_upnp", &start_upnp, session_start_upnp_doc) .def("stop_upnp", allow_threads(&session::stop_upnp), session_stop_upnp_doc) .def("start_lsd", allow_threads(&session::start_lsd), session_start_lsd_doc) diff --git a/libtorrent/src/disk_io_thread.cpp b/libtorrent/src/disk_io_thread.cpp index 3ff193c3c..e446964b0 100644 --- a/libtorrent/src/disk_io_thread.cpp +++ b/libtorrent/src/disk_io_thread.cpp @@ -452,7 +452,7 @@ namespace libtorrent { l.unlock(); ret += p.storage->read_impl(p.blocks[i], p.piece, piece_offset, block_size); - if (!p.storage->error()) { return -1; } + if (p.storage->error()) { return -1; } l.lock(); ++m_cache_stats.reads; } diff --git a/libtorrent/src/kademlia/dht_tracker.cpp b/libtorrent/src/kademlia/dht_tracker.cpp index 485471555..88bc7738d 100644 --- a/libtorrent/src/kademlia/dht_tracker.cpp +++ b/libtorrent/src/kademlia/dht_tracker.cpp @@ -298,7 +298,7 @@ namespace libtorrent { namespace dht int peers = 0; std::for_each(m_dht.begin_data(), m_dht.end_data(), count_peers(peers)); - std::ofstream pc("libtorrent_logs/dht_stats.log", std::ios_base::app); + std::ofstream pc("libtorrent_logs/dht_stats.log", first ? std::ios_base::trunc : std::ios_base::app); if (first) { first = false; diff --git a/libtorrent/src/kademlia/rpc_manager.cpp b/libtorrent/src/kademlia/rpc_manager.cpp index 6aa410061..a2082b2e3 100644 --- a/libtorrent/src/kademlia/rpc_manager.cpp +++ b/libtorrent/src/kademlia/rpc_manager.cpp @@ -263,7 +263,7 @@ bool rpc_manager::incoming(msg const& m) } #ifdef TORRENT_DHT_VERBOSE_LOGGING - std::ofstream reply_stats("libtorrent_logs/round_trip_ms.log", std::ios::app); + std::ofstream reply_stats("round_trip_ms.log", std::ios::app); reply_stats << m.addr << "\t" << total_milliseconds(time_now() - o->sent) << std::endl; #endif diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index dffcf18bc..efb97a77d 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -3421,6 +3421,8 @@ namespace libtorrent TORRENT_ASSERT(m_torrent_file->is_valid()); INVARIANT_CHECK; + if (m_abort) return; + // we might be finished already, in which case we should // not switch to downloading mode. if (m_state != torrent_status::finished) diff --git a/libtorrent/src/torrent_info.cpp b/libtorrent/src/torrent_info.cpp index e7f173d6c..7c109e693 100755 --- a/libtorrent/src/torrent_info.cpp +++ b/libtorrent/src/torrent_info.cpp @@ -74,13 +74,12 @@ namespace str += 0x80 | (chr & 0x3f); } - void verify_encoding(file_entry& target) + bool verify_encoding(std::string& target) { std::string tmp_path; - std::string file_path = target.path.string(); bool valid_encoding = true; - for (std::string::iterator i = file_path.begin() - , end(file_path.end()); i != end; ++i) + for (std::string::iterator i = target.begin() + , end(target.end()); i != end; ++i) { // valid ascii-character if ((*i & 0x80) == 0) @@ -153,7 +152,14 @@ namespace // save the original encoding and replace the // commonly used path with the correctly // encoded string - if (!valid_encoding) target.path = tmp_path; + if (!valid_encoding) target = tmp_path; + return valid_encoding; + } + + void verify_encoding(file_entry& target) + { + std::string p = target.path.string(); + if (!verify_encoding(p)) target.path = p; } bool extract_single_file(lazy_entry const& dict, file_entry& target @@ -420,6 +426,9 @@ namespace libtorrent error = "invalid 'name' of torrent (possible exploit attempt)"; return false; } + + // correct utf-8 encoding errors + verify_encoding(name); // extract file list lazy_entry const* i = info.dict_find_list("files"); @@ -573,9 +582,11 @@ namespace libtorrent m_comment = torrent_file.dict_find_string_value("comment.utf-8"); if (m_comment.empty()) m_comment = torrent_file.dict_find_string_value("comment"); + verify_encoding(m_comment); m_created_by = torrent_file.dict_find_string_value("created by.utf-8"); if (m_created_by.empty()) m_created_by = torrent_file.dict_find_string_value("created by"); + verify_encoding(m_created_by); lazy_entry const* info = torrent_file.dict_find_dict("info"); if (info == 0)