Skip to content

Commit

Permalink
Display an error message when the wrong pcap file was authorized
Browse files Browse the repository at this point in the history
  • Loading branch information
haegardev committed Sep 4, 2013
1 parent fcfb309 commit 7137020
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pcapdj.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ void delete_next_file_queue(redisContext* ctx)
freeReplyObject(reply);
}


void delete_auth_file(redisContext* ctx)
{
/* FIXME errors are ignored */
redisReply * reply;
reply = redisCommand(ctx, "DEL %s", AKEY);
if (reply)
freeReplyObject(reply);
}

void wait_auth_to_proceed(redisContext* ctx, char* filename)
{
redisReply *reply;
Expand All @@ -92,12 +102,17 @@ void wait_auth_to_proceed(redisContext* ctx, char* filename)
reply = redisCommand(ctx,"GET %s",AKEY);
if (reply){
if (reply->type == REDIS_REPLY_STRING) {
/* Delete the authorized key. So in the next
* iteration the AUTH_KEY is not there anymore and
* the error message is not reated all the times
*/
delete_auth_file(ctx);
if (!strncmp(reply->str, filename, strlen(filename))) {
fprintf(stderr, "Got authorization to proceed\n");
freeReplyObject(reply);
return;
}else{
//fprintf(stderr,"Got the wrong authorization. Waited for (%s). Got %s.\n", filename, reply->str);
fprintf(stderr,"[ERROR] Got the wrong authorization. Waited for (%s). Got %s.\n", filename, reply->str);
}
}
freeReplyObject(reply);
Expand Down

0 comments on commit 7137020

Please sign in to comment.