format code

This commit is contained in:
LingZhaoHui 2023-05-10 22:49:47 +08:00
parent e6fe5045cb
commit 8df4a09922
Signed by: zeekling
GPG Key ID: D96E4E75267CA2CC

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;
}