aboutsummaryrefslogtreecommitdiff
path: root/src/net/socks.h
diff options
context:
space:
mode:
authorLee Clagett <code@leeclagett.com>2019-01-23 21:37:43 +0000
committerLee Clagett <code@leeclagett.com>2019-03-25 01:35:13 +0000
commit7acfa9f3cc7b52c0f4776dde3c3f80674cc3306f (patch)
tree5d1903ab4b132c137b1bb838037f024d6fb8b0d3 /src/net/socks.h
parentMerge pull request #5286 (diff)
downloadmonero-7acfa9f3cc7b52c0f4776dde3c3f80674cc3306f.tar.xz
Added socks proxy (tor/i2pd/kovri) support to wallet
Diffstat (limited to '')
-rw-r--r--src/net/socks.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/net/socks.h b/src/net/socks.h
index 825937792..4d1d34e9e 100644
--- a/src/net/socks.h
+++ b/src/net/socks.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2018, The Monero Project
+// Copyright (c) 2018-2019, The Monero Project
//
// All rights reserved.
//
@@ -31,6 +31,7 @@
#include <cstdint>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/io_service.hpp>
+#include <boost/asio/strand.hpp>
#include <boost/system/error_code.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/utility/string_ref.hpp>
@@ -92,6 +93,7 @@ namespace socks
class client
{
boost::asio::ip::tcp::socket proxy_;
+ boost::asio::io_service::strand strand_;
std::uint16_t buffer_size_;
std::uint8_t buffer_[1024];
socks::version ver_;
@@ -168,6 +170,8 @@ namespace socks
\note Must use one of the `self->set_*_command` calls before using
this function.
+ \note Only `async_close` can be invoked on `self` until the `done`
+ callback is invoked.
\param self ownership of object is given to function.
\param proxy_address of the socks server.
@@ -182,11 +186,21 @@ namespace socks
\note Must use one of the `self->set_*_command` calls before using
the function.
+ \note Only `async_close` can be invoked on `self` until the `done`
+ callback is invoked.
\param self ownership of object is given to function.
\return False if `self->buffer().empty()` (no command set).
*/
static bool send(std::shared_ptr<client> self);
+
+ /*! Callback for closing socket. Thread-safe with `*send` functions;
+ never blocks (uses strands). */
+ struct async_close
+ {
+ std::shared_ptr<client> self_;
+ void operator()(boost::system::error_code error = boost::system::error_code{});
+ };
};
template<typename Handler>