|
|
|
@ -32,6 +32,8 @@ using namespace boost;
@@ -32,6 +32,8 @@ using namespace boost;
|
|
|
|
|
CWallet* pwalletMain; |
|
|
|
|
CClientUIInterface uiInterface; |
|
|
|
|
|
|
|
|
|
void startSessionTorrent(boost::thread_group& threadGroup); |
|
|
|
|
|
|
|
|
|
#ifdef WIN32 |
|
|
|
|
// Win32 LevelDB doesn't use filedescriptors, and the ones used for
|
|
|
|
|
// accessing block files, don't count towards to fd_set size limit
|
|
|
|
@ -947,5 +949,57 @@ bool AppInit2(boost::thread_group& threadGroup)
@@ -947,5 +949,57 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|
|
|
|
// Run a thread to flush wallet periodically
|
|
|
|
|
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile))); |
|
|
|
|
|
|
|
|
|
startSessionTorrent(threadGroup); |
|
|
|
|
|
|
|
|
|
return !fRequestShutdown; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ===================== LIBTORRENT & DHT ===========================
|
|
|
|
|
|
|
|
|
|
#include "libtorrent/config.hpp" |
|
|
|
|
#include "libtorrent/entry.hpp" |
|
|
|
|
#include "libtorrent/bencode.hpp" |
|
|
|
|
#include "libtorrent/session.hpp" |
|
|
|
|
|
|
|
|
|
using namespace libtorrent; |
|
|
|
|
static session *ses; |
|
|
|
|
|
|
|
|
|
void startSessionTorrent(boost::thread_group& threadGroup) |
|
|
|
|
{ |
|
|
|
|
error_code ec; |
|
|
|
|
int listen_port = GetListenPort() + 1000; |
|
|
|
|
std::string bind_to_interface = ""; |
|
|
|
|
|
|
|
|
|
printf("startSessionTorrent port=%d\n", listen_port); |
|
|
|
|
|
|
|
|
|
ses = new session(fingerprint("LT", LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0) |
|
|
|
|
, session::add_default_plugins |
|
|
|
|
, alert::all_categories |
|
|
|
|
& ~(alert::dht_notification |
|
|
|
|
+ alert::progress_notification |
|
|
|
|
+ alert::debug_notification |
|
|
|
|
+ alert::stats_notification)); |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
std::vector<char> in; |
|
|
|
|
if (load_file(".ses_state", in, ec) == 0) |
|
|
|
|
{ |
|
|
|
|
lazy_entry e; |
|
|
|
|
if (lazy_bdecode(&in[0], &in[0] + in.size(), e, ec) == 0) |
|
|
|
|
ses.load_state(e); |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
ses->listen_on(std::make_pair(listen_port, listen_port) |
|
|
|
|
, ec, bind_to_interface.c_str()); |
|
|
|
|
if (ec) |
|
|
|
|
{ |
|
|
|
|
fprintf(stderr, "failed to listen%s%s on ports %d-%d: %s\n" |
|
|
|
|
, bind_to_interface.empty() ? "" : " on ", bind_to_interface.c_str() |
|
|
|
|
, listen_port, listen_port+1, ec.message().c_str()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ses->start_dht(); |
|
|
|
|
printf("libtorrent + dht started\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|