forked from premiere/premiere-libtorrent
minor asio.ssl abstraction cleanup. update libsimulator with build fix. only run simulator on one of the build variants on travis, since the simulator does not support ssl
This commit is contained in:
parent
97d46997c9
commit
72286eb0dc
|
@ -49,7 +49,9 @@ script:
|
|||
- cd ../bindings/python
|
||||
- bjam -j 3 variant=$variant warnings=off $CC stage_module
|
||||
- LD_LIBRARY_PATH=. python test.py
|
||||
- cd ../../simulation
|
||||
- bjam -j 3 variant=$variant warnings=off $CC
|
||||
- if [ $variant == "test_debug" ]; then
|
||||
cd ../../simulation;
|
||||
bjam -j 3 crypto=built-in warnings=off $CC;
|
||||
fi
|
||||
- ccache --show-stats
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#endif
|
||||
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
#include <boost/asio/ssl/context.hpp>
|
||||
#include "libtorrent/ssl_stream.hpp"
|
||||
#endif
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||
|
@ -696,7 +696,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_USE_OPENSSL
|
||||
// this is a generic SSL context used when talking to
|
||||
// unauthenticated HTTPS servers
|
||||
boost::asio::ssl::context m_ssl_ctx;
|
||||
ssl::context m_ssl_ctx;
|
||||
#endif
|
||||
|
||||
// handles delayed alerts
|
||||
|
@ -862,7 +862,7 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
boost::asio::ssl::context* ssl_ctx() { return &m_ssl_ctx; }
|
||||
ssl::context* ssl_ctx() { return &m_ssl_ctx; }
|
||||
void on_incoming_utp_ssl(boost::shared_ptr<socket_type> const& s);
|
||||
void ssl_handshake(error_code const& ec, boost::shared_ptr<socket_type> s);
|
||||
#endif
|
||||
|
|
|
@ -90,7 +90,7 @@ struct TORRENT_EXTRA_EXPORT http_connection
|
|||
, http_connect_handler const& ch = http_connect_handler()
|
||||
, http_filter_handler const& fh = http_filter_handler()
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
, boost::asio::ssl::context* ssl_ctx = 0
|
||||
, ssl::context* ssl_ctx = 0
|
||||
#endif
|
||||
);
|
||||
|
||||
|
@ -158,7 +158,7 @@ private:
|
|||
socket_type m_sock;
|
||||
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
boost::asio::ssl::context* m_ssl_ctx;
|
||||
ssl::context* m_ssl_ctx;
|
||||
bool m_own_ssl_context;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -49,16 +49,32 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
// this name in every single scope
|
||||
#undef set_key
|
||||
|
||||
#if defined TORRENT_BUILD_SIMULATOR
|
||||
#include "simulator/simulator.hpp"
|
||||
#endif
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||
|
||||
namespace libtorrent {
|
||||
|
||||
namespace ssl {
|
||||
#if defined TORRENT_BUILD_SIMULATOR
|
||||
using sim::asio::ssl::context;
|
||||
using sim::asio::ssl::stream_base;
|
||||
using sim::asio::ssl::stream;
|
||||
#else
|
||||
using boost::asio::ssl::context;
|
||||
using boost::asio::ssl::stream_base;
|
||||
using boost::asio::ssl::stream;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class Stream>
|
||||
class ssl_stream
|
||||
{
|
||||
public:
|
||||
|
||||
explicit ssl_stream(io_service& io_service, boost::asio::ssl::context& ctx)
|
||||
explicit ssl_stream(io_service& io_service, ssl::context& ctx)
|
||||
: m_sock(io_service, ctx)
|
||||
{
|
||||
}
|
||||
|
@ -106,14 +122,14 @@ public:
|
|||
{
|
||||
// this is used for accepting SSL connections
|
||||
boost::shared_ptr<handler_type> h(new handler_type(handler));
|
||||
m_sock.async_handshake(boost::asio::ssl::stream_base::server
|
||||
m_sock.async_handshake(ssl::stream_base::server
|
||||
, boost::bind(&ssl_stream::handshake, this, _1, h));
|
||||
}
|
||||
|
||||
void accept_handshake(error_code& ec)
|
||||
{
|
||||
// this is used for accepting SSL connections
|
||||
m_sock.handshake(boost::asio::ssl::stream_base::server, ec);
|
||||
m_sock.handshake(ssl::stream_base::server, ec);
|
||||
}
|
||||
|
||||
template <class Handler>
|
||||
|
@ -302,7 +318,7 @@ private:
|
|||
return;
|
||||
}
|
||||
|
||||
m_sock.async_handshake(boost::asio::ssl::stream_base::client
|
||||
m_sock.async_handshake(ssl::stream_base::client
|
||||
, boost::bind(&ssl_stream::handshake, this, _1, h));
|
||||
}
|
||||
|
||||
|
@ -311,7 +327,7 @@ private:
|
|||
(*h)(e);
|
||||
}
|
||||
|
||||
boost::asio::ssl::stream<Stream> m_sock;
|
||||
ssl::stream<Stream> m_sock;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 4f3d6916d553849e19962f54342a87a7d75c1840
|
||||
Subproject commit 020651306c06a444744c6f769fdab996be233efa
|
|
@ -59,7 +59,7 @@ http_connection::http_connection(io_service& ios
|
|||
, http_connect_handler const& ch
|
||||
, http_filter_handler const& fh
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
, boost::asio::ssl::context* ssl_ctx
|
||||
, ssl::context* ssl_ctx
|
||||
#endif
|
||||
)
|
||||
: m_sock(ios)
|
||||
|
@ -330,13 +330,13 @@ void http_connection::start(std::string const& hostname, int port
|
|||
{
|
||||
if (m_ssl_ctx == 0)
|
||||
{
|
||||
m_ssl_ctx = new (std::nothrow) boost::asio::ssl::context(
|
||||
m_timer.get_io_service(), boost::asio::ssl::context::sslv23_client);
|
||||
m_ssl_ctx = new (std::nothrow) ssl::context(
|
||||
m_timer.get_io_service(), ssl::context::sslv23_client);
|
||||
if (m_ssl_ctx)
|
||||
{
|
||||
m_own_ssl_context = true;
|
||||
error_code ec;
|
||||
m_ssl_ctx->set_verify_mode(boost::asio::ssl::context::verify_none, ec);
|
||||
m_ssl_ctx->set_verify_mode(ssl::context::verify_none, ec);
|
||||
TORRENT_ASSERT(!ec);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,22 +243,22 @@ namespace libtorrent
|
|||
case socket_type_int_impl<ssl_stream<tcp::socket> >::value:
|
||||
TORRENT_ASSERT(userdata);
|
||||
new ((ssl_stream<tcp::socket>*)m_data) ssl_stream<tcp::socket>(m_io_service
|
||||
, *((boost::asio::ssl::context*)userdata));
|
||||
, *static_cast<ssl::context*>(userdata));
|
||||
break;
|
||||
case socket_type_int_impl<ssl_stream<socks5_stream> >::value:
|
||||
TORRENT_ASSERT(userdata);
|
||||
new ((ssl_stream<socks5_stream>*)m_data) ssl_stream<socks5_stream>(m_io_service
|
||||
, *((boost::asio::ssl::context*)userdata));
|
||||
, *static_cast<ssl::context*>(userdata));
|
||||
break;
|
||||
case socket_type_int_impl<ssl_stream<http_stream> >::value:
|
||||
TORRENT_ASSERT(userdata);
|
||||
new ((ssl_stream<http_stream>*)m_data) ssl_stream<http_stream>(m_io_service
|
||||
, *((boost::asio::ssl::context*)userdata));
|
||||
, *static_cast<ssl::context*>(userdata));
|
||||
break;
|
||||
case socket_type_int_impl<ssl_stream<utp_stream> >::value:
|
||||
TORRENT_ASSERT(userdata);
|
||||
new ((ssl_stream<utp_stream>*)m_data) ssl_stream<utp_stream>(m_io_service
|
||||
, *((boost::asio::ssl::context*)userdata));
|
||||
, *static_cast<ssl::context*>(userdata));
|
||||
break;
|
||||
#else
|
||||
TORRENT_UNUSED(userdata);
|
||||
|
|
Loading…
Reference in New Issue