Add version to connection_history.
This commit is contained in:
parent
0700434acb
commit
ed92ba75fe
7 changed files with 12 additions and 9 deletions
|
@ -375,12 +375,12 @@ void dbconn::insert_addon_info(const std::string& instance_version, const std::s
|
|||
}
|
||||
}
|
||||
|
||||
unsigned long long dbconn::insert_login(const std::string& username, const std::string& ip)
|
||||
unsigned long long dbconn::insert_login(const std::string& username, const std::string& ip, const std::string& version)
|
||||
{
|
||||
try
|
||||
{
|
||||
return modify(connection_, "INSERT INTO `"+db_connection_history_table_+"`(USER_NAME, IP) values(lower(?), ?)",
|
||||
username, ip);
|
||||
return modify(connection_, "INSERT INTO `"+db_connection_history_table_+"`(USER_NAME, IP, VERSION) values(lower(?), ?, ?)",
|
||||
username, ip, version);
|
||||
}
|
||||
catch(const mariadb::exception::base& e)
|
||||
{
|
||||
|
|
|
@ -156,7 +156,7 @@ class dbconn
|
|||
/**
|
||||
* @see forum_user_handler::db_insert_login().
|
||||
*/
|
||||
unsigned long long insert_login(const std::string& username, const std::string& ip);
|
||||
unsigned long long insert_login(const std::string& username, const std::string& ip, const std::string& version);
|
||||
|
||||
/**
|
||||
* @see forum_user_handler::db_update_logout().
|
||||
|
|
|
@ -251,8 +251,8 @@ void fuh::db_insert_addon_info(const std::string& instance_version, const std::s
|
|||
conn_.insert_addon_info(instance_version, id, name, type, version, forum_auth, topic_id);
|
||||
}
|
||||
|
||||
unsigned long long fuh::db_insert_login(const std::string& username, const std::string& ip) {
|
||||
return conn_.insert_login(username, ip);
|
||||
unsigned long long fuh::db_insert_login(const std::string& username, const std::string& ip, const std::string& version) {
|
||||
return conn_.insert_login(username, ip, version);
|
||||
}
|
||||
|
||||
void fuh::db_update_logout(unsigned long long login_id) {
|
||||
|
|
|
@ -226,8 +226,9 @@ public:
|
|||
*
|
||||
* @param username The username of who logged in. The username is converted to lower case when inserting in order to allow index usage when querying.
|
||||
* @param ip The ip address of who logged in.
|
||||
* @param version The version of the client that logged in.
|
||||
*/
|
||||
unsigned long long db_insert_login(const std::string& username, const std::string& ip);
|
||||
unsigned long long db_insert_login(const std::string& username, const std::string& ip, const std::string& version);
|
||||
|
||||
/**
|
||||
* Updates the database for when a player logs out.
|
||||
|
|
|
@ -144,7 +144,7 @@ public:
|
|||
virtual void async_test_query(boost::asio::io_service& io_service, int limit) = 0;
|
||||
virtual bool db_topic_id_exists(int topic_id) = 0;
|
||||
virtual void db_insert_addon_info(const std::string& instance_version, const std::string& id, const std::string& name, const std::string& type, const std::string& version, bool forum_auth, int topic_id) = 0;
|
||||
virtual unsigned long long db_insert_login(const std::string& username, const std::string& ip) = 0;
|
||||
virtual unsigned long long db_insert_login(const std::string& username, const std::string& ip, const std::string& version) = 0;
|
||||
virtual void db_update_logout(unsigned long long login_id) = 0;
|
||||
virtual void get_users_for_ip(const std::string& ip, std::ostringstream* out) = 0;
|
||||
virtual void get_ips_for_user(const std::string& username, std::ostringstream* out) = 0;
|
||||
|
|
|
@ -709,7 +709,7 @@ void server::login_client(boost::asio::yield_context yield, socket_ptr socket)
|
|||
registered,
|
||||
client_version,
|
||||
client_source,
|
||||
user_handler_ ? user_handler_->db_insert_login(username, client_address(socket)) : 0,
|
||||
user_handler_ ? user_handler_->db_insert_login(username, client_address(socket), client_version) : 0,
|
||||
default_max_messages_,
|
||||
default_time_period_,
|
||||
is_moderator
|
||||
|
|
|
@ -153,6 +153,7 @@ create table addon_info
|
|||
-- IP: the IP address the login originated from
|
||||
-- LOGIN_TIME: when the user logged in
|
||||
-- LOGOUT_TIME: when the user logged out
|
||||
-- VERSION: the version the user logged in with
|
||||
create table connection_history
|
||||
(
|
||||
LOGIN_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
|
@ -160,6 +161,7 @@ create table connection_history
|
|||
IP VARCHAR(255) NOT NULL,
|
||||
LOGIN_TIME TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
LOGOUT_TIME TIMESTAMP NULL DEFAULT NULL,
|
||||
VERSION VARCHAR(255),
|
||||
PRIMARY KEY (LOGIN_ID)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE INDEX CONNECTION_IP_IDX ON connection_history(IP);
|
||||
|
|
Loading…
Add table
Reference in a new issue