format code #4

Merged
zeekling merged 1 commits from format into master 2023-05-10 14:50:29 +00:00

View File

@ -1,4 +1,3 @@
#include <stdio.h>
#include "redis-acl.h"
#include "redismodule.h"
@ -6,8 +5,8 @@
static RedisModuleCommandFilter *filter;
void AuthFilter_CommandFilter(RedisModuleCommandFilter *filter) {
int log = 0;
int pos = 0;
int log = 0;
int pos = 0;
RedisModule_Log(NULL, LOG_LEVL_NOTICE, "command filter");
while (pos < RedisModule_CommandFilterArgsCount(filter)) {
const RedisModuleString *arg = RedisModule_CommandFilterArgGet(filter, pos);
@ -33,15 +32,15 @@ int AuthCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
void create_users(RedisModuleCtx *ctx) {
RedisModuleUser *user = RedisModule_CreateModuleUser("default");
RedisModule_SetModuleUserACL(user, "allcommands");
RedisModule_SetModuleUserACL(user, "allkeys");
RedisModule_SetModuleUserACL(user, "on");
RedisModule_SetModuleUserACL(user, "allkeys");
RedisModule_SetModuleUserACL(user, "on");
RedisModule_Log(ctx, LOG_LEVL_NOTICE, "init module user success!");
RedisModule_FreeModuleUser(user);
}
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
REDISMODULE_NOT_USED(argv);
REDISMODULE_NOT_USED(argc);
REDISMODULE_NOT_USED(argc);
if (RedisModule_Init(ctx, "redis-auth", 1, REDISMODULE_APIVER_1) == REDISMODULE_ERR) {
RedisModule_Log(ctx, LOG_LEVL_NOTICE, "init redis-auth failed");
return REDISMODULE_ERR;
@ -49,8 +48,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
create_users(ctx);
filter = RedisModule_RegisterCommandFilter(ctx, AuthFilter_CommandFilter, 0);
filter = RedisModule_RegisterCommandFilter(ctx, AuthFilter_CommandFilter, 0);
if (filter == NULL) {
return REDISMODULE_ERR;
}