EgtLock 2.5j1 :

- aggiunta gestione chiavi di rete esposte su Internet (tramite inirizzo:porta).
This commit is contained in:
Dario Sassi
2023-10-09 10:35:39 +02:00
parent 7327931e1f
commit cc7630fa70
3 changed files with 22 additions and 15 deletions
+8 -6
View File
@@ -28,9 +28,10 @@
using namespace std ;
//----------------------------------------------------------------------------
static int s_nLockType = KEY_LOCK_TYPE_ANY ;
static bool s_bNetHwKey = false ;
static int s_nNetUserId = 0 ;
static int s_nLockType = KEY_LOCK_TYPE_ANY ;
static bool s_bNetHwKey = false ;
static int s_nNetUserId = 0 ;
static string s_sAddrPort = "" ;
//----------------------------------------------------------------------------
bool
@@ -46,12 +47,13 @@ SetLockType( int nType)
//----------------------------------------------------------------------------
bool
SetNetHwKey( bool bNetHwKey, int nUserId)
SetNetHwKey( bool bNetHwKey, int nUserId, const std::string& sAddrPort)
{
s_bNetHwKey = bNetHwKey ;
if ( s_bNetHwKey) {
s_nLockType = KEY_LOCK_TYPE_HW ;
s_nNetUserId = Clamp( nUserId, 0, 9) ;
s_sAddrPort = sAddrPort ;
}
return true ;
}
@@ -70,7 +72,7 @@ GetLockId( string& sLockId)
switch ( s_nLockType) {
default : // KEY_LOCK_TYPE_ANY
if ( s_bNetHwKey)
return GetNetDongleId( s_nNetUserId, sLockId) ;
return GetNetDongleId( s_nNetUserId, s_sAddrPort, sLockId) ;
else if ( GetDongleId( sLockId))
return true ;
else
@@ -81,7 +83,7 @@ GetLockId( string& sLockId)
if ( ! s_bNetHwKey)
return GetDongleId( sLockId) ;
else
return GetNetDongleId( s_nNetUserId, sLockId) ;
return GetNetDongleId( s_nNetUserId, s_sAddrPort, sLockId) ;
}
}
+9 -4
View File
@@ -21,6 +21,7 @@
using namespace std ;
//----------------------------------------------------------------------------
static string s_sAddrPort = "seriate.egalware.com:15678" ;
static XND_XLT_ENV s_env = nullptr ;
static XND_NET_DATA s_net_data = nullptr ;
static XND_DEVICE_CONTEXT s_dev_ctx = nullptr ;
@@ -40,10 +41,10 @@ static const char* user2_data_blob = "DHn2Cq9uYJKBJUYCRuVyQIz9JWqyWVZU
//----------------------------------------------------------------------------
bool
GetNetDongleId( int nNetUserId, string& sDongleId)
GetNetDongleId( int nNetUserId, const string& sAddrPort, string& sDongleId)
{
if ( s_env == nullptr) {
if ( ! NetDongleConnect( nNetUserId))
if ( ! NetDongleConnect( nNetUserId, sAddrPort))
return false ;
}
// richiamo funzioni di verifica chiave con decifratura RSA 512 di dati generati al volo
@@ -93,7 +94,7 @@ GetNetDongleId( int nNetUserId, string& sDongleId)
//----------------------------------------------------------------------------
bool
NetDongleConnect( int nNetUserId)
NetDongleConnect( int nNetUserId, const string& sAddrPort)
{
// se connessione già aperta, la chiudo per poi riaprirla
if ( s_env != nullptr)
@@ -108,7 +109,11 @@ NetDongleConnect( int nNetUserId)
strcpy_s( (char*)label, XLT_LABEL_SIZE, sLabel.c_str()) ;
memset( label + sLabel.size(), 0x00, sizeof( label) - sLabel.size()) ;
int nStatusND = 0 ;
s_net_data = xnd_net_data_create_resolving_local_search( s_env, XND_DEFAULT_PORT, label, 30000, 0, 0, &nStatusND) ;
if ( &sAddrPort == nullptr || sAddrPort.empty() ||
sAddrPort.find_first_not_of( " \t\r\n") == std::string::npos)
s_net_data = xnd_net_data_create_resolving_local_search( s_env, XND_DEFAULT_PORT, label, 30000, 0, 0, &nStatusND) ;
else
s_net_data = xnd_net_data_create_resolving_addr_port( s_env, s_sAddrPort.c_str(), 0, 30000, &nStatusND) ;
if ( s_net_data == nullptr) {
xnd_xlt_env_release( s_env) ;
return false ;
+5 -5
View File
@@ -1,13 +1,13 @@
//----------------------------------------------------------------------------
// EgalTech 2022-2022
// EgalTech 2022-2023
//----------------------------------------------------------------------------
// File : NetDongleId.h Data : 16.05.22 Versione : 2.4e3
// File : NetDongleId.h Data : 09.10.23 Versione : 2.5j1
// Contenuto : Dichiarazione funzioni locali per gestione/calcolo Id chiave.
//
//
//
// Modifiche : 16.05.22 DS Creazione modulo.
//
// 09.10.23 DS Aggiunto parametro IndirizzoPorta.
//
//----------------------------------------------------------------------------
@@ -16,6 +16,6 @@
#include <string>
//-------------------------------------------------------------------------------
bool GetNetDongleId( int nNetUserId, std::string& sDongleId) ;
bool NetDongleConnect( int nNetUserId) ;
bool GetNetDongleId( int nNetUserId, const std::string& sAddrPort, std::string& sDongleId) ;
bool NetDongleConnect( int nNetUserId, const std::string& sAddrPort) ;
bool NetDongleClose( void) ;