Skip to content

Commit

Permalink
Merge with our internal repo
Browse files Browse the repository at this point in the history
FC - FC communication can use OpenSSL now
One SQLLibrary base structure created, which give us possiblity to write and use other db.libs
User bandwith added
Code cleaning
  • Loading branch information
Pawel Stefanski committed Sep 11, 2017
1 parent 7f2d75a commit 34ce679
Show file tree
Hide file tree
Showing 85 changed files with 1,943 additions and 1,203 deletions.
36 changes: 18 additions & 18 deletions authmods/fcdb/fcdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,20 +260,20 @@ int UpdatePassword( struct AuthMod *l, Http *r, User *usr, char *pass )
usr->u_Password = StringDuplicate( pass );

SystemBase *sb = (SystemBase *)l->sb;
MYSQLLibrary *sqlLib = sb->LibraryMYSQLGet( sb );
SQLLibrary *sqlLib = sb->LibrarySQLGet( sb );
if( sqlLib != NULL )
{
char temptext[ 2048 ];

sqlLib->SNPrintF( sqlLib, temptext, 2048, "UPDATE `FUser` f SET f.Password = '%s' WHERE`ID` = '%ld'", pass, usr->u_ID );

MYSQL_RES *res = sqlLib->Query( sqlLib, temptext );
void *res = sqlLib->Query( sqlLib, temptext );
if( res != NULL )
{
sqlLib->FreeResult( sqlLib, res );
}

sb->LibraryMYSQLDrop( sb, sqlLib );
sb->LibrarySQLDrop( sb, sqlLib );
}
}

Expand All @@ -287,7 +287,7 @@ int UpdatePassword( struct AuthMod *l, Http *r, User *usr, char *pass )
* @param tmpusr pointer to User structure which will be checked
* @return TRUE when success, otherwise FALSE
*/
FBOOL isAPIUser( MYSQLLibrary *sqlLib, User *tmpusr )
FBOOL isAPIUser( SQLLibrary *sqlLib, User *tmpusr )
{
// If we are not an API user:
return tmpusr->u_IsAPI;
Expand Down Expand Up @@ -569,7 +569,7 @@ UserSession *Authenticate( struct AuthMod *l, Http *r, struct UserSession *logse
SystemBase *sb = (SystemBase *)l->sb;

DEBUG("[FCDB] SB %p\n", sb );
MYSQLLibrary *sqlLib = sb->LibraryMYSQLGet( sb );
SQLLibrary *sqlLib = sb->LibrarySQLGet( sb );
if( sqlLib != NULL )
{
FBOOL testAPIUser = isAPIUser( sqlLib, tmpusr );
Expand All @@ -578,7 +578,7 @@ UserSession *Authenticate( struct AuthMod *l, Http *r, struct UserSession *logse
if( uses->us_SessionID == NULL || testAPIUser == FALSE )
{
DEBUG( "[FCDB] : We got a response on: \nAUTHENTICATE: SessionID = %s\n", uses->us_SessionID ? uses->us_SessionID : "No session id" );
DEBUG("\n\n\n1============================================================ tmiest %lld usertime %lld logouttst %lld\n\
DEBUG("\n\n\n1============================================================ tmiest %ld usertime %ld logouttst %d\n\
==========================================================================\n", timestamp, uses->us_LoggedTime , REMOVE_SESSIONS_AFTER_TIME);

//char tmpQuery[ 512 ];
Expand Down Expand Up @@ -611,7 +611,7 @@ UserSession *Authenticate( struct AuthMod *l, Http *r, struct UserSession *logse
DEBUG("[FCDB] Update filesystems\n");
uses->us_LoggedTime = timestamp;

sb->LibraryMYSQLDrop( sb, sqlLib );
sb->LibrarySQLDrop( sb, sqlLib );
// TODO: Generate sessionid the first time if it is empty!!
INFO("Auth return user %s with sessionid %s\n", tmpusr->u_Name, uses->us_SessionID );
if( tmpusr != NULL && userFromDB == TRUE ){ UserDelete( tmpusr ); tmpusr = NULL; }
Expand All @@ -628,7 +628,7 @@ UserSession *Authenticate( struct AuthMod *l, Http *r, struct UserSession *logse
if( uses->us_SessionID == NULL || !strlen( uses->us_SessionID ) )
{
DEBUG("\n\n\n============================================================\n \
user name %s current timestamp %%lld login time %lld logout time %lld\n\
user name %s current timestamp %ld login time %ld logout time %d\n\
============================================================\n", tmpusr->u_Name, timestamp, uses->us_LoggedTime , REMOVE_SESSIONS_AFTER_TIME);

char *hashBase = MakeString( 255 );
Expand All @@ -642,13 +642,13 @@ UserSession *Authenticate( struct AuthMod *l, Http *r, struct UserSession *logse
}
uses->us_SessionID = hashBase;
}
sb->LibraryMYSQLDrop( sb, sqlLib );
sb->LibrarySQLDrop( sb, sqlLib );
DEBUG( "[FCDB] AUTHENTICATE: We found an API user! sessionid=%s\n", uses->us_SessionID );
if( tmpusr != NULL && userFromDB == TRUE ){ UserDelete( tmpusr ); tmpusr = NULL; }
goto loginok;
}
}
sb->LibraryMYSQLDrop( sb, sqlLib );
sb->LibrarySQLDrop( sb, sqlLib );
}
if( tmpusr != NULL && userFromDB == TRUE ){ UserDelete( tmpusr ); tmpusr = NULL; }
goto loginfail;
Expand Down Expand Up @@ -685,7 +685,7 @@ void Logout( struct AuthMod *l, Http *r, char *name )
SystemBase *sb = (SystemBase *)l->sb;
UserSession *users = sb->sl_UserSessionManagerInterface.USMGetSessionBySessionID( sb->sl_USM, name );

MYSQLLibrary *sqlLib = sb->LibraryMYSQLGet( sb );
SQLLibrary *sqlLib = sb->LibrarySQLGet( sb );
if( sqlLib != NULL )
{
char tmpQuery[ 1024 ];
Expand All @@ -694,7 +694,7 @@ void Logout( struct AuthMod *l, Http *r, char *name )

sqlLib->QueryWithoutResults( sqlLib, tmpQuery );

sb->LibraryMYSQLDrop( sb, sqlLib );
sb->LibrarySQLDrop( sb, sqlLib );
}
}

Expand All @@ -714,7 +714,7 @@ UserSession *IsSessionValid( struct AuthMod *l, Http *r, char *sessionId )
time_t timestamp = time ( NULL );


MYSQLLibrary *sqlLib = sb->LibraryMYSQLGet( sb );
SQLLibrary *sqlLib = sb->LibrarySQLGet( sb );
if( sqlLib == NULL )
{
FERROR("Cannot get mysql.library slot!\n");
Expand All @@ -740,12 +740,12 @@ UserSession *IsSessionValid( struct AuthMod *l, Http *r, char *sessionId )
sqlLib->SNPrintF( sqlLib, tmpQuery, sizeof(tmpQuery), "UPDATE FUserSession SET `LoggedTime` = '%ld' WHERE `SessionID` = '%s'", timestamp, sessionId );
//sprintf( tmpQuery, "UPDATE FUserSession SET `LoggedTime` = '%ld' WHERE `SessionID` = '%s'", timestamp, sessionId );

MYSQL_RES *res = sqlLib->Query( sqlLib, tmpQuery );
void *res = sqlLib->Query( sqlLib, tmpQuery );
if( res != NULL )
{
//users->us_User->u_Error = FUP_AUTHERR_UPDATE;
sqlLib->FreeResult( sqlLib, res );
sb->LibraryMYSQLDrop( sb, sqlLib );
sb->LibrarySQLDrop( sb, sqlLib );
return users;
}
}
Expand All @@ -755,18 +755,18 @@ UserSession *IsSessionValid( struct AuthMod *l, Http *r, char *sessionId )

// same session, update loggedtime
//user->u_Error = FUP_AUTHERR_WRONGSESID;
sb->LibraryMYSQLDrop( sb, sqlLib );
sb->LibrarySQLDrop( sb, sqlLib );
return users;
}
}
else
{
DEBUG( "[FCDB] IsSessionValid: Session has timed out! %s\n", sessionId );
//user->u_Error = FUP_AUTHERR_TIMEOUT;
sb->LibraryMYSQLDrop( sb, sqlLib );
sb->LibrarySQLDrop( sb, sqlLib );
return users;
}
sb->LibraryMYSQLDrop( sb, sqlLib );
sb->LibrarySQLDrop( sb, sqlLib );
return users;
}

Expand Down
14 changes: 10 additions & 4 deletions core/communication/comm_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ typedef FLONG ID;
#define ID_FCRS MAKE_ID32('F','C','R','S') // friend cores
#define ID_FCID MAKE_ID32('F','C','I','D') // friend core ID
#define ID_FRID MAKE_ID32('F','R','I','D') // friend request id
#define ID_FCRI MAKE_ID32('F','C','R','I') // friend request id (in reponse message)

#define ID_FCON MAKE_ID32('F','C','O','N') // friend connection
#define ID_FCOR MAKE_ID32('F','C','O','R') // friend connection response
Expand Down Expand Up @@ -101,9 +102,14 @@ typedef FLONG ID;
#define ID_APID MAKE_ID32('A','P','I','D') // application id

#define MSG_END 0
#define MSG_GROUP_START 0xf0000001
#define MSG_GROUP_END 0xf0000002
#define MSG_INTEGER_VALUE 0xf0000003
#define MSG_GROUP_START 0xf0000001
#define MSG_GROUP_END 0xf0000002
#define MSG_INTEGER_VALUE 0xf0000003

#define FC_QUERY_DEFAULT 0x000f0000
#define FC_QUERY_SERVICES (FC_QUERY_DEFAULT)
#define FC_QUERY_GEOLOC (FC_QUERY_DEFAULT+1)
#define FC_QUERY_FRIENDCORE_INFO (FC_QUERY_DEFAULT+2)

//
// Message item defined by the user
Expand All @@ -122,7 +128,7 @@ typedef struct MsgItem

typedef struct DataForm
{
FULONG df_ID;
FULONG df_ID;
FULONG df_Size;
FULONG df_Data;
}DataForm;
Expand Down
Loading

0 comments on commit 34ce679

Please sign in to comment.