| 117 | } |
| 118 | |
| 119 | int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { |
| 120 | if (RedisModule_Init(ctx,"commandfilter",1,REDISMODULE_APIVER_1) |
| 121 | == REDISMODULE_ERR) return REDISMODULE_ERR; |
| 122 | |
| 123 | if (argc != 2) { |
| 124 | RedisModule_Log(ctx, "warning", "Log key name not specified"); |
| 125 | return REDISMODULE_ERR; |
| 126 | } |
| 127 | |
| 128 | long long noself = 0; |
| 129 | log_key_name = RedisModule_CreateStringFromString(ctx, argv[0]); |
| 130 | RedisModule_StringToLongLong(argv[1], &noself); |
| 131 | |
| 132 | if (RedisModule_CreateCommand(ctx,log_command_name, |
| 133 | CommandFilter_LogCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) |
| 134 | return REDISMODULE_ERR; |
| 135 | |
| 136 | if (RedisModule_CreateCommand(ctx,ping_command_name, |
| 137 | CommandFilter_PingCommand,"deny-oom",1,1,1) == REDISMODULE_ERR) |
| 138 | return REDISMODULE_ERR; |
| 139 | |
| 140 | if (RedisModule_CreateCommand(ctx,unregister_command_name, |
| 141 | CommandFilter_UnregisterCommand,"write deny-oom",1,1,1) == REDISMODULE_ERR) |
| 142 | return REDISMODULE_ERR; |
| 143 | |
| 144 | if ((filter = RedisModule_RegisterCommandFilter(ctx, CommandFilter_CommandFilter, |
| 145 | noself ? REDISMODULE_CMDFILTER_NOSELF : 0)) |
| 146 | == NULL) return REDISMODULE_ERR; |
| 147 | |
| 148 | return REDISMODULE_OK; |
| 149 | } |
| 150 | |
| 151 | int RedisModule_OnUnload(RedisModuleCtx *ctx) { |
| 152 | RedisModule_FreeString(ctx, log_key_name); |
nothing calls this directly
no test coverage detected