2015-02-28 20:51:15 +01:00
|
|
|
/*
|
|
|
|
|
2016-01-18 00:57:46 +01:00
|
|
|
Copyright (c) 2015-2016, Arvid Norberg
|
2015-02-28 20:51:15 +01:00
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
* Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in
|
|
|
|
the documentation and/or other materials provided with the distribution.
|
|
|
|
* Neither the name of the author nor the names of its
|
|
|
|
contributors may be used to endorse or promote products derived
|
|
|
|
from this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TORRENT_CLOSE_REASON_HPP
|
|
|
|
#define TORRENT_CLOSE_REASON_HPP
|
|
|
|
|
|
|
|
#include "libtorrent/error_code.hpp"
|
|
|
|
|
2017-04-12 19:00:57 +02:00
|
|
|
namespace libtorrent {
|
|
|
|
|
2015-03-13 06:42:18 +01:00
|
|
|
// internal: these are all the reasons to disconnect a peer
|
2015-02-28 20:51:15 +01:00
|
|
|
// all reasons caused by the peer sending unexpected data
|
|
|
|
// are 256 and up.
|
2017-02-04 02:27:31 +01:00
|
|
|
enum class close_reason_t : std::uint16_t
|
2015-02-28 20:51:15 +01:00
|
|
|
{
|
|
|
|
// no reason specified. Generic close.
|
2017-02-04 02:27:31 +01:00
|
|
|
none = 0,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// we're already connected to
|
2017-02-04 02:27:31 +01:00
|
|
|
duplicate_peer_id,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// this torrent has been removed, paused or stopped from this client.
|
2017-02-04 02:27:31 +01:00
|
|
|
torrent_removed,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// client failed to allocate necessary memory for this peer connection
|
2017-02-04 02:27:31 +01:00
|
|
|
no_memory,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the source port of this peer is blocked
|
2017-02-04 02:27:31 +01:00
|
|
|
port_blocked,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the source IP has been blocked
|
2017-02-04 02:27:31 +01:00
|
|
|
blocked,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// both ends of the connection are upload-only. staying connected would
|
|
|
|
// be redundant
|
2017-02-04 02:27:31 +01:00
|
|
|
upload_to_upload,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// connection was closed because the other end is upload only and does
|
|
|
|
// not have any pieces we're interested in
|
2017-02-04 02:27:31 +01:00
|
|
|
not_interested_upload_only,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// peer connection timed out (generic timeout)
|
2017-02-04 02:27:31 +01:00
|
|
|
timeout,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the peers have not been interested in each other for a very long time.
|
|
|
|
// disconnect
|
2017-02-04 02:27:31 +01:00
|
|
|
timed_out_interest,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the peer has not sent any message in a long time.
|
2017-02-04 02:27:31 +01:00
|
|
|
timed_out_activity,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the peer did not complete the handshake in too long
|
2017-02-04 02:27:31 +01:00
|
|
|
timed_out_handshake,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the peer sent an interested message, but did not send a request
|
|
|
|
// after a very long time after being unchoked.
|
2017-02-04 02:27:31 +01:00
|
|
|
timed_out_request,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the encryption mode is blocked
|
2017-02-04 02:27:31 +01:00
|
|
|
protocol_blocked,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the peer was disconnected in the hopes of finding a better peer
|
|
|
|
// in the swarm
|
2017-02-04 02:27:31 +01:00
|
|
|
peer_churn,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// we have too many peers connected
|
2017-02-04 02:27:31 +01:00
|
|
|
too_many_connections,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// we have too many file-descriptors open
|
2017-02-04 02:27:31 +01:00
|
|
|
too_many_files,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the encryption handshake failed
|
2017-02-04 02:27:31 +01:00
|
|
|
encryption_error = 256,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the info hash sent as part of the handshake was not what we expected
|
2017-02-04 02:27:31 +01:00
|
|
|
invalid_info_hash,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
2017-02-04 02:27:31 +01:00
|
|
|
self_connection,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the metadata received matched the info-hash, but failed to parse.
|
|
|
|
// this is either someone finding a SHA1 collision, or the author of
|
|
|
|
// the magnet link creating it from an invalid torrent
|
2017-02-04 02:27:31 +01:00
|
|
|
invalid_metadata,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the advertised metadata size
|
2017-02-04 02:27:31 +01:00
|
|
|
metadata_too_big,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// invalid bittorrent messages
|
2017-02-04 02:27:31 +01:00
|
|
|
message_too_big,
|
|
|
|
invalid_message_id,
|
|
|
|
invalid_message,
|
|
|
|
invalid_piece_message,
|
|
|
|
invalid_have_message,
|
|
|
|
invalid_bitfield_message,
|
|
|
|
invalid_choke_message,
|
|
|
|
invalid_unchoke_message,
|
|
|
|
invalid_interested_message,
|
|
|
|
invalid_not_interested_message,
|
|
|
|
invalid_request_message,
|
|
|
|
invalid_reject_message,
|
|
|
|
invalid_allow_fast_message,
|
|
|
|
invalid_extended_message,
|
|
|
|
invalid_cancel_message,
|
|
|
|
invalid_dht_port_message,
|
|
|
|
invalid_suggest_message,
|
|
|
|
invalid_have_all_message,
|
|
|
|
invalid_dont_have_message,
|
|
|
|
invalid_have_none_message,
|
|
|
|
invalid_pex_message,
|
|
|
|
invalid_metadata_request_message,
|
|
|
|
invalid_metadata_message,
|
|
|
|
invalid_metadata_offset,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the peer sent a request while being choked
|
2017-02-04 02:27:31 +01:00
|
|
|
request_when_choked,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
|
|
|
// the peer sent corrupt data
|
2017-02-04 02:27:31 +01:00
|
|
|
corrupt_pieces,
|
2015-02-28 20:51:15 +01:00
|
|
|
|
2017-02-04 02:27:31 +01:00
|
|
|
pex_message_too_big,
|
|
|
|
pex_too_frequent
|
2015-02-28 20:51:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
close_reason_t error_to_close_reason(error_code const& ec);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|