forked from premiere/premiere-libtorrent
fix build issue out of recent changes of exported functions
This commit is contained in:
parent
bbcfeeab8d
commit
1b07ec491d
|
@ -114,6 +114,7 @@ set(kademlia_sources
|
||||||
dos_blocker
|
dos_blocker
|
||||||
dht_tracker
|
dht_tracker
|
||||||
node
|
node
|
||||||
|
node_entry
|
||||||
refresh
|
refresh
|
||||||
rpc_manager
|
rpc_manager
|
||||||
find_data
|
find_data
|
||||||
|
|
1
Jamfile
1
Jamfile
|
@ -631,6 +631,7 @@ SOURCES =
|
||||||
KADEMLIA_SOURCES =
|
KADEMLIA_SOURCES =
|
||||||
dht_tracker
|
dht_tracker
|
||||||
node
|
node
|
||||||
|
node_entry
|
||||||
refresh
|
refresh
|
||||||
rpc_manager
|
rpc_manager
|
||||||
find_data
|
find_data
|
||||||
|
|
|
@ -40,6 +40,17 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
namespace lt = libtorrent;
|
namespace lt = libtorrent;
|
||||||
|
|
||||||
|
void sleep_ms(int milliseconds)
|
||||||
|
{
|
||||||
|
#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN
|
||||||
|
Sleep(milliseconds);
|
||||||
|
#elif defined TORRENT_BEOS
|
||||||
|
snooze_until(system_time() + boost::int64_t(milliseconds) * 1000, B_SYSTEM_TIMEBASE);
|
||||||
|
#else
|
||||||
|
usleep(milliseconds * 1000);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int load_file(std::string const& filename, std::vector<char>& v, libtorrent::error_code& ec, int limit = 8000000)
|
int load_file(std::string const& filename, std::vector<char>& v, libtorrent::error_code& ec, int limit = 8000000)
|
||||||
{
|
{
|
||||||
ec.clear();
|
ec.clear();
|
||||||
|
@ -210,7 +221,7 @@ int main(int argc, char* argv[])
|
||||||
fprintf(stderr, "fetching feed ... %c", spinner[i]);
|
fprintf(stderr, "fetching feed ... %c", spinner[i]);
|
||||||
while (fs.updating)
|
while (fs.updating)
|
||||||
{
|
{
|
||||||
sleep(100);
|
sleep_ms(100);
|
||||||
i = (i + 1) % 4;
|
i = (i + 1) % 4;
|
||||||
fprintf(stderr, "\b%c", spinner[i]);
|
fprintf(stderr, "\b%c", spinner[i]);
|
||||||
fs = fh.get_feed_status();
|
fs = fh.get_feed_status();
|
||||||
|
@ -251,7 +262,7 @@ int main(int argc, char* argv[])
|
||||||
, st.num_peers, st.num_seeds, status.c_str());
|
, st.num_peers, st.num_seeds, status.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(500);
|
sleep_ms(500);
|
||||||
if (quit) break;
|
if (quit) break;
|
||||||
printf("\033[%dA", int(t.size()));
|
printf("\033[%dA", int(t.size()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,10 +56,10 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
// return true if the status code is 200, 206, or in the 300-400 range
|
// return true if the status code is 200, 206, or in the 300-400 range
|
||||||
bool is_ok_status(int http_status);
|
TORRENT_EXTRA_EXPORT bool is_ok_status(int http_status);
|
||||||
|
|
||||||
// return true if the status code is a redirect
|
// return true if the status code is a redirect
|
||||||
bool is_redirect(int http_status);
|
TORRENT_EXTRA_EXPORT bool is_redirect(int http_status);
|
||||||
|
|
||||||
TORRENT_EXTRA_EXPORT std::string resolve_redirect_location(std::string referrer
|
TORRENT_EXTRA_EXPORT std::string resolve_redirect_location(std::string referrer
|
||||||
, std::string location);
|
, std::string location);
|
||||||
|
|
|
@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/socket.hpp"
|
#include "libtorrent/socket.hpp"
|
||||||
#include "libtorrent/address.hpp"
|
#include "libtorrent/address.hpp"
|
||||||
#include "libtorrent/union_endpoint.hpp"
|
#include "libtorrent/union_endpoint.hpp"
|
||||||
#include "libtorrent/aux_/time.hpp" // for aux::time_now()
|
#include "libtorrent/time.hpp" // for time_point
|
||||||
|
|
||||||
namespace libtorrent { namespace dht
|
namespace libtorrent { namespace dht
|
||||||
{
|
{
|
||||||
|
@ -45,43 +45,10 @@ namespace libtorrent { namespace dht
|
||||||
struct node_entry
|
struct node_entry
|
||||||
{
|
{
|
||||||
node_entry(node_id const& id_, udp::endpoint ep, int roundtriptime = 0xffff
|
node_entry(node_id const& id_, udp::endpoint ep, int roundtriptime = 0xffff
|
||||||
, bool pinged = false)
|
, bool pinged = false);
|
||||||
: last_queried(pinged ? aux::time_now() : min_time())
|
node_entry(udp::endpoint ep);
|
||||||
, id(id_)
|
node_entry();
|
||||||
, a(ep.address().to_v4().to_bytes())
|
void update_rtt(int new_rtt);
|
||||||
, p(ep.port())
|
|
||||||
, rtt(roundtriptime & 0xffff)
|
|
||||||
, timeout_count(pinged ? 0 : 0xff)
|
|
||||||
{
|
|
||||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
|
||||||
first_seen = aux::time_now();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
node_entry(udp::endpoint ep)
|
|
||||||
: last_queried(min_time())
|
|
||||||
, id(0)
|
|
||||||
, a(ep.address().to_v4().to_bytes())
|
|
||||||
, p(ep.port())
|
|
||||||
, rtt(0xffff)
|
|
||||||
, timeout_count(0xff)
|
|
||||||
{
|
|
||||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
|
||||||
first_seen = aux::time_now();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
node_entry()
|
|
||||||
: last_queried(min_time())
|
|
||||||
, id(0)
|
|
||||||
, p(0)
|
|
||||||
, rtt(0xffff)
|
|
||||||
, timeout_count(0xff)
|
|
||||||
{
|
|
||||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
|
||||||
first_seen = aux::time_now();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool pinged() const { return timeout_count != 0xff; }
|
bool pinged() const { return timeout_count != 0xff; }
|
||||||
void set_pinged() { if (timeout_count == 0xff) timeout_count = 0; }
|
void set_pinged() { if (timeout_count == 0xff) timeout_count = 0; }
|
||||||
|
@ -90,14 +57,6 @@ struct node_entry
|
||||||
void reset_fail_count() { if (pinged()) timeout_count = 0; }
|
void reset_fail_count() { if (pinged()) timeout_count = 0; }
|
||||||
udp::endpoint ep() const { return udp::endpoint(address_v4(a), p); }
|
udp::endpoint ep() const { return udp::endpoint(address_v4(a), p); }
|
||||||
bool confirmed() const { return timeout_count == 0; }
|
bool confirmed() const { return timeout_count == 0; }
|
||||||
void update_rtt(int new_rtt)
|
|
||||||
{
|
|
||||||
TORRENT_ASSERT(new_rtt <= 0xffff);
|
|
||||||
TORRENT_ASSERT(new_rtt >= 0);
|
|
||||||
if (new_rtt == 0xffff) return;
|
|
||||||
if (rtt == 0xffff) rtt = new_rtt;
|
|
||||||
else rtt = int(rtt) * 2 / 3 + int(new_rtt) / 3;
|
|
||||||
}
|
|
||||||
address addr() const { return address_v4(a); }
|
address addr() const { return address_v4(a); }
|
||||||
int port() const { return p; }
|
int port() const { return p; }
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ KADEMLIA_SOURCES = \
|
||||||
kademlia/dht_tracker.cpp \
|
kademlia/dht_tracker.cpp \
|
||||||
kademlia/find_data.cpp \
|
kademlia/find_data.cpp \
|
||||||
kademlia/node.cpp \
|
kademlia/node.cpp \
|
||||||
|
kademlia/node_entry.cpp \
|
||||||
kademlia/node_id.cpp \
|
kademlia/node_id.cpp \
|
||||||
kademlia/refresh.cpp \
|
kademlia/refresh.cpp \
|
||||||
kademlia/routing_table.cpp \
|
kademlia/routing_table.cpp \
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2006-2014, Arvid Norberg
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the author nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived
|
||||||
|
from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libtorrent/kademlia/node_entry.hpp"
|
||||||
|
#include "libtorrent/aux_/time.hpp" // for aux::time_now()
|
||||||
|
|
||||||
|
namespace libtorrent { namespace dht
|
||||||
|
{
|
||||||
|
|
||||||
|
node_entry::node_entry(node_id const& id_, udp::endpoint ep
|
||||||
|
, int roundtriptime
|
||||||
|
, bool pinged)
|
||||||
|
: last_queried(pinged ? aux::time_now() : min_time())
|
||||||
|
, id(id_)
|
||||||
|
, a(ep.address().to_v4().to_bytes())
|
||||||
|
, p(ep.port())
|
||||||
|
, rtt(roundtriptime & 0xffff)
|
||||||
|
, timeout_count(pinged ? 0 : 0xff)
|
||||||
|
{
|
||||||
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||||
|
first_seen = aux::time_now();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
node_entry::node_entry(udp::endpoint ep)
|
||||||
|
: last_queried(min_time())
|
||||||
|
, id(0)
|
||||||
|
, a(ep.address().to_v4().to_bytes())
|
||||||
|
, p(ep.port())
|
||||||
|
, rtt(0xffff)
|
||||||
|
, timeout_count(0xff)
|
||||||
|
{
|
||||||
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||||
|
first_seen = aux::time_now();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
node_entry::node_entry()
|
||||||
|
: last_queried(min_time())
|
||||||
|
, id(0)
|
||||||
|
, p(0)
|
||||||
|
, rtt(0xffff)
|
||||||
|
, timeout_count(0xff)
|
||||||
|
{
|
||||||
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||||
|
first_seen = aux::time_now();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void node_entry::update_rtt(int new_rtt)
|
||||||
|
{
|
||||||
|
TORRENT_ASSERT(new_rtt <= 0xffff);
|
||||||
|
TORRENT_ASSERT(new_rtt >= 0);
|
||||||
|
if (new_rtt == 0xffff) return;
|
||||||
|
if (rtt == 0xffff) rtt = new_rtt;
|
||||||
|
else rtt = int(rtt) * 2 / 3 + int(new_rtt) / 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <libtorrent/hasher.hpp>
|
#include <libtorrent/hasher.hpp>
|
||||||
#include <libtorrent/session_settings.hpp> // for dht_settings
|
#include <libtorrent/session_settings.hpp> // for dht_settings
|
||||||
#include <libtorrent/time.hpp>
|
#include <libtorrent/time.hpp>
|
||||||
|
#include <libtorrent/aux_/time.hpp> // for aux::time_now
|
||||||
|
|
||||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
|
@ -284,7 +284,7 @@ void test_transfer(settings_pack const& sett)
|
||||||
}
|
}
|
||||||
TEST_CHECK(resume_data.size());
|
TEST_CHECK(resume_data.size());
|
||||||
|
|
||||||
fprintf(stderr, "%s\n", resume_data.data());
|
fprintf(stderr, "%s\n", &resume_data[0]);
|
||||||
|
|
||||||
ses2.remove_torrent(tor2);
|
ses2.remove_torrent(tor2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue