ircproxy  The Ultimate Cyborg

AuthState Class Reference

#include <AuthState.h>

Inheritance diagram for AuthState:

List of all members.


Detailed Description

State information very early in a new connection.

Definition at line 29 of file AuthState.h.


Public Member Functions

 AuthState (ServerConnection &server_connection)
 Contruct a new AuthState object, starting a new authentication cycle.
 ~AuthState ()
 @ brief Destructor of AuthState.
void set_auth_ping_argument (std::string const &auth_ping_argument)
 Remember the argument of the first PING.
std::string const & auth_ping_argument (void) const
 Return argument of the first PING.
void auth_notice_looking_up_hostname (MatcherEventType const &event_type)
 This function is called when a NOTICE AUTH message is received from the server.
void auth_notice_fin_hostname (MatcherEventType const &event_type)
 This function is called when a NOTICE AUTH message is received from the server.
void auth_notice_looking_up_ident (MatcherEventType const &event_type)
 This function is called when a NOTICE AUTH message is received from the server.
void auth_notice_fin_ident (MatcherEventType const &event_type)
 This function is called when a NOTICE AUTH message is received from the server.
void auth_timeout (timer_event_type_ct const &expired_at)
 This function is called one second after connection attempt.
void send_pong_and_mode (ExpressionEventType const &event_type)
 Call ServerConnection::send_pong_and_mode.

Private Attributes

ServerConnectionM_server_connection
 Reference to the underlying server connection.
Bool M_auth_one_second_passed
 Set to true one second after connect.
Watched< std::string > M_auth_ping_argument
 The argument of the first PING message.
Bool M_doing_hostname_lookup
 Set to true if the notice '*** Looking up your hostname' was received.
Bool M_finished_hostname_lookup
 Set to true if the hostname lookup finished.
Bool M_doing_ident_lookup
 Set to true if the notice '*** Checking Ident' was received.
Bool M_finished_ident_lookup
 Set to true if the ident lookup finished.

Constructor & Destructor Documentation

AuthState::AuthState ( ServerConnection server_connection  ) 

Contruct a new AuthState object, starting a new authentication cycle.

Definition at line 28 of file AuthState.cc.

References auth_notice_looking_up_hostname(), auth_notice_looking_up_ident(), auth_timeout(), Identity::authentication(), IdentityReference::identity(), M_auth_one_second_passed, M_auth_ping_argument, M_doing_hostname_lookup, M_doing_ident_lookup, M_finished_hostname_lookup, M_finished_ident_lookup, M_server_connection, ServerSession::message_event_server(), debug::channels::dc::objects, ServerConnection::secondary_connection(), Authentication::send_authentication(), send_pong_and_mode(), and ServerConnection::server_session().

00028                                                         : event_client_ct(), M_server_connection(server_connection)
00029 #ifdef CWDEBUG
00030       , M_auth_one_second_passed("AuthState::M_auth_one_second_passed"),
00031       M_auth_ping_argument("AuthState::M_auth_ping_argument"),
00032       M_doing_hostname_lookup("AuthState::M_doing_hostname_lookup"),
00033       M_finished_hostname_lookup("AuthState::M_finished_hostname_lookup"),
00034       M_doing_ident_lookup("AuthState::M_doing_ident_lookup"),
00035       M_finished_ident_lookup("AuthState::M_finished_ident_lookup")
00036 #endif
00037 {
00038   Dout(dc::objects, "Constructing AuthState(" << server_connection << ')');
00039 
00040   // We can't send a MODE <mynick> messages right away.
00041   // Instead we have to wait 1 second to see if the server is sending us NOTICE AUTH messages or not.
00042   // If it is, we have to wait until it's done with that.
00043 
00044   // Set M_doing_hostname_lookup if appropriate, and M_finished_hostname_lookup when finished.
00045   MatchRequest match_request1(M_server_connection.secondary_connection());
00046   match_request1(keys::NOTICE).exactmatch("AUTH", 0).exactmatch("*** Looking up your hostname", 1);
00047   M_server_connection.server_session().message_event_server()(match_request1, *this, &AuthState::auth_notice_looking_up_hostname);
00048 
00049   // Set M_doing_ident_lookup if appropriate, and M_finished_ident_lookup when finished.
00050   MatchRequest match_request2(M_server_connection.secondary_connection());
00051   match_request2(keys::NOTICE).exactmatch("AUTH", 0).exactmatch("*** Checking Ident", 1);
00052   M_server_connection.server_session().message_event_server()(match_request2, *this, &AuthState::auth_notice_looking_up_ident);
00053 
00054   // Set M_auth_one_second_passed 1 second from now.
00055   timeval delay = { 1, 0 };
00056   timerRequest(delay, *this, &AuthState::auth_timeout);
00057 
00058   // As soon as it is safe to sent PONG and MODE in one burst, call send_pong_and_mode().
00059   ON_TRUE(
00060       ((*M_auth_one_second_passed &&
00061         (!*M_doing_hostname_lookup || *M_finished_hostname_lookup) &&
00062         (!*M_doing_ident_lookup || *M_finished_ident_lookup)) ||
00063        (*M_finished_hostname_lookup &&
00064         *M_finished_ident_lookup)) &&
00065       *M_auth_ping_argument != ConstExpression<std::string>(""),
00066        *this, &AuthState::send_pong_and_mode);
00067 
00068   // Start the authentication.
00069   M_server_connection.identity().authentication().send_authentication(M_server_connection);
00070 }

AuthState::~AuthState (  ) 

@ brief Destructor of AuthState.

Definition at line 83 of file AuthState.cc.

References debug::channels::dc::objects.

00084 {
00085   Dout(dc::objects, "Destructing AuthState " << *this << ".");
00086   cancel_all_requests();
00087 }


Member Function Documentation

void AuthState::set_auth_ping_argument ( std::string const &  auth_ping_argument  )  [inline]

Remember the argument of the first PING.

Definition at line 43 of file AuthState.h.

References M_auth_ping_argument.

std::string const& AuthState::auth_ping_argument ( void   )  const [inline]

Return argument of the first PING.

Definition at line 45 of file AuthState.h.

References M_auth_ping_argument, and Watched< T >::value().

00045 { return M_auth_ping_argument.value(); }

void AuthState::auth_notice_looking_up_hostname ( MatcherEventType const &  event_type  ) 

This function is called when a NOTICE AUTH message is received from the server.

Never call this function directly.

Definition at line 103 of file AuthState.cc.

References auth_notice_fin_hostname(), DoutEntering, M_doing_hostname_lookup, M_server_connection, ServerSession::message_event_server(), ServerConnection::secondary_connection(), ServerConnection::server_session(), and ServerConnection::successful_connection().

Referenced by AuthState().

00104 {
00105   DoutEntering(dc::debug, "AuthState::auth_notice_looking_up_hostname(" << event_type << ")");
00106   M_doing_hostname_lookup = true;
00107   M_server_connection.successful_connection();  // We didn't get throttled.
00108 
00109   MatchRequest match_request(M_server_connection.secondary_connection());
00110   match_request(keys::NOTICE).exactmatch("AUTH", 0).wildcard("*your hostname*", 1);
00111   M_server_connection.server_session().message_event_server()(match_request, *this, &AuthState::auth_notice_fin_hostname);
00112 }

void AuthState::auth_notice_fin_hostname ( MatcherEventType const &  event_type  ) 

This function is called when a NOTICE AUTH message is received from the server.

Never call this function directly.

Definition at line 118 of file AuthState.cc.

References DoutEntering, and M_finished_hostname_lookup.

Referenced by auth_notice_looking_up_hostname().

00119 {
00120   DoutEntering(dc::debug, "AuthState::auth_notice_fin_hostname(" << event_type << ")");
00121   M_finished_hostname_lookup = true;
00122 }

void AuthState::auth_notice_looking_up_ident ( MatcherEventType const &  event_type  ) 

This function is called when a NOTICE AUTH message is received from the server.

Never call this function directly.

Definition at line 128 of file AuthState.cc.

References auth_notice_fin_ident(), DoutEntering, M_doing_ident_lookup, M_server_connection, ServerSession::message_event_server(), ServerConnection::secondary_connection(), ServerConnection::server_session(), and ServerConnection::successful_connection().

Referenced by AuthState().

00129 {
00130   DoutEntering(dc::debug, "AuthState::auth_notice_looking_up_ident(" << event_type << ")");
00131   M_doing_ident_lookup = true;
00132   M_server_connection.successful_connection();  // We didn't get throttled.
00133 
00134   MatchRequest match_request(M_server_connection.secondary_connection());
00135   match_request(keys::NOTICE).exactmatch("AUTH", 0).wildcard("*ident response*", 1);
00136   M_server_connection.server_session().message_event_server()(match_request, *this, &AuthState::auth_notice_fin_ident);
00137 }

void AuthState::auth_notice_fin_ident ( MatcherEventType const &  event_type  ) 

This function is called when a NOTICE AUTH message is received from the server.

Never call this function directly.

Definition at line 143 of file AuthState.cc.

References DoutEntering, and M_finished_ident_lookup.

Referenced by auth_notice_looking_up_ident().

00144 {
00145   DoutEntering(dc::debug, "AuthState::auth_notice_fin_ident(" << event_type << ")");
00146   M_finished_ident_lookup = true;
00147 }

void AuthState::auth_timeout ( timer_event_type_ct const &  expired_at  ) 

This function is called one second after connection attempt.

Never call this function directly.

Definition at line 93 of file AuthState.cc.

References DoutEntering, and M_auth_one_second_passed.

Referenced by AuthState().

00094 {
00095   DoutEntering(dc::debug, "AuthState::auth_timeout(" << expired_at.get_expire_time() << ")");
00096   M_auth_one_second_passed = true;
00097 }

void AuthState::send_pong_and_mode ( ExpressionEventType const &  event_type  ) 

Call ServerConnection::send_pong_and_mode.

Definition at line 75 of file AuthState.cc.

References M_server_connection, and ServerConnection::send_pong_and_mode().

Referenced by AuthState().

00076 {
00077   M_server_connection.send_pong_and_mode(event_type);
00078 }


Member Data Documentation

Reference to the underlying server connection.

Definition at line 31 of file AuthState.h.

Referenced by auth_notice_looking_up_hostname(), auth_notice_looking_up_ident(), AuthState(), and send_pong_and_mode().

Set to true one second after connect.

Definition at line 32 of file AuthState.h.

Referenced by auth_timeout(), and AuthState().

Watched<std::string> AuthState::M_auth_ping_argument [private]

The argument of the first PING message.

Definition at line 33 of file AuthState.h.

Referenced by auth_ping_argument(), AuthState(), and set_auth_ping_argument().

Set to true if the notice '*** Looking up your hostname' was received.

Definition at line 34 of file AuthState.h.

Referenced by auth_notice_looking_up_hostname(), and AuthState().

Set to true if the hostname lookup finished.

Definition at line 35 of file AuthState.h.

Referenced by auth_notice_fin_hostname(), and AuthState().

Set to true if the notice '*** Checking Ident' was received.

Definition at line 36 of file AuthState.h.

Referenced by auth_notice_looking_up_ident(), and AuthState().

Set to true if the ident lookup finished.

Definition at line 37 of file AuthState.h.

Referenced by auth_notice_fin_ident(), and AuthState().


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

Copyright © 2005-2007 Carlo Wood.  All rights reserved.