Patch level : 05.054

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Corretto frontend che sbagliava a leggere i moduli attivi dalla
chiave hardlock.  Ora stampa anche i codici dei moduli attivati.


git-svn-id: svn://10.65.10.50/trunk@7446 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-11-13 14:54:23 +00:00
parent 062476b25d
commit 6e30f9c6dd
11 changed files with 168 additions and 77 deletions

View File

@ -6,8 +6,8 @@
///////////////////////////////////////////////////////////
// TPrassiConnection
TPrassiConnection::TPrassiConnection(TLanManager* lm, DWORD id)
: TConnection(lm, id), m_nFirm(0)
TPrassiConnection::TPrassiConnection(TLanManager* lm, DWORD id, const char* name)
: TConnection(lm, id), m_strPeer(name), m_nFirm(0)
{
}
@ -26,7 +26,7 @@ BOOL TPrassiConnection::Trace(int level, const char* str) const
}
catch(...)
{
user = "";
user = "GUEST";
}
CString trc;
trc.Format("%-8s %s", user, str);

View File

@ -12,6 +12,7 @@ class TPrassiConnection : public TConnection
{
CString m_strUser;
CString m_strApp;
CString m_strPeer;
int m_nFirm;
protected:
@ -32,8 +33,10 @@ public:
BOOL SetFirm(int nFirm);
const CString& User() const { return m_strUser; }
const CString& Application() const { return m_strApp; }
const CString& PeerName() const { return m_strPeer; }
TPrassiConnection(TLanManager* lm, DWORD id);
TPrassiConnection(TLanManager* lm, DWORD id, const char* name);
virtual ~TPrassiConnection();
};

View File

@ -3,11 +3,20 @@
#include "connect.h"
#include "server.h"
int CountUser(TConnection& conn, void* pJolly)
int CountPeerUser(TConnection& conn, void* pJolly)
{
const CString& user = *(CString*)pJolly;
const CString& strPeerUser = *(CString*)pJolly;
const int at = strPeerUser.Find('@');
const CString strUser = strPeerUser.Left(at);
const TPrassiConnection& c = (TPrassiConnection&)conn;
return user.CompareNoCase(c.User()) == 0;
CString pu = c.User();
if (pu != strUser)
return 0;
pu += "@";
pu += c.PeerName();
return strPeerUser != pu;
}
BOOL TPrassiConnection::DoUserLogin(const CString& user,
@ -18,24 +27,25 @@ BOOL TPrassiConnection::DoUserLogin(const CString& user,
if (ok)
{
m_strUser = "";
int total = Server().ForEachConnection(CountUser, (void *)&user);
if (app == "ba0100")
{
if (user == "******")
ok = !pwd.IsEmpty();
else
ok = total == 0 && !pwd.IsEmpty();
if (user != "******" && user != "GUEST")
{
CString security = GetIniString("Server", "Security", "0");
if (atoi(security) > 0)
{
CString strPeerUser = user; strPeerUser.MakeUpper();
strPeerUser += "@";
strPeerUser += PeerName();
int total = Server().ForEachConnection(CountPeerUser,
(void*)&strPeerUser);
ok = total == 0;
}
}
else
{
ok = total == 1;
}
if (ok)
if (ok)
{
m_strUser = user; m_strUser.MakeUpper();
m_strApp = app;
m_strApp = app; m_strApp.MakeUpper();
}
}
return ReturnBool(ok);

Binary file not shown.

View File

@ -17,9 +17,9 @@ Class4=CMainFrame
ResourceCount=3
Resource1=IDR_MAINFRAME
Class5=CAboutDlg
Resource2=IDD_ABOUTBOX
Resource2=IDD_STATUS
Class6=CStatusDlg
Resource3=IDD_STATUS
Resource3=IDD_ABOUTBOX
[CLS:CFrontEndApp]
Type=0
@ -124,12 +124,14 @@ CommandCount=6
[DLG:IDD_STATUS]
Type=1
Class=CStatusDlg
ControlCount=5
ControlCount=7
Control1=IDOK,button,1342242817
Control2=IDC_STATIC,static,1342308352
Control3=IDC_USERS,static,1342308352
Control3=IDC_USERS,static,1342312448
Control4=IDC_STATIC,static,1342308352
Control5=IDC_CONNECTIONS,static,1342308352
Control5=IDC_CONNECTIONS,static,1342312448
Control6=IDC_STATIC,static,1342308352
Control7=IDC_PEERS,static,1342312448
[CLS:CStatusDlg]
Type=0

View File

@ -96,6 +96,9 @@ BOOL CFrontEndApp::InitInstance()
{
AfxMessageBox("Non e' possibile attivare due server contemporaneamente!",
MB_ICONEXCLAMATION);
#ifndef NDEBUG
ok = StartServer();
#endif
}
return ok;

View File

@ -160,7 +160,7 @@ CAPTION "Server PRASSI"
FONT 8, "MS Sans Serif"
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,7,7,20,20
LTEXT "Server Versione 1.0",IDC_STATIC,49,7,119,10,SS_NOPREFIX |
LTEXT "Server Versione 1.5",IDC_STATIC,49,7,119,10,SS_NOPREFIX |
SS_SUNKEN
LTEXT "Disk space",IDC_DISK_SPACE,84,54,84,9,SS_SUNKEN
DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP
@ -170,16 +170,18 @@ BEGIN
LTEXT "Disco",IDC_STATIC,50,55,19,8
END
IDD_STATUS DIALOGEX 0, 0, 152, 71
IDD_STATUS DIALOGEX 0, 0, 152, 78
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Utenti del sistema"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,50,45,50,14
LTEXT "Numero connessioni",IDC_STATIC,7,23,84,8
LTEXT "0",IDC_USERS,111,7,34,10,0,WS_EX_RIGHT
LTEXT "Numero utenti",IDC_STATIC,7,7,84,8
LTEXT "0",IDC_CONNECTIONS,111,20,34,10,0,WS_EX_RIGHT
DEFPUSHBUTTON "OK",IDOK,50,55,50,14
LTEXT "Numero connessioni",IDC_STATIC,7,40,84,8
LTEXT "0",IDC_USERS,111,23,34,10,SS_SUNKEN,WS_EX_RIGHT
LTEXT "Numero utenti",IDC_STATIC,7,25,84,8
LTEXT "0",IDC_CONNECTIONS,111,38,34,10,SS_SUNKEN,WS_EX_RIGHT
LTEXT "Numero stazioni di lavoro",IDC_STATIC,7,9,84,8
LTEXT "0",IDC_PEERS,111,7,34,10,SS_SUNKEN,WS_EX_RIGHT
END
@ -190,8 +192,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1998,1,3,75
PRODUCTVERSION 1998,1,3,0
FILEVERSION 1998,1,5,75
PRODUCTVERSION 1998,1,5,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -208,12 +210,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "AGA\0"
VALUE "FileDescription", "Network Dongle Server \0"
VALUE "FileVersion", "1998, 1, 3, 75\0"
VALUE "FileVersion", "1998, 1, 5, 75\0"
VALUE "InternalName", "FRONTEND\0"
VALUE "LegalCopyright", "Copyright © 1998\0"
VALUE "OriginalFilename", "FRONTEND.EXE\0"
VALUE "ProductName", "FRONTEND Applicazione\0"
VALUE "ProductVersion", "1998, 1, 3, 0\0"
VALUE "ProductVersion", "1998, 1, 5, 0\0"
END
END
BLOCK "VarFileInfo"
@ -246,7 +248,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 145
TOPMARGIN, 7
BOTTOMMARGIN, 59
BOTTOMMARGIN, 69
END
END
#endif // APSTUDIO_INVOKED

View File

@ -15,6 +15,7 @@
#define IDC_USERS 1008
#define IDC_GRID 1009
#define IDC_CONNECTIONS 1009
#define IDC_PEERS 1010
#define stc32 0x045f
#define ID_BUTTON32772 32772
#define ID_VIEW_TRACE 32773

View File

@ -38,9 +38,9 @@ static char THIS_FILE[] = __FILE__;
// @rdesc Ritorna il valore corrispondente alla chiave appartenente
// ad una sezione del file di configurazione
static CString GetIniString(LPCSTR sec, // @parm Sezione
LPCSTR key, // @parm Chiave
LPCSTR def) // @parm Valore di default
CString GetIniString(LPCSTR sec, // @parm Sezione
LPCSTR key, // @parm Chiave
LPCSTR def) // @parm Valore di default
{
// Nome del file .ini
static CString m_strIniFile;
@ -111,6 +111,7 @@ BOOL TDongleServer::ReadHardlockWords(unsigned short reg,
{
for (unsigned short n = 0; n < num; n++)
HL_READ(reg+n, EYECAST &data[n]);
HL_CODE(EYECAST data, 1);
}
return ok;
}
@ -124,17 +125,16 @@ BOOL TDongleServer::HardlockLogin()
unsigned char ref[9]; strcpy((char*)ref, REFKEY);
unsigned char ver[9]; strcpy((char*)ver, VERKEY);
const int status = HL_LOGIN(26952, LOCAL_DEVICE, ref, ver);
const int status = HL_LOGIN(26952, LOCAL_DEVICE, ref, ver);
Trace(-1, "Login Hardlock %s: %d",
status == STATUS_OK ? "OK" : "FALLITO", status);
_SerNo = 0xFFFF;
if (status == STATUS_OK)
if (status == STATUS_OK)
{
Word Val[4] = { 0, 0, 0, 0 };
ReadHardlockWords(0, 4, Val);
HL_CODE(EYECAST Val, 1);
if (Val[0] == 0xFAE8)
_SerNo = Val[1];
else
@ -143,7 +143,6 @@ BOOL TDongleServer::HardlockLogin()
if (_SerNo != 0)
{
ReadHardlockWords(60, 4, Val);
HL_CODE(EYECAST Val, 1);
_AssistanceYear = Val[0];
_MaxUsers = Val[1];
@ -151,14 +150,16 @@ BOOL TDongleServer::HardlockLogin()
for (unsigned short reg = 48; reg < 60; reg += 4)
{
ReadHardlockWords(reg, 4, Val);
HL_CODE(EYECAST Val, 1);
Val[0] ^= _SerNo;
Val[1] ^= _SerNo;
Val[2] ^= _SerNo;
memcpy(&_int_tab[index], Val, 3);
index += 3;
}
}
}
return status == STATUS_OK;
return status == STATUS_OK;
}
BOOL TDongleServer::EutronLogin()
@ -167,45 +168,44 @@ BOOL TDongleServer::EutronLogin()
memset(&_Eutron, 0, sizeof(_Eutron));
_Eutron.net_command = NET_KEY_OPEN;
const char* labels[2] = { "AGA.CAMPO", "2699DP" };
const char* labels[2] = { "AGA.CAMPO", "25EBAI" };
for (int k = 0; k < 2; k++)
{
memset(_Eutron.label, 0, LABEL_LENGTH);
memcpy(_Eutron.label, labels[k], strlen(labels[k]));
memset(_Eutron.password, 0, PASSWORD_LENGTH);
if (k == 0)
{
char pwd[PASSWORD_LENGTH];
Encode(labels[k], pwd);
memcpy(_Eutron.password, pwd, strlen(pwd));
}
if (k == 0)
{
char pwd[PASSWORD_LENGTH];
Encode(labels[k], pwd);
memcpy(_Eutron.password, pwd, strlen(pwd));
}
smartlink(&_Eutron);
ok = _Eutron.status == ST_OK;
if (ok)
{
if (k == 1)
_SerNo = 0;
if (k == 1)
_SerNo = 0;
break;
}
}
Trace(-1, "Login Eutron %s: %d",
ok ? "OK" : "FALLITO", _Eutron.status);
Trace(-1, "Login Eutron %s: %d", ok ? "OK" : "FALLITO", _Eutron.status);
if (ok && _SerNo != 0)
{
TEutronHeader eh;
if (ReadEutronWords(0, sizeof(TEutronHeader)/2, (unsigned short*)&eh))
{
char serno[16];
strncpy(serno, eh._serno, 8);
serno[8] = '\0';
_SerNo = (unsigned long)atol(serno);
if (eh._max_users > 0)
{
_MaxUsers = eh._max_users;
_AssistanceYear = eh._year_assist;
ReadEutronWords(16, 16, _int_tab);
}
char serno[16];
strncpy(serno, eh._serno, 8);
serno[8] = '\0';
_SerNo = (unsigned long)atol(serno);
if (eh._max_users > 0)
{
_MaxUsers = eh._max_users;
_AssistanceYear = eh._year_assist;
ReadEutronWords(16, 16, _int_tab);
}
}
}
@ -237,6 +237,32 @@ BOOL TDongleServer::Login()
Trace(-1, "Numero di serie %u", _SerNo);
Trace(-1, "Anno assistenza %u", _AssistanceYear);
Trace(-1, "Numero utenti %u", _MaxUsers);
CString modules = "Moduli attivi: ";
if (_SerNo > 0 && _SerNo != 0xFFFF)
{
for (int n = 0; n < MAX_MODULES; n++)
{
const unsigned short index = n / 16;
if (index < 4)
{
if ((_int_tab[index] >> (n % 16)) & 0x1)
{
char buff[24];
sprintf(buff, "%d ", n+1);
modules += buff;
}
}
}
}
else
{
if (_SerNo == 0)
modules += "Tutti";
else
modules += "Nessuno";
}
Trace(-1, modules);
}
return ok;
}
@ -270,23 +296,30 @@ BOOL TDongleServer::OnConnect(const CString& topic)
TConnection* TDongleServer::OnCreateConnection(DWORD id)
{
TConnection* c = NULL;
if (Users() < MaxUsers())
CString strPeer;
GetPeerName(id, strPeer);
const int n = GetPeerConnections(strPeer);
if (n > 0 || Peers() < MaxUsers())
{
Trace(0, "Connecting %lu", id);
c = new TPrassiConnection(this, id);
Trace(0, "Connecting %lu from %s", id, strPeer);
c = new TPrassiConnection(this, id, strPeer);
}
else
Trace(0, "Refusing Connection %lu", id);
Trace(0, "Refusing Connection %lu from %s", id, strPeer);
return c;
}
BOOL TDongleServer::OnRemoveConnection(DWORD id)
{
Trace(0, "Disconnecting %lu", id);
CString strPeer;
GetPeerName(id, strPeer);
Trace(0, "Disconnecting %lu from %s", id, strPeer);
return BASE_SERVER::OnRemoveConnection(id);
}
int CountUsers(TConnection& conn, void* pJolly)
static int CountUsers(TConnection& conn, void* pJolly)
{
CMapStringToOb& users = *(CMapStringToOb*)pJolly;
const TPrassiConnection& c = (TPrassiConnection&)conn;
@ -297,7 +330,6 @@ int CountUsers(TConnection& conn, void* pJolly)
return ok;
}
unsigned short TDongleServer::Users() const
{
CMapStringToOb u;
@ -306,6 +338,37 @@ unsigned short TDongleServer::Users() const
return nTotal;
}
static int CountPeerConnections(TConnection& conn, void* pJolly)
{
const CString& name = *(const CString*)pJolly;
const TPrassiConnection& c = (TPrassiConnection&)conn;
return c.PeerName() == name;
}
int TDongleServer::GetPeerConnections(const CString& strPeer) const
{
int nTotal = ((TDongleServer*)this)->ForEachConnection(CountPeerConnections, (void*)&strPeer);
return nTotal;
}
static int CountPeers(TConnection& conn, void* pJolly)
{
CMapStringToOb& users = *(CMapStringToOb*)pJolly;
const TPrassiConnection& c = (TPrassiConnection&)conn;
const CString& name = c.PeerName();
users.SetAt(name, NULL);
return 1;
}
unsigned short TDongleServer::Peers() const
{
CMapStringToOb u;
((TDongleServer*)this)->ForEachConnection(CountPeers, &u);
unsigned short nTotal = (unsigned short)u.GetCount();
return nTotal;
}
TDongleServer::TDongleServer()
: BASE_SERVER("DONGLE")
{

View File

@ -10,8 +10,8 @@
#ifndef __NETSOCK_H__
#include "NetSock.h"
#define BASE_SERVER TSocketServer
#endif
#define BASE_SERVER TSocketServer
/////////////////////////////////////////////////////////////////////////////
// TDongleServer
@ -36,6 +36,8 @@ protected:
BOOL ReadHardlockWords(unsigned short reg, unsigned short num, unsigned short* data);
BOOL ReadEutronWords(unsigned short reg, unsigned short num, unsigned short* data);
int GetPeerConnections(const CString& strPeer) const;
public:
unsigned short SerialNumber() const
{ return _SerNo; }
@ -50,11 +52,14 @@ public:
{ return _MaxUsers; }
unsigned short Users() const;
unsigned short Peers() const;
TDongleServer();
virtual ~TDongleServer();
};
CString GetIniString(LPCSTR sec, LPCSTR key, LPCSTR def);
BOOL StartServer();
TDongleServer& GetServer();
BOOL StopServer();

View File

@ -47,8 +47,10 @@ BOOL CStatusDlg::OnInitDialog()
CDialog::OnInitDialog();
TDongleServer& srv = GetServer();
const int nPeers = srv.Peers();
const int nUsers = srv.Users();
const int nConns = srv.Connections();
SetDlgItemInt(IDC_PEERS, nPeers);
SetDlgItemInt(IDC_USERS, nUsers);
SetDlgItemInt(IDC_CONNECTIONS, nConns);