Add a quit reason to the log messages printed by !log.
This commit is contained in:
parent
1f24bd6812
commit
4666311516
|
@ -459,7 +459,7 @@ static int command_log(struct hub_info* hub, struct hub_user* user, struct hub_c
|
|||
|
||||
if (show)
|
||||
{
|
||||
sprintf(tmp, "* %s %s, %s (%s)", get_timestamp(log->time), log->cid, log->nick, ip_convert_to_string(&log->addr));
|
||||
sprintf(tmp, "* %s %s, %s [%s] - %s", get_timestamp(log->time), log->cid, log->nick, ip_convert_to_string(&log->addr), user_get_quit_reason_string(log->reason));
|
||||
send_message(hub, user, tmp);
|
||||
}
|
||||
log = (struct hub_logout_info*) list_get_next(messages);
|
||||
|
|
|
@ -995,7 +995,6 @@ void hub_disconnect_user(struct hub_info* hub, struct hub_user* user, int reason
|
|||
}
|
||||
else
|
||||
{
|
||||
user->quit_reason = quit_unknown;
|
||||
hub_schedule_destroy_user(hub, user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ struct hub_logout_info
|
|||
char cid[MAX_CID_LEN+1];
|
||||
char nick[MAX_NICK_LEN+1];
|
||||
struct ip_addr_encap addr;
|
||||
int reason;
|
||||
enum user_quit_reason reason;
|
||||
};
|
||||
|
||||
struct hub_info
|
||||
|
@ -358,5 +358,6 @@ extern void hub_disconnect_user(struct hub_info* hub, struct hub_user* user, int
|
|||
*/
|
||||
extern void hub_logout_log(struct hub_info* hub, struct hub_user* user);
|
||||
|
||||
|
||||
#endif /* HAVE_UHUB_HUB_H */
|
||||
|
||||
|
|
|
@ -89,32 +89,8 @@ void on_nick_change(struct hub_info* hub, struct hub_user* u, const char* nick)
|
|||
|
||||
void on_logout_user(struct hub_info* hub, struct hub_user* user)
|
||||
{
|
||||
const char* reason = "";
|
||||
|
||||
/* These are used for logging purposes */
|
||||
switch (user->quit_reason)
|
||||
{
|
||||
case quit_disconnected: reason = "disconnected"; break;
|
||||
case quit_kicked: reason = "kicked"; break;
|
||||
case quit_banned: reason = "banned"; break;
|
||||
case quit_timeout: reason = "timeout"; break;
|
||||
case quit_send_queue: reason = "send queue"; break;
|
||||
case quit_memory_error: reason = "out of memory"; break;
|
||||
case quit_socket_error: reason = "socket error"; break;
|
||||
case quit_protocol_error: reason = "protocol error"; break;
|
||||
case quit_logon_error: reason = "login error"; break;
|
||||
case quit_hub_disabled: reason = "hub disabled"; break;
|
||||
case quit_ghost_timeout: reason = "ghost"; break;
|
||||
default:
|
||||
if (hub->status == hub_status_shutdown)
|
||||
reason = "hub shutdown";
|
||||
else
|
||||
reason = "unknown error";
|
||||
break;
|
||||
}
|
||||
|
||||
const char* reason = user_get_quit_reason_string(user->quit_reason);
|
||||
log_user_logout(user, reason);
|
||||
hub_logout_log(hub, user);
|
||||
user->quit_reason = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -351,4 +351,25 @@ void user_set_timeout(struct hub_user* user, int seconds)
|
|||
evtimer_add(&user->net.timeout, &timeout);
|
||||
}
|
||||
|
||||
const char* user_get_quit_reason_string(enum user_quit_reason reason)
|
||||
{
|
||||
switch (reason)
|
||||
{
|
||||
case quit_unknown: return "unknown"; break;
|
||||
case quit_disconnected: return "disconnected"; break;
|
||||
case quit_kicked: return "kicked"; break;
|
||||
case quit_banned: return "banned"; break;
|
||||
case quit_timeout: return "timeout"; break;
|
||||
case quit_send_queue: return "send queue"; break;
|
||||
case quit_memory_error: return "out of memory"; break;
|
||||
case quit_socket_error: return "socket error"; break;
|
||||
case quit_protocol_error: return "protocol error"; break;
|
||||
case quit_logon_error: return "login error"; break;
|
||||
case quit_hub_disabled: return "hub disabled"; break;
|
||||
case quit_ghost_timeout: return "ghost"; break;
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -70,6 +70,9 @@ enum user_quit_reason
|
|||
quit_ghost_timeout = 11, /** The user is a ghost, and trying to login from another connection */
|
||||
};
|
||||
|
||||
/** Returns an apropriate string for the given quit reason */
|
||||
extern const char* user_get_quit_reason_string(enum user_quit_reason);
|
||||
|
||||
struct hub_user_info
|
||||
{
|
||||
sid_t sid; /** session ID */
|
||||
|
@ -117,7 +120,7 @@ struct hub_user
|
|||
struct adc_message* info; /** ADC 'INF' message (broadcasted to everyone joining the hub) */
|
||||
struct hub_info* hub; /** The hub instance this user belong to */
|
||||
struct hub_user_limits limits; /** Data used for limitation */
|
||||
int quit_reason; /** Quit reason (see user_quit_reason) */
|
||||
enum user_quit_reason quit_reason; /** Quit reason (see user_quit_reason) */
|
||||
|
||||
};
|
||||
|
||||
|
@ -282,6 +285,8 @@ extern void user_reset_last_write(struct hub_user* user);
|
|||
*/
|
||||
extern void user_reset_last_read(struct hub_user* user);
|
||||
|
||||
|
||||
|
||||
#endif /* HAVE_UHUB_USER_H */
|
||||
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ int uman_init(struct hub_info* hub)
|
|||
|
||||
users->list = list_create();
|
||||
users->sids = sid_pool_create(net_get_max_sockets());
|
||||
|
||||
|
||||
if (!users->list)
|
||||
{
|
||||
list_destroy(users->list);
|
||||
|
|
Loading…
Reference in New Issue