1 /*
2 
3 Copyright (c) 2003-2018, Arvid Norberg
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9 
10     * Redistributions of source code must retain the above copyright
11       notice, this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright
13       notice, this list of conditions and the following disclaimer in
14       the documentation and/or other materials provided with the distribution.
15     * Neither the name of the author nor the names of its
16       contributors may be used to endorse or promote products derived
17       from this software without specific prior written permission.
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 POSSIBILITY OF SUCH DAMAGE.
30 
31 */
32 
33 #ifndef TORRENT_IDENTIFY_CLIENT_HPP_INCLUDED
34 #define TORRENT_IDENTIFY_CLIENT_HPP_INCLUDED
35 
36 #include "libtorrent/config.hpp"
37 
38 #if TORRENT_ABI_VERSION == 1
39 #include "libtorrent/aux_/disable_warnings_push.hpp"
40 #include <boost/optional.hpp>
41 #include "libtorrent/aux_/disable_warnings_pop.hpp"
42 #endif
43 
44 #include "libtorrent/peer_id.hpp"
45 #include "libtorrent/fingerprint.hpp"
46 
47 // TODO: hide this declaration when deprecated functions are disabled, and
48 // remove its internal use
49 namespace libtorrent {
50 
51 namespace aux {
52 
53 	TORRENT_EXTRA_EXPORT
54 	std::string identify_client_impl(const peer_id& p);
55 
56 }
57 
58 	// these functions don't really need to be public. This mechanism of
59 	// advertising client software and version is also out-dated.
60 
61 	// This function can can be used to extract a string describing a client
62 	// version from its peer-id. It will recognize most clients that have this
63 	// kind of identification in the peer-id.
64 	TORRENT_DEPRECATED_EXPORT
65 	std::string identify_client(const peer_id& p);
66 
67 #if TORRENT_ABI_VERSION == 1
68 
69 #ifdef __GNUC__
70 #pragma GCC diagnostic push
71 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
72 #endif
73 #ifdef __clang__
74 #pragma clang diagnostic push
75 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
76 #endif
77 #ifdef _MSC_VER
78 #pragma warning(push, 1)
79 #pragma warning(disable: 4996)
80 #endif
81 	// Returns an optional fingerprint if any can be identified from the peer
82 	// id. This can be used to automate the identification of clients. It will
83 	// not be able to identify peers with non- standard encodings. Only Azureus
84 	// style, Shadow's style and Mainline style.
85 	TORRENT_DEPRECATED_EXPORT
86 	boost::optional<fingerprint>
87 		client_fingerprint(peer_id const& p);
88 
89 #ifdef __GNUC__
90 #pragma GCC diagnostic pop
91 #endif
92 #ifdef __clang__
93 #pragma clang diagnostic pop
94 #endif
95 #ifdef _MSC_VER
96 #pragma warning(pop)
97 #endif
98 
99 #endif // TORRENT_ABI_VERSION
100 
101 }
102 
103 #endif // TORRENT_IDENTIFY_CLIENT_HPP_INCLUDED
104