From fe54812cd70955f47af4010cedcf26e7ff6b592a Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 22 Jul 2012 19:20:28 -0500 Subject: Add server index --- servers/auth_server_lin/src/auth_conn.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'servers/auth_server_lin/src/auth_conn.cpp') diff --git a/servers/auth_server_lin/src/auth_conn.cpp b/servers/auth_server_lin/src/auth_conn.cpp index e073e12..f3f3474 100644 --- a/servers/auth_server_lin/src/auth_conn.cpp +++ b/servers/auth_server_lin/src/auth_conn.cpp @@ -25,6 +25,7 @@ #include #include +#include #include "auth_conn.h" @@ -39,8 +40,8 @@ struct exit_exception { For every client that connects to the server, the server creates a new instance of this class. */ -AuthSocket::AuthSocket(int sock, TQObject *parent, const char *name) : - TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_stationID(-1), m_bound(false), m_servActive(false), m_servState(0), m_servClientSocket(NULL), m_servClientTimeout(NULL), m_loopTimer(NULL), m_config(static_cast(parent)->m_config), m_database(NULL), m_databaseStationsCursor(NULL), +AuthSocket::AuthSocket(int sock, int serverID, TQObject *parent, const char *name) : + TDEKerberosServerSocket(parent, name), m_criticalSection(0), m_stationID(-1), m_bound(false), m_serverID(serverID), m_servActive(false), m_servState(0), m_servClientSocket(NULL), m_servClientTimeout(NULL), m_loopTimer(NULL), m_config(static_cast(parent)->m_config), m_database(NULL), m_databaseStationsCursor(NULL), m_databaseServicesCursor(NULL), m_databaseServiceTypesCursor(NULL), m_databasePermissionsCursor(NULL), m_databaseActivityCursor(NULL) { @@ -445,6 +446,7 @@ void AuthSocket::commandLoop() { buffer->setValue("username", m_authenticatedUserName); buffer->setValue("realmname", m_authenticatedRealmName); buffer->setValue("logontime", TQDateTime::currentDateTime().toTime_t()); + buffer->setValue("serverid", m_serverID); m_databaseActivityCursor->insert(); ds << TQString("OK"); @@ -578,6 +580,20 @@ AuthServer::AuthServer(TQObject* parent) : exit(1); } + m_serverID = 0; + KCmdLineArgs* const args = KCmdLineArgs::parsedArgs(); + if ((args) && (args->count() > 0)) { + m_serverID = TQString(args->arg(0)).toInt(); + } + + // Delete existing activity entries for this server ID + TQSqlCursor databaseActivityCursor("activity", TRUE, m_database); + databaseActivityCursor.select(TQString("serverid='%1'").arg(m_serverID)); + if (databaseActivityCursor.next()) { + databaseActivityCursor.primeDelete(); + databaseActivityCursor.del(true); + } + if ( !ok() ) { printf("[ERROR] Failed to bind to port 4004\n\r"); exit(1); @@ -675,7 +691,7 @@ void AuthServer::pingSQLServer() { } void AuthServer::newConnection(int socket) { - AuthSocket *s = new AuthSocket(socket, this); + AuthSocket *s = new AuthSocket(socket, m_serverID, this); s->m_remoteHost = s->peerAddress().toString(); printf("[DEBUG] New connection from %s\n\r", s->m_remoteHost.ascii()); connect(s, SIGNAL(connectionClosed()), s, SLOT(deleteLater())); -- cgit v1.2.3