Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
RASocket Class Reference

Remote Administration socket. More...

#include <RASocket.h>

Inheritance diagram for RASocket:
Collaboration diagram for RASocket:

Classes

struct  PendingWrite

Public Member Functions

 RASocket (std::shared_ptr< Skyfire::Asio::IoContextExecutor > executor, std::unique_ptr< RASocketHandle > socket, std::string const &remoteAddress)
void start ()
virtual ~RASocket ()

Private Types

typedef std::function< void(bool, std::string)> ReadLineCallback
typedef std::function< void(bool)> WriteCallback

Private Member Functions

void async_read_line (ReadLineCallback callback)
int check_access_level (const std::string &user)
int check_password (const std::string &user, const std::string &pass)
void close ()
void drain_command_output ()
void finish_subnegotiation ()
void handle_async_write (boost::system::error_code const &error)
void handle_command (std::string const &command)
void handle_credentials ()
void handle_read_line (boost::system::error_code const &error, size_t transferredBytes, ReadLineCallback callback)
void handle_subnegotiation_read (boost::system::error_code const &error, size_t transferredBytes)
bool is_open () const
void prompt_command ()
void prompt_password ()
void prompt_username ()
void queue_write (std::string data, WriteCallback callback=WriteCallback())
void send_authentication_required ()
void start_async_write ()
void start_command (std::string const &command)
void start_subnegotiation ()
 Used by telnet protocol RFC 854 / 855.

Static Private Member Functions

static void commandFinished (void *callbackArg, bool success)
static void zprint (void *callbackArg, const char *szText)

Private Attributes

std::atomic< bool > _closed
bool _commandComplete
std::atomic< bool > _commandExecuting
std::mutex _commandLock
std::queue< std::string > _commandOutput
bool _commandOutputDrainInProgress
std::shared_ptr< RASocket_commandSelf
std::shared_ptr< Skyfire::Asio::IoContextExecutor_executor
boost::asio::streambuf _lineBuffer
uint8 _minLevel
 Minimum security level required to connect.
std::string _pass
std::string _remoteAddress
std::unique_ptr< RASocketHandle_socket
std::array< char, 1024 > _subnegotiationBuffer
bool _subnegotiationDone
bool _subnegotiationTimedOut
boost::asio::steady_timer _subnegotiationTimer
std::string _user
bool _writeInProgress
std::deque< PendingWrite_writeQueue

Detailed Description

Remote Administration socket.

Definition at line 31 of file RASocket.h.

Member Typedef Documentation

◆ ReadLineCallback

typedef std::function<void(bool, std::string)> RASocket::ReadLineCallback
private

Definition at line 41 of file RASocket.h.

◆ WriteCallback

typedef std::function<void(bool)> RASocket::WriteCallback
private

Definition at line 40 of file RASocket.h.

Constructor & Destructor Documentation

◆ RASocket()

◆ ~RASocket()

RASocket::~RASocket ( )
virtual

Definition at line 54 of file RASocket.cpp.

References close().

Member Function Documentation

◆ async_read_line()

void RASocket::async_read_line ( ReadLineCallback callback)
private

Definition at line 418 of file RASocket.cpp.

References _closed, _lineBuffer, and _socket.

◆ check_access_level()

int RASocket::check_access_level ( const std::string & user)
private

◆ check_password()

◆ close()

◆ commandFinished()

void RASocket::commandFinished ( void * callbackArg,
bool success )
staticprivate

Definition at line 589 of file RASocket.cpp.

References _closed, _commandComplete, _commandExecuting, _commandLock, _commandSelf, and RASocket().

Referenced by start_command().

◆ drain_command_output()

void RASocket::drain_command_output ( )
private

◆ finish_subnegotiation()

void RASocket::finish_subnegotiation ( )
private

Definition at line 202 of file RASocket.cpp.

References send_authentication_required().

Referenced by handle_subnegotiation_read().

◆ handle_async_write()

void RASocket::handle_async_write ( boost::system::error_code const & error)
private

Definition at line 390 of file RASocket.cpp.

References _writeInProgress, _writeQueue, close(), and start_async_write().

◆ handle_command()

void RASocket::handle_command ( std::string const & command)
private

Definition at line 319 of file RASocket.cpp.

References prompt_command(), queue_write(), SF_LOG_INFO, and start_command().

◆ handle_credentials()

void RASocket::handle_credentials ( )
private

◆ handle_read_line()

void RASocket::handle_read_line ( boost::system::error_code const & error,
size_t transferredBytes,
ReadLineCallback callback )
private

Definition at line 434 of file RASocket.cpp.

References _lineBuffer, and close().

◆ handle_subnegotiation_read()

void RASocket::handle_subnegotiation_read ( boost::system::error_code const & error,
size_t transferredBytes )
private

◆ is_open()

bool RASocket::is_open ( ) const
private

Definition at line 81 of file RASocket.cpp.

References _closed, and _socket.

Referenced by start_subnegotiation().

◆ prompt_command()

void RASocket::prompt_command ( )
private

Definition at line 295 of file RASocket.cpp.

References queue_write().

Referenced by drain_command_output(), and handle_command().

◆ prompt_password()

void RASocket::prompt_password ( )
private

Definition at line 244 of file RASocket.cpp.

References queue_write().

◆ prompt_username()

void RASocket::prompt_username ( )
private

Definition at line 219 of file RASocket.cpp.

References queue_write().

◆ queue_write()

◆ send_authentication_required()

void RASocket::send_authentication_required ( )
private

Definition at line 207 of file RASocket.cpp.

References queue_write().

Referenced by finish_subnegotiation().

◆ start()

void RASocket::start ( )

Definition at line 59 of file RASocket.cpp.

References _executor.

◆ start_async_write()

void RASocket::start_async_write ( )
private

Definition at line 375 of file RASocket.cpp.

References _closed, _socket, _writeInProgress, and _writeQueue.

Referenced by handle_async_write(), and queue_write().

◆ start_command()

void RASocket::start_command ( std::string const & command)
private

◆ start_subnegotiation()

void RASocket::start_subnegotiation ( )
private

Used by telnet protocol RFC 854 / 855.

Definition at line 86 of file RASocket.cpp.

References _socket, _subnegotiationBuffer, _subnegotiationDone, _subnegotiationTimedOut, _subnegotiationTimer, close(), and is_open().

◆ zprint()

void RASocket::zprint ( void * callbackArg,
const char * szText )
staticprivate

Definition at line 564 of file RASocket.cpp.

References _closed, _commandLock, _commandOutput, _commandSelf, and RASocket().

Referenced by start_command().

Member Data Documentation

◆ _closed

std::atomic<bool> RASocket::_closed
private

◆ _commandComplete

bool RASocket::_commandComplete
private

Definition at line 91 of file RASocket.h.

Referenced by commandFinished(), drain_command_output(), RASocket(), and start_command().

◆ _commandExecuting

std::atomic<bool> RASocket::_commandExecuting
private

Definition at line 88 of file RASocket.h.

Referenced by commandFinished(), RASocket(), and start_command().

◆ _commandLock

std::mutex RASocket::_commandLock
private

Definition at line 89 of file RASocket.h.

Referenced by commandFinished(), drain_command_output(), start_command(), and zprint().

◆ _commandOutput

std::queue<std::string> RASocket::_commandOutput
private

Definition at line 90 of file RASocket.h.

Referenced by drain_command_output(), RASocket(), start_command(), and zprint().

◆ _commandOutputDrainInProgress

bool RASocket::_commandOutputDrainInProgress
private

Definition at line 92 of file RASocket.h.

Referenced by drain_command_output(), RASocket(), and start_command().

◆ _commandSelf

std::shared_ptr<RASocket> RASocket::_commandSelf
private

Definition at line 93 of file RASocket.h.

Referenced by commandFinished(), drain_command_output(), RASocket(), start_command(), and zprint().

◆ _executor

std::shared_ptr<Skyfire::Asio::IoContextExecutor> RASocket::_executor
private

Definition at line 74 of file RASocket.h.

Referenced by RASocket(), and start().

◆ _lineBuffer

boost::asio::streambuf RASocket::_lineBuffer
private

Definition at line 79 of file RASocket.h.

Referenced by async_read_line(), handle_read_line(), and RASocket().

◆ _minLevel

uint8 RASocket::_minLevel
private

Minimum security level required to connect.

Definition at line 87 of file RASocket.h.

Referenced by check_access_level(), and RASocket().

◆ _pass

std::string RASocket::_pass
private

Definition at line 86 of file RASocket.h.

Referenced by handle_credentials(), and RASocket().

◆ _remoteAddress

std::string RASocket::_remoteAddress
private

Definition at line 77 of file RASocket.h.

Referenced by RASocket().

◆ _socket

std::unique_ptr<RASocketHandle> RASocket::_socket
private

◆ _subnegotiationBuffer

std::array<char, 1024> RASocket::_subnegotiationBuffer
private

Definition at line 78 of file RASocket.h.

Referenced by handle_subnegotiation_read(), RASocket(), and start_subnegotiation().

◆ _subnegotiationDone

bool RASocket::_subnegotiationDone
private

Definition at line 83 of file RASocket.h.

Referenced by handle_subnegotiation_read(), RASocket(), and start_subnegotiation().

◆ _subnegotiationTimedOut

bool RASocket::_subnegotiationTimedOut
private

Definition at line 84 of file RASocket.h.

Referenced by handle_subnegotiation_read(), RASocket(), and start_subnegotiation().

◆ _subnegotiationTimer

boost::asio::steady_timer RASocket::_subnegotiationTimer
private

Definition at line 76 of file RASocket.h.

Referenced by close(), handle_subnegotiation_read(), RASocket(), and start_subnegotiation().

◆ _user

std::string RASocket::_user
private

Definition at line 85 of file RASocket.h.

Referenced by handle_credentials(), and RASocket().

◆ _writeInProgress

bool RASocket::_writeInProgress
private

Definition at line 81 of file RASocket.h.

Referenced by handle_async_write(), queue_write(), RASocket(), and start_async_write().

◆ _writeQueue

std::deque<PendingWrite> RASocket::_writeQueue
private

Definition at line 80 of file RASocket.h.

Referenced by handle_async_write(), queue_write(), RASocket(), and start_async_write().


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