ircproxy The Ultimate Cyborg |
#include <Identity.h>
The IRC Client provides a unique key with the PASS message. Each unique key corresponds to a single Identity, making it possible to re-attach to an identity after losing connection.
The uniqueness corresponds therefore to the uniqueness of a nick/network combination (also in that case there can only be one unique value).
Definition at line 58 of file Identity.h.
Public Member Functions | |
Identity (void) | |
Construct an Identity object for initialization from XML file. | |
Identity (std::string const &key) | |
Construct an Identity object with key key. | |
~Identity () | |
Destruct an Identity. | |
Identity (Identity const &identity) | |
WARNING: This is NOT a real copy constructor. It's unfortunately needed for identities_type to work. | |
void | serialize (PersistXML &xml) |
Serialize the object. | |
std::string const & | key (void) const |
The key of this Identity. | |
void | new_client_message_received (ClientMessageIn const &msg) |
Called when a new message was received from the associated client. | |
void | new_server_message_received (ServerMessageIn const &msg) |
Called when a new message was received from the associated server. | |
boost::shared_ptr< Nick const > | mynick (void) const |
Returns a pointer to my Nick object. | |
boost::shared_ptr< Nick > | mynick (void) |
Returns a pointer to my Nick object. | |
std::string | server_source (void) const |
Return a reasonable servername that can be used as source for client messages. | |
std::string | ident (void) const |
Returns a best-guess for the users ident string. | |
std::string | real_hostname (void) const |
Returns a best-guess for the users host name. | |
std::string | hostname (void) const |
Returns a best-guess for the users host name. | |
std::string | real_name (void) const |
Returns a best-guess for the users real name. | |
std::string | network_name (void) const |
Returns the network name that this identity corresponds with. | |
void | set_ident (std::string const &ident) |
Set ident string as returned by ident(). | |
void | set_real_hostname (std::string const &real_hostname) |
Set host name string as returned by real_hostname(). | |
void | set_hostname (std::string const &hostname) |
Set host name string as returned by hostname(). | |
void | set_real_name (std::string const &real_name) |
Set real name string as returned by real_name(). | |
void | set_network_name (std::string const &network_name) |
Set network name string as returned by real_name(). | |
bool | has_authentication_password (void) const |
Returns true if an authentication password is needed. | |
std::string const & | authentication_password (void) const |
Returns the authentication password. Should only be called if has_authentication_password returns true. | |
Network const & | private_network (void) const |
Return the fake network object, private to this identity. | |
Network & | private_network (void) |
Return the fake network object, private to this identity. | |
Network const & | network (void) const |
Return the network object of the connection belonging to this identity. | |
Network & | network (void) |
Return the network object of the connection belonging to this identity. | |
void | set_client_session (ClientSession *client_session) |
Set current ClientSession of this Identity, called by ClientSession::new_message_received. | |
void | reset_client_session (ClientSession *client_session) |
Reset the ClientSession of this Identity, provided it matches the currently set ClientSession. | |
bool | has_client_session (void) const |
Return true if this identity is associated with a client session. | |
bool | has_server_session (void) const |
Return true if this identity is associated with a server session. | |
ClientSession const & | client_session (void) const |
Return the current ClientSession. | |
ClientSession & | client_session (void) |
Return the current ClientSession. | |
ServerSession const & | server_session (void) const |
Return the current ClientSession. | |
ServerSession & | server_session (void) |
Return the current ClientSession. | |
boost::shared_ptr< Target > | notice_target (question_nt number) |
Return a target with prefix prefix that is not already in the private network map. | |
ServerConnection const & | server_connection (void) const |
Return the primary server connection object. | |
ServerConnection & | server_connection (void) |
Return the primary server connection object. | |
void | start_secondary_server_connection (boost::shared_ptr< Server > new_server) |
Start a secondary server connection, which will take over the primary once connected. | |
void | swap_primary_and_secondary_connection (void) |
Swap primary and secondary connection. | |
void | end_secondary_server_connection (void) |
Terminate the secondary connection. | |
bool | has_secondary_server_connection (void) const |
Return true if this identity is associated with a secondary server connection. | |
boost::shared_ptr < ServerConnection const > | secondary_server_connection (void) const |
Return the secondary server connection. Only valid if has_secondary_server_connection returns true. | |
boost::shared_ptr < ServerConnection > | secondary_server_connection (void) |
Return the secondary server connection. Only valid if has_secondary_server_connection returns true. | |
Authentication const & | authentication (void) const |
Return the authentication object. | |
Authentication & | authentication (void) |
Return the authentication object. | |
void | send_notice (std::string const ¬ice, question_nt number=no_related_question) |
Send a notice to the client. | |
void | received_network_domain_answer (UserAnswerEventType const &event_type, std::pair< std::string, std::string > network_domain) |
Event call back: network domain answer received. Process it. | |
void | pass_as_is_to_server (ClientMessageIn const &msg) |
Write ClientMessageIn msg to the server. | |
void | pass_as_is_to_client (ServerMessageIn const &msg) |
Write ServerMessageIn msg to the client. | |
Private Member Functions | |
void | pass_as_is_to (MessageIn const &msg, std::ostream &os) |
Write MessageIn msg to the ostream os. | |
Private Attributes | |
std::string | M_key |
The unique identity key as used with the identity map. | |
boost::shared_ptr< Authentication > | M_authentication |
Temporary authentication token, or NULL. | |
boost::shared_ptr< Nick > | M_mynick |
Pointer to the Nick object representing my own nick. | |
std::string | M_authpass |
Authentication password. | |
Network | M_private_network |
Fake network, private to this identity. | |
ClientSession * | M_client_session |
Pointer to the current client session. | |
std::string | M_ident |
A best-guess for this users ident. | |
std::string | M_real_hostname |
A best-guess for this users real hostname. | |
std::string | M_hostname |
A best-guess for this users (cloaked) hostname. | |
std::string | M_real_name |
A best-guess for this users real name. | |
std::string | M_network_name |
The network name that corresponds to this identity. | |
boost::shared_ptr < ServerConnection > | M_primary_server_connection |
Our link to some server. | |
boost::shared_ptr < ServerConnection > | M_secondary_server_connection |
Link to a secondary server connection in progress, or NULL when none. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, Identity const &identity) |
For debugging purposes. Write a Identity to os. |
Identity::Identity | ( | void | ) | [inline] |
Construct an Identity object for initialization from XML file.
Definition at line 76 of file Identity.h.
References debug::channels::dc::objects.
00076 : 00077 M_mynick(NEW(MyNick(*this))), 00078 M_private_network("private network", true), 00079 M_client_session(NULL), 00080 M_ident(unknown_ident), 00081 M_real_hostname(unknown_hostname), 00082 M_hostname(unknown_hostname), 00083 M_real_name(unknown_real_name), 00084 M_network_name(unknown_network_name), 00085 M_primary_server_connection(NEW(ServerConnection(this))) 00086 { Dout(dc::objects, "Constructing Identity"); }
Identity::Identity | ( | std::string const & | key | ) | [inline] |
Construct an Identity object with key key.
Definition at line 89 of file Identity.h.
References debug::channels::dc::objects.
00089 : 00090 M_key(key), 00091 M_mynick(NEW(MyNick(*this))), 00092 M_private_network("private network of " + key, true), 00093 M_client_session(NULL), 00094 M_ident(unknown_ident), 00095 M_real_hostname(unknown_hostname), 00096 M_hostname(unknown_hostname), 00097 M_real_name(unknown_real_name), 00098 M_network_name(unknown_network_name), 00099 M_primary_server_connection(NEW(ServerConnection(this))) 00100 { Dout(dc::objects, "Constructing Identity(\"" << key << "\")"); }
Identity::~Identity | ( | ) |
Destruct an Identity.
Definition at line 777 of file Identity.cc.
References client_session(), has_client_session(), has_server_session(), ServerSession::joined_channels(), ClientSession::joined_channels(), debug::channels::dc::objects, and server_session().
00778 { 00779 Dout(dc::objects, "Destructing Identity " << *this << "."); 00780 // Destruct channels before destructing private network. 00781 if (has_client_session()) 00782 client_session().joined_channels().clear(); 00783 if (has_server_session()) 00784 server_session().joined_channels().clear(); 00785 cancel_all_requests(); 00786 }
Identity::Identity | ( | Identity const & | identity | ) | [inline] |
WARNING: This is NOT a real copy constructor. It's unfortunately needed for identities_type to work.
Definition at line 106 of file Identity.h.
References ASSERT, M_mynick, M_secondary_server_connection, and debug::channels::dc::objects.
00106 : event_client_ct(identity), 00107 M_key(identity.M_key), 00108 M_authentication(identity.M_authentication), 00109 M_mynick(NEW(MyNick(*this))), 00110 M_authpass(identity.M_authpass), 00111 M_private_network(identity.M_private_network), 00112 M_client_session(identity.M_client_session), 00113 M_ident(identity.M_ident), 00114 M_real_hostname(identity.M_real_hostname), 00115 M_hostname(identity.M_hostname), 00116 M_real_name(identity.M_real_name), 00117 M_network_name(identity.M_network_name), 00118 M_primary_server_connection(NEW(ServerConnection(this))), 00119 M_secondary_server_connection(identity.M_secondary_server_connection) 00120 { ASSERT(!M_secondary_server_connection.get()); ASSERT(M_mynick.use_count() <= 1); Dout(dc::objects, "Copy-constructing Identity from " << identity); }
void Identity::serialize | ( | PersistXML & | xml | ) |
Serialize the object.
Serialize object to XML.
Definition at line 770 of file Identity.cc.
References M_authpass, M_key, M_network_name, and PersistXML::serialize().
00771 { 00772 xml.serialize("M_key", M_key); 00773 xml.serialize("M_authpass", M_authpass); 00774 xml.serialize("M_network_name", M_network_name); 00775 }
std::string const& Identity::key | ( | void | ) | const [inline] |
The key of this Identity.
Definition at line 126 of file Identity.h.
References M_key.
Referenced by Target::clientside_get_channel(), Target::get_joined_nick(), ServerConnection::invisible_event(), operator<<(), and Target::serverside_get_channel().
00126 { return M_key; }
void Identity::new_client_message_received | ( | ClientMessageIn const & | msg | ) |
Called when a new message was received from the associated client.
Definition at line 92 of file Identity.cc.
References ASSERT, edragon::caught(), ClientMessageIn::client_session(), client_session(), Target::clientside_get_channel(), default_priority(), DoutEntering, Authentication::get(), ClientSession::get_nick(), is_channel(), MessageIn::key(), M_authentication, M_ident, M_real_name, mynick(), ClientSession::new_client_nick_received(), MessageIn::param(), MessageIn::params(), MessageIn::params_size(), ClientSession::private_targets(), ServerSession::queue_msg(), ClientSession::queue_msg(), ServerSession::queue_msg_as_is(), safe_query, ServerSession::send_who_write_event(), server_connection(), and server_session().
Referenced by ClientSession::process_message().
00093 { 00094 DoutEntering(dc::debug, "Identity::new_client_message_received(" << msg << ")"); 00095 00096 switch (msg.key()) 00097 { 00098 using namespace keys; 00099 case PASS: // No target 00100 Authentication::get(this, M_authentication); 00101 M_authentication->decode_pass(msg); 00102 break; 00103 case USER: // No target 00104 if (M_ident == unknown_ident) // It might be retrieved already from identd. 00105 M_ident = msg.param(0); 00106 M_real_name = msg.param(3); 00107 Authentication::get(this, M_authentication); 00108 M_authentication->decode_user(msg); 00109 break; 00110 case PING: // No target 00111 { 00112 std::string server_name(server_connection().has_server() ? server_connection().server()->get_irc_name() : "noserver.pong.org"); 00113 Prefix prefix(server_name); 00114 MessageOut msgout(default_priority(keys::PONG)); 00115 client_session().queue_msg(msgout << prefix << keys::PONG << server_name << msg.params(0)); 00116 break; 00117 } 00118 case SILENCE: // No target 00119 { 00120 // FIXME. 00121 // For now, just pass it on the server as-is. 00122 server_session().queue_msg_as_is(msg); 00123 break; 00124 } 00125 case OPER: // No target 00126 case MAP: 00127 case WALLOPS: 00128 case WALLUSERS: 00129 { 00130 // FIXME. 00131 // For now, just pass it on the server as-is. 00132 server_session().queue_msg_as_is(msg); 00133 break; 00134 } 00135 case STATS: // No target, or server target. 00136 case VERSION: 00137 { 00138 // FIXME. 00139 // For now, just pass it on the server as-is. 00140 server_session().queue_msg_as_is(msg); 00141 break; 00142 } 00143 case WHO: // Query 00144 { 00145 WhoRequest who_request(msg.client_session(), (msg.params_size() >= 3) ? msg.param(2) : msg.param(0), msg.param(1)); 00146 if (msg.params().size() >= 1 && who_request.options().matches_against_channel() && is_channel(who_request.mask())) 00147 { 00148 // Search in the private network targets map. 00149 ClientSession::private_targets_type::iterator priv_iter = client_session().private_targets().find(who_request.mask()); 00150 if (priv_iter != client_session().private_targets().end()) 00151 { 00152 boost::static_pointer_cast<PrivateTarget>(priv_iter->second)->handle_who(who_request); 00153 break; 00154 } 00155 } 00156 // Not a private channel, pass it on to the server. 00157 PseudoMessageOut pseudo_msg(default_priority(keys::WHO), safe_query); 00158 pseudo_msg.writeEventRequest(server_session(), &ServerSession::send_who_write_event, who_request); 00159 server_session().queue_msg(pseudo_msg); 00160 break; 00161 } 00162 case WHOIS: // Query 00163 case WHOWAS: // Query 00164 case LIST: // Query 00165 { 00166 // Extract the prefix of the input message. 00167 Prefix prefix(msg); 00168 // FIXME: needs caching. 00169 MessageOut msgout(default_priority(msg.key())); 00170 server_session().queue_msg(msgout << prefix << msg.key() << msg.params(0)); 00171 break; 00172 } 00173 case LINKS: // Disabled 00174 break; 00175 case NICK: // Target: this 00176 // Handle NICK 00177 msg.client_session().new_client_nick_received(msg.param(0)); 00178 break; 00179 case QUIT: // Target: this 00180 break; 00181 case KILL: // Target: nick 00182 { 00183 Prefix prefix(msg); 00184 MessageOut msgout(default_priority(msg.key())); 00185 try 00186 { 00187 // Is this a known target? 00188 boost::shared_ptr<Target> nick = msg.client_session().get_nick(msg.param(0)); 00189 server_session().queue_msg(msgout << prefix << msg.key() << nick << msg.params(1)); 00190 } 00191 catch(unknown_target& error) 00192 { 00193 Debug(edragon::caught(error)); 00194 server_session().queue_msg(msgout << prefix << msg.key() << msg.params(0)); 00195 } 00196 break; 00197 } 00198 case MODE: // Target: channel or nick (this) 00199 case PRIVMSG: // Target: channel or nick 00200 case NOTICE: // Target: channel or nick 00201 { 00202 if (!msg.params().empty()) 00203 { 00204 char c = *msg.params().front().start(); 00205 if (c != '#' && c != '&') 00206 { 00207 if (msg.key() == MODE) 00208 { 00209 // Handle MODE <nick> 00210 // FIXME: replace ASSERT with code that handles the other case. 00211 ASSERT(msg.param(0) == mynick()->in_name(client_session())); 00212 Prefix prefix(msg); 00213 MessageOut msgout(default_priority(msg.key())); 00214 server_session().queue_msg(msgout << prefix << msg.key() << mynick() << msg.params(1)); 00215 break; 00216 } 00217 else 00218 { 00219 try 00220 { 00221 // Is this a known target? 00222 msg.client_session().get_nick(msg.param(0))->new_client_message_received(msg); 00223 } 00224 catch(unknown_target& error) 00225 { 00226 Debug(edragon::caught(error)); 00227 // Client is sending a message to an unknown target. 00228 // FIXME: Shouldn't we do something here? 00229 // Pass the message as-is to the server. 00230 server_session().queue_msg_as_is(msg); 00231 } 00232 } 00233 break; 00234 } 00235 } 00236 /* FALL-THROUGH */ 00237 } 00238 case INVITE: // Target: channel 00239 case CPRIVMSG: // Target: channel 00240 case CNOTICE: // Target: channel 00241 case JOIN: // Target: channel 00242 case PART: // Target: channel 00243 case KICK: // Target: channel 00244 case NAMES: // Target: channel 00245 case TOPIC: // Target: channel 00246 try 00247 { 00248 // Are we really on this channel? 00249 Target::clientside_get_channel(*this, msg.param(0))->new_client_message_received(msg); 00250 } 00251 catch(unknown_target& error) 00252 { 00253 Debug(edragon::caught(error)); 00254 // FIXME: Shouldn't we do something here? 00255 // Client targets an unknown channel. Just pass the message on as-is to the server. 00256 server_session().queue_msg_as_is(msg); 00257 } 00258 break; 00259 } 00260 }
void Identity::new_server_message_received | ( | ServerMessageIn const & | msg | ) |
Called when a new message was received from the associated server.
Definition at line 278 of file Identity.cc.
References Target::add_joined_nick(), ASSERT, edragon::caught(), client_session(), default_priority(), DoutEntering, WhoOptions::fields(), Target::get_joined_nick(), Prefix::get_nick(), ServerSession::get_nick(), hostname(), NickPair::in_nick(), NickPair::inuse(), MessageIn::key(), WhoRequest::mask(), mynick(), network(), ServerSession::nicks(), WhoRequest::options(), Prefix::out_prefix(), MessageIn::param(), MessageIn::params(), pass_as_is_to_client(), pong_sent, ServerSession::pop_who_request(), MessageIn::prefix(), ClientSession::queue_msg(), server_connection(), ServerMessageIn::server_session(), server_session(), Target::serverside_get_channel(), and ServerConnection::state().
Referenced by ServerSession::new_message_received().
00279 { 00280 ASSERT(!debug::secondary_connection); 00281 DoutEntering(dc::debug, "Identity::new_server_message_received(" << msg << ")"); 00282 00283 switch (msg.key()) 00284 { 00285 using namespace keys; 00286 case 315: // End of /WHO list. 00287 { 00288 Prefix prefix(msg); 00289 MessageOut msgout(default_priority(msg.key())); 00290 client_session().queue_msg(msgout << prefix << msg.key() << mynick() << msg.params(1)); 00291 #ifdef CWDEBUG 00292 WhoRequest who_request(server_session().current_who_request()); 00293 ASSERT(who_request.mask() == msg.param(1)); 00294 #endif 00295 server_session().pop_who_request(); 00296 break; 00297 } 00298 case 324: 00299 { 00300 Prefix prefix(msg); 00301 MessageOut msgout(default_priority(msg.key())); 00302 // Parameter 0 should be my own nick name. 00303 std::string my_nick_name(msg.param(0)); 00304 ASSERT(my_nick_name == mynick()->in_name(msg.server_session())); 00305 // Write the first part of the message. 00306 msgout << prefix << msg.key() << mynick(); 00307 // FIXME: decode channel modes. 00308 try 00309 { 00310 boost::shared_ptr<Channel> channel(Target::serverside_get_channel(*this, msg.param(1))); 00311 msgout << channel; 00312 } 00313 catch (unknown_target& error) 00314 { 00315 Debug(edragon::caught(error)); 00316 msgout << msg.param(1); 00317 } 00318 msgout << msg.params(2); 00319 // Write the message. 00320 client_session().queue_msg(msgout); 00321 break; 00322 } 00323 case 329: // Channel timestamp. 00324 { 00325 Prefix prefix(msg); 00326 MessageOut msgout(default_priority(msg.key())); 00327 // Parameter 0 should be my own nick name. 00328 std::string my_nick_name(msg.param(0)); 00329 ASSERT(my_nick_name == mynick()->in_name(msg.server_session())); 00330 // Write the first part of the message. 00331 msgout << prefix << msg.key() << mynick(); 00332 time_t creation_time = atol(msg.param(2).c_str()); 00333 try 00334 { 00335 boost::shared_ptr<Channel> channel(Target::serverside_get_channel(*this, msg.param(1))); 00336 channel->set_creation_time(creation_time); 00337 msgout << channel; 00338 } 00339 catch (unknown_target& error) 00340 { 00341 Debug(edragon::caught(error)); 00342 msgout << msg.param(1); 00343 } 00344 msgout << creation_time; 00345 // Write the message. 00346 client_session().queue_msg(msgout); 00347 break; 00348 } 00349 case 352: // WHO, without fields, reply. 00350 { 00351 // Get the corresponding WhoRequest. 00352 WhoRequest who_request(server_session().current_who_request()); 00353 Dout(dc::notice, "Decoding numeric 352 for WHO request " << who_request); 00354 // The format of this numeric is: 00355 // 0: My nick 00356 // 1: (first) channel 00357 // 2: username 00358 // 3: hostname 00359 // 4: servername 00360 // 5: nick 00361 // 6: flags 00362 // 7: hop realname 00363 Prefix prefix(msg); 00364 MessageOut msgout(default_priority(msg.key())); 00365 // Parameter 0 should be my own nick name. 00366 std::string my_nick_name(msg.param(0)); 00367 ASSERT(my_nick_name == mynick()->in_name(msg.server_session())); 00368 // Write the first part of the message. 00369 msgout << prefix << msg.key() << mynick(); 00370 try 00371 { 00372 boost::shared_ptr<Channel> channel(Target::serverside_get_channel(*this, msg.param(1))); 00373 msgout << channel; 00374 } 00375 catch (unknown_target& error) 00376 { 00377 Debug(edragon::caught(error)); 00378 msgout << msg.param(1); 00379 } 00380 std::string username(msg.param(2)); 00381 std::string hostname(msg.param(3)); 00382 std::string servername(msg.param(4)); 00383 std::string flags(msg.param(6)); 00384 std::string realname(msg.param(7)); 00385 int hopcount = atoi(realname.c_str()); 00386 realname = realname.substr(realname.find(' ') + 1); 00387 msgout << username << hostname << servername; 00388 try 00389 { 00390 boost::shared_ptr<Nick> nick(msg.server_session().get_nick(msg.param(5))); 00391 msgout << nick; 00392 nick->data().set_username(username); 00393 nick->data().set_hostname(hostname); 00394 nick->data().set_realname(realname); 00395 nick->data().set_hopcount(hopcount); 00396 nick->data().set_flags(Flags(network(), flags)); 00397 } 00398 catch(unknown_target& error) 00399 { 00400 Debug(edragon::caught(error)); 00401 msgout << msg.param(5); 00402 } 00403 msgout << flags << msg.params(7); 00404 // Write the message. 00405 client_session().queue_msg(msgout); 00406 break; 00407 } 00408 case 354: // WHO, with fields, reply. 00409 { 00410 // Get the corresponding WhoRequest. 00411 WhoRequest who_request(server_session().current_who_request()); 00412 Dout(dc::notice, "Decoding numeric 354 for WHO request " << who_request); 00413 // The format of this numeric is: 00414 // - t: The left-most three digits of the query type (or 0, if there was none, or non-numeric, or negative). 00415 // - c: The (first) channel name. 00416 // - u: User name with eventual ~. 00417 // - i: IP 00418 // - h: Host name. 00419 // - s: Server name. 00420 // - n: Nick name. 00421 // - f: Flags (all of them). 00422 // - d: Hop count. 3 for non-Opers. 00423 // - l: Idle time (0 for remote users). Also 0 for non-Opers. 00424 // - a: Account name. 00425 // - r: Real name. 00426 00427 Prefix prefix(msg); 00428 MessageOut msgout(default_priority(msg.key())); 00429 // Parameter 0 should be my own nick name. 00430 std::string my_nick_name(msg.param(0)); 00431 ASSERT(my_nick_name == mynick()->in_name(msg.server_session())); 00432 // Write the first part of the message. 00433 msgout << prefix << msg.key() << mynick(); 00434 00435 int n = 0; 00436 // Run over all field flags. 00437 for (unsigned int field = 1; field < field_percentage; field <<= 1) 00438 { 00439 if ((who_request.options().fields() & field)) 00440 { 00441 // Next message parameter. 00442 ++n; 00443 // Ok, this field exists. Write it out. 00444 if (field == field_c) // A channel name? 00445 { 00446 try 00447 { 00448 boost::shared_ptr<Channel> channel(Target::serverside_get_channel(*this, msg.param(n))); 00449 msgout << channel; 00450 } 00451 catch (unknown_target& error) 00452 { 00453 Debug(edragon::caught(error)); 00454 msgout << msg.param(n); 00455 } 00456 } 00457 else if (field == field_n) // A nick name? 00458 { 00459 try 00460 { 00461 boost::shared_ptr<Nick> nick(msg.server_session().get_nick(msg.param(n))); 00462 msgout << nick; 00463 int n2 = 0; 00464 for (unsigned int field2 = 1; field2 < field_percentage; field2 <<= 1) 00465 if ((who_request.options().fields() & field2)) 00466 { 00467 ++n2; 00468 switch(field2) 00469 { 00470 case field_u: 00471 nick->data().set_username(msg.param(n2)); 00472 break; 00473 case field_h: 00474 nick->data().set_hostname(msg.param(n2)); 00475 break; 00476 case field_i: 00477 nick->data().set_ip(IPNumber(msg.param(n2))); 00478 break; 00479 case field_r: 00480 nick->data().set_realname(msg.param(n2)); 00481 break; 00482 case field_d: 00483 nick->data().set_hopcount(atoi(msg.param(n2).c_str())); 00484 break; 00485 case field_f: 00486 nick->data().set_flags(Flags(network(), msg.param(n2))); 00487 break; 00488 case field_s: 00489 nick->data().set_servername(msg.param(n2)); 00490 break; 00491 case field_l: 00492 nick->data().set_idletime(atoi(msg.param(n2).c_str())); 00493 break; 00494 case field_a: 00495 nick->data().set_accountname(msg.param(n2)); 00496 break; 00497 } 00498 } 00499 } 00500 catch(unknown_target& error) 00501 { 00502 Debug(edragon::caught(error)); 00503 msgout << msg.param(n); 00504 } 00505 } 00506 else 00507 msgout << msg.param(n); 00508 } 00509 } 00510 // Write the message. 00511 client_session().queue_msg(msgout); 00512 break; 00513 } 00514 case 353: // NAMES reply 00515 { 00516 // Get prefix. 00517 Prefix prefix(msg); 00518 // Prepare message to be sent to client. 00519 MessageOut msgout(default_priority(msg.key())); 00520 // Lookup the channel. 00521 boost::shared_ptr<Channel> channel(Target::serverside_get_channel(*this, msg.param(2))); 00522 bool received_first_names = channel->received_names(); 00523 // Parameter 0 should be my own nick name. 00524 std::string my_nick_name(msg.param(0)); 00525 ASSERT(my_nick_name == mynick()->in_name(msg.server_session())); 00526 // Write first part of message. 00527 msgout << prefix << msg.key() << mynick() << msg.param(1) << channel; 00528 // Run over each parameter. 00529 MsgPart names_list(msg.params(3)); 00530 char const* list_start = names_list.start(); 00531 if (*list_start == ':') 00532 ++list_start; 00533 char const* const list_end = names_list.end(); 00534 char const* word_end; 00535 for (char const* word_start = list_start; word_start < list_end; word_start = word_end + 1) 00536 { 00537 ASSERT(*word_start != ' '); 00538 for (word_end = word_start; word_end < list_end && *word_end != ' '; ++word_end); 00539 std::string param(word_start, word_end - word_start); 00540 if (!IsNickChar(*word_start)) 00541 { 00542 ASSERT(*word_start == '@' || *word_start == '+'); 00543 std::string nick_name(word_start + 1, word_end - word_start - 1); 00544 boost::shared_ptr<Nick> nick; 00545 if (received_first_names) 00546 nick = Target::get_joined_nick(*this, nick_name, channel); 00547 else if (nick_name == my_nick_name) // Was already added by the JOIN. 00548 nick = mynick(); 00549 else 00550 nick = Target::add_joined_nick(*this, nick_name, channel); 00551 msgout << *word_start << JustInTimeCatenate(nick); 00552 } 00553 else 00554 { 00555 std::string nick_name(word_start, word_end - word_start); 00556 boost::shared_ptr<Nick> nick; 00557 if (received_first_names) 00558 nick = Target::get_joined_nick(*this, nick_name, channel); 00559 else if (nick_name == my_nick_name) // Was already added by the JOIN. 00560 nick = mynick(); 00561 else 00562 nick = Target::add_joined_nick(*this, nick_name, channel); 00563 msgout << nick; 00564 } 00565 } 00566 client_session().queue_msg(msgout); 00567 break; 00568 } 00569 case 366: // End of /NAMES list. 00570 { 00571 // Get prefix. 00572 Prefix prefix(msg); 00573 // Prepare message to be sent to client. 00574 MessageOut msgout(default_priority(msg.key())); 00575 // Lookup the channel. 00576 boost::shared_ptr<Channel> channel(Target::serverside_get_channel(*this, msg.param(1))); 00577 if (!channel->received_names()) 00578 { 00579 // Tell channel we received the first 366. 00580 channel->set_received_names(); 00581 } 00582 // Parameter 0 should be my own nick name. 00583 ASSERT(msg.param(0) == mynick()->in_name(msg.server_session())); 00584 // Pass message on the client. 00585 client_session().queue_msg(msgout << prefix << msg.key() << mynick() << channel << msg.params(2)); 00586 break; 00587 } 00588 case 433: // Nickname is already in use. 00589 server_session().nicks().inuse(msg.param(1)); 00590 break; 00591 case 451: // Register first 00592 if (server_connection().state() == pong_sent) 00593 { 00594 // This probably means that something went wrong with the registration part. 00595 // For example Undernet server version 2.10.12.10 has no means to set MODE +xi 00596 // with the USER command, but requires hostname and ident lookup to be finished 00597 // before it considers registration to be finished. Therefore it is not possible 00598 // to send the PONG and the MODE +ix in one packet (as we do) until after the 00599 // hostname and ident look ups actually have finished. However, because we don't 00600 // know if those lookups are merely delayed a lot, or that we aren't connected 00601 // to an undernet server, we send the PONG and MODE anyway after a certain timeout. 00602 // If the MODE failed, we are vulnerable. Disconnect immediately. 00603 server_session() << "QUIT\r\n" << std::flush; 00604 } 00605 break; 00606 case QUIT: 00607 do_quit(msg.prefix().get_nick(), msg.param(0)); 00608 break; 00609 case NICK: 00610 { 00611 Prefix prefix(msg); 00612 Prefix old_prefix(prefix.out_prefix(client_session())); 00613 boost::shared_ptr<Nick> nick(prefix.get_nick()); 00614 nick->serverside_nick_changed_to(msg.server_session(), msg.param(0)); // This updates the maps. 00615 // FIXME: check for collisions etc. 00616 nick->clientside_nick_changed_to(client_session(), msg.param(0)); // This is passed as parameter 0 to the client in the message below. 00617 // Pass the message as-is to the client. 00618 MessageOut msgout(default_priority(msg.key())); 00619 client_session().queue_msg(msgout << old_prefix << msg.key() << nick); 00620 break; 00621 } 00622 case NOTICE: // Target: channel or nick 00623 if (server_connection().state() <= pong_sent) // On the last AUTH message the state is already set to pong_sent. 00624 break; // Ignore NOTICE AUTH messages in the beginning (already handled). 00625 /* FALL-THROUGH */ 00626 case PRIVMSG: // Target: channel or nick 00627 { 00628 if (msg.params().empty()) 00629 break; // Should never happen. 00630 char c = *msg.params().front().start(); 00631 if (c != '#' && c != '&' && c != '@') 00632 { 00633 // We should only receive PRIVMSG, NOTICE and user MODE's for ourselves. 00634 // A NOTICE can be sent to $mask or * as well. 00635 ASSERT(c == '$' || msg.param(0) == server_session().nicks().in_nick() || (msg.key() == NOTICE && msg.param(0) == "*")); 00636 // Received private PRIVMSG or NOTICE. 00637 // Pass to client as-is. 00638 Prefix prefix(msg); 00639 MessageOut msgout(default_priority(msg.key())); 00640 if (c == '$' || msg.param(0) == "*") 00641 client_session().queue_msg(msgout << prefix << msg.key() << msg.params(0)); 00642 else 00643 client_session().queue_msg(msgout << prefix << msg.key() << mynick() << msg.params(1)); 00644 break; 00645 } 00646 /* FALL-THROUGH */ 00647 } 00648 case MODE: // Target: channel 00649 case PART: // Target: channel 00650 case KICK: // Target: channel 00651 case TOPIC: // Target: channel 00652 { 00653 // If we receive a message from the server targetted to a channel, we should already 00654 // be on the channel, so there is no need to catch the unknown_target exception here. 00655 // If it's JOIN we might not be on the channel, but in that case we create it here. 00656 Target::serverside_get_channel(*this, msg.param(0), msg.key() == JOIN)->new_server_message_received(msg); 00657 break; 00658 } 00659 case JOIN: // Target: channel 00660 { 00661 Target::serverside_get_channel(*this, msg.param(0), msg.key() == JOIN)->new_server_message_received(msg); 00662 break; 00663 } 00664 default: 00665 Dout(dc::warning, "Unhandled command " << msg << " from server"); 00666 pass_as_is_to_client(msg); 00667 break; 00668 } 00669 }
boost::shared_ptr<Nick const> Identity::mynick | ( | void | ) | const [inline] |
Returns a pointer to my Nick object.
Definition at line 135 of file Identity.h.
References ASSERT, and M_mynick.
Referenced by ServerSession::detected_network(), new_client_message_received(), ClientSession::new_client_nick_received(), ServerSession::new_message_received(), new_server_message_received(), ClientSession::queue_msg_me_as_is(), Authentication::send_authentication(), and Target::sub_channel().
boost::shared_ptr<Nick> Identity::mynick | ( | void | ) | [inline] |
std::string Identity::server_source | ( | void | ) | const |
Return a reasonable servername that can be used as source for client messages.
Obtain associated server name.
Definition at line 759 of file Identity.cc.
References M_primary_server_connection.
Referenced by PrivateTarget::do_names_output(), and PrivateTarget::new_client_message_received().
00760 { 00761 std::string result; 00762 if (M_primary_server_connection->has_server()) 00763 result = M_primary_server_connection->server()->get_irc_name(); 00764 if (result.empty()) 00765 result = "ircproxy.net"; 00766 return result; 00767 }
std::string Identity::ident | ( | void | ) | const [inline] |
Returns a best-guess for the users ident string.
Definition at line 144 of file Identity.h.
References M_ident.
Referenced by QuestionTarget::new_client_message_received().
00144 { return M_ident; }
std::string Identity::real_hostname | ( | void | ) | const [inline] |
Returns a best-guess for the users host name.
Definition at line 147 of file Identity.h.
References M_real_hostname.
00147 { return M_real_hostname; }
std::string Identity::hostname | ( | void | ) | const [inline] |
Returns a best-guess for the users host name.
Definition at line 150 of file Identity.h.
References M_hostname.
Referenced by QuestionTarget::new_client_message_received(), and new_server_message_received().
00150 { return M_hostname; }
std::string Identity::real_name | ( | void | ) | const [inline] |
Returns a best-guess for the users real name.
Definition at line 153 of file Identity.h.
References M_real_name.
00153 { return M_real_name; }
std::string Identity::network_name | ( | void | ) | const [inline] |
Returns the network name that this identity corresponds with.
Definition at line 156 of file Identity.h.
References M_network_name.
Referenced by ServerConnection::connect(), and ServerSession::found_network_name().
00156 { return M_network_name; }
void Identity::set_ident | ( | std::string const & | ident | ) | [inline] |
Set ident string as returned by ident().
Definition at line 159 of file Identity.h.
References M_ident.
Referenced by ServerConnection::received_first_umode().
void Identity::set_real_hostname | ( | std::string const & | real_hostname | ) | [inline] |
Set host name string as returned by real_hostname().
Definition at line 163 of file Identity.h.
References M_real_hostname.
Referenced by ServerConnection::received_first_umode().
00164 { Dout(dc::debug, "Setting real hostname to \"" << real_hostname << "\"."); M_real_hostname = real_hostname; }
void Identity::set_hostname | ( | std::string const & | hostname | ) | [inline] |
Set host name string as returned by hostname().
Definition at line 167 of file Identity.h.
References M_hostname.
Referenced by ServerSession::new_message_received(), and ClientSession::new_message_received().
00168 { Dout(dc::debug, "Setting hostname to \"" << hostname << "\"."); M_hostname = hostname; }
void Identity::set_real_name | ( | std::string const & | real_name | ) | [inline] |
Set real name string as returned by real_name().
Definition at line 171 of file Identity.h.
References M_real_name.
00171 { M_real_name = real_name; }
void Identity::set_network_name | ( | std::string const & | network_name | ) | [inline] |
Set network name string as returned by real_name().
Definition at line 174 of file Identity.h.
References M_network_name.
Referenced by ServerSession::found_network_name().
00174 { M_network_name = network_name; }
bool Identity::has_authentication_password | ( | void | ) | const [inline] |
Returns true if an authentication password is needed.
Definition at line 177 of file Identity.h.
References M_authpass.
Referenced by authentication_password(), and Authentication::decode_pass().
00177 { return !M_authpass.empty(); }
std::string const& Identity::authentication_password | ( | void | ) | const [inline] |
Returns the authentication password. Should only be called if has_authentication_password returns true.
Definition at line 180 of file Identity.h.
References ASSERT, has_authentication_password(), and M_authpass.
Referenced by Authentication::decode_pass().
00180 { ASSERT(has_authentication_password()); return M_authpass; }
Network const& Identity::private_network | ( | void | ) | const [inline] |
Return the fake network object, private to this identity.
Definition at line 183 of file Identity.h.
References M_private_network.
00183 { return M_private_network; }
Network& Identity::private_network | ( | void | ) | [inline] |
Return the fake network object, private to this identity.
Definition at line 186 of file Identity.h.
References M_private_network.
00186 { return M_private_network; }
Network const& Identity::network | ( | void | ) | const [inline] |
Return the network object of the connection belonging to this identity.
Definition at line 189 of file Identity.h.
References ServerConnection::network(), and server_connection().
Referenced by UserAnswer::is_match(), and new_server_message_received().
00189 { return server_connection().network(); }
Network& Identity::network | ( | void | ) | [inline] |
Return the network object of the connection belonging to this identity.
Definition at line 192 of file Identity.h.
References ServerConnection::network(), and server_connection().
00192 { return server_connection().network(); }
void Identity::set_client_session | ( | ClientSession * | client_session | ) | [inline] |
Set current ClientSession of this Identity, called by ClientSession::new_message_received.
Definition at line 195 of file Identity.h.
References M_client_session.
Referenced by ClientSession::new_message_received().
00195 { M_client_session = client_session; }
void Identity::reset_client_session | ( | ClientSession * | client_session | ) | [inline] |
Reset the ClientSession of this Identity, provided it matches the currently set ClientSession.
Definition at line 198 of file Identity.h.
References M_client_session.
Referenced by ClientSession::~ClientSession().
00199 { if (M_client_session == client_session) M_client_session = NULL; }
bool Identity::has_client_session | ( | void | ) | const [inline] |
Return true if this identity is associated with a client session.
Definition at line 202 of file Identity.h.
References M_client_session.
Referenced by ~Identity().
00202 { return M_client_session; }
bool Identity::has_server_session | ( | void | ) | const [inline] |
Return true if this identity is associated with a server session.
Definition at line 205 of file Identity.h.
References M_primary_server_connection.
Referenced by ~Identity().
00205 { return M_primary_server_connection->has_server_session(); }
ClientSession const& Identity::client_session | ( | void | ) | const [inline] |
Return the current ClientSession.
Definition at line 208 of file Identity.h.
References ASSERT, and M_client_session.
Referenced by Target::add_channel(), Target::clientside_get_channel(), ServerConnection::connect(), ServerConnection::do_connect(), ServerSession::found_network_name(), new_client_message_received(), Channel::new_client_message_received(), ServerSession::new_message_received(), new_server_message_received(), Channel::new_server_message_received(), notice_target(), pass_as_is_to_client(), received_network_domain_answer(), ServerSession::send_rejoins(), ServerConnection::session_lost(), Target::sub_channel(), and ~Identity().
00208 { ASSERT(M_client_session != NULL); return *M_client_session; }
ClientSession& Identity::client_session | ( | void | ) | [inline] |
Return the current ClientSession.
Definition at line 211 of file Identity.h.
References ASSERT, and M_client_session.
00211 { ASSERT(M_client_session != NULL); return *M_client_session; }
ServerSession const& Identity::server_session | ( | void | ) | const [inline] |
Return the current ClientSession.
Definition at line 214 of file Identity.h.
References M_primary_server_connection.
Referenced by Target::add_channel(), new_client_message_received(), Channel::new_client_message_received(), ClientSession::new_client_nick_received(), new_server_message_received(), Channel::new_server_message_received(), pass_as_is_to_server(), received_network_domain_answer(), Target::serverside_get_channel(), Target::sub_channel(), and ~Identity().
00214 { return M_primary_server_connection->server_session(); }
ServerSession& Identity::server_session | ( | void | ) | [inline] |
Return the current ClientSession.
Definition at line 217 of file Identity.h.
References M_primary_server_connection.
00217 { return M_primary_server_connection->server_session(); }
boost::shared_ptr< Target > Identity::notice_target | ( | question_nt | number | ) |
Return a target with prefix prefix that is not already in the private network map.
Return a target for ircproxy notices related to question number.
Definition at line 713 of file Identity.cc.
References ClientSession::add_private_target(), ASSERT, ClientSession::client_out_nick(), client_session(), PrivateTarget::do_names_output(), is_channel(), M_private_network, no_related_question, ClientSession::private_targets(), and question_target_name().
Referenced by send_notice().
00714 { 00715 char const* channel_name; 00716 00717 if (number != no_related_question) 00718 { 00719 channel_name = question_target_name(number); 00720 ASSERT(is_channel(channel_name)); 00721 } 00722 00723 while(1) 00724 { 00725 if (number == no_related_question) 00726 channel_name = "¬ices"; 00727 // Is the client already joined? 00728 ClientSession::private_targets_type::iterator iter = client_session().private_targets().find(channel_name); 00729 if (iter != client_session().private_targets().end()) 00730 return iter->second; 00731 if (number == no_related_question) 00732 break; 00733 number = no_related_question; 00734 } 00735 00736 // Create the new NoticeTarget. 00737 NoticeTarget* new_notice_target = new NoticeTarget(client_session(), channel_name, M_private_network); 00738 AllocTag(new_notice_target, channel_name); 00739 // Add it to the private targets map. 00740 boost::shared_ptr<Target> private_target(new_notice_target); 00741 client_session().add_private_target(private_target); 00742 // Have the client join it. 00743 client_session() << ":" << client_session().client_out_nick() << " JOIN " << channel_name << "\r\n"; 00744 new_notice_target->do_names_output(); 00745 00746 return private_target; 00747 }
ServerConnection const& Identity::server_connection | ( | void | ) | const [inline] |
Return the primary server connection object.
Definition at line 226 of file Identity.h.
References M_primary_server_connection.
Referenced by Target::add_channel(), Target::add_joined_nick(), Target::get_joined_nick(), network(), new_client_message_received(), new_server_message_received(), pass_as_is_to_server(), and Authentication::received_nick_and_user().
00226 { return *M_primary_server_connection; }
ServerConnection& Identity::server_connection | ( | void | ) | [inline] |
Return the primary server connection object.
Definition at line 229 of file Identity.h.
References M_primary_server_connection.
00229 { return *M_primary_server_connection; }
void Identity::start_secondary_server_connection | ( | boost::shared_ptr< Server > | new_server | ) | [inline] |
Start a secondary server connection, which will take over the primary once connected.
Definition at line 232 of file Identity.h.
References ASSERT, has_secondary_server_connection(), and M_secondary_server_connection.
00233 { 00234 ASSERT(!has_secondary_server_connection()); 00235 #ifdef CWDEBUG 00236 // Mark that we are about to start handling a secondary connection. 00237 debug::SecondaryConnection dummy(true); 00238 #endif 00239 M_secondary_server_connection.reset(NEW(ServerConnection(this, new_server))); 00240 M_secondary_server_connection->connect(false); 00241 }
void Identity::swap_primary_and_secondary_connection | ( | void | ) | [inline] |
Swap primary and secondary connection.
Definition at line 244 of file Identity.h.
References M_primary_server_connection, and M_secondary_server_connection.
Referenced by ServerSession::new_message_received().
00245 { 00246 std::swap(M_primary_server_connection, M_secondary_server_connection); 00247 M_primary_server_connection->make_primary(); 00248 M_secondary_server_connection->make_secondary(); 00249 }
void Identity::end_secondary_server_connection | ( | void | ) | [inline] |
Terminate the secondary connection.
Definition at line 252 of file Identity.h.
References ASSERT, has_secondary_server_connection(), and M_secondary_server_connection.
00253 { 00254 ASSERT(has_secondary_server_connection()); 00255 #ifdef CWDEBUG 00256 // Mark that we are about to start handling a secondary connection. 00257 debug::SecondaryConnection dummy(true); 00258 #endif 00259 M_secondary_server_connection->disconnect(); // This will result in ServerConnection::session_lost being called, 00260 // which will call destroy_secondary_server_connection(). 00261 }
bool Identity::has_secondary_server_connection | ( | void | ) | const [inline] |
Return true if this identity is associated with a secondary server connection.
Definition at line 271 of file Identity.h.
References M_secondary_server_connection.
Referenced by end_secondary_server_connection(), and start_secondary_server_connection().
00271 { return M_secondary_server_connection.get(); }
boost::shared_ptr<ServerConnection const> Identity::secondary_server_connection | ( | void | ) | const [inline] |
Return the secondary server connection. Only valid if has_secondary_server_connection returns true.
Definition at line 274 of file Identity.h.
References M_secondary_server_connection.
Referenced by ServerSession::new_message_received().
00275 { return boost::const_pointer_cast<ServerConnection const>(M_secondary_server_connection); }
boost::shared_ptr<ServerConnection> Identity::secondary_server_connection | ( | void | ) | [inline] |
Return the secondary server connection. Only valid if has_secondary_server_connection returns true.
Definition at line 278 of file Identity.h.
References M_secondary_server_connection.
00279 { return M_secondary_server_connection; }
Authentication const& Identity::authentication | ( | void | ) | const [inline] |
Return the authentication object.
Definition at line 282 of file Identity.h.
References M_authentication.
Referenced by AuthState::AuthState(), ServerConnection::invisible_event(), and ClientSession::new_client_nick_received().
00282 { return *M_authentication; }
Authentication& Identity::authentication | ( | void | ) | [inline] |
Return the authentication object.
Definition at line 285 of file Identity.h.
References M_authentication.
00285 { return *M_authentication; }
void Identity::send_notice | ( | std::string const & | notice, | |
question_nt | number = no_related_question | |||
) |
Send a notice to the client.
Definition at line 753 of file Identity.cc.
References M_client_session, and notice_target().
Referenced by ServerSession::construct_network_object(), ServerConnection::do_connect(), ServerSession::found_network_name(), ServerSession::network_connection_terminated(), and ServerSession::new_message_received().
00754 { 00755 *M_client_session << ":Leandro PRIVMSG " << notice_target(number)->out_name(*M_client_session) << " :" << notice << "\r\n"; 00756 }
void Identity::received_network_domain_answer | ( | UserAnswerEventType const & | event_type, | |
std::pair< std::string, std::string > | network_domain | |||
) |
Event call back: network domain answer received. Process it.
Definition at line 672 of file Identity.cc.
References UserAnswer::answer(), client_session(), ServerSession::construct_network_object(), DoutEntering, IRCStringCompare(), network_domain_question, server_session(), and ClientSession::user_answer_event_server.
Referenced by ServerSession::found_network_name().
00674 { 00675 DoutEntering(dc::debug, "Identity::received_network_domain_answer(" << event_type); 00676 std::string answer = event_type.answer(); 00677 bool yes = IRCStringCompare(answer, "Yes") == 0; 00678 bool no = IRCStringCompare(answer, "No") == 0; 00679 if (!yes && !no) 00680 { 00681 std::ostringstream the_question; 00682 the_question << "Does the " << network_domain.first << " IRC network use \"" << 00683 network_domain.second << "\" as common domain for all servers (type: Yes|No)?"; 00684 client_session().user_answer_event_server 00685 (UserAnswerRequestData(client_session(), network_domain_question, the_question.str()), 00686 *this, &Identity::received_network_domain_answer, network_domain); 00687 } 00688 else if (no) 00689 server_session().construct_network_object(network_domain.first, ""); 00690 else 00691 server_session().construct_network_object(network_domain.first, network_domain.second); 00692 }
void Identity::pass_as_is_to_server | ( | ClientMessageIn const & | msg | ) |
Write ClientMessageIn msg to the server.
Definition at line 63 of file Identity.cc.
References MessageIn::key(), pass_as_is_to(), real_nick_sent, server_connection(), server_session(), ServerConnection::state(), and THROW_EXCEPTION.
00064 { 00065 bool blocked = true; 00066 switch (msg.key()) 00067 { 00068 using namespace keys; 00069 case WHO: // Query 00070 case WHOIS: // Query 00071 case WHOWAS: // Query 00072 blocked = false; 00073 break; 00074 default: 00075 break; 00076 } 00077 if (blocked && server_connection().state() < real_nick_sent) 00078 THROW_EXCEPTION(FatalError("Message to be passed as-is is blocked!"), 00079 "Identity::pass_as_is_to_server(" << msg << ") called while server connection in state " << server_connection().state() << '!'); 00080 pass_as_is_to(msg, server_session()); 00081 }
void Identity::pass_as_is_to_client | ( | ServerMessageIn const & | msg | ) |
Write ServerMessageIn msg to the client.
Definition at line 87 of file Identity.cc.
References client_session(), and pass_as_is_to().
Referenced by new_server_message_received().
00088 { 00089 pass_as_is_to(msg, client_session()); 00090 }
void Identity::pass_as_is_to | ( | MessageIn const & | msg, | |
std::ostream & | os | |||
) | [private] |
Write MessageIn msg to the ostream os.
Definition at line 40 of file Identity.cc.
References MessageIn::has_prefix(), MessageIn::is_numeric(), MessageIn::numeric(), MessageIn::param(), MessageIn::params_size(), MessageIn::prefix_str(), and MessageIn::uppercase_command().
Referenced by pass_as_is_to_client(), and pass_as_is_to_server().
00041 { 00042 if (msg.has_prefix()) 00043 os << ':' << msg.prefix_str() << ' '; 00044 if (msg.is_numeric()) 00045 os << msg.numeric(); 00046 else 00047 os << msg.uppercase_command(); 00048 int number_of_parameters = msg.params_size(); 00049 for (int param = 0; param < number_of_parameters; ++param) 00050 { 00051 os << ' '; 00052 if (param == number_of_parameters - 1) 00053 os << ':'; 00054 os << msg.param(param); 00055 } 00056 os << "\r\n"; 00057 }
std::ostream& operator<< | ( | std::ostream & | os, | |
Identity const & | identity | |||
) | [friend] |
For debugging purposes. Write a Identity to os.
Definition at line 294 of file debug_ostream_operators.cc.
00295 { 00296 os << "{key:" << identity.M_key; 00297 #ifdef VERBOSE_IDENTITY 00298 #ifdef PRINT_AUTHENTICATION 00299 if (identity.M_authentication.get()) 00300 os << ", authentication:" << *identity.M_authentication.get(); 00301 os << ", server_connection:" << identity.M_server_connection; 00302 if (!identity.M_authpass.empty()) 00303 os << ", authpass:" << identity.M_authpass; 00304 #endif 00305 os << ", private_network:" << identity.M_private_network; 00306 if (identity.M_client_session) 00307 os << ", client_session:" << *identity.M_client_session; 00308 os << ", ident:\"" << identity.M_ident << 00309 "\", hostname:\"" << identity.M_hostname << 00310 "\", real_name:\"" << identity.M_real_name << 00311 "\", network_name:\"" << identity.M_network_name << '"'; 00312 #endif 00313 os << '}'; 00314 return os; 00315 }
std::string Identity::M_key [private] |
The unique identity key as used with the identity map.
Definition at line 60 of file Identity.h.
Referenced by key(), operator<<(), and serialize().
boost::shared_ptr<Authentication> Identity::M_authentication [private] |
Temporary authentication token, or NULL.
Definition at line 61 of file Identity.h.
Referenced by authentication(), new_client_message_received(), and operator<<().
boost::shared_ptr<Nick> Identity::M_mynick [private] |
Pointer to the Nick object representing my own nick.
Definition at line 62 of file Identity.h.
Referenced by Identity(), and mynick().
std::string Identity::M_authpass [private] |
Authentication password.
Definition at line 63 of file Identity.h.
Referenced by authentication_password(), has_authentication_password(), operator<<(), and serialize().
Network Identity::M_private_network [private] |
Fake network, private to this identity.
Definition at line 64 of file Identity.h.
Referenced by notice_target(), operator<<(), and private_network().
ClientSession* Identity::M_client_session [private] |
Pointer to the current client session.
Definition at line 65 of file Identity.h.
Referenced by client_session(), has_client_session(), operator<<(), reset_client_session(), send_notice(), and set_client_session().
std::string Identity::M_ident [private] |
A best-guess for this users ident.
Definition at line 66 of file Identity.h.
Referenced by ident(), new_client_message_received(), operator<<(), and set_ident().
std::string Identity::M_real_hostname [private] |
A best-guess for this users real hostname.
Definition at line 67 of file Identity.h.
Referenced by real_hostname(), and set_real_hostname().
std::string Identity::M_hostname [private] |
A best-guess for this users (cloaked) hostname.
Definition at line 68 of file Identity.h.
Referenced by hostname(), operator<<(), and set_hostname().
std::string Identity::M_real_name [private] |
A best-guess for this users real name.
Definition at line 69 of file Identity.h.
Referenced by new_client_message_received(), operator<<(), real_name(), and set_real_name().
std::string Identity::M_network_name [private] |
The network name that corresponds to this identity.
Definition at line 70 of file Identity.h.
Referenced by network_name(), operator<<(), serialize(), and set_network_name().
boost::shared_ptr<ServerConnection> Identity::M_primary_server_connection [private] |
Our link to some server.
Definition at line 71 of file Identity.h.
Referenced by has_server_session(), server_connection(), server_session(), server_source(), and swap_primary_and_secondary_connection().
boost::shared_ptr<ServerConnection> Identity::M_secondary_server_connection [private] |
Link to a secondary server connection in progress, or NULL when none.
Definition at line 72 of file Identity.h.
Referenced by end_secondary_server_connection(), has_secondary_server_connection(), Identity(), secondary_server_connection(), start_secondary_server_connection(), and swap_primary_and_secondary_connection().
Copyright © 2005-2007 Carlo Wood. All rights reserved. |
---|