Patch level : 10.0

Files correlati     : authoriz.exe
Ricompilazione Demo : [ ]
Commento            :
Migliorata gestione disconnessioni, soprattutto da parte di programmi mai connessi


git-svn-id: svn://10.65.10.50/branches/R_10_00@22312 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2011-06-23 14:17:15 +00:00
parent 32acfde9b6
commit 42f1e17b4a
2 changed files with 53 additions and 36 deletions

View File

@ -36,7 +36,8 @@ public:
TUserInfo* AddConnection(wxSocketBase& sock, const wxChar* user, int session);
TUserInfo* Find(wxSocketBase& sock, const wxChar* user, int session);
void RemoveConnection(wxSocketBase& sock, const wxChar* user, int session);
void Kill(const wxChar* strUserAtHost);
bool Kill(const wxChar* strUserAtHost);
bool Kill(TUserInfo* ui);
void KillSession(wxSocketBase& sock, int session);
size_t GetCount() const { return size(); }
@ -86,45 +87,54 @@ TUserInfo* TUserTable::Find(wxSocketBase& sock, const wxChar* user, int session)
return (*this)[strUserAtHost];
const wxString strHost = strUserAtHost.After('@');
for( TUsersHashMap::iterator it = begin(); it != end(); ++it )
for (TUsersHashMap::iterator it = begin(); it != end(); ++it)
{
TUserInfo* ui = it->second;
if (ui->m_strHost == strHost)
if (ui != NULL && ui->m_strHost == strHost)
return ui;
}
return NULL;
}
bool TUserTable::Kill(const wxChar* strUserAtHost)
{
const int erased = erase(strUserAtHost);
return erased != 0;
}
bool TUserTable::Kill(TUserInfo* ui)
{
for (TUsersHashMap::iterator it = begin(); it != end(); ++it)
{
if (it->second == ui)
{
erase(it);
return true;
}
}
return false;
}
void TUserTable::RemoveConnection(wxSocketBase& sock, const wxChar* user, int session)
{
TUserInfo* ui = Find(sock, user, session);
if (ui)
if (ui != NULL)
{
ui->m_nPrograms--;
if (ui->m_nPrograms <= 0)
{
const wxString strUserAtHost = BuildKey(sock, user, session);
erase(strUserAtHost);
}
Kill(ui);
}
}
void TUserTable::Kill(const wxChar* strUserAtHost)
{
erase(strUserAtHost);
}
void TUserTable::KillSession(wxSocketBase& sock, int session)
{
while (true)
{
TUserInfo* ui = Find(sock, NULL, session);
if (ui != NULL)
{
const wxString strUserAtHost = BuildKey(sock, ui->m_strName.c_str(), session);
erase(strUserAtHost);
}
Kill(ui);
else
break;
}
@ -343,22 +353,25 @@ void TAuthorizationServer::GenerateIndex(wxString& strFilename)
TXmlItem& tr = title.AddChild("table").SetAttr("width", "40%").AddChild("tr");
TXmlItem& td = tr.AddChild("td").SetAttr("width", "30%");
const bool hard = m_Dongle.hardware() == _dongle_hardlock;
TXmlItem& img = td.AddChild("img");
wxString strModel;
switch (m_Dongle.hardware())
{
case _dongle_aladdin:
img.SetAttr("src", "aladdin.gif");
case _dongle_xsec:
img.SetAttr("src", "xsec.gif");
strModel = wxT("XSec");
break;
case _dongle_hardlock:
img.SetAttr("src", "hardlock.gif");
strModel = wxT("Hardlock");
break;
default:
img.SetAttr("src", "eutron.gif");
strModel = wxT("Eutron");
break;
}
tr.AddChild("td").SetAttr("align", "center").AddChild("h1") << (hard ? "Hardlock EYE" : "Eutron Smartkey");
tr.AddChild("td").SetAttr("align", "center").AddChild("h1") << strModel;
}
else
{
@ -494,20 +507,23 @@ void TAuthorizationServer::GenerateUsers(wxString& strFilename)
th.AddChild("th").SetAttr("width", "15%") << "Kill";
int nUser = 0;
for( TUsersHashMap::const_iterator it = m_Users.begin(); it != m_Users.end(); ++it )
for (TUsersHashMap::const_iterator it = m_Users.begin(); it != m_Users.end(); ++it )
{
const TUserInfo* ui = it->second;
TXmlItem& tr = table.AddChild("tr");
tr.AddChild("td").SetAttr("align", "right") << wxString::Format("%d", ++nUser);
tr.AddChild("td").AddChild("b") << ui->m_strName;
tr.AddChild("td") << ui->m_strHost;
tr.AddChild("td").SetAttr("align", "right") << wxString::Format("%u", ui->m_nPrograms);
tr.AddChild("td").SetAttr("align", "center") << ui->m_time.Format("%H:%M:%S");
tr.AddChild("td").SetAttr("align", "center") << ui->m_time.Format("%d-%m-%Y");
if (ui != NULL)
{
TXmlItem& tr = table.AddChild("tr");
tr.AddChild("td").SetAttr("align", "right") << wxString::Format("%d", ++nUser);
tr.AddChild("td").AddChild("b") << ui->m_strName;
tr.AddChild("td") << ui->m_strHost;
tr.AddChild("td").SetAttr("align", "right") << wxString::Format("%u", ui->m_nPrograms);
tr.AddChild("td").SetAttr("align", "center") << ui->m_time.Format("%H:%M:%S");
tr.AddChild("td").SetAttr("align", "center") << ui->m_time.Format("%d-%m-%Y");
wxString strKey; strKey << ui->m_strName << wxT("@") << ui->m_strHost;
wxString href = wxString::Format("kill.cgi?%s", strKey.c_str());
AddLinkButton(tr.AddChild("td"), "Kill", href).SetAttr("width", "100%");
wxString strKey; strKey << ui->m_strName << wxT("@") << ui->m_strHost;
wxString href = wxString::Format("kill.cgi?%s", strKey.c_str());
AddLinkButton(tr.AddChild("td"), "Kill", href).SetAttr("width", "100%");
}
}
body.AddChild("br");
@ -986,8 +1002,9 @@ bool TAuthorizationServer::ProcessCommand(wxString cmd, wxSocketBase& outs)
if (cmd.StartsWith("UserLogout"))
{
bool ok = ProcessUserLogout(cmd, outs);
return ReturnBool(outs, ok);
ReturnBool(outs, true); // ATTENZIONE! Prima rispondo ok ...
ProcessUserLogout(cmd, outs); // ... poi chiudo la connessione
return true;
}
if (cmd.StartsWith("DongleInfo"))

View File

@ -5,8 +5,8 @@
#include <wx/datetime.h>
#endif
enum TDongleHardware { _dongle_unknown, _dongle_hardlock, _dongle_eutron, _dongle_aladdin };
enum TDongleType { _no_dongle, _user_dongle, _developer_dongle, _aga_dongle, _prassi_dongle, _procom_dongle };
enum TDongleHardware { _dongle_unknown, _dongle_hardlock, _dongle_eutron, _dongle_xsec };
enum TDongleType { _no_dongle, _user_dongle, _developer_dongle, _aga_dongle, _prassi_dongle };
enum { MAX_DONGLE_ASSIST = 8 };
class TBit_array : public wxObject