static void Adjust_Counters( CLIENT *Client ) { long count; assert( Client != NULL ); if( Client->type != CLIENT_USER ) return; if( Client->conn_id != NONE ) { /* Local connection */ count = Client_MyUserCount( ); if( count > My_Max_Users ) My_Max_Users = count; } count = Client_UserCount( ); if( count > Max_Users ) Max_Users = count; } /* Adjust_Counters */
/** * Handler for the IRC "PONG" command. * * See RFC 2812, 3.7.3 "Pong message". * * @param Client The client from which this command has been received. * @param Req Request structure with prefix and all parameters. * @returns CONNECTED or DISCONNECTED. */ GLOBAL bool IRC_PONG(CLIENT *Client, REQUEST *Req) { CLIENT *target, *from; CONN_ID conn; #ifndef STRICT_RFC long auth_ping; #endif char *s; assert(Client != NULL); assert(Req != NULL); /* Wrong number of arguments? */ if (Req->argc < 1) { if (Client_Type(Client) == CLIENT_USER) return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG, Client_ID(Client)); else return CONNECTED; } if (Req->argc > 2) { if (Client_Type(Client) == CLIENT_USER) return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command); else return CONNECTED; } /* Forward? */ if (Req->argc == 2 && Client_Type(Client) == CLIENT_SERVER) { target = Client_Search(Req->argv[0]); if (!target) return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG, Client_ID(Client), Req->argv[0]); from = Client_Search(Req->prefix); if (target != Client_ThisServer() && target != from) { /* Ok, we have to forward the message. */ if (!from) return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG, Client_ID(Client), Req->prefix); if (Client_Type(Client_NextHop(target)) != CLIENT_SERVER) s = Client_ID(from); else s = Req->argv[0]; return IRC_WriteStrClientPrefix(target, from, "PONG %s :%s", s, Req->argv[1]); } } /* The connection timestamp has already been updated when the data has * been read from so socket, so we don't need to update it here. */ conn = Client_Conn(Client); #ifndef STRICT_RFC /* Check authentication PING-PONG ... */ auth_ping = Conn_GetAuthPing(conn); if (auth_ping) { LogDebug("AUTH PONG: waiting for token \"%ld\", got \"%s\" ...", auth_ping, Req->argv[0]); if (auth_ping == atoi(Req->argv[0])) { Conn_SetAuthPing(conn, 0); if (Client_Type(Client) == CLIENT_WAITAUTHPING) Login_User(Client); } else if (!IRC_WriteStrClient(Client, "To connect, type /QUOTE PONG %ld", auth_ping)) return DISCONNECTED; } #endif if (Client_Type(Client) == CLIENT_SERVER && Conn_LastPing(conn) == 0) { Log(LOG_INFO, "Synchronization with \"%s\" done (connection %d): %ld seconds [%ld users, %ld channels]", Client_ID(Client), conn, time(NULL) - Conn_GetSignon(conn), Client_UserCount(), Channel_CountVisible(NULL)); Conn_UpdatePing(conn); } else LogDebug("Connection %d: received PONG. Lag: %ld seconds.", conn, time(NULL) - Conn_LastPing(conn)); return CONNECTED; } /* IRC_PONG */