diff options
| author | David Sommerseth <dazo@users.sourceforge.net> | 2008-09-19 16:21:53 +0200 |
|---|---|---|
| committer | David Sommerseth <dazo@users.sourceforge.net> | 2008-09-19 16:21:53 +0200 |
| commit | 54bc224a6c7f282b74db18a740e47a15fb538b74 (patch) | |
| tree | 2b93348cdb248c9629a14439c85d6771d798ad46 /database/sqlite/eurephiadb-sqlite.c | |
| parent | ca36dfb1569a0501df403fa9e2ae3af8d1b63e06 (diff) | |
| parent | 30530b5bd9f901d59df80b363e8751bf993503e4 (diff) | |
Merged in changes from master, tagged as alpha_0.7alpha_0.7
Diffstat (limited to 'database/sqlite/eurephiadb-sqlite.c')
| -rw-r--r-- | database/sqlite/eurephiadb-sqlite.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/database/sqlite/eurephiadb-sqlite.c b/database/sqlite/eurephiadb-sqlite.c index 512bd57..1abcfeb 100644 --- a/database/sqlite/eurephiadb-sqlite.c +++ b/database/sqlite/eurephiadb-sqlite.c @@ -550,6 +550,15 @@ int eDBregister_vpnmacaddr(eurephiaCTX *ctx, eurephiaSESSION *session, const cha return 0; } + // Register MAC address into history table + res = sqlite_query(ctx, "INSERT INTO openvpn_macaddr_history (sessionkey, macaddr) VALUES ('%q','%q')", + session->sessionkey, macaddr); + if( res == NULL ) { + eurephia_log(ctx, LOG_CRITICAL, 0, "Failed to log new MAC address for session"); + return 0; + } + + // Update lastlog to reflect last used MAC address for the session res = sqlite_query(ctx, "UPDATE openvpn_lastlog SET sessionstatus = 2, macaddr = '%q' " " WHERE sessionkey = '%q' AND sessionstatus = 1", macaddr, session->sessionkey); @@ -569,9 +578,10 @@ int eDBregister_vpnmacaddr(eurephiaCTX *ctx, eurephiaSESSION *session, const cha return 1; } + // Register the user as logged out int eDBregister_logout(eurephiaCTX *ctx, eurephiaSESSION *skey, - const char *bytes_sent, const char *bytes_received) + const char *bytes_sent, const char *bytes_received, const char *duration) { dbresult *res = NULL; @@ -582,9 +592,10 @@ int eDBregister_logout(eurephiaCTX *ctx, eurephiaSESSION *skey, res = sqlite_query(ctx, "UPDATE openvpn_lastlog " " SET sessionstatus = 3, logout = CURRENT_TIMESTAMP, " - " bytes_sent = '%i', bytes_received = '%i' " + " bytes_sent = '%i', bytes_received = '%i', session_duration = '%i' " " WHERE sessionkey = '%q' AND sessionstatus = 2", - atoi_nullsafe(bytes_sent), atoi_nullsafe(bytes_received), skey->sessionkey); + atoi_nullsafe(bytes_sent), atoi_nullsafe(bytes_received), + atoi_nullsafe(duration), skey->sessionkey); if( res == NULL ) { eurephia_log(ctx, LOG_CRITICAL, 0, "Could not update lastlog with logout information (%s)", skey->sessionkey); @@ -817,7 +828,7 @@ int eDBdestroy_session(eurephiaCTX *ctx, eurephiaSESSION *session) { // Update session status res = sqlite_query(ctx, "UPDATE openvpn_lastlog " - " SET sessionstatus = 4, session_del = CURRENT_TIMESTAMP " + " SET sessionstatus = 4, session_deleted = CURRENT_TIMESTAMP " " WHERE sessionkey = '%q' AND sessionstatus = 3", session->sessionkey); if( res == NULL ) { eurephia_log(ctx, LOG_CRITICAL, 0, |
