merged fixes from RC_1_0

This commit is contained in:
Arvid Norberg 2014-07-21 03:19:58 +00:00
parent 79a2744fa8
commit 805c823523
9 changed files with 122 additions and 63 deletions

View File

@ -468,24 +468,11 @@ namespace libtorrent
bad_gateway = 502,
service_unavailable = 503
};
}
}
#if BOOST_VERSION >= 103500
// hidden
TORRENT_EXPORT boost::system::error_code make_error_code(error_code_enum e);
namespace boost { namespace system {
template<> struct is_error_code_enum<libtorrent::errors::error_code_enum>
{ static const bool value = true; };
template<> struct is_error_condition_enum<libtorrent::errors::error_code_enum>
{ static const bool value = true; };
} }
#endif
namespace libtorrent
{
} // namespace errors
#if BOOST_VERSION < 103500
typedef asio::error_code error_code;
@ -519,15 +506,6 @@ namespace libtorrent
// returns the error_category for HTTP errors
TORRENT_EXPORT boost::system::error_category& get_http_category();
namespace errors
{
// hidden
inline boost::system::error_code make_error_code(error_code_enum e)
{
return boost::system::error_code(e, get_libtorrent_category());
}
}
using boost::system::error_code;
// hidden
@ -619,5 +597,25 @@ namespace libtorrent
}
#if BOOST_VERSION >= 103500
namespace boost { namespace system {
template<> struct is_error_code_enum<libtorrent::errors::error_code_enum>
{ static const bool value = true; };
template<> struct is_error_condition_enum<libtorrent::errors::error_code_enum>
{ static const bool value = true; };
template<> struct is_error_code_enum<libtorrent::errors::http_errors>
{ static const bool value = true; };
template<> struct is_error_condition_enum<libtorrent::errors::http_errors>
{ static const bool value = true; };
} }
#endif // BOOST_VERSION
#endif

View File

@ -120,9 +120,11 @@ namespace boost { namespace system {
template<>
struct is_error_code_enum<libtorrent::gzip_errors::error_code_enum>
{
static const bool value = true;
};
{ static const bool value = true; };
template<>
struct is_error_condition_enum<libtorrent::gzip_errors::error_code_enum>
{ static const bool value = true; };
} }
#endif // BOOST_VERSION

View File

@ -220,9 +220,11 @@ namespace boost { namespace system {
template<>
struct is_error_code_enum<libtorrent::i2p_error::i2p_error_code>
{
static const bool value = true;
};
{ static const bool value = true; };
template<>
struct is_error_condition_enum<libtorrent::i2p_error::i2p_error_code>
{ static const bool value = true; };
} }
#endif // BOOST_VERSION

View File

@ -438,6 +438,8 @@ namespace boost { namespace system {
template<> struct is_error_code_enum<libtorrent::bdecode_errors::error_code_enum>
{ static const bool value = true; };
template<> struct is_error_condition_enum<libtorrent::bdecode_errors::error_code_enum>
{ static const bool value = true; };
} }
#endif

View File

@ -42,31 +42,32 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
namespace libtorrent {
namespace socks_error {
namespace socks_error {
// SOCKS5 error values. If an error_code has the
// socks error category (get_socks_category()), these
// are the error values.
enum socks_error_code
{
no_error = 0,
unsupported_version,
unsupported_authentication_method,
unsupported_authentication_version,
authentication_error,
username_required,
general_failure,
command_not_supported,
no_identd,
identd_error,
// SOCKS5 error values. If an error_code has the
// socks error category (get_socks_category()), these
// are the error values.
enum socks_error_code
{
no_error = 0,
unsupported_version,
unsupported_authentication_method,
unsupported_authentication_version,
authentication_error,
username_required,
general_failure,
command_not_supported,
no_identd,
identd_error,
num_errors
};
num_errors
};
}
TORRENT_EXPORT boost::system::error_code make_error_code(socks_error_code e);
} // namespace socks_error
// returns the error_category for SOCKS5 errors
TORRENT_EXPORT boost::system::error_category& get_socks_category();
// returns the error_category for SOCKS5 errors
TORRENT_EXPORT boost::system::error_category& get_socks_category();
class socks5_stream : public proxy_base
{
@ -170,5 +171,18 @@ private:
}
#if BOOST_VERSION >= 103500
namespace boost { namespace system {
template<> struct is_error_code_enum<libtorrent::socks_error::socks_error_code>
{ static const bool value = true; };
template<> struct is_error_condition_enum<libtorrent::socks_error::socks_error_code>
{ static const bool value = true; };
} }
#endif // BOOST_VERSION
#endif

View File

@ -93,6 +93,9 @@ namespace libtorrent
// specific port
external_port_must_be_wildcard = 727
};
// hidden
TORRENT_EXPORT boost::system::error_code make_error_code(error_code_enum e);
}
TORRENT_EXPORT boost::system::error_category& get_upnp_category();
@ -380,6 +383,18 @@ private:
}
#if BOOST_VERSION >= 103500
namespace boost { namespace system {
template<> struct is_error_code_enum<libtorrent::upnp_errors::error_code_enum>
{ static const bool value = true; };
template<> struct is_error_condition_enum<libtorrent::upnp_errors::error_code_enum>
{ static const bool value = true; };
} }
#endif // BOOST_VERSION
#endif

View File

@ -342,5 +342,14 @@ namespace libtorrent
}
#endif
namespace errors
{
// hidden
boost::system::error_code make_error_code(error_code_enum e)
{
return boost::system::error_code(e, get_libtorrent_category());
}
}
}

View File

@ -37,6 +37,14 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
namespace socks_error
{
boost::system::error_code make_error_code(socks_error_code e)
{
return error_code(e, get_socks_category());
}
}
struct socks_error_category : boost::system::error_category
{
virtual const char* name() const BOOST_SYSTEM_NOEXCEPT
@ -132,7 +140,7 @@ namespace libtorrent
}
else
{
(*h)(error_code(socks_error::unsupported_version, get_socks_category()));
(*h)(socks_error::unsupported_version);
error_code ec;
close(ec);
}
@ -168,7 +176,7 @@ namespace libtorrent
if (version < m_version)
{
(*h)(error_code(socks_error::unsupported_version, get_socks_category()));
(*h)(socks_error::unsupported_version);
error_code ec;
close(ec);
return;
@ -182,7 +190,7 @@ namespace libtorrent
{
if (m_user.empty())
{
(*h)(error_code(socks_error::username_required, get_socks_category()));
(*h)(socks_error::username_required);
error_code ec;
close(ec);
return;
@ -205,7 +213,7 @@ namespace libtorrent
}
else
{
(*h)(error_code(socks_error::unsupported_authentication_method, get_socks_category()));
(*h)(socks_error::unsupported_authentication_method);
error_code ec;
close(ec);
return;
@ -244,7 +252,7 @@ namespace libtorrent
if (version != 1)
{
(*h)(error_code(socks_error::unsupported_authentication_version, get_socks_category()));
(*h)(socks_error::unsupported_authentication_version);
error_code ec;
close(ec);
return;
@ -252,7 +260,7 @@ namespace libtorrent
if (status != 0)
{
(*h)(error_code(socks_error::authentication_error, get_socks_category()));
(*h)(socks_error::authentication_error);
error_code ec;
close(ec);
return;
@ -296,7 +304,7 @@ namespace libtorrent
// SOCKS4 only supports IPv4
if (!m_remote_endpoint.address().is_v4())
{
(*h)(error_code(boost::asio::error::address_family_not_supported));
(*h)(boost::asio::error::address_family_not_supported);
error_code ec;
close(ec);
return;
@ -313,7 +321,7 @@ namespace libtorrent
}
else
{
(*h)(error_code(socks_error::unsupported_version, get_socks_category()));
(*h)(socks_error::unsupported_version);
error_code ec;
close(ec);
return;
@ -363,7 +371,7 @@ namespace libtorrent
{
if (version < m_version)
{
(*h)(error_code(socks_error::unsupported_version, get_socks_category()));
(*h)(socks_error::unsupported_version);
error_code ec;
close(ec);
return;
@ -378,7 +386,7 @@ namespace libtorrent
case 4: ec = asio::error::host_unreachable; break;
case 5: ec = asio::error::connection_refused; break;
case 6: ec = asio::error::timed_out; break;
case 7: ec = error_code(socks_error::command_not_supported, get_socks_category()); break;
case 7: ec = socks_error::command_not_supported; break;
case 8: ec = asio::error::address_family_not_supported; break;
}
(*h)(ec);
@ -442,7 +450,7 @@ namespace libtorrent
{
if (version != 0)
{
(*h)(error_code(socks_error::general_failure, get_socks_category()));
(*h)(socks_error::general_failure);
error_code ec;
close(ec);
return;

View File

@ -58,6 +58,15 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent {
namespace upnp_errors
{
boost::system::error_code make_error_code(error_code_enum e)
{
return error_code(e, get_upnp_category());
}
} // upnp_errors namespace
static error_code ec;
// TODO: listen_interface is not used. It's meant to bind the broadcast socket