Electroneum
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
net::socks::client Class Referenceabstract

Client support for socks connect and resolve commands. More...

#include <socks.h>

Inheritance diagram for net::socks::client:
Inheritance graph
[legend]

Classes

struct  async_close
 
struct  completed
 
struct  read
 
struct  write
 

Public Types

using stream_type = boost::asio::ip::tcp
 

Public Member Functions

 client (stream_type::socket &&proxy, socks::version ver)
 
 client (const client &)=delete
 
virtual ~client ()
 
clientoperator= (const client &)=delete
 
stream_type::socket take_socket ()
 
socks::version socks_version () const noexcept
 
epee::span< const std::uint8_t > buffer () const noexcept
 
void clear_command () noexcept
 
bool set_connect_command (const epee::net_utils::ipv4_network_address &address)
 Try to set address as remote connection request. More...
 
bool set_connect_command (boost::string_ref domain, std::uint16_t port)
 Try to set domain + port as remote connection request. More...
 
bool set_connect_command (const net::tor_address &address)
 Try to set address as remote Tor hidden service connection request. More...
 
bool set_connect_command (const net::i2p_address &address)
 Try to set address as remote i2p hidden service connection request. More...
 
bool set_resolve_command (boost::string_ref domain)
 Try to set domain as remote DNS A record lookup request. More...
 

Static Public Member Functions

static bool connect_and_send (std::shared_ptr< client > self, const stream_type::endpoint &proxy_address)
 
static bool send (std::shared_ptr< client > self)
 

Private Member Functions

virtual void done (boost::system::error_code error, std::shared_ptr< client > self)=0
 

Private Attributes

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_
 

Detailed Description

Client support for socks connect and resolve commands.

Member Typedef Documentation

◆ stream_type

using net::socks::client::stream_type = boost::asio::ip::tcp

Constructor & Destructor Documentation

◆ client() [1/2]

net::socks::client::client ( stream_type::socket &&  proxy,
socks::version  ver 
)
explicit
Parameters
proxyownership is passed into this. Does not have to be in connected state.
versocks version for the connection.

◆ client() [2/2]

net::socks::client::client ( const client )
delete

◆ ~client()

net::socks::client::~client ( )
virtual

Member Function Documentation

◆ buffer()

epee::span<const std::uint8_t> net::socks::client::buffer ( ) const
inlinenoexcept
Returns
Contents of internal buffer.

◆ clear_command()

void net::socks::client::clear_command ( )
inlinenoexcept
Postcondition
buffer.empty().

◆ connect_and_send()

bool net::socks::client::connect_and_send ( std::shared_ptr< client self,
const stream_type::endpoint &  proxy_address 
)
static

Asynchronously connect to proxy_address then issue command in buffer(). The done(...) method will be invoked upon completion with self and potential errors.

Note
Must use one of the self->set_*_command calls before using this function.
Only async_close can be invoked on self until the done callback is invoked.
Parameters
selfownership of object is given to function.
proxy_addressof the socks server.
Returns
False if self->buffer().empty() (no command set).

◆ done()

virtual void net::socks::client::done ( boost::system::error_code  error,
std::shared_ptr< client self 
)
privatepure virtual

Only invoked after *send(...) function completes or fails. bool(error) == false indicates success; self.get() is always this and allows implementations to skip std::enable_shared_from_this<T> (ASIO callbacks need shared_ptr). The design saves space and reduces cycles (everything uses moves, so no atomic operations are ever necessary).

Parameters
errorwhen processing last command (if any).
selfshared_ptr<client> handle to this.

Implemented in net::socks::connect_client< Handler >.

◆ operator=()

client& net::socks::client::operator= ( const client )
delete

◆ send()

bool net::socks::client::send ( std::shared_ptr< client self)
static

Assume existing connection to proxy server; asynchronously issue command in buffer(). The done(...) method will be invoked upon completion with self and potential errors.

Note
Must use one of the self->set_*_command calls before using the function.
Only async_close can be invoked on self until the done callback is invoked.
Parameters
selfownership of object is given to function.
Returns
False if self->buffer().empty() (no command set).

◆ set_connect_command() [1/4]

bool net::socks::client::set_connect_command ( boost::string_ref  domain,
std::uint16_t  port 
)

Try to set domain + port as remote connection request.

◆ set_connect_command() [2/4]

bool net::socks::client::set_connect_command ( const epee::net_utils::ipv4_network_address &  address)

Try to set address as remote connection request.

◆ set_connect_command() [3/4]

bool net::socks::client::set_connect_command ( const net::i2p_address address)

Try to set address as remote i2p hidden service connection request.

◆ set_connect_command() [4/4]

bool net::socks::client::set_connect_command ( const net::tor_address address)

Try to set address as remote Tor hidden service connection request.

◆ set_resolve_command()

bool net::socks::client::set_resolve_command ( boost::string_ref  domain)

Try to set domain as remote DNS A record lookup request.

◆ socks_version()

socks::version net::socks::client::socks_version ( ) const
inlinenoexcept
Returns
Socks version.

◆ take_socket()

stream_type::socket net::socks::client::take_socket ( )
inline
Returns
Ownership of socks client socket object.

Member Data Documentation

◆ buffer_

std::uint8_t net::socks::client::buffer_[1024]
private

◆ buffer_size_

std::uint16_t net::socks::client::buffer_size_
private

◆ proxy_

boost::asio::ip::tcp::socket net::socks::client::proxy_
private

◆ strand_

boost::asio::io_service::strand net::socks::client::strand_
private

◆ ver_

socks::version net::socks::client::ver_
private

The documentation for this class was generated from the following files: