git.ucc.asn.au
/
tpg
/
opendispense2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Reset slot names on startup
[tpg/opendispense2.git]
/
src
/
server
/
server.c
diff --git
a/src/server/server.c
b/src/server/server.c
index
3973690
..
315b129
100644
(file)
--- a/
src/server/server.c
+++ b/
src/server/server.c
@@
-68,6
+68,7
@@
void _SendUserInfo(tClient *Client, int UserID);
void Server_Cmd_USERADD(tClient *Client, char *Args);
void Server_Cmd_USERFLAGS(tClient *Client, char *Args);
// --- Helpers ---
void Server_Cmd_USERADD(tClient *Client, char *Args);
void Server_Cmd_USERFLAGS(tClient *Client, char *Args);
// --- Helpers ---
+void Debug(tClient *Client, const char *Format, ...);
int Server_int_ParseFlags(tClient *Client, const char *Str, int *Mask, int *Value);
int sendf(int Socket, const char *Format, ...);
int Server_int_ParseFlags(tClient *Client, const char *Str, int *Mask, int *Value);
int sendf(int Socket, const char *Format, ...);
@@
-341,7
+342,7
@@
void Server_Cmd_USER(tClient *Client, char *Args)
// Debug!
if( giDebugLevel )
// Debug!
if( giDebugLevel )
-
printf("Client %i authenticating as '%s'\n", Client->ID
, Args);
+
Debug(Client, "Authenticating as '%s'"
, Args);
// Save username
if(Client->Username)
// Save username
if(Client->Username)
@@
-402,7
+403,7
@@
void Server_Cmd_AUTOAUTH(tClient *Client, char *Args)
// Check if trusted
if( !Client->bIsTrusted ) {
if(giDebugLevel)
// Check if trusted
if( !Client->bIsTrusted ) {
if(giDebugLevel)
-
printf("Client %i: Untrusted client attempting to AUTOAUTH\n", Client->ID
);
+
Debug(Client, "Untrusted client attempting to AUTOAUTH"
);
sendf(Client->Socket, "401 Untrusted\n");
return ;
}
sendf(Client->Socket, "401 Untrusted\n");
return ;
}
@@
-411,7
+412,7
@@
void Server_Cmd_AUTOAUTH(tClient *Client, char *Args)
Client->UID = Bank_GetAcctByName( Args );
if( Client->UID < 0 ) {
if(giDebugLevel)
Client->UID = Bank_GetAcctByName( Args );
if( Client->UID < 0 ) {
if(giDebugLevel)
-
printf("Client %i: Unknown user '%s'\n", Client->ID
, Args);
+
Debug(Client, "Unknown user '%s'"
, Args);
sendf(Client->Socket, "401 Auth Failure\n");
return ;
}
sendf(Client->Socket, "401 Auth Failure\n");
return ;
}
@@
-422,9
+423,11
@@
void Server_Cmd_AUTOAUTH(tClient *Client, char *Args)
sendf(Client->Socket, "401 Auth Failure\n");
return ;
}
sendf(Client->Socket, "401 Auth Failure\n");
return ;
}
+
+ Client->bIsAuthed = 1;
if(giDebugLevel)
if(giDebugLevel)
-
printf("Client %i: Authenticated as '%s' (%i)\n", Client->ID
, Args, Client->UID);
+
Debug(Client, "Auto authenticated as '%s' (%i)"
, Args, Client->UID);
sendf(Client->Socket, "200 Auth OK\n");
}
sendf(Client->Socket, "200 Auth OK\n");
}
@@
-1028,10
+1031,14
@@
void Server_Cmd_USERINFO(tClient *Client, char *Args)
space = strchr(user, ' ');
if(space) *space = '\0';
space = strchr(user, ' ');
if(space) *space = '\0';
+ if( giDebugLevel ) Debug(Client, "User Info '%s'", user);
+
// Get recipient
uid = Bank_GetAcctByName(user);
// Get recipient
uid = Bank_GetAcctByName(user);
+
+ if( giDebugLevel >= 2 ) Debug(Client, "uid = %i", uid);
if( uid == -1 ) {
if( uid == -1 ) {
- sendf(Client->Socket, "404 Invalid user");
+ sendf(Client->Socket, "404 Invalid user
\n
");
return ;
}
return ;
}
@@
-1151,6
+1158,17
@@
void Server_Cmd_USERFLAGS(tClient *Client, char *Args)
}
// --- INTERNAL HELPERS ---
}
// --- INTERNAL HELPERS ---
+void Debug(tClient *Client, const char *Format, ...)
+{
+ va_list args;
+ //printf("%010i [%i] ", (int)time(NULL), Client->ID);
+ printf("[%i] ", Client->ID);
+ va_start(args, Format);
+ vprintf(Format, args);
+ va_end(args);
+ printf("\n");
+}
+
int sendf(int Socket, const char *Format, ...)
{
va_list args;
int sendf(int Socket, const char *Format, ...)
{
va_list args;
UCC
git Repository :: git.ucc.asn.au