Author: | Arvid Norberg, arvid@libtorrent.org |
---|---|
Version: | 1.1.6 |
Alerts
Table of contents
- Alerts
- alert
- torrent_alert
- peer_alert
- tracker_alert
- torrent_removed_alert
- read_piece_alert
- file_completed_alert
- file_renamed_alert
- file_rename_failed_alert
- performance_alert
- state_changed_alert
- tracker_error_alert
- tracker_warning_alert
- scrape_reply_alert
- scrape_failed_alert
- tracker_reply_alert
- dht_reply_alert
- tracker_announce_alert
- hash_failed_alert
- peer_ban_alert
- peer_unsnubbed_alert
- peer_snubbed_alert
- peer_error_alert
- peer_connect_alert
- peer_disconnected_alert
- invalid_request_alert
- torrent_finished_alert
- piece_finished_alert
- request_dropped_alert
- block_timeout_alert
- block_finished_alert
- block_downloading_alert
- unwanted_block_alert
- storage_moved_alert
- storage_moved_failed_alert
- torrent_deleted_alert
- torrent_delete_failed_alert
- save_resume_data_alert
- save_resume_data_failed_alert
- torrent_paused_alert
- torrent_resumed_alert
- torrent_checked_alert
- url_seed_alert
- file_error_alert
- metadata_failed_alert
- metadata_received_alert
- udp_error_alert
- external_ip_alert
- listen_failed_alert
- listen_succeeded_alert
- portmap_error_alert
- portmap_alert
- portmap_log_alert
- fastresume_rejected_alert
- peer_blocked_alert
- dht_announce_alert
- dht_get_peers_alert
- stats_alert
- cache_flushed_alert
- anonymous_mode_alert
- lsd_peer_alert
- trackerid_alert
- dht_bootstrap_alert
- torrent_error_alert
- torrent_need_cert_alert
- incoming_connection_alert
- add_torrent_alert
- state_update_alert
- session_stats_alert
- dht_error_alert
- dht_immutable_item_alert
- dht_mutable_item_alert
- dht_put_alert
- i2p_alert
- dht_outgoing_get_peers_alert
- log_alert
- torrent_log_alert
- peer_log_alert
- lsd_error_alert
- dht_lookup
- dht_routing_bucket
- dht_stats_alert
- incoming_request_alert
- dht_log_alert
- dht_pkt_alert
- dht_get_peers_reply_alert
- dht_direct_response_alert
- picker_log_alert
- alert_cast()
- operation_name()
- enum operation_t
The pop_alerts() function on session is the main interface for retrieving alerts (warnings, messages and errors from libtorrent). If no alerts have been posted by libtorrent pop_alerts() will return an empty list.
By default, only errors are reported. settings_pack::alert_mask can be used to specify which kinds of events should be reported. The alert mask is comprised by bits from the category_t enum.
Every alert belongs to one or more category. There is a cost associated with posting alerts. Only alerts that belong to an enabled category are posted. Setting the alert bitmask to 0 will disable all alerts (except those that are non-discardable). Alerts that are responses to API calls such as save_resume_data() and post_session_stats() are non-discardable and will be posted even if their category is disabled.
There are other alert base classes that some alerts derive from, all the alerts that are generated for a specific torrent are derived from torrent_alert, and tracker events derive from tracker_alert.
Alerts returned by pop_alerts() are only valid until the next call to pop_alerts(). You may not copy an alert object to access it after the next call to pop_alerts(). Internal members of alerts also become invalid once pop_alerts() is called again.
alert
Declared in "libtorrent/alert.hpp"
The alert class is the base class that specific messages are derived from. alert types are not copyable, and cannot be constructed by the client. The pointers returned by libtorrent are short lived (the details are described under session_handle::pop_alerts())
class alert { time_point timestamp () const; virtual int type () const = 0; virtual char const* what () const = 0; virtual std::string message () const = 0; virtual int category () const = 0; enum category_t { error_notification, peer_notification, port_mapping_notification, storage_notification, tracker_notification, debug_notification, status_notification, progress_notification, ip_block_notification, performance_warning, dht_notification, stats_notification, session_log_notification, torrent_log_notification, peer_log_notification, incoming_request_notification, dht_log_notification, dht_operation_notification, port_mapping_log_notification, picker_log_notification, all_categories, }; };
type()
virtual int type () const = 0;
returns an integer that is unique to this alert type. It can be compared against a specific alert by querying a static constant called alert_type in the alert. It can be used to determine the run-time type of an alert* in order to cast to that alert type and access specific members.
e.g:
std::vector<alert*> alerts; ses.pop_alerts(&alerts); for (alert* i : alerts) { switch (a->type()) { case read_piece_alert::alert_type: { read_piece_alert* p = (read_piece_alert*)a; if (p->ec) { // read_piece failed break; } // use p break; } case file_renamed_alert::alert_type: { // etc... } } }
what()
virtual char const* what () const = 0;
returns a string literal describing the type of the alert. It does not include any information that might be bundled with the alert.
message()
virtual std::string message () const = 0;
generate a string describing the alert and the information bundled with it. This is mainly intended for debug and development use. It is not suitable to use this for applications that may be localized. Instead, handle each alert type individually and extract and render the information from the alert depending on the locale.
category()
virtual int category () const = 0;
returns a bitmask specifying which categories this alert belong to.
enum category_t
Declared in "libtorrent/alert.hpp"
name | value | description |
---|---|---|
error_notification | 1 | Enables alerts that report an error. This includes:
|
peer_notification | 2 | Enables alerts when peers send invalid requests, get banned or snubbed. |
port_mapping_notification | 4 | Enables alerts for port mapping events. For NAT-PMP and UPnP. |
storage_notification | 8 | Enables alerts for events related to the storage. File errors and synchronization events for moving the storage, renaming files etc. |
tracker_notification | 16 | Enables all tracker events. Includes announcing to trackers, receiving responses, warnings and errors. |
debug_notification | 32 | Low level alerts for when peers are connected and disconnected. |
status_notification | 64 | Enables alerts for when a torrent or the session changes state. |
progress_notification | 128 | Alerts for when blocks are requested and completed. Also when pieces are completed. |
ip_block_notification | 256 | Alerts when a peer is blocked by the ip blocker or port blocker. |
performance_warning | 512 | Alerts when some limit is reached that might limit the download or upload rate. |
dht_notification | 1024 | Alerts on events in the DHT node. For incoming searches or bootstrapping being done etc. |
stats_notification | 2048 | If you enable these alerts, you will receive a stats_alert approximately once every second, for every active torrent. These alerts contain all statistics counters for the interval since the lasts stats alert. |
session_log_notification | 8192 | Enables debug logging alerts. These are available unless libtorrent was built with logging disabled (TORRENT_DISABLE_LOGGING). The alerts being posted are log_alert and are session wide. |
torrent_log_notification | 16384 | Enables debug logging alerts for torrents. These are available unless libtorrent was built with logging disabled (TORRENT_DISABLE_LOGGING). The alerts being posted are torrent_log_alert and are torrent wide debug events. |
peer_log_notification | 32768 | Enables debug logging alerts for peers. These are available unless libtorrent was built with logging disabled (TORRENT_DISABLE_LOGGING). The alerts being posted are peer_log_alert and low-level peer events and messages. |
incoming_request_notification | 65536 | enables the incoming_request_alert. |
dht_log_notification | 131072 | enables dht_log_alert, debug logging for the DHT |
dht_operation_notification | 262144 | enable events from pure dht operations not related to torrents |
port_mapping_log_notification | 524288 | enables port mapping log events. This log is useful for debugging the UPnP or NAT-PMP implementation |
picker_log_notification | 1048576 | enables verbose logging from the piece picker. |
all_categories | 2147483647 | The full bitmask, representing all available categories. since the enum is signed, make sure this isn't interpreted as -1. For instance, boost.python does that and fails when assigning it to an unsigned parameter. |
torrent_alert
Declared in "libtorrent/alert_types.hpp"
This is a base class for alerts that are associated with a specific torrent. It contains a handle to the torrent.
struct torrent_alert : alert { virtual std::string message () const override; char const* torrent_name () const; torrent_handle handle; };
message()
virtual std::string message () const override;
returns the message associated with this alert
- handle
- The torrent_handle pointing to the torrent this alert is associated with.
peer_alert
Declared in "libtorrent/alert_types.hpp"
The peer alert is a base class for alerts that refer to a specific peer. It includes all the information to identify the peer. i.e. ip and peer-id.
struct peer_alert : torrent_alert { virtual int category () const override; virtual std::string message () const override; static const int alert_type = 1; static const int static_category = alert::peer_notification; tcp::endpoint ip; peer_id pid; };
- ip
- The peer's IP address and port.
- pid
- the peer ID, if known.
tracker_alert
Declared in "libtorrent/alert_types.hpp"
This is a base class used for alerts that are associated with a specific tracker. It derives from torrent_alert since a tracker is also associated with a specific torrent.
struct tracker_alert : torrent_alert { virtual int category () const override; virtual std::string message () const override; char const* tracker_url () const; static const int alert_type = 2; static const int static_category = alert::tracker_notification; };
torrent_removed_alert
Declared in "libtorrent/alert_types.hpp"
The torrent_removed_alert is posted whenever a torrent is removed. Since the torrent handle in its base class will always be invalid (since the torrent is already removed) it has the info hash as a member, to identify it. It's posted when the status_notification bit is set in the alert_mask.
Even though the handle member doesn't point to an existing torrent anymore, it is still useful for comparing to other handles, which may also no longer point to existing torrents, but to the same non-existing torrents.
The torrent_handle acts as a weak_ptr, even though its object no longer exists, it can still compare equal to another weak pointer which points to the same non-existent object.
struct torrent_removed_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::status_notification; sha1_hash info_hash; };
read_piece_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted when the asynchronous read operation initiated by a call to torrent_handle::read_piece() is completed. If the read failed, the torrent is paused and an error state is set and the buffer member of the alert is 0. If successful, buffer points to a buffer containing all the data of the piece. piece is the piece index that was read. size is the number of bytes that was read.
If the operation fails, ec will indicate what went wrong.
struct read_piece_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::storage_notification; error_code ec; boost::shared_array<char> buffer; int piece; int size; };
file_completed_alert
Declared in "libtorrent/alert_types.hpp"
This is posted whenever an individual file completes its download. i.e. All pieces overlapping this file have passed their hash check.
struct file_completed_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::progress_notification; int index; };
- index
- refers to the index of the file that completed.
file_renamed_alert
Declared in "libtorrent/alert_types.hpp"
This is posted as a response to a torrent_handle::rename_file() call, if the rename operation succeeds.
struct file_renamed_alert final : torrent_alert { virtual std::string message () const override; char const* new_name () const; static const int static_category = alert::storage_notification; int index; };
- index
- refers to the index of the file that was renamed,
file_rename_failed_alert
Declared in "libtorrent/alert_types.hpp"
This is posted as a response to a torrent_handle::rename_file() call, if the rename operation failed.
struct file_rename_failed_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::storage_notification; int index; error_code error; };
- index error
- refers to the index of the file that was supposed to be renamed, error is the error code returned from the filesystem.
performance_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a limit is reached that might have a negative impact on upload or download rate performance.
struct performance_alert final : torrent_alert { virtual std::string message () const override; enum performance_warning_t { outstanding_disk_buffer_limit_reached, outstanding_request_limit_reached, upload_limit_too_low, download_limit_too_low, send_buffer_watermark_too_low, too_many_optimistic_unchoke_slots, too_high_disk_queue_limit, aio_limit_reached, bittyrant_with_no_uplimit, too_few_outgoing_ports, too_few_file_descriptors, num_warnings, }; static const int static_category = alert::performance_warning; performance_warning_t warning_code; };
enum performance_warning_t
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
outstanding_disk_buffer_limit_reached | 0 | This warning means that the number of bytes queued to be written to disk exceeds the max disk byte queue setting (settings_pack::max_queued_disk_bytes). This might restrict the download rate, by not queuing up enough write jobs to the disk I/O thread. When this alert is posted, peer connections are temporarily stopped from downloading, until the queued disk bytes have fallen below the limit again. Unless your max_queued_disk_bytes setting is already high, you might want to increase it to get better performance. |
outstanding_request_limit_reached | 1 | This is posted when libtorrent would like to send more requests to a peer, but it's limited by settings_pack::max_out_request_queue. The queue length libtorrent is trying to achieve is determined by the download rate and the assumed round-trip-time (settings_pack::request_queue_time). The assumed round-trip-time is not limited to just the network RTT, but also the remote disk access time and message handling time. It defaults to 3 seconds. The target number of outstanding requests is set to fill the bandwidth-delay product (assumed RTT times download rate divided by number of bytes per request). When this alert is posted, there is a risk that the number of outstanding requests is too low and limits the download rate. You might want to increase the max_out_request_queue setting. |
upload_limit_too_low | 2 | This warning is posted when the amount of TCP/IP overhead is greater than the upload rate limit. When this happens, the TCP/IP overhead is caused by a much faster download rate, triggering TCP ACK packets. These packets eat into the rate limit specified to libtorrent. When the overhead traffic is greater than the rate limit, libtorrent will not be able to send any actual payload, such as piece requests. This means the download rate will suffer, and new requests can be sent again. There will be an equilibrium where the download rate, on average, is about 20 times the upload rate limit. If you want to maximize the download rate, increase the upload rate limit above 5% of your download capacity. |
download_limit_too_low | 3 | This is the same warning as upload_limit_too_low but referring to the download limit instead of upload. This suggests that your download rate limit is much lower than your upload capacity. Your upload rate will suffer. To maximize upload rate, make sure your download rate limit is above 5% of your upload capacity. |
send_buffer_watermark_too_low | 4 | We're stalled on the disk. We want to write to the socket, and we can write but our send buffer is empty, waiting to be refilled from the disk. This either means the disk is slower than the network connection or that our send buffer watermark is too small, because we can send it all before the disk gets back to us. The number of bytes that we keep outstanding, requested from the disk, is calculated as follows: min(512, max(upload_rate * send_buffer_watermark_factor / 100, send_buffer_watermark)) If you receive this alert, you might want to either increase your send_buffer_watermark or send_buffer_watermark_factor. |
too_many_optimistic_unchoke_slots | 5 | If the half (or more) of all upload slots are set as optimistic unchoke slots, this warning is issued. You probably want more regular (rate based) unchoke slots. |
too_high_disk_queue_limit | 6 | If the disk write queue ever grows larger than half of the cache size, this warning is posted. The disk write queue eats into the total disk cache and leaves very little left for the actual cache. This causes the disk cache to oscillate in evicting large portions of the cache before allowing peers to download any more, onto the disk write queue. Either lower max_queued_disk_bytes or increase cache_size. |
aio_limit_reached | 7 | |
bittyrant_with_no_uplimit | 8 | |
too_few_outgoing_ports | 9 | This is generated if outgoing peer connections are failing because of address in use errors, indicating that settings_pack::outgoing_ports is set and is too small of a range. Consider not using the outgoing_ports setting at all, or widen the range to include more ports. |
too_few_file_descriptors | 10 | |
num_warnings | 11 |
state_changed_alert
Declared in "libtorrent/alert_types.hpp"
Generated whenever a torrent changes its state.
struct state_changed_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::status_notification; torrent_status::state_t state; torrent_status::state_t prev_state; };
- state
- the new state of the torrent.
- prev_state
- the previous state.
tracker_error_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated on tracker time outs, premature disconnects, invalid response or a HTTP response other than "200 OK". From the alert you can get the handle to the torrent the tracker belongs to.
The times_in_row member says how many times in a row this tracker has failed. status_code is the code returned from the HTTP server. 401 means the tracker needs authentication, 404 means not found etc. If the tracker timed out, the code will be set to 0.
struct tracker_error_alert final : tracker_alert { virtual std::string message () const override; char const* error_message () const; static const int static_category = alert::tracker_notification | alert::error_notification; int times_in_row; int status_code; error_code error; };
tracker_warning_alert
Declared in "libtorrent/alert_types.hpp"
This alert is triggered if the tracker reply contains a warning field. Usually this means that the tracker announce was successful, but the tracker has a message to the client.
struct tracker_warning_alert final : tracker_alert { virtual std::string message () const override; char const* warning_message () const; static const int static_category = alert::tracker_notification | alert::error_notification; };
scrape_reply_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a scrape request succeeds.
struct scrape_reply_alert final : tracker_alert { virtual std::string message () const override; int incomplete; int complete; };
- incomplete complete
- the data returned in the scrape response. These numbers may be -1 if the response was malformed.
scrape_failed_alert
Declared in "libtorrent/alert_types.hpp"
If a scrape request fails, this alert is generated. This might be due to the tracker timing out, refusing connection or returning an http response code indicating an error.
struct scrape_failed_alert final : tracker_alert { virtual std::string message () const override; char const* error_message () const; static const int static_category = alert::tracker_notification | alert::error_notification; error_code error; };
error_message()
char const* error_message () const;
if the error indicates there is an associated message, this returns that message. Otherwise and empty string.
- error
- the error itself. This may indicate that the tracker sent an error message (error::tracker_failure), in which case it can be retrieved by calling error_message().
tracker_reply_alert
Declared in "libtorrent/alert_types.hpp"
This alert is only for informational purpose. It is generated when a tracker announce succeeds. It is generated regardless what kind of tracker was used, be it UDP, HTTP or the DHT.
struct tracker_reply_alert final : tracker_alert { virtual std::string message () const override; int num_peers; };
- num_peers
- tells how many peers the tracker returned in this response. This is not expected to be greater than the num_want settings. These are not necessarily all new peers, some of them may already be connected.
dht_reply_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated each time the DHT receives peers from a node. num_peers is the number of peers we received in this packet. Typically these packets are received from multiple DHT nodes, and so the alerts are typically generated a few at a time.
struct dht_reply_alert final : tracker_alert { virtual std::string message () const override; int num_peers; };
tracker_announce_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated each time a tracker announce is sent (or attempted to be sent). There are no extra data members in this alert. The url can be found in the base class however.
struct tracker_announce_alert final : tracker_alert { virtual std::string message () const override; int event; };
- event
specifies what event was sent to the tracker. It is defined as:
- None
- Completed
- Started
- Stopped
hash_failed_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a finished piece fails its hash check. You can get the handle to the torrent which got the failed piece and the index of the piece itself from the alert.
struct hash_failed_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::status_notification; int piece_index; };
peer_ban_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a peer is banned because it has sent too many corrupt pieces to us. ip is the endpoint to the peer that was banned.
struct peer_ban_alert final : peer_alert { virtual std::string message () const override; };
peer_unsnubbed_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a peer is unsnubbed. Essentially when it was snubbed for stalling sending data, and now it started sending data again.
struct peer_unsnubbed_alert final : peer_alert { virtual std::string message () const override; };
peer_snubbed_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a peer is snubbed, when it stops sending data when we request it.
struct peer_snubbed_alert final : peer_alert { virtual std::string message () const override; };
peer_error_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a peer sends invalid data over the peer-peer protocol. The peer will be disconnected, but you get its ip address from the alert, to identify it.
struct peer_error_alert final : peer_alert { virtual std::string message () const override; static const int static_category = alert::peer_notification; int operation; error_code error; };
- operation
- a NULL-terminated string of the low-level operation that failed, or NULL if there was no low level disk operation.
- error
- tells you what error caused this alert.
peer_connect_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted every time an outgoing peer connect attempts succeeds.
struct peer_connect_alert final : peer_alert { virtual std::string message () const override; static const int static_category = alert::debug_notification; int socket_type; };
peer_disconnected_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a peer is disconnected for any reason (other than the ones covered by peer_error_alert ).
struct peer_disconnected_alert final : peer_alert { virtual std::string message () const override; static const int static_category = alert::debug_notification; int socket_type; operation_t operation; error_code error; close_reason_t reason; };
- socket_type
- the kind of socket this peer was connected over
- operation
- the operation or level where the error occurred. Specified as an value from the operation_t enum. Defined in operations.hpp.
- error
- tells you what error caused peer to disconnect.
- reason
- the reason the peer disconnected (if specified)
invalid_request_alert
Declared in "libtorrent/alert_types.hpp"
This is a debug alert that is generated by an incoming invalid piece request. ip is the address of the peer and the request is the actual incoming request from the peer. See peer_request for more info.
struct invalid_request_alert final : peer_alert { virtual std::string message () const override; peer_request request; bool we_have; bool peer_interested; bool withheld; };
- request
- the request we received from the peer
- we_have
- true if we have this piece
- peer_interested
- true if the peer indicated that it was interested to download before sending the request
- withheld
- if this is true, the peer is not allowed to download this piece because of super-seeding rules.
torrent_finished_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a torrent switches from being a downloader to a seed. It will only be generated once per torrent. It contains a torrent_handle to the torrent in question.
struct torrent_finished_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::status_notification; };
piece_finished_alert
Declared in "libtorrent/alert_types.hpp"
this alert is posted every time a piece completes downloading and passes the hash check. This alert derives from torrent_alert which contains the torrent_handle to the torrent the piece belongs to.
struct piece_finished_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::progress_notification; int piece_index; };
- piece_index
- the index of the piece that finished
request_dropped_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a peer rejects or ignores a piece request.
struct request_dropped_alert final : peer_alert { virtual std::string message () const override; static const int static_category = alert::progress_notification | alert::peer_notification; int block_index; int piece_index; };
block_timeout_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a block request times out.
struct block_timeout_alert final : peer_alert { virtual std::string message () const override; static const int static_category = alert::progress_notification | alert::peer_notification; int block_index; int piece_index; };
block_finished_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a block request receives a response.
struct block_finished_alert final : peer_alert { virtual std::string message () const override; static const int static_category = alert::progress_notification; int block_index; int piece_index; };
block_downloading_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a block request is sent to a peer.
struct block_downloading_alert final : peer_alert { virtual std::string message () const override; static const int static_category = alert::progress_notification; int block_index; int piece_index; };
unwanted_block_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a block is received that was not requested or whose request timed out.
struct unwanted_block_alert final : peer_alert { virtual std::string message () const override; int block_index; int piece_index; };
storage_moved_alert
Declared in "libtorrent/alert_types.hpp"
The storage_moved_alert is generated when all the disk IO has completed and the files have been moved, as an effect of a call to torrent_handle::move_storage. This is useful to synchronize with the actual disk. The storage_path() member return the new path of the storage.
struct storage_moved_alert final : torrent_alert { virtual std::string message () const override; char const* storage_path () const; static const int static_category = alert::storage_notification; };
storage_moved_failed_alert
Declared in "libtorrent/alert_types.hpp"
The storage_moved_failed_alert is generated when an attempt to move the storage, via torrent_handle::move_storage(), fails.
struct storage_moved_failed_alert final : torrent_alert { virtual std::string message () const override; char const* file_path () const; static const int static_category = alert::storage_notification; error_code error; char const* operation; };
torrent_deleted_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a request to delete the files of a torrent complete.
The info_hash is the info-hash of the torrent that was just deleted. Most of the time the torrent_handle in the torrent_alert will be invalid by the time this alert arrives, since the torrent is being deleted. The info_hash member is hence the main way of identifying which torrent just completed the delete.
This alert is posted in the storage_notification category, and that bit needs to be set in the alert_mask.
struct torrent_deleted_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::storage_notification; sha1_hash info_hash; };
torrent_delete_failed_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a request to delete the files of a torrent fails. Just removing a torrent from the session cannot fail
struct torrent_delete_failed_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::storage_notification | alert::error_notification; error_code error; sha1_hash info_hash; };
- error
- tells you why it failed.
- info_hash
- the info hash of the torrent whose files failed to be deleted
save_resume_data_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated as a response to a torrent_handle::save_resume_data request. It is generated once the disk IO thread is done writing the state for this torrent.
struct save_resume_data_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::storage_notification; boost::shared_ptr<entry> resume_data; };
- resume_data
- points to the resume data.
save_resume_data_failed_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated instead of save_resume_data_alert if there was an error generating the resume data. error describes what went wrong.
struct save_resume_data_failed_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::storage_notification | alert::error_notification; error_code error; };
- error
- the error code from the resume_data failure
torrent_paused_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated as a response to a torrent_handle::pause request. It is generated once all disk IO is complete and the files in the torrent have been closed. This is useful for synchronizing with the disk.
struct torrent_paused_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::status_notification; };
torrent_resumed_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated as a response to a torrent_handle::resume() request. It is generated when a torrent goes from a paused state to an active state.
struct torrent_resumed_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::status_notification; };
torrent_checked_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted when a torrent completes checking. i.e. when it transitions out of the checking files state into a state where it is ready to start downloading
struct torrent_checked_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::status_notification; };
url_seed_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a HTTP seed name lookup fails.
struct url_seed_alert final : torrent_alert { virtual std::string message () const override; char const* server_url () const; char const* error_message () const; static const int static_category = alert::peer_notification | alert::error_notification; error_code error; };
file_error_alert
Declared in "libtorrent/alert_types.hpp"
If the storage fails to read or write files that it needs access to, this alert is generated and the torrent is paused.
struct file_error_alert final : torrent_alert { virtual std::string message () const override; char const* filename () const; static const int static_category = alert::status_notification | alert::storage_notification; error_code error; char const* operation; };
metadata_failed_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when the metadata has been completely received and the info-hash failed to match it. i.e. the metadata that was received was corrupt. libtorrent will automatically retry to fetch it in this case. This is only relevant when running a torrent-less download, with the metadata extension provided by libtorrent.
struct metadata_failed_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::error_notification; error_code error; };
- error
- indicates what failed when parsing the metadata. This error is what's returned from lazy_bdecode().
metadata_received_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when the metadata has been completely received and the torrent can start downloading. It is not generated on torrents that are started with metadata, but only those that needs to download it from peers (when utilizing the libtorrent extension).
There are no additional data members in this alert.
Typically, when receiving this alert, you would want to save the torrent file in order to load it back up again when the session is restarted. Here's an example snippet of code to do that:
torrent_handle h = alert->handle(); if (h.is_valid()) { boost::shared_ptr<torrent_info const> ti = h.torrent_file(); create_torrent ct(*ti); entry te = ct.generate(); std::vector<char> buffer; bencode(std::back_inserter(buffer), te); FILE* f = fopen((to_hex(ti->info_hash().to_string()) + ".torrent").c_str(), "wb+"); if (f) { fwrite(&buffer[0], 1, buffer.size(), f); fclose(f); } }
struct metadata_received_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::status_notification; };
udp_error_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted when there is an error on the UDP socket. The UDP socket is used for all uTP, DHT and UDP tracker traffic. It's global to the session.
struct udp_error_alert final : alert { virtual std::string message () const override; static const int static_category = alert::error_notification; udp::endpoint endpoint; error_code error; };
- endpoint
- the source address associated with the error (if any)
- error
- the error code describing the error
external_ip_alert
Declared in "libtorrent/alert_types.hpp"
Whenever libtorrent learns about the machines external IP, this alert is generated. The external IP address can be acquired from the tracker (if it supports that) or from peers that supports the extension protocol. The address can be accessed through the external_address member.
struct external_ip_alert final : alert { virtual std::string message () const override; static const int static_category = alert::status_notification; address external_address; };
- external_address
- the IP address that is believed to be our external IP
listen_failed_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when none of the ports, given in the port range, to session can be opened for listening. The endpoint member is the interface and port that failed, error is the error code describing the failure.
libtorrent may sometimes try to listen on port 0, if all other ports failed. Port 0 asks the operating system to pick a port that's free). If that fails you may see a listen_failed_alert with port 0 even if you didn't ask to listen on it.
struct listen_failed_alert final : alert { virtual std::string message () const override; char const* listen_interface () const; enum socket_type_t { tcp, tcp_ssl, udp, i2p, socks5, utp_ssl, }; enum op_t { parse_addr, open, bind, listen, get_peer_name, accept, }; static const int static_category = alert::status_notification | alert::error_notification; error_code error; int operation; socket_type_t sock_type; tcp::endpoint endpoint; };
listen_interface()
char const* listen_interface () const;
the interface libtorrent attempted to listen on that failed.
enum socket_type_t
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
tcp | 0 | |
tcp_ssl | 1 | |
udp | 2 | |
i2p | 3 | |
socks5 | 4 | |
utp_ssl | 5 |
enum op_t
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
parse_addr | 0 | |
open | 1 | |
bind | 2 | |
listen | 3 | |
get_peer_name | 4 | |
accept | 5 |
- error
- the error the system returned
- operation
- the specific low level operation that failed. See op_t.
- sock_type
- the type of listen socket this alert refers to.
- endpoint
- the address and port libtorrent attempted to listen on
listen_succeeded_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted when the listen port succeeds to be opened on a particular interface. endpoint is the endpoint that successfully was opened for listening.
struct listen_succeeded_alert final : alert { virtual std::string message () const override; enum socket_type_t { tcp, tcp_ssl, udp, i2p, socks5, utp_ssl, }; static const int static_category = alert::status_notification; tcp::endpoint endpoint; socket_type_t sock_type; };
enum socket_type_t
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
tcp | 0 | |
tcp_ssl | 1 | |
udp | 2 | |
i2p | 3 | |
socks5 | 4 | |
utp_ssl | 5 |
- endpoint
- the endpoint libtorrent ended up listening on. The address refers to the local interface and the port is the listen port.
- sock_type
- the type of listen socket this alert refers to.
portmap_error_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a NAT router was successfully found but some part of the port mapping request failed. It contains a text message that may help the user figure out what is wrong. This alert is not generated in case it appears the client is not running on a NAT:ed network or if it appears there is no NAT router that can be remote controlled to add port mappings.
struct portmap_error_alert final : alert { virtual std::string message () const override; static const int static_category = alert::port_mapping_notification | alert::error_notification; int mapping; int map_type; error_code error; };
- mapping
- refers to the mapping index of the port map that failed, i.e. the index returned from add_mapping().
- map_type
- is 0 for NAT-PMP and 1 for UPnP.
- error
- tells you what failed.
portmap_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a NAT router was successfully found and a port was successfully mapped on it. On a NAT:ed network with a NAT-PMP capable router, this is typically generated once when mapping the TCP port and, if DHT is enabled, when the UDP port is mapped.
struct portmap_alert final : alert { virtual std::string message () const override; enum protocol_t { tcp, udp, }; static const int static_category = alert::port_mapping_notification; int mapping; int external_port; int map_type; int protocol; };
enum protocol_t
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
tcp | 0 | |
udp | 1 |
- mapping
- refers to the mapping index of the port map that failed, i.e. the index returned from add_mapping().
- external_port
- the external port allocated for the mapping.
- map_type
- 0 for NAT-PMP and 1 for UPnP.
- protocol
- the protocol this mapping was for. one of protocol_t enums
portmap_log_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated to log informational events related to either UPnP or NAT-PMP. They contain a log line and the type (0 = NAT-PMP and 1 = UPnP). Displaying these messages to an end user is only useful for debugging the UPnP or NAT-PMP implementation. This alert is only posted if the alert::port_mapping_log_notification flag is enabled in the alert mask.
struct portmap_log_alert final : alert { virtual std::string message () const override; char const* log_message () const; static const int static_category = alert::port_mapping_log_notification; int map_type; };
fastresume_rejected_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a fastresume file has been passed to add_torrent() but the files on disk did not match the fastresume file. The error_code explains the reason why the resume file was rejected.
struct fastresume_rejected_alert final : torrent_alert { virtual std::string message () const override; char const* file_path () const; static const int static_category = alert::status_notification | alert::error_notification; error_code error; char const* operation; };
peer_blocked_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted when an incoming peer connection, or a peer that's about to be added to our peer list, is blocked for some reason. This could be any of:
- the IP filter
- i2p mixed mode restrictions (a normal peer is not allowed on an i2p swarm)
- the port filter
- the peer has a low port and no_connect_privileged_ports is enabled
- the protocol of the peer is blocked (uTP/TCP blocking)
struct peer_blocked_alert final : torrent_alert { virtual std::string message () const override; enum reason_t { ip_filter, port_filter, i2p_mixed, privileged_ports, utp_disabled, tcp_disabled, invalid_local_interface, }; static const int static_category = alert::ip_block_notification; address ip; int reason; };
enum reason_t
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
ip_filter | 0 | |
port_filter | 1 | |
i2p_mixed | 2 | |
privileged_ports | 3 | |
utp_disabled | 4 | |
tcp_disabled | 5 | |
invalid_local_interface | 6 |
- ip
- the address that was blocked.
dht_announce_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a DHT node announces to an info-hash on our DHT node. It belongs to the dht_notification category.
struct dht_announce_alert final : alert { virtual std::string message () const override; static const int static_category = alert::dht_notification; address ip; int port; sha1_hash info_hash; };
dht_get_peers_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when a DHT node sends a get_peers message to our DHT node. It belongs to the dht_notification category.
struct dht_get_peers_alert final : alert { virtual std::string message () const override; static const int static_category = alert::dht_notification; sha1_hash info_hash; };
stats_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted approximately once every second, and it contains byte counters of most statistics that's tracked for torrents. Each active torrent posts these alerts regularly. This alert has been superceded by calling post_torrent_updates() regularly on the session object. This alert will be removed
struct stats_alert final : torrent_alert { virtual std::string message () const override; enum stats_channel { upload_payload, upload_protocol, download_payload, download_protocol, upload_ip_protocol, deprecated1, deprecated2, download_ip_protocol, deprecated3, deprecated4, num_channels, }; static const int static_category = alert::stats_notification; int transferred[num_channels]; int interval; };
enum stats_channel
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
upload_payload | 0 | |
upload_protocol | 1 | |
download_payload | 2 | |
download_protocol | 3 | |
upload_ip_protocol | 4 | |
deprecated1 | 5 | |
deprecated2 | 6 | |
download_ip_protocol | 7 | |
deprecated3 | 8 | |
deprecated4 | 9 | |
num_channels | 10 |
- transferred[num_channels]
- an array of samples. The enum describes what each sample is a measurement of. All of these are raw, and not smoothing is performed.
- interval
- the number of milliseconds during which these stats were collected. This is typically just above 1000, but if CPU is limited, it may be higher than that.
cache_flushed_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted when the disk cache has been flushed for a specific torrent as a result of a call to torrent_handle::flush_cache(). This alert belongs to the storage_notification category, which must be enabled to let this alert through. The alert is also posted when removing a torrent from the session, once the outstanding cache flush is complete and the torrent does no longer have any files open.
struct cache_flushed_alert final : torrent_alert { static const int static_category = alert::storage_notification; };
anonymous_mode_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted when a bittorrent feature is blocked because of the anonymous mode. For instance, if the tracker proxy is not set up, no trackers will be used, because trackers can only be used through proxies when in anonymous mode.
struct anonymous_mode_alert final : torrent_alert { virtual std::string message () const override; enum kind_t { tracker_not_anonymous, }; static const int static_category = alert::error_notification; int kind; std::string str; };
enum kind_t
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
tracker_not_anonymous | 0 | means that there's no proxy set up for tracker communication and the tracker will not be contacted. The tracker which this failed for is specified in the str member. |
- kind str
- specifies what error this is, see kind_t.
lsd_peer_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when we receive a local service discovery message from a peer for a torrent we're currently participating in.
struct lsd_peer_alert final : peer_alert { virtual std::string message () const override; static const int static_category = alert::peer_notification; };
trackerid_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted whenever a tracker responds with a trackerid. The tracker ID is like a cookie. The libtorrent will store the tracker ID for this tracker and repeat it in subsequent announces.
struct trackerid_alert final : tracker_alert { virtual std::string message () const override; char const* tracker_id () const; static const int static_category = alert::status_notification; };
dht_bootstrap_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted when the initial DHT bootstrap is done.
struct dht_bootstrap_alert final : alert { virtual std::string message () const override; static const int static_category = alert::dht_notification; };
torrent_error_alert
Declared in "libtorrent/alert_types.hpp"
This is posted whenever a torrent is transitioned into the error state.
struct torrent_error_alert final : torrent_alert { virtual std::string message () const override; char const* filename () const; static const int static_category = alert::error_notification | alert::status_notification; error_code error; };
torrent_need_cert_alert
Declared in "libtorrent/alert_types.hpp"
This is always posted for SSL torrents. This is a reminder to the client that the torrent won't work unless torrent_handle::set_ssl_certificate() is called with a valid certificate. Valid certificates MUST be signed by the SSL certificate in the .torrent file.
struct torrent_need_cert_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::status_notification; error_code error; };
incoming_connection_alert
Declared in "libtorrent/alert_types.hpp"
The incoming connection alert is posted every time we successfully accept an incoming connection, through any mean. The most straight-forward ways of accepting incoming connections are through the TCP listen socket and the UDP listen socket for uTP sockets. However, connections may also be accepted through a Socks5 or i2p listen socket, or via an SSL listen socket.
struct incoming_connection_alert final : alert { virtual std::string message () const override; static const int static_category = alert::peer_notification; int socket_type; tcp::endpoint ip; };
- socket_type
tells you what kind of socket the connection was accepted as:
- none (no socket instantiated)
- TCP
- Socks5
- HTTP
- uTP
- i2p
- SSL/TCP
- SSL/Socks5
- HTTPS (SSL/HTTP)
- SSL/uTP
- ip
- is the IP address and port the connection came from.
add_torrent_alert
Declared in "libtorrent/alert_types.hpp"
This alert is always posted when a torrent was attempted to be added and contains the return status of the add operation. The torrent handle of the new torrent can be found in the base class' handle member. If adding the torrent failed, error contains the error code.
struct add_torrent_alert final : torrent_alert { virtual std::string message () const override; static const int static_category = alert::status_notification; add_torrent_params params; error_code error; };
- params
- a copy of the parameters used when adding the torrent, it can be used to identify which invocation to async_add_torrent() caused this alert.
- error
- set to the error, if one occurred while adding the torrent.
state_update_alert
Declared in "libtorrent/alert_types.hpp"
This alert is only posted when requested by the user, by calling session::post_torrent_updates() on the session. It contains the torrent status of all torrents that changed since last time this message was posted. Its category is status_notification, but it's not subject to filtering, since it's only manually posted anyway.
struct state_update_alert final : alert { state_update_alert (aux::stack_allocator& alloc , std::vector<torrent_status> st); virtual std::string message () const override; static const int static_category = alert::status_notification; std::vector<torrent_status> status; };
- status
- contains the torrent status of all torrents that changed since last time this message was posted. Note that you can map a torrent status to a specific torrent via its handle member. The receiving end is suggested to have all torrents sorted by the torrent_handle or hashed by it, for efficient updates.
session_stats_alert
Declared in "libtorrent/alert_types.hpp"
The session_stats_alert is posted when the user requests session statistics by calling post_session_stats() on the session object. Its category is status_notification, but it is not subject to filtering, since it's only manually posted anyway.
struct session_stats_alert final : alert { session_stats_alert (aux::stack_allocator& alloc, counters const& cnt); virtual std::string message () const override; static const int static_category = alert::stats_notification; boost::uint64_t values[counters::num_counters]; };
- values[counters
An array are a mix of counters and gauges, which meanings can be queries via the session_stats_metrics() function on the session. The mapping from a specific metric to an index into this array is constant for a specific version of libtorrent, but may differ for other versions. The intended usage is to request the mapping, i.e. call session_stats_metrics(), once on startup, and then use that mapping to interpret these values throughout the process' runtime.
For more information, see the session statistics section.
dht_error_alert
Declared in "libtorrent/alert_types.hpp"
posted when something fails in the DHT. This is not necessarily a fatal error, but it could prevent proper operation
struct dht_error_alert final : alert { virtual std::string message () const override; enum op_t { unknown, hostname_lookup, }; static const int static_category = alert::error_notification | alert::dht_notification; error_code error; op_t operation; };
enum op_t
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
unknown | 0 | |
hostname_lookup | 1 |
- error
- the error code
- operation
- the operation that failed
dht_immutable_item_alert
Declared in "libtorrent/alert_types.hpp"
this alert is posted as a response to a call to session::get_item(), specifically the overload for looking up immutable items in the DHT.
struct dht_immutable_item_alert final : alert { dht_immutable_item_alert (aux::stack_allocator& alloc, sha1_hash const& t , entry const& i); virtual std::string message () const override; static const int static_category = alert::dht_notification; sha1_hash target; entry item; };
- target
- the target hash of the immutable item. This must match the SHA-1 hash of the bencoded form of item.
- item
- the data for this item
dht_mutable_item_alert
Declared in "libtorrent/alert_types.hpp"
this alert is posted as a response to a call to session::get_item(), specifically the overload for looking up mutable items in the DHT.
struct dht_mutable_item_alert final : alert { dht_mutable_item_alert (aux::stack_allocator& alloc , boost::array<char, 32> k , boost::array<char, 64> sig , boost::uint64_t sequence , std::string const& s , entry const& i , bool a); virtual std::string message () const override; static const int static_category = alert::dht_notification; boost::array<char, 32> key; boost::array<char, 64> signature; boost::uint64_t seq; std::string salt; entry item; bool authoritative; };
- key
- the public key that was looked up
- signature
- the signature of the data. This is not the signature of the plain encoded form of the item, but it includes the sequence number and possibly the hash as well. See the dht_store document for more information. This is primarily useful for echoing back in a store request.
- seq
- the sequence number of this item
- salt
- the salt, if any, used to lookup and store this item. If no salt was used, this is an empty string
- item
- the data for this item
- authoritative
- the last response for mutable data is authoritative.
dht_put_alert
Declared in "libtorrent/alert_types.hpp"
this is posted when a DHT put operation completes. This is useful if the client is waiting for a put to complete before shutting down for instance.
struct dht_put_alert final : alert { virtual std::string message () const override; static const int static_category = alert::dht_notification; sha1_hash target; boost::array<char, 32> public_key; boost::array<char, 64> signature; std::string salt; boost::uint64_t seq; int num_success; };
- target
- the target hash the item was stored under if this was an immutable item.
- public_key signature salt seq
- if a mutable item was stored, these are the public key, signature, salt and sequence number the item was stored under.
- num_success
- DHT put operation usually writes item to k nodes, maybe the node is stale so no response, or the node doesn't support 'put', or the token for write is out of date, etc. num_success is the number of successful responses we got from the puts.
i2p_alert
Declared in "libtorrent/alert_types.hpp"
this alert is used to report errors in the i2p SAM connection
struct i2p_alert final : alert { i2p_alert (aux::stack_allocator& alloc, error_code const& ec); virtual std::string message () const override; static const int static_category = alert::error_notification; error_code error; };
- error
- the error that occurred in the i2p SAM connection
dht_outgoing_get_peers_alert
Declared in "libtorrent/alert_types.hpp"
This alert is generated when we send a get_peers request It belongs to the dht_notification category.
struct dht_outgoing_get_peers_alert final : alert { virtual std::string message () const override; static const int static_category = alert::dht_notification; sha1_hash info_hash; sha1_hash obfuscated_info_hash; udp::endpoint ip; };
- info_hash
- the info_hash of the torrent we're looking for peers for.
- obfuscated_info_hash
- if this was an obfuscated lookup, this is the info-hash target actually sent to the node.
- ip
- the endpoint we're sending this query to
log_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted by some session wide event. Its main purpose is trouble shooting and debugging. It's not enabled by the default alert mask and is enabled by the alert::session_log_notification bit. Furthermore, it's by default disabled as a build configuration.
struct log_alert final : alert { virtual std::string message () const override; char const* msg () const; static const int static_category = alert::session_log_notification; };
torrent_log_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted by torrent wide events. It's meant to be used for trouble shooting and debugging. It's not enabled by the default alert mask and is enabled by the alert::torrent_log_notification bit. By default it is disabled as a build configuration.
struct torrent_log_alert final : torrent_alert { virtual std::string message () const override; char const* msg () const; static const int static_category = alert::torrent_log_notification; };
peer_log_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted by events specific to a peer. It's meant to be used for trouble shooting and debugging. It's not enabled by the default alert mask and is enabled by the alert::peer_log_notification bit. By default it is disabled as a build configuration.
struct peer_log_alert final : peer_alert { virtual std::string message () const override; char const* msg () const; enum direction_t { incoming_message, outgoing_message, incoming, outgoing, info, }; static const int static_category = alert::peer_log_notification; char const* event_type; direction_t direction; };
enum direction_t
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
incoming_message | 0 | |
outgoing_message | 1 | |
incoming | 2 | |
outgoing | 3 | |
info | 4 |
- event_type
- string literal indicating the kind of event. For messages, this is the message name.
lsd_error_alert
Declared in "libtorrent/alert_types.hpp"
posted if the local service discovery socket fails to start properly. it's categorized as error_notification.
struct lsd_error_alert final : alert { virtual std::string message () const override; static const int static_category = alert::error_notification; error_code error; };
- error
- The error code
dht_lookup
Declared in "libtorrent/alert_types.hpp"
holds statistics about a current dht_lookup operation. a DHT lookup is the traversal of nodes, looking up a set of target nodes in the DHT for retrieving and possibly storing information in the DHT
struct dht_lookup { char const* type; int outstanding_requests; int timeouts; int responses; int branch_factor; int nodes_left; int last_sent; int first_timeout; };
- type
- string literal indicating which kind of lookup this is
- outstanding_requests
- the number of outstanding request to individual nodes this lookup has right now
- timeouts
- the total number of requests that have timed out so far for this lookup
- responses
- the total number of responses we have received for this lookup so far for this lookup
- branch_factor
- the branch factor for this lookup. This is the number of nodes we keep outstanding requests to in parallel by default. when nodes time out we may increase this.
- nodes_left
- the number of nodes left that could be queries for this lookup. Many of these are likely to be part of the trail while performing the lookup and would never end up actually being queried.
- last_sent
- the number of seconds ago the last message was sent that's still outstanding
- first_timeout
- the number of outstanding requests that have exceeded the short timeout and are considered timed out in the sense that they increased the branch factor
dht_routing_bucket
Declared in "libtorrent/alert_types.hpp"
struct to hold information about a single DHT routing table bucket
struct dht_routing_bucket { int num_nodes; int num_replacements; int last_active; };
- num_nodes num_replacements
- the total number of nodes and replacement nodes in the routing table
- last_active
- number of seconds since last activity
dht_stats_alert
Declared in "libtorrent/alert_types.hpp"
contains current DHT state. Posted in response to session::post_dht_stats().
struct dht_stats_alert final : alert { virtual std::string message () const override; static const int static_category = alert::stats_notification; std::vector<dht_lookup> active_requests; std::vector<dht_routing_bucket> routing_table; };
- active_requests
- a vector of the currently running DHT lookups.
- routing_table
- contains information about every bucket in the DHT routing table.
incoming_request_alert
Declared in "libtorrent/alert_types.hpp"
posted every time an incoming request from a peer is accepted and queued up for being serviced. This alert is only posted if the alert::incoming_request_notification flag is enabled in the alert mask.
struct incoming_request_alert final : peer_alert { virtual std::string message () const override; static const int static_category = alert::incoming_request_notification; peer_request req; };
- req
- the request this peer sent to us
dht_log_alert
Declared in "libtorrent/alert_types.hpp"
struct dht_log_alert final : alert { dht_log_alert (aux::stack_allocator& alloc , dht_module_t m, char const* msg); virtual std::string message () const override; char const* log_message () const; enum dht_module_t { tracker, node, routing_table, rpc_manager, traversal, }; static const int static_category = alert::dht_log_notification; dht_module_t module; };
enum dht_module_t
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
tracker | 0 | |
node | 1 | |
routing_table | 2 | |
rpc_manager | 3 | |
traversal | 4 |
- module
- the module, or part, of the DHT that produced this log message.
dht_pkt_alert
Declared in "libtorrent/alert_types.hpp"
This alert is posted every time a DHT message is sent or received. It is only posted if the alert::dht_log_notification alert category is enabled. It contains a verbatim copy of the message.
struct dht_pkt_alert final : alert { dht_pkt_alert (aux::stack_allocator& alloc, char const* buf, int size , dht_pkt_alert::direction_t d, udp::endpoint ep); virtual std::string message () const override; int pkt_size () const; char const* pkt_buf () const; enum direction_t { incoming, outgoing, }; static const int static_category = alert::dht_log_notification; direction_t dir; udp::endpoint node; };
pkt_size() pkt_buf()
int pkt_size () const; char const* pkt_buf () const;
returns a pointer to the packet buffer and size of the packet, respectively. This buffer is only valid for as long as the alert itself is valid, which is owned by libtorrent and reclaimed whenever pop_alerts() is called on the session.
enum direction_t
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
incoming | 0 | |
outgoing | 1 |
- dir
- whether this is an incoming or outgoing packet.
- node
- the DHT node we received this packet from, or sent this packet to (depending on dir).
dht_get_peers_reply_alert
Declared in "libtorrent/alert_types.hpp"
struct dht_get_peers_reply_alert final : alert { dht_get_peers_reply_alert (aux::stack_allocator& alloc , sha1_hash const& ih , std::vector<tcp::endpoint> const& v); virtual std::string message () const override; int num_peers () const; std::vector<tcp::endpoint> peers () const; static const int static_category = alert::dht_operation_notification; sha1_hash info_hash; };
dht_direct_response_alert
Declared in "libtorrent/alert_types.hpp"
This is posted exactly once for every call to session_handle::dht_direct_request. If the request failed, response() will return a default constructed bdecode_node.
struct dht_direct_response_alert final : alert { dht_direct_response_alert (aux::stack_allocator& alloc, void* userdata , udp::endpoint const& addr, bdecode_node const& response); virtual std::string message () const override; dht_direct_response_alert (aux::stack_allocator& alloc, void* userdata , udp::endpoint const& addr); bdecode_node response () const; static const int static_category = alert::dht_notification; void* userdata; udp::endpoint addr; };
picker_log_alert
Declared in "libtorrent/alert_types.hpp"
this is posted when one or more blocks are picked by the piece picker, assuming the verbose piece picker logging is enabled (see picker_log_notification).
struct picker_log_alert final : peer_alert { virtual std::string message () const override; std::vector<piece_block> blocks () const; enum picker_flags_t { partial_ratio, prioritize_partials, rarest_first_partials, rarest_first, reverse_rarest_first, suggested_pieces, prio_sequential_pieces, sequential_pieces, reverse_pieces, time_critical, random_pieces, prefer_contiguous, reverse_sequential, backup1, backup2, end_game, }; static const int static_category = alert::picker_log_notification; boost::uint32_t picker_flags; };
enum picker_flags_t
Declared in "libtorrent/alert_types.hpp"
name | value | description |
---|---|---|
partial_ratio | 1 | the ratio of partial pieces is too high. This forces a preference for picking blocks from partial pieces. |
prioritize_partials | 2 | |
rarest_first_partials | 4 | |
rarest_first | 8 | |
reverse_rarest_first | 16 | |
suggested_pieces | 32 | |
prio_sequential_pieces | 64 | |
sequential_pieces | 128 | |
reverse_pieces | 256 | |
time_critical | 512 | |
random_pieces | 1024 | |
prefer_contiguous | 2048 | |
reverse_sequential | 4096 | |
backup1 | 8192 | |
backup2 | 16384 | |
end_game | 32768 |
- picker_flags
- this is a bitmask of which features were enabled for this particular pick. The bits are defined in the picker_flags_t enum.
alert_cast()
Declared in "libtorrent/alert.hpp"
template <class T> T* alert_cast (alert* a); template <class T> T const* alert_cast (alert const* a);
When you get an alert, you can use alert_cast<> to attempt to cast the pointer to a specific alert type, in order to query it for more information.
Note
alert_cast<> can only cast to an exact alert type, not a base class
operation_name()
Declared in "libtorrent/alert_types.hpp"
char const* operation_name (int op);
maps an operation id (from peer_error_alert and peer_disconnected_alert) to its name. See peer_connection for the constants
enum operation_t
Declared in "libtorrent/operations.hpp"
name | value | description |
---|---|---|
op_bittorrent | 0 | this is used when the bittorrent logic determines to disconnect |
op_iocontrol | 1 | a call to iocontrol failed |
op_getpeername | 2 | a call to getpeername failed (querying the remote IP of a connection) |
op_getname | 3 | a call to getname failed (querying the local IP of a connection) |
op_alloc_recvbuf | 4 | an attempt to allocate a receive buffer failed |
op_alloc_sndbuf | 5 | an attempt to allocate a send buffer failed |
op_file_write | 6 | writing to a file failed |
op_file_read | 7 | reading from a file failed |
op_file | 8 | a non-read and non-write file operation failed |
op_sock_write | 9 | a socket write operation failed |
op_sock_read | 10 | a socket read operation failed |
op_sock_open | 11 | a call to open(), to create a socket socket failed |
op_sock_bind | 12 | a call to bind() on a socket failed |
op_available | 13 | an attempt to query the number of bytes available to read from a socket failed |
op_encryption | 14 | a call related to bittorrent protocol encryption failed |
op_connect | 15 | an attempt to connect a socket failed |
op_ssl_handshake | 16 | establishing an SSL connection failed |
op_get_interface | 17 | a connection failed to satisfy the bind interface setting |