#include <TCPAuthServer.hpp>
Inheritance diagram for Ionflux::Tools::TCPAuthServer:
Public Member Functions | |
TCPAuthServer () | |
Constructor. | |
TCPAuthServer (const std::string &initAuthFileName) | |
Constructor. | |
virtual | ~TCPAuthServer () |
Destructor. | |
virtual void | onMessage (TCPRemotePeer &peer) |
Event handler for received messages. | |
virtual void | onInvalidMessage (TCPRemotePeer &peer) |
Event handler for invalid messages. | |
virtual void | broadcast (const std::string &bytes) |
Broadcast bytes. | |
virtual void | setAuth (Auth *newAuth) |
Set authentication facility. | |
virtual void | setAuthFileName (const std::string &newAuthFileName) |
Set authentication file name. | |
virtual void | setCurrentMsgID (unsigned int newCurrentMsgID) |
Set current Message ID. | |
virtual Auth * | getAuth () |
Get authentication facility. | |
virtual std::string | getAuthFileName () |
Get authentication file name. | |
virtual unsigned int | getCurrentMsgID () |
Get current Message ID. | |
Static Public Attributes | |
static const std::string | MAGIC_WORD = "IFTA" |
Magic word. | |
static const unsigned int | AUTH_VERSION = 0x000001L |
Protocol version. | |
static const unsigned int | AUTH_VERSION_UPPER = 0x000001L |
Protocol version (upper boundary). | |
static const unsigned int | AUTH_VERSION_LOWER = 0x000001L |
Protocol version (lower boundary). | |
static const int | MSGID_HELLO = 101 |
Message type ID: HELLO. | |
static const int | MSGID_WELCOME = 201 |
Message type ID: WELCOME. | |
static const int | MSGID_AUTH = 102 |
Message type ID: AUTH. | |
static const int | MSGID_AUTH_OK = 202 |
Message type ID: AUTH_OK. | |
static const int | MSGID_AUTH_FAILED = 401 |
Message type ID: AUTH_FAILED. | |
static const int | PS_WAIT_HELLO = 1 |
Protocol state: Wait for HELLO. | |
static const int | PS_WAIT_AUTH = 2 |
Protocol state: Wait for AUTH. | |
static const int | PS_AUTH_OK = 3 |
Protocol state: Authentication succeeded. | |
Protected Member Functions | |
virtual void | onConnect (TCPRemotePeer &client) |
Event handler for new connections. | |
virtual void | onAuthMessage (TCPRemotePeer &peer) |
Event handler for authenticated messages. | |
virtual void | onAuthOK (TCPRemotePeer &peer) |
Event handler for successful authentication. | |
virtual void | onAuthFailed (TCPRemotePeer &peer) |
Event handler for failed authentication. | |
Protected Attributes | |
Auth * | auth |
Authentication facility. | |
std::string | authFileName |
Authentication file name. | |
unsigned int | currentMsgID |
Current Message ID. | |
MTRand * | randomizer |
Randomizer. |
A Message based TCP server supporting a simple client authentication protocol.
To define your own protocol on top of an authenticated connection, override the TCPAuthServer::onAuthMessage() function. The TCPAuthServer will handle all the rest for you. If you want to define additional protocol states for your own protocol, the associated values must be of the form TCPAuthServer::PS_AUTH_OK + n, where n is a positive integer.
See misc/ifta.txt
for a specification of the authentication protocol.
|
Constructor. Construct new TCPAuthServer object. |
|
Constructor. Construct new TCPAuthServer object.
|
|
Destructor. Destruct TCPAuthServer object. |
|
Broadcast bytes. Sends the specified byte string to all connected peers.
Reimplemented from Ionflux::Tools::TCPMessageServer. |
|
Get authentication facility.
|
|
Get authentication file name.
|
|
Get current Message ID.
|
|
Event handler for failed authentication. This is called when authentication with a peer has failed.
|
|
Event handler for authenticated messages. This is called whenever a message is received from an authenticated peer. The received message will be available from TCPRemotePeer::getMessage().
|
|
Event handler for successful authentication. This is called when authentication with a peer has succeeded.
|
|
Event handler for new connections. This is called by the main loop whenever a new client connects.
Reimplemented from Ionflux::Tools::TCPMessageServer. |
|
Event handler for invalid messages. This is called whenever an invalid message is received from a peer.
Reimplemented from Ionflux::Tools::TCPMessageServer. |
|
Event handler for received messages. This is called whenever a valid message is received from a peer. The received message will be available from TCPRemotePeer::getMessage().
Reimplemented from Ionflux::Tools::TCPMessageServer. |
|
Set authentication facility. Set new value of authentication facility.
|
|
Set authentication file name. Set new value of authentication file name.
|
|
Set current Message ID. Set new value of current Message ID.
|
|
Authentication facility.
|
|
Protocol version.
|
|
Protocol version (lower boundary).
|
|
Protocol version (upper boundary).
|
|
Authentication file name.
|
|
Current Message ID.
|
|
Magic word.
|
|
Message type ID: AUTH.
|
|
Message type ID: AUTH_FAILED.
|
|
Message type ID: AUTH_OK.
|
|
Message type ID: HELLO.
|
|
Message type ID: WELCOME.
|
|
Protocol state: Authentication succeeded.
|
|
Protocol state: Wait for AUTH.
|
|
Protocol state: Wait for HELLO.
|
|
Randomizer.
|