33#include <boost/asio/io_context.hpp>
34#include <boost/asio/ip/tcp.hpp>
35#include <boost/asio/strand.hpp>
36#include <boost/system/error_code.hpp>
37#include <boost/type_traits/integral_constant.hpp>
38#include <boost/utility/string_ref.hpp>
109 boost::asio::strand<boost::asio::ip::tcp::socket::executor_type>
strand_;
125 virtual void done(boost::system::error_code
error,
const std::shared_ptr<client>& self) = 0;
150 return stream_type::socket{std::move(
proxy_)};
177 boost::string_ref domain,
208 static bool connect_and_send(std::shared_ptr<client> self,
const stream_type::endpoint& proxy_address);
223 static bool send(std::shared_ptr<client> self);
230 void operator()(boost::system::error_code
error = boost::system::error_code{});
241 template<
typename Handler>
246 virtual void done(boost::system::error_code
error,
const std::shared_ptr<client>&)
override
259 template<
typename Handler>
260 inline std::shared_ptr<client>
263 return std::make_shared<connect_client<Handler>>(std::move(proxy), ver, std::move(handler));
273 struct is_error_code_enum<
net::socks::error>
Definition net_utils_base.h:69
Definition net_utils_base.h:172
Non-owning sequence of data. Does not deep copy.
Definition span.h:55
b32 i2p address; internal format not condensed/decoded.
Definition i2p_address.h:52
boost::asio::ip::tcp::socket proxy_
Definition socks.h:108
bool set_connect_command(const epee::net_utils::ipv4_network_address &address, const user_and_pass *userinfo=nullptr)
Try to set address as remote connection request.
Definition socks.cpp:661
void clear_command() noexcept
Definition socks.h:163
boost::asio::ip::tcp stream_type
Definition socks.h:128
client(const client &)=delete
std::array< std::uint16_t, 3 > buffer_size_
Definition socks.h:110
stream_type::socket take_socket()
Definition socks.h:148
virtual ~client()
Definition socks.cpp:659
bool set_resolve_command(boost::string_ref domain)
Try to set domain as remote DNS A record lookup request.
Definition socks.cpp:744
epee::span< const std::uint8_t > buffer() const noexcept
Definition socks.h:157
static bool connect_and_send(std::shared_ptr< client > self, const stream_type::endpoint &proxy_address)
Definition socks.cpp:755
client(stream_type::socket &&proxy, socks::version ver)
Definition socks.cpp:655
std::uint8_t buffer_[1024]
Definition socks.h:111
virtual void done(boost::system::error_code error, const std::shared_ptr< client > &self)=0
socks::version ver_
Definition socks.h:112
client & operator=(const client &)=delete
static bool send(std::shared_ptr< client > self)
Definition socks.cpp:766
socks::version socks_version() const noexcept
Definition socks.h:154
boost::asio::strand< boost::asio::ip::tcp::socket::executor_type > strand_
Definition socks.h:109
virtual void done(boost::system::error_code error, const std::shared_ptr< client > &) override
Definition socks.h:246
connect_client(stream_type::socket &&proxy, socks::version ver, Handler &&handler)
Definition socks.h:252
Handler handler_
Definition socks.h:244
virtual ~connect_client() override
Definition socks.h:256
Tor onion address; internal format not condensed/decoded.
Definition tor_address.h:53
Concept for receiving events from GenericReader upon parsing. The functions return true if no error o...
static epee::net_utils::http::http_simple_client_template< dummy_client > client
Definition http-client.cpp:62
#define inline
Definition inline_c.h:34
Definition portable_binary_archive.hpp:29
Definition abstract_http_client.h:36
TODO: (mj-xmr) This will be reduced in an another PR.
Definition byte_slice.h:40
std::shared_ptr< client > make_connect_client(client::stream_type::socket &&proxy, socks::version ver, Handler handler)
Definition socks.h:261
const boost::system::error_category & error_category() noexcept
Definition socks.cpp:413
error
Possible errors with socks communication. Defined in https://www.openssh.com/txt/socks4....
Definition socks.h:69
@ ttl_expired
Definition socks.h:77
@ command_not_supported
Definition socks.h:78
@ bad_write
Definition socks.h:87
@ not_allowed
Definition socks.h:73
@ bad_read
Definition socks.h:86
@ address_type_not_supported
Definition socks.h:79
@ connection_refused
Definition socks.h:76
@ auth_failure
Definition socks.h:85
@ network_unreachable
Definition socks.h:74
@ identd_user
Definition socks.h:83
@ rejected
Definition socks.h:81
@ general_failure
Definition socks.h:72
@ unexpected_version
Definition socks.h:88
@ identd_connection
Definition socks.h:82
@ host_unreachable
Definition socks.h:75
version
Supported socks variants.
Definition socks.h:60
@ v4a_tor
Extensions defined in Tor codebase.
Definition socks.h:63
@ v5
Definition socks.h:64
@ v4a
Definition socks.h:62
@ v4
Definition socks.h:61
boost::system::error_code make_error_code(error value) noexcept
Definition socks.h:100
Definition net_utils_base.h:59
const GenericPointer< typename T::ValueType > T2 value
Definition pointer.h:1225
static cryptonote::account_public_address address
Definition signature.cpp:38
void operator()(boost::system::error_code error=boost::system::error_code{})
Definition socks.cpp:780
std::shared_ptr< client > self_
Definition socks.h:229
Calls async_close on self at destruction. NOP if nullptr.
Definition socks.h:235
std::shared_ptr< client > self
Definition socks.h:236
~close_on_exit()
Definition socks.h:237
Separates the user and pass sections from URI userinfo.
Definition parse.h:65