added proper support for dht router nodes (which are automatically used to bootstrap from, and won't get added to the routing table)

This commit is contained in:
Arvid Norberg 2006-09-27 17:20:18 +00:00
parent 411bc4895c
commit 910733f29e
13 changed files with 228 additions and 121 deletions

View File

@ -40,125 +40,126 @@
<li><a class="reference" href="#is-listening-listen-port-listen-on" id="id28" name="id28">is_listening() listen_port() listen_on()</a></li> <li><a class="reference" href="#is-listening-listen-port-listen-on" id="id28" name="id28">is_listening() listen_port() listen_on()</a></li>
<li><a class="reference" href="#pop-alert-set-severity-level" id="id29" name="id29">pop_alert() set_severity_level()</a></li> <li><a class="reference" href="#pop-alert-set-severity-level" id="id29" name="id29">pop_alert() set_severity_level()</a></li>
<li><a class="reference" href="#start-dht-stop-dht-set-dht-settings-dht-state" id="id30" name="id30">start_dht() stop_dht() set_dht_settings() dht_state()</a></li> <li><a class="reference" href="#start-dht-stop-dht-set-dht-settings-dht-state" id="id30" name="id30">start_dht() stop_dht() set_dht_settings() dht_state()</a></li>
<li><a class="reference" href="#add-dht-node-add-dht-router" id="id31" name="id31">add_dht_node() add_dht_router()</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference" href="#entry" id="id31" name="id31">entry</a><ul> <li><a class="reference" href="#entry" id="id32" name="id32">entry</a><ul>
<li><a class="reference" href="#integer-string-list-dict-type" id="id32" name="id32">integer() string() list() dict() type()</a></li> <li><a class="reference" href="#integer-string-list-dict-type" id="id33" name="id33">integer() string() list() dict() type()</a></li>
<li><a class="reference" href="#operator" id="id33" name="id33">operator[]</a></li> <li><a class="reference" href="#operator" id="id34" name="id34">operator[]</a></li>
<li><a class="reference" href="#find-key" id="id34" name="id34">find_key()</a></li> <li><a class="reference" href="#find-key" id="id35" name="id35">find_key()</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference" href="#torrent-info" id="id35" name="id35">torrent_info</a><ul> <li><a class="reference" href="#torrent-info" id="id36" name="id36">torrent_info</a><ul>
<li><a class="reference" href="#id3" id="id36" name="id36">torrent_info()</a></li> <li><a class="reference" href="#id3" id="id37" name="id37">torrent_info()</a></li>
<li><a class="reference" href="#set-comment-set-piece-size-set-creator-set-hash-add-tracker-add-file" id="id37" name="id37">set_comment() set_piece_size() set_creator() set_hash() add_tracker() add_file()</a></li> <li><a class="reference" href="#set-comment-set-piece-size-set-creator-set-hash-add-tracker-add-file" id="id38" name="id38">set_comment() set_piece_size() set_creator() set_hash() add_tracker() add_file()</a></li>
<li><a class="reference" href="#create-torrent" id="id38" name="id38">create_torrent()</a></li> <li><a class="reference" href="#create-torrent" id="id39" name="id39">create_torrent()</a></li>
<li><a class="reference" href="#begin-files-end-files-rbegin-files-rend-files" id="id39" name="id39">begin_files() end_files() rbegin_files() rend_files()</a></li> <li><a class="reference" href="#begin-files-end-files-rbegin-files-rend-files" id="id40" name="id40">begin_files() end_files() rbegin_files() rend_files()</a></li>
<li><a class="reference" href="#num-files-file-at" id="id40" name="id40">num_files() file_at()</a></li> <li><a class="reference" href="#num-files-file-at" id="id41" name="id41">num_files() file_at()</a></li>
<li><a class="reference" href="#map-block" id="id41" name="id41">map_block()</a></li> <li><a class="reference" href="#map-block" id="id42" name="id42">map_block()</a></li>
<li><a class="reference" href="#map-file" id="id42" name="id42">map_file()</a></li> <li><a class="reference" href="#map-file" id="id43" name="id43">map_file()</a></li>
<li><a class="reference" href="#url-seeds" id="id43" name="id43">url_seeds()</a></li> <li><a class="reference" href="#url-seeds" id="id44" name="id44">url_seeds()</a></li>
<li><a class="reference" href="#print" id="id44" name="id44">print()</a></li> <li><a class="reference" href="#print" id="id45" name="id45">print()</a></li>
<li><a class="reference" href="#trackers" id="id45" name="id45">trackers()</a></li> <li><a class="reference" href="#trackers" id="id46" name="id46">trackers()</a></li>
<li><a class="reference" href="#total-size-piece-length-piece-size-num-pieces" id="id46" name="id46">total_size() piece_length() piece_size() num_pieces()</a></li> <li><a class="reference" href="#total-size-piece-length-piece-size-num-pieces" id="id47" name="id47">total_size() piece_length() piece_size() num_pieces()</a></li>
<li><a class="reference" href="#hash-for-piece-info-hash" id="id47" name="id47">hash_for_piece() info_hash()</a></li> <li><a class="reference" href="#hash-for-piece-info-hash" id="id48" name="id48">hash_for_piece() info_hash()</a></li>
<li><a class="reference" href="#name-comment-creation-date-creator" id="id48" name="id48">name() comment() creation_date() creator()</a></li> <li><a class="reference" href="#name-comment-creation-date-creator" id="id49" name="id49">name() comment() creation_date() creator()</a></li>
<li><a class="reference" href="#priv-set-priv" id="id49" name="id49">priv() set_priv()</a></li> <li><a class="reference" href="#priv-set-priv" id="id50" name="id50">priv() set_priv()</a></li>
<li><a class="reference" href="#nodes" id="id50" name="id50">nodes()</a></li> <li><a class="reference" href="#nodes" id="id51" name="id51">nodes()</a></li>
<li><a class="reference" href="#add-node" id="id51" name="id51">add_node()</a></li> <li><a class="reference" href="#add-node" id="id52" name="id52">add_node()</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference" href="#torrent-handle" id="id52" name="id52">torrent_handle</a><ul> <li><a class="reference" href="#torrent-handle" id="id53" name="id53">torrent_handle</a><ul>
<li><a class="reference" href="#file-progress" id="id53" name="id53">file_progress()</a></li> <li><a class="reference" href="#file-progress" id="id54" name="id54">file_progress()</a></li>
<li><a class="reference" href="#save-path" id="id54" name="id54">save_path()</a></li> <li><a class="reference" href="#save-path" id="id55" name="id55">save_path()</a></li>
<li><a class="reference" href="#move-storage" id="id55" name="id55">move_storage()</a></li> <li><a class="reference" href="#move-storage" id="id56" name="id56">move_storage()</a></li>
<li><a class="reference" href="#force-reannounce" id="id56" name="id56">force_reannounce()</a></li> <li><a class="reference" href="#force-reannounce" id="id57" name="id57">force_reannounce()</a></li>
<li><a class="reference" href="#connect-peer" id="id57" name="id57">connect_peer()</a></li> <li><a class="reference" href="#connect-peer" id="id58" name="id58">connect_peer()</a></li>
<li><a class="reference" href="#set-ratio" id="id58" name="id58">set_ratio()</a></li> <li><a class="reference" href="#set-ratio" id="id59" name="id59">set_ratio()</a></li>
<li><a class="reference" href="#set-upload-limit-set-download-limit" id="id59" name="id59">set_upload_limit() set_download_limit()</a></li> <li><a class="reference" href="#set-upload-limit-set-download-limit" id="id60" name="id60">set_upload_limit() set_download_limit()</a></li>
<li><a class="reference" href="#set-sequenced-download-threshold" id="id60" name="id60">set_sequenced_download_threshold()</a></li> <li><a class="reference" href="#set-sequenced-download-threshold" id="id61" name="id61">set_sequenced_download_threshold()</a></li>
<li><a class="reference" href="#set-peer-upload-limit-set-peer-download-limit" id="id61" name="id61">set_peer_upload_limit() set_peer_download_limit()</a></li> <li><a class="reference" href="#set-peer-upload-limit-set-peer-download-limit" id="id62" name="id62">set_peer_upload_limit() set_peer_download_limit()</a></li>
<li><a class="reference" href="#pause-resume-is-paused" id="id62" name="id62">pause() resume() is_paused()</a></li> <li><a class="reference" href="#pause-resume-is-paused" id="id63" name="id63">pause() resume() is_paused()</a></li>
<li><a class="reference" href="#is-seed" id="id63" name="id63">is_seed()</a></li> <li><a class="reference" href="#is-seed" id="id64" name="id64">is_seed()</a></li>
<li><a class="reference" href="#has-metadata" id="id64" name="id64">has_metadata()</a></li> <li><a class="reference" href="#has-metadata" id="id65" name="id65">has_metadata()</a></li>
<li><a class="reference" href="#set-tracker-login" id="id65" name="id65">set_tracker_login()</a></li> <li><a class="reference" href="#set-tracker-login" id="id66" name="id66">set_tracker_login()</a></li>
<li><a class="reference" href="#trackers-replace-trackers" id="id66" name="id66">trackers() replace_trackers()</a></li> <li><a class="reference" href="#trackers-replace-trackers" id="id67" name="id67">trackers() replace_trackers()</a></li>
<li><a class="reference" href="#add-url-seed" id="id67" name="id67">add_url_seed()</a></li> <li><a class="reference" href="#add-url-seed" id="id68" name="id68">add_url_seed()</a></li>
<li><a class="reference" href="#use-interface" id="id68" name="id68">use_interface()</a></li> <li><a class="reference" href="#use-interface" id="id69" name="id69">use_interface()</a></li>
<li><a class="reference" href="#info-hash" id="id69" name="id69">info_hash()</a></li> <li><a class="reference" href="#info-hash" id="id70" name="id70">info_hash()</a></li>
<li><a class="reference" href="#id5" id="id70" name="id70">set_max_uploads() set_max_connections()</a></li> <li><a class="reference" href="#id5" id="id71" name="id71">set_max_uploads() set_max_connections()</a></li>
<li><a class="reference" href="#write-resume-data" id="id71" name="id71">write_resume_data()</a></li> <li><a class="reference" href="#write-resume-data" id="id72" name="id72">write_resume_data()</a></li>
<li><a class="reference" href="#metadata" id="id72" name="id72">metadata()</a></li> <li><a class="reference" href="#metadata" id="id73" name="id73">metadata()</a></li>
<li><a class="reference" href="#id6" id="id73" name="id73">status()</a></li> <li><a class="reference" href="#id6" id="id74" name="id74">status()</a></li>
<li><a class="reference" href="#get-download-queue" id="id74" name="id74">get_download_queue()</a></li> <li><a class="reference" href="#get-download-queue" id="id75" name="id75">get_download_queue()</a></li>
<li><a class="reference" href="#get-peer-info" id="id75" name="id75">get_peer_info()</a></li> <li><a class="reference" href="#get-peer-info" id="id76" name="id76">get_peer_info()</a></li>
<li><a class="reference" href="#get-torrent-info" id="id76" name="id76">get_torrent_info()</a></li> <li><a class="reference" href="#get-torrent-info" id="id77" name="id77">get_torrent_info()</a></li>
<li><a class="reference" href="#is-valid" id="id77" name="id77">is_valid()</a></li> <li><a class="reference" href="#is-valid" id="id78" name="id78">is_valid()</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference" href="#torrent-status" id="id78" name="id78">torrent_status</a></li> <li><a class="reference" href="#torrent-status" id="id79" name="id79">torrent_status</a></li>
<li><a class="reference" href="#peer-info" id="id79" name="id79">peer_info</a></li> <li><a class="reference" href="#peer-info" id="id80" name="id80">peer_info</a></li>
<li><a class="reference" href="#session-settings" id="id80" name="id80">session_settings</a></li> <li><a class="reference" href="#session-settings" id="id81" name="id81">session_settings</a></li>
<li><a class="reference" href="#ip-filter" id="id81" name="id81">ip_filter</a><ul> <li><a class="reference" href="#ip-filter" id="id82" name="id82">ip_filter</a><ul>
<li><a class="reference" href="#id8" id="id82" name="id82">ip_filter()</a></li> <li><a class="reference" href="#id8" id="id83" name="id83">ip_filter()</a></li>
<li><a class="reference" href="#add-rule" id="id83" name="id83">add_rule()</a></li> <li><a class="reference" href="#add-rule" id="id84" name="id84">add_rule()</a></li>
<li><a class="reference" href="#access" id="id84" name="id84">access()</a></li> <li><a class="reference" href="#access" id="id85" name="id85">access()</a></li>
<li><a class="reference" href="#export-filter" id="id85" name="id85">export_filter()</a></li> <li><a class="reference" href="#export-filter" id="id86" name="id86">export_filter()</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference" href="#big-number" id="id86" name="id86">big_number</a></li> <li><a class="reference" href="#big-number" id="id87" name="id87">big_number</a></li>
<li><a class="reference" href="#hasher" id="id87" name="id87">hasher</a></li> <li><a class="reference" href="#hasher" id="id88" name="id88">hasher</a></li>
<li><a class="reference" href="#fingerprint" id="id88" name="id88">fingerprint</a></li> <li><a class="reference" href="#fingerprint" id="id89" name="id89">fingerprint</a></li>
<li><a class="reference" href="#free-functions" id="id89" name="id89">free functions</a><ul> <li><a class="reference" href="#free-functions" id="id90" name="id90">free functions</a><ul>
<li><a class="reference" href="#identify-client" id="id90" name="id90">identify_client()</a></li> <li><a class="reference" href="#identify-client" id="id91" name="id91">identify_client()</a></li>
<li><a class="reference" href="#client-fingerprint" id="id91" name="id91">client_fingerprint()</a></li> <li><a class="reference" href="#client-fingerprint" id="id92" name="id92">client_fingerprint()</a></li>
<li><a class="reference" href="#bdecode-bencode" id="id92" name="id92">bdecode() bencode()</a></li> <li><a class="reference" href="#bdecode-bencode" id="id93" name="id93">bdecode() bencode()</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference" href="#alerts" id="id93" name="id93">alerts</a><ul> <li><a class="reference" href="#alerts" id="id94" name="id94">alerts</a><ul>
<li><a class="reference" href="#listen-failed-alert" id="id94" name="id94">listen_failed_alert</a></li> <li><a class="reference" href="#listen-failed-alert" id="id95" name="id95">listen_failed_alert</a></li>
<li><a class="reference" href="#file-error-alert" id="id95" name="id95">file_error_alert</a></li> <li><a class="reference" href="#file-error-alert" id="id96" name="id96">file_error_alert</a></li>
<li><a class="reference" href="#tracker-announce-alert" id="id96" name="id96">tracker_announce_alert</a></li> <li><a class="reference" href="#tracker-announce-alert" id="id97" name="id97">tracker_announce_alert</a></li>
<li><a class="reference" href="#tracker-alert" id="id97" name="id97">tracker_alert</a></li> <li><a class="reference" href="#tracker-alert" id="id98" name="id98">tracker_alert</a></li>
<li><a class="reference" href="#tracker-reply-alert" id="id98" name="id98">tracker_reply_alert</a></li> <li><a class="reference" href="#tracker-reply-alert" id="id99" name="id99">tracker_reply_alert</a></li>
<li><a class="reference" href="#tracker-warning-alert" id="id99" name="id99">tracker_warning_alert</a></li> <li><a class="reference" href="#tracker-warning-alert" id="id100" name="id100">tracker_warning_alert</a></li>
<li><a class="reference" href="#url-seed-alert" id="id100" name="id100">url_seed_alert</a></li> <li><a class="reference" href="#url-seed-alert" id="id101" name="id101">url_seed_alert</a></li>
<li><a class="reference" href="#hash-failed-alert" id="id101" name="id101">hash_failed_alert</a></li> <li><a class="reference" href="#hash-failed-alert" id="id102" name="id102">hash_failed_alert</a></li>
<li><a class="reference" href="#peer-ban-alert" id="id102" name="id102">peer_ban_alert</a></li> <li><a class="reference" href="#peer-ban-alert" id="id103" name="id103">peer_ban_alert</a></li>
<li><a class="reference" href="#peer-error-alert" id="id103" name="id103">peer_error_alert</a></li> <li><a class="reference" href="#peer-error-alert" id="id104" name="id104">peer_error_alert</a></li>
<li><a class="reference" href="#invalid-request-alert" id="id104" name="id104">invalid_request_alert</a></li> <li><a class="reference" href="#invalid-request-alert" id="id105" name="id105">invalid_request_alert</a></li>
<li><a class="reference" href="#torrent-finished-alert" id="id105" name="id105">torrent_finished_alert</a></li> <li><a class="reference" href="#torrent-finished-alert" id="id106" name="id106">torrent_finished_alert</a></li>
<li><a class="reference" href="#metadata-failed-alert" id="id106" name="id106">metadata_failed_alert</a></li> <li><a class="reference" href="#metadata-failed-alert" id="id107" name="id107">metadata_failed_alert</a></li>
<li><a class="reference" href="#metadata-received-alert" id="id107" name="id107">metadata_received_alert</a></li> <li><a class="reference" href="#metadata-received-alert" id="id108" name="id108">metadata_received_alert</a></li>
<li><a class="reference" href="#fastresume-rejected-alert" id="id108" name="id108">fastresume_rejected_alert</a></li> <li><a class="reference" href="#fastresume-rejected-alert" id="id109" name="id109">fastresume_rejected_alert</a></li>
<li><a class="reference" href="#dispatcher" id="id109" name="id109">dispatcher</a></li> <li><a class="reference" href="#dispatcher" id="id110" name="id110">dispatcher</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference" href="#exceptions" id="id110" name="id110">exceptions</a><ul> <li><a class="reference" href="#exceptions" id="id111" name="id111">exceptions</a><ul>
<li><a class="reference" href="#invalid-handle" id="id111" name="id111">invalid_handle</a></li> <li><a class="reference" href="#invalid-handle" id="id112" name="id112">invalid_handle</a></li>
<li><a class="reference" href="#duplicate-torrent" id="id112" name="id112">duplicate_torrent</a></li> <li><a class="reference" href="#duplicate-torrent" id="id113" name="id113">duplicate_torrent</a></li>
<li><a class="reference" href="#invalid-encoding" id="id113" name="id113">invalid_encoding</a></li> <li><a class="reference" href="#invalid-encoding" id="id114" name="id114">invalid_encoding</a></li>
<li><a class="reference" href="#type-error" id="id114" name="id114">type_error</a></li> <li><a class="reference" href="#type-error" id="id115" name="id115">type_error</a></li>
<li><a class="reference" href="#invalid-torrent-file" id="id115" name="id115">invalid_torrent_file</a></li> <li><a class="reference" href="#invalid-torrent-file" id="id116" name="id116">invalid_torrent_file</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference" href="#fast-resume" id="id116" name="id116">fast resume</a><ul> <li><a class="reference" href="#fast-resume" id="id117" name="id117">fast resume</a><ul>
<li><a class="reference" href="#file-format" id="id117" name="id117">file format</a></li> <li><a class="reference" href="#file-format" id="id118" name="id118">file format</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference" href="#threads" id="id118" name="id118">threads</a></li> <li><a class="reference" href="#threads" id="id119" name="id119">threads</a></li>
<li><a class="reference" href="#storage-allocation" id="id119" name="id119">storage allocation</a><ul> <li><a class="reference" href="#storage-allocation" id="id120" name="id120">storage allocation</a><ul>
<li><a class="reference" href="#full-allocation" id="id120" name="id120">full allocation</a></li> <li><a class="reference" href="#full-allocation" id="id121" name="id121">full allocation</a></li>
<li><a class="reference" href="#compact-allocation" id="id121" name="id121">compact allocation</a></li> <li><a class="reference" href="#compact-allocation" id="id122" name="id122">compact allocation</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference" href="#extensions" id="id122" name="id122">extensions</a><ul> <li><a class="reference" href="#extensions" id="id123" name="id123">extensions</a><ul>
<li><a class="reference" href="#chat-messages" id="id123" name="id123">chat messages</a></li> <li><a class="reference" href="#chat-messages" id="id124" name="id124">chat messages</a></li>
<li><a class="reference" href="#metadata-from-peers" id="id124" name="id124">metadata from peers</a></li> <li><a class="reference" href="#metadata-from-peers" id="id125" name="id125">metadata from peers</a></li>
<li><a class="reference" href="#http-seeding" id="id125" name="id125">HTTP seeding</a></li> <li><a class="reference" href="#http-seeding" id="id126" name="id126">HTTP seeding</a></li>
</ul> </ul>
</li> </li>
<li><a class="reference" href="#filename-checks" id="id126" name="id126">filename checks</a></li> <li><a class="reference" href="#filename-checks" id="id127" name="id127">filename checks</a></li>
<li><a class="reference" href="#acknowledgments" id="id127" name="id127">acknowledgments</a></li> <li><a class="reference" href="#acknowledgments" id="id128" name="id128">acknowledgments</a></li>
</ul> </ul>
</div> </div>
<div class="section" id="overview"> <div class="section" id="overview">
@ -274,7 +275,8 @@ class session: public boost::noncopyable
entry dht_state() const; entry dht_state() const;
void add_dht_node(std::pair&lt;std::string void add_dht_node(std::pair&lt;std::string
, int&gt; const&amp; node); , int&gt; const&amp; node);
void add_dht_router(std::pair&lt;std::string
, int&gt; const&amp; node);
}; };
</pre> </pre>
<p>Once it's created, the session object will spawn the main thread that will do all the work. <p>Once it's created, the session object will spawn the main thread that will do all the work.
@ -547,7 +549,6 @@ void start_dht(entry const&amp; startup_state);
void stop_dht(); void stop_dht();
void set_dht_settings(dht_settings const&amp; settings); void set_dht_settings(dht_settings const&amp; settings);
entry dht_state() const; entry dht_state() const;
void add_dht_node(std::pair&lt;std::string, int&gt; const&amp; node);
</pre> </pre>
</blockquote> </blockquote>
<p>These functions are not available in case <tt class="docutils literal"><span class="pre">TORRENT_DISABLE_DHT</span></tt> is <p>These functions are not available in case <tt class="docutils literal"><span class="pre">TORRENT_DISABLE_DHT</span></tt> is
@ -595,6 +596,25 @@ that are ready to replace a failing node, it will be replaced immediately,
this limit is only used to clear out nodes that don't have any node that can this limit is only used to clear out nodes that don't have any node that can
replace them.</p> replace them.</p>
</div> </div>
<div class="section" id="add-dht-node-add-dht-router">
<h2><a name="add-dht-node-add-dht-router">add_dht_node() add_dht_router()</a></h2>
<blockquote>
<pre class="literal-block">
void add_dht_node(std::pair&lt;std::string, int&gt; const&amp; node);
void add_dht_router(std::pair&lt;std::string, int&gt; const&amp; node);
</pre>
</blockquote>
<p><tt class="docutils literal"><span class="pre">add_dht_node</span></tt> takes a host name and port pair. That endpoint will be
pinged, and if a valid DHT reply is received, the node will be added to
the routing table.</p>
<p><tt class="docutils literal"><span class="pre">add_dht_router</span></tt> adds the given endpoint to a list of DHT router nodes.
If a search is ever made while the routing table is empty, those nodes will
be used as backups. Nodes in the router node list will also never be added
to the regular routing table, which effectively means they are only used
for bootstrapping, to keep the load off them.</p>
<p>An example routing node that you could typically add is
<tt class="docutils literal"><span class="pre">router.bittorrent.com</span></tt>.</p>
</div>
</div> </div>
<div class="section" id="entry"> <div class="section" id="entry">
<h1><a name="entry">entry</a></h1> <h1><a name="entry">entry</a></h1>
@ -2458,7 +2478,7 @@ struct peer_error_alert: alert
<div class="section" id="invalid-request-alert"> <div class="section" id="invalid-request-alert">
<h2><a name="invalid-request-alert">invalid_request_alert</a></h2> <h2><a name="invalid-request-alert">invalid_request_alert</a></h2>
<p>This is a debug alert that is generated by an incoming invalid piece request. The <tt class="docutils literal"><span class="pre">handle</span></tt> <p>This is a debug alert that is generated by an incoming invalid piece request. The <tt class="docutils literal"><span class="pre">handle</span></tt>
is a handle to the torrent the peer is a member of. <tt class="docutils literal"><span class="pre">ìp</span></tt> is the address of the peer and the is a handle to the torrent the peer is a member of. <tt class="docutils literal"><span class="pre">Ïp</span></tt> is the address of the peer and the
<tt class="docutils literal"><span class="pre">request</span></tt> is the actual incoming request from the peer. The alert is generated as severity level <tt class="docutils literal"><span class="pre">request</span></tt> is the actual incoming request from the peer. The alert is generated as severity level
<tt class="docutils literal"><span class="pre">debug</span></tt>.</p> <tt class="docutils literal"><span class="pre">debug</span></tt>.</p>
<pre class="literal-block"> <pre class="literal-block">
@ -3051,7 +3071,7 @@ boost::filesystem::path::default_name_check(boost::filesystem::native);
<p>Big thanks to Michael Wojciechowski and Peter Koeleman for making the autotools <p>Big thanks to Michael Wojciechowski and Peter Koeleman for making the autotools
scripts.</p> scripts.</p>
<p>Thanks to Reimond Retz for bugfixes, suggestions and testing</p> <p>Thanks to Reimond Retz for bugfixes, suggestions and testing</p>
<p>Thanks to <a class="reference" href="http://www.cs.umu.se">University of Umeå</a> for providing development and test hardware.</p> <p>Thanks to <a class="reference" href="http://www.cs.umu.se">University of UmeÂ</a> for providing development and test hardware.</p>
<p>Project is hosted by sourceforge.</p> <p>Project is hosted by sourceforge.</p>
<p><a class="reference" href="http://sourceforge.net"><img alt="sf_logo" src="http://sourceforge.net/sflogo.php?group_id=7994" /></a></p> <p><a class="reference" href="http://sourceforge.net"><img alt="sf_logo" src="http://sourceforge.net/sflogo.php?group_id=7994" /></a></p>
</div> </div>

View File

@ -120,7 +120,8 @@ The ``session`` class has the following synopsis::
entry dht_state() const; entry dht_state() const;
void add_dht_node(std::pair<std::string void add_dht_node(std::pair<std::string
, int> const& node); , int> const& node);
void add_dht_router(std::pair<std::string
, int> const& node);
}; };
Once it's created, the session object will spawn the main thread that will do all the work. Once it's created, the session object will spawn the main thread that will do all the work.
@ -420,7 +421,6 @@ start_dht() stop_dht() set_dht_settings() dht_state()
void stop_dht(); void stop_dht();
void set_dht_settings(dht_settings const& settings); void set_dht_settings(dht_settings const& settings);
entry dht_state() const; entry dht_state() const;
void add_dht_node(std::pair<std::string, int> const& node);
These functions are not available in case ``TORRENT_DISABLE_DHT`` is These functions are not available in case ``TORRENT_DISABLE_DHT`` is
defined. ``start_dht`` starts the dht node and makes the trackerless service defined. ``start_dht`` starts the dht node and makes the trackerless service
@ -474,6 +474,26 @@ that are ready to replace a failing node, it will be replaced immediately,
this limit is only used to clear out nodes that don't have any node that can this limit is only used to clear out nodes that don't have any node that can
replace them. replace them.
add_dht_node() add_dht_router()
-------------------------------
::
void add_dht_node(std::pair<std::string, int> const& node);
void add_dht_router(std::pair<std::string, int> const& node);
``add_dht_node`` takes a host name and port pair. That endpoint will be
pinged, and if a valid DHT reply is received, the node will be added to
the routing table.
``add_dht_router`` adds the given endpoint to a list of DHT router nodes.
If a search is ever made while the routing table is empty, those nodes will
be used as backups. Nodes in the router node list will also never be added
to the regular routing table, which effectively means they are only used
for bootstrapping, to keep the load off them.
An example routing node that you could typically add is
``router.bittorrent.com``.
entry entry

View File

@ -575,14 +575,15 @@ int main(int ac, char* av[])
entry dht_state = bdecode( entry dht_state = bdecode(
std::istream_iterator<char>(dht_state_file) std::istream_iterator<char>(dht_state_file)
, std::istream_iterator<char>()); , std::istream_iterator<char>());
ses.start_dht(dht_state);
} }
catch (std::exception&) catch (std::exception&) {}
{
ses.start_dht(); ses.start_dht();
ses.add_dht_node(std::make_pair(std::string("router.bittorrent.com") ses.add_dht_router(std::make_pair(std::string("router.bittorrent.com")
, 6881));
ses.add_dht_router(std::make_pair(std::string("router.utorrent.com")
, 6881));
ses.add_dht_router(std::make_pair(std::string("router.bitcomet.com")
, 6881)); , 6881));
}
#endif #endif
ses.set_max_half_open_connections(half_open_limit); ses.set_max_half_open_connections(half_open_limit);

View File

@ -67,6 +67,7 @@ namespace libtorrent { namespace dht
void add_node(udp::endpoint node); void add_node(udp::endpoint node);
void add_node(std::pair<std::string, int> const& node); void add_node(std::pair<std::string, int> const& node);
void add_router_node(std::pair<std::string, int> const& node);
void rebind(asio::ip::address listen_interface, int listen_port); void rebind(asio::ip::address listen_interface, int listen_port);
@ -82,6 +83,8 @@ namespace libtorrent { namespace dht
void on_name_lookup(asio::error const& e void on_name_lookup(asio::error const& e
, udp::resolver::iterator host); , udp::resolver::iterator host);
void on_router_name_lookup(asio::error const& e
, udp::resolver::iterator host);
void connection_timeout(asio::error const& e); void connection_timeout(asio::error const& e);
void refresh_timeout(asio::error const& e); void refresh_timeout(asio::error const& e);
void tick(asio::error const& e); void tick(asio::error const& e);

View File

@ -99,6 +99,7 @@ public:
, boost::function0<void> f); , boost::function0<void> f);
void find_node(node_id const& id, boost::function< void find_node(node_id const& id, boost::function<
void(std::vector<node_entry> const&)> f); void(std::vector<node_entry> const&)> f);
void add_router_node(udp::endpoint router);
void incoming(msg const& m); void incoming(msg const& m);

View File

@ -157,6 +157,15 @@ public:
void node_failed(node_id const& id); void node_failed(node_id const& id);
// adds an endpoint that will never be added to
// the routing table
void add_router_node(udp::endpoint router);
// iterates over the router nodes added
typedef std::set<udp::endpoint>::const_iterator router_iterator;
router_iterator router_begin() const { return m_router_nodes.begin(); }
router_iterator router_end() const { return m_router_nodes.end(); }
// this function is called every time the node sees // this function is called every time the node sees
// a sign of a node being alive. This node will either // a sign of a node being alive. This node will either
// be inserted in the k-buckets or be moved to the top // be inserted in the k-buckets or be moved to the top
@ -220,6 +229,12 @@ private:
table_activity_t m_bucket_activity; table_activity_t m_bucket_activity;
node_id m_id; // our own node id node_id m_id; // our own node id
// this is a set of all the endpoints that have
// been identified as router nodes. They will
// be used in searches, but they will never
// be added to the routing table.
std::set<udp::endpoint> m_router_nodes;
// this is the lowest bucket index with nodes in it // this is the lowest bucket index with nodes in it
int m_lowest_active_bucket; int m_lowest_active_bucket;
}; };

View File

@ -142,6 +142,17 @@ traversal_algorithm::traversal_algorithm(
add_entry(i->id, i->addr, result::initial); add_entry(i->id, i->addr, result::initial);
} }
// in case the routing table is empty, use the
// router nodes in the table
if (start == end)
{
for (routing_table::router_iterator i = table.router_begin()
, end(table.router_end()); i != end; ++i)
{
add_entry(node_id(0), *i, result::initial);
}
}
} }
} } // namespace libtorrent::dht } } // namespace libtorrent::dht

View File

@ -382,6 +382,7 @@ namespace libtorrent
void set_dht_settings(dht_settings const& settings); void set_dht_settings(dht_settings const& settings);
entry dht_state() const; entry dht_state() const;
void add_dht_node(std::pair<std::string, int> const& node); void add_dht_node(std::pair<std::string, int> const& node);
void add_dht_router(std::pair<std::string, int> const& node);
#endif #endif
void enable_extension(extension_index i); void enable_extension(extension_index i);

View File

@ -650,8 +650,8 @@ namespace libtorrent { namespace dht
, this, _1, _2)); , this, _1, _2));
} }
void dht_tracker::on_name_lookup(asio::error const& e, udp::resolver::iterator host) void dht_tracker::on_name_lookup(asio::error const& e
try , udp::resolver::iterator host) try
{ {
if (e || host == udp::resolver::iterator()) return; if (e || host == udp::resolver::iterator()) return;
add_node(host->endpoint()); add_node(host->endpoint());
@ -661,6 +661,24 @@ namespace libtorrent { namespace dht
assert(false); assert(false);
}; };
void dht_tracker::add_router_node(std::pair<std::string, int> const& node)
{
udp::resolver::query q(node.first, lexical_cast<std::string>(node.second));
m_host_resolver.async_resolve(q, bind(&dht_tracker::on_router_name_lookup
, this, _1, _2));
}
void dht_tracker::on_router_name_lookup(asio::error const& e
, udp::resolver::iterator host) try
{
if (e || host == udp::resolver::iterator()) return;
m_dht.add_router_node(host->endpoint());
}
catch (std::exception&)
{
assert(false);
};
void dht_tracker::on_bootstrap() void dht_tracker::on_bootstrap()
{} {}

View File

@ -347,6 +347,11 @@ namespace
}; };
} }
void node_impl::add_router_node(udp::endpoint router)
{
m_table.add_router_node(router);
}
void node_impl::add_node(udp::endpoint node) void node_impl::add_node(udp::endpoint node)
{ {
// ping the node, and if we get a reply, it // ping the node, and if we get a reply, it

View File

@ -221,6 +221,11 @@ void routing_table::node_failed(node_id const& id)
rb.erase(rb.end() - 1); rb.erase(rb.end() - 1);
} }
void routing_table::add_router_node(udp::endpoint router)
{
m_router_nodes.insert(router);
}
// this function is called every time the node sees // this function is called every time the node sees
// a sign of a node being alive. This node will either // a sign of a node being alive. This node will either
// be inserted in the k-buckets or be moved to the top // be inserted in the k-buckets or be moved to the top
@ -230,6 +235,7 @@ void routing_table::node_failed(node_id const& id)
// on its own id) // on its own id)
bool routing_table::node_seen(node_id const& id, udp::endpoint addr) bool routing_table::node_seen(node_id const& id, udp::endpoint addr)
{ {
if (m_router_nodes.find(addr) != m_router_nodes.end()) return false;
int bucket_index = distance_exp(m_id, id); int bucket_index = distance_exp(m_id, id);
assert(bucket_index < (int)m_buckets.size()); assert(bucket_index < (int)m_buckets.size());
assert(bucket_index >= 0); assert(bucket_index >= 0);
@ -266,7 +272,10 @@ bool routing_table::node_seen(node_id const& id, udp::endpoint addr)
if ((int)b.size() < m_bucket_size) if ((int)b.size() < m_bucket_size)
{ {
b.push_back(node_entry(id, addr)); b.push_back(node_entry(id, addr));
if (bucket_index < m_lowest_active_bucket) // if bucket index is 0, the node is ourselves
// don't updated m_lowest_active_bucket
if (bucket_index < m_lowest_active_bucket
&& bucket_index > 0)
m_lowest_active_bucket = bucket_index; m_lowest_active_bucket = bucket_index;
// TORRENT_LOG(table) << "inserting node: " << id << " " << addr; // TORRENT_LOG(table) << "inserting node: " << id << " " << addr;
return ret; return ret;

View File

@ -672,8 +672,7 @@ namespace libtorrent { namespace detail
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
(*m_logger) << endp << " <== INCOMING CONNECTION\n"; (*m_logger) << endp << " <== INCOMING CONNECTION\n";
#endif #endif
if (endp.address().is_v4() if (m_ip_filter.access(endp.address().to_v4()) & ip_filter::blocked)
&& (m_ip_filter.access(endp.address().to_v4()) & ip_filter::blocked))
{ {
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
(*m_logger) << "filtered blocked ip\n"; (*m_logger) << "filtered blocked ip\n";
@ -1175,9 +1174,7 @@ namespace libtorrent
= m_impl.m_connections.begin(); i != m_impl.m_connections.end();) = m_impl.m_connections.begin(); i != m_impl.m_connections.end();)
{ {
tcp::endpoint sender = i->first->remote_endpoint(); tcp::endpoint sender = i->first->remote_endpoint();
if (sender.address().is_v4() if (m_impl.m_ip_filter.access(sender.address()) & ip_filter::blocked)
&& (m_impl.m_ip_filter.access(sender.address().to_v4())
& ip_filter::blocked))
{ {
#if defined(TORRENT_VERBOSE_LOGGING) #if defined(TORRENT_VERBOSE_LOGGING)
(*i->second->m_logger) << "*** CONNECTION FILTERED'\n"; (*i->second->m_logger) << "*** CONNECTION FILTERED'\n";
@ -1541,6 +1538,12 @@ namespace libtorrent
m_impl.m_dht->add_node(node); m_impl.m_dht->add_node(node);
} }
void session::add_dht_router(std::pair<std::string, int> const& node)
{
assert(m_impl.m_dht);
m_impl.m_dht->add_router_node(node);
}
#endif #endif
bool session::is_listening() const bool session::is_listening() const